diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-04-29 21:13:14 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-04-29 21:13:14 +0000 |
commit | 19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch) | |
tree | 40b1cb534496a7f1ca0f5c314a523c69f1fee464 /kernel/resource.c | |
parent | 7206675c40394c78a90e74812bbdbf8cf3cca1be (diff) |
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 69 |
1 files changed, 65 insertions, 4 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 48184bfcf..27abcf4dc 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -13,7 +13,7 @@ #include <linux/types.h> #include <linux/ioport.h> -#define IOTABLE_SIZE 64 +#define IOTABLE_SIZE 128 typedef struct resource_entry_t { u_long from, num; @@ -69,7 +69,7 @@ static resource_entry_t *find_gap(resource_entry_t *root, /* * Call this from the device driver to register the ioport region. */ -void request_region(unsigned int from, unsigned int num, const char *name) +void request_region(unsigned long from, unsigned long num, const char *name) { resource_entry_t *p; int i; @@ -95,7 +95,7 @@ void request_region(unsigned int from, unsigned int num, const char *name) /* * Call this when the device driver is unloaded */ -void release_region(unsigned int from, unsigned int num) +void release_region(unsigned long from, unsigned long num) { resource_entry_t *p, *q; @@ -114,11 +114,72 @@ void release_region(unsigned int from, unsigned int num) /* * Call this to check the ioport region before probing */ -int check_region(unsigned int from, unsigned int num) +int check_region(unsigned long from, unsigned long num) { return (find_gap(&iolist, from, num) == NULL) ? -EBUSY : 0; } +#ifdef __sparc__ /* Why to carry unused code on other architectures? */ +/* + * This is for architectures with MMU-managed ports (sparc). + */ +unsigned long occupy_region(unsigned long base, unsigned long end, + unsigned long num, unsigned int align, const char *name) +{ + unsigned long from = 0, till; + unsigned long flags; + int i; + resource_entry_t *p; /* Scanning ptr */ + resource_entry_t *p1; /* === p->next */ + resource_entry_t *s; /* Found slot */ + + if (base > end-1) + return 0; + if (num > end - base) + return 0; + + for (i = 0; i < IOTABLE_SIZE; i++) + if (iotable[i].num == 0) + break; + if (i == IOTABLE_SIZE) { + /* Driver prints a warning typicaly. */ + return 0; + } + + save_flags(flags); + cli(); + /* printk("occupy: search in %08lx[%08lx] ", base, end - base); */ + s = NULL; + for (p = &iolist; p != NULL; p = p1) { + p1 = p->next; + /* Find window in list */ + from = (p->from+p->num + align-1) & ~((unsigned long)align-1); + till = (p1 == NULL)? (unsigned long) (0 - (unsigned long)align): p1->from; + /* printk(" %08lx:%08lx", from, till); */ + /* Clip window with base and end */ + if (from < base) from = base; + if (till > end) till = end; + /* See if result is large enougth */ + if (from < till && from + num < till) { + s = p; + break; + } + } + /* printk("\r\n"); */ + restore_flags(flags); + + if (s == NULL) + return 0; + + iotable[i].name = name; + iotable[i].from = from; + iotable[i].num = num; + iotable[i].next = s->next; + s->next = &iotable[i]; + return from; +} +#endif + /* Called from init/main.c to reserve IO ports. */ void reserve_setup(char *str, int *ints) { |