Rev 475 |
Rev 537 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <ll/i386/hw-instr.h>
#include <ll/i386/cons.h>
#include <ll/sys/ll/time.h>
#include <linuxcomp.h>
#include <linux/time.h>
#include <linux/sched.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <asm/io.h>
#include <linux/ctype.h>
#include <linux/device.h>
#include <linux/completion.h>
#include <linux/tty.h>
#include <asm/setup.h>
extern unsigned long intr_count
;
extern int activeInt
;
unsigned char _ctype
[] = {
_C
,_C
,_C
,_C
,_C
,_C
,_C
,_C
, /* 0-7 */
_C
,_C
|_S
,_C
|_S
,_C
|_S
,_C
|_S
,_C
|_S
,_C
,_C
, /* 8-15 */
_C
,_C
,_C
,_C
,_C
,_C
,_C
,_C
, /* 16-23 */
_C
,_C
,_C
,_C
,_C
,_C
,_C
,_C
, /* 24-31 */
_S
|_SP
,_P
,_P
,_P
,_P
,_P
,_P
,_P
, /* 32-39 */
_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
, /* 40-47 */
_D
,_D
,_D
,_D
,_D
,_D
,_D
,_D
, /* 48-55 */
_D
,_D
,_P
,_P
,_P
,_P
,_P
,_P
, /* 56-63 */
_P
,_U
|_X
,_U
|_X
,_U
|_X
,_U
|_X
,_U
|_X
,_U
|_X
,_U
, /* 64-71 */
_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
, /* 72-79 */
_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
, /* 80-87 */
_U
,_U
,_U
,_P
,_P
,_P
,_P
,_P
, /* 88-95 */
_P
,_L
|_X
,_L
|_X
,_L
|_X
,_L
|_X
,_L
|_X
,_L
|_X
,_L
, /* 96-103 */
_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
, /* 104-111 */
_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
, /* 112-119 */
_L
,_L
,_L
,_P
,_P
,_P
,_P
,_C
, /* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
_S
|_SP
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
, /* 160-175 */
_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
,_P
, /* 176-191 */
_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_U
, /* 192-207 */
_U
,_U
,_U
,_U
,_U
,_U
,_U
,_P
,_U
,_U
,_U
,_U
,_U
,_U
,_U
,_L
, /* 208-223 */
_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
, /* 224-239 */
_L
,_L
,_L
,_L
,_L
,_L
,_L
,_P
,_L
,_L
,_L
,_L
,_L
,_L
,_L
,_L
}; /* 240-255 */
__kernel_size_t strnlen
(const char *s
, __kernel_size_t count
)
{
const char *sc
;
for (sc
= s
; count
-- && *sc
!= '\0'; ++sc
)
/* nothing */;
return sc
- s
;
}
int nanosleep
(const struct timespec
*rqtp
, struct timespec
*rmtp
);
struct resource ioport_resource
= {
.
name = "PCI IO",
.
start = 0x0000,
.
end = IO_SPACE_LIMIT
,
.
flags = IORESOURCE_IO
,
};
struct resource iomem_resource
= {
.
name = "PCI mem",
.
start = 0UL
,
.
end = ~0UL
,
.
flags = IORESOURCE_MEM
,
};
/* Return the conflict entry if you can't request it */
static struct resource
* __request_resource
(struct resource
*root
, struct resource
*new
)
{
unsigned long start
= new
->start
;
unsigned long end
= new
->end
;
struct resource
*tmp
, **p
;
if (end
< start
)
return root
;
if (start
< root
->start
)
return root
;
if (end
> root
->end
)
return root
;
p
= &root
->child
;
for (;;) {
tmp
= *p
;
if (!tmp
|| tmp
->start
> end
) {
new
->sibling
= tmp
;
*p
= new
;
new
->parent
= root
;
return NULL
;
}
p
= &tmp
->sibling
;
if (tmp
->end
< start
)
continue;
return tmp
;
}
}
static int __release_resource
(struct resource
*old
)
{
struct resource
*tmp
, **p
;
p
= &old
->parent
->child
;
for (;;) {
tmp
= *p
;
if (!tmp
)
break;
if (tmp
== old
) {
*p
= tmp
->sibling
;
old
->parent
= NULL
;
return 0;
}
p
= &tmp
->sibling
;
}
return -EINVAL
;
}
int release_resource
(struct resource
*old
)
{
int retval
;
retval
= __release_resource
(old
);
return retval
;
}
int request_resource
(struct resource
*root
, struct resource
*new
)
{
struct resource
*conflict
;
conflict
= __request_resource
(root
, new
);
return conflict
? -EBUSY
: 0;
}
struct resource
* __request_region
(struct resource
*parent
, unsigned long start
, unsigned long n
, const char *name
)
{
return (void *)(0xFFFFFFFF);
}
void __release_region
(struct resource
*parent
, unsigned long start
, unsigned long n
)
{
}
static int find_resource
(struct resource
*root
, struct resource
*new
,
unsigned long size
,
unsigned long min
, unsigned long max
,
unsigned long align
,
void (*alignf
)(void *, struct resource
*,
unsigned long, unsigned long),
void *alignf_data
)
{
struct resource
*this
= root
->child
;
new
->start
= root
->start
;
/*
* Skip past an allocated resource that starts at 0, since the assignment
* of this->start - 1 to new->end below would cause an underflow.
*/
if (this
&& this
->start
== 0) {
new
->start
= this
->end
+ 1;
this
= this
->sibling
;
}
for(;;) {
if (this
)
new
->end
= this
->start
- 1;
else
new
->end
= root
->end
;
if (new
->start
< min
)
new
->start
= min
;
if (new
->end
> max
)
new
->end
= max
;
new
->start
= (new
->start
+ align
- 1) & ~
(align
- 1);
if (alignf
)
alignf
(alignf_data
, new
, size
, align
);
if (new
->start
< new
->end
&& new
->end
- new
->start
+ 1 >= size
) {
new
->end
= new
->start
+ size
- 1;
return 0;
}
if (!this
)
break;
new
->start
= this
->end
+ 1;
this
= this
->sibling
;
}
return -EBUSY
;
}
int allocate_resource
(struct resource
*root
, struct resource
*new
,
unsigned long size
,
unsigned long min
, unsigned long max
,
unsigned long align
,
void (*alignf
)(void *, struct resource
*,
unsigned long, unsigned long),
void *alignf_data
)
{
int err
;
err
= find_resource
(root
, new
, size
, min
, max
, align
, alignf
, alignf_data
);
if (err
>= 0 && __request_resource
(root
, new
))
err
= -EBUSY
;
return err
;
}
int remap_page_range
(struct vm_area_struct
*vma
, unsigned long from
, unsigned long phys_addr
, unsigned long size
, pgprot_t prot
)
{ return 0; }
void dump_stack
(void) { }
void panic
(const char * fmt
, ...
) {
cprintf
((char *)(fmt
));
}
extern void * malloc(size_t size
);
void *__kmalloc
(size_t size
, int flags
) {
return malloc(size
);
}
extern void free(void *);
void kfree
(const void *ptr
) {
free((void *)(ptr
));
}
unsigned long pci_mem_start
= 0x10000000;
signed long schedule_timeout
(signed long timeout
) {
struct timespec t
,s
,e
;
jiffies_to_timespec
(timeout
, &t
);
if (!activeInt
&& !intr_count
) {
nanosleep
(&t
,NULL
);
} else {
ll_gettime
(TIME_NEW
,&s
);
ADDTIMESPEC
(&t
,&s
,&e
);
while(TIMESPEC_A_LT_B
(&s
,&e
)) ll_gettime
(TIME_NEW
,&s
);
}
return 0;
}
void __const_udelay
(unsigned long usecs
) {
struct timespec t
,s
,e
;
if (!activeInt
&& !intr_count
) {
t.
tv_sec = 0;
t.
tv_nsec = usecs
* 1000;
nanosleep
(&t
,NULL
);
} else {
ll_gettime
(TIME_NEW
,&e
);
ADDUSEC2TIMESPEC
(usecs
,&e
);
ll_gettime
(TIME_NEW
,&s
);
while(TIMESPEC_A_LT_B
(&s
,&e
)) ll_gettime
(TIME_NEW
,&s
);
}
}
void complete
(struct completion
*c
) {
}
void wait_for_completion
(struct completion
*c
) {
}
struct device legacy_bus
= {
.
bus_id = "legacy",
};
int register_chrdev
(unsigned int a
, const char *b
, struct file_operations
*c
) {
return 0;
}
int unregister_chrdev
(unsigned int a
, const char *b
) {
return 0;
}
void * __ioremap
(unsigned long offset
, unsigned long size
, unsigned long flags
) {
return (void *)offset
;
}
void iounmap
(void *addr
) {
}
void *vmalloc
(unsigned long size
) {
return malloc(size
);
}
void vfree
(void *addr
) {
return free(addr
);
}
/* TODO */
char * strsep
(char **a
,const char *b
) {
return NULL
;
}
struct screen_info screen_info
;
int linuxcomp_setfd
(struct inode
*i
, int i_rdev
) {
i
->i_rdev
= i_rdev
;
return 0;
}
int linuxcomp_init
(void) {
return 0;
}