--- zzzz-none-000/linux-2.6.19.2/kernel/resource.c 2007-01-10 19:10:37.000000000 +0000 +++ davinci-8020-5505/linux-2.6.19.2/kernel/resource.c 2007-06-19 11:37:20.000000000 +0000 @@ -36,6 +36,86 @@ }; EXPORT_SYMBOL(iomem_resource); +#ifdef CONFIG_MIPS_UR8 +struct resource nwss_tx_queue_resource = { + .name = "NWSS Tx Queue", + .start = 0, + .end = 17, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(nwss_tx_queue_resource); + +struct resource nwss_tx_completion_queue_resource = { + .name = "NWSS Tx Completion Queue", + .start = 0, + .end = 3, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(nwss_tx_completion_queue_resource); + +struct resource nwss_rx_queue_resource = { + .name = "NWSS Rx Queue", + .start = 0, + .end = 7, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(nwss_rx_queue_resource); + +struct resource nwss_free_buffer_queue_resource = { + .name = "NWSS Free Buffer Descriptor Queue", + .start = 0, + .end = 3, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(nwss_free_buffer_queue_resource); + +struct resource nwss_free_packet_queue_resource = { + .name = "NWSS Free Packet Descriptor Queue", + .start = 0, + .end = 1, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(nwss_free_packet_queue_resource); + +struct resource gpio_resource = { + .name = "gpio", + .start = 0, + .end = 43, + .flags = IORESOURCE_IO +}; +EXPORT_SYMBOL(gpio_resource); + +struct resource timer_resource = { + .name = "timer", + .start = 0, + .end = 3, + .flags = IORESOURCE_IO +}; +EXPORT_SYMBOL(timer_resource); +#endif /*--- #ifdef CONFIG_MIPS_UR8 ---*/ + +#if defined(CONFIG_ARCH_DAVINCI) +extern int alloc_gpio_resource(unsigned int start, unsigned int end, unsigned long flags); + +struct resource gpio_resource = { + .name = "gpio", + .start = 0, + .end = 63, + .flags = IORESOURCE_DMA, + .alloc = alloc_gpio_resource +}; +EXPORT_SYMBOL(gpio_resource); + +struct resource timer_resource = { + .name = "timer", + .start = 0, + .end = 3, + .flags = IORESOURCE_DMA +}; +EXPORT_SYMBOL(timer_resource); +#endif /*--- #if defined(CONFIG_ARCH_DAVINCI) ---*/ + + static DEFINE_RWLOCK(resource_lock); #ifdef CONFIG_PROC_FS @@ -129,22 +209,234 @@ .release = seq_release, }; +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +#if defined(CONFIG_MIPS_UR8) || defined(CONFIG_ARCH_DAVINCI) +static int iogpio_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &gpio_resource; + } + return res; +} + +static struct file_operations proc_gpio_operations = { + .open = iogpio_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int iotimer_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &timer_resource; + } + return res; +} + +static struct file_operations proc_timer_operations = { + .open = iotimer_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; +#endif /*--- #if defined(CONFIG_MIPS_UR8) || defined(CONFIG_ARCH_DAVINCI) ---*/ + +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +#ifdef CONFIG_MIPS_UR8 +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +char *proc_nwss_names[] = { + "nwss_tx_queue", + "nwss_tx_completion_queue", + "nwss_rx_queue", + "nwss_free_buffer_queue", + "nwss_free_packet_queue", + NULL +}; + +static int nwss_tx_queue_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &nwss_tx_queue_resource; + } + return res; +} + +static int nwss_tx_completion_queue_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &nwss_tx_completion_queue_resource; + } + return res; +} + +static int nwss_rx_queue_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &nwss_rx_queue_resource; + } + return res; +} + +static int nwss_free_buffer_queue_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &nwss_free_buffer_queue_resource; + } + return res; +} + +static int nwss_free_packet_queue_open(struct inode *inode, struct file *file) +{ + int res = seq_open(file, &resource_op); + if (!res) { + struct seq_file *m = file->private_data; + m->private = &nwss_free_packet_queue_resource; + } + return res; +} + +static struct file_operations proc_nwss_operations[] = { + { + .open = nwss_tx_queue_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + }, + { + .open = nwss_tx_completion_queue_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + }, + { + .open = nwss_rx_queue_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + }, + { + .open = nwss_free_buffer_queue_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + }, + { + .open = nwss_free_packet_queue_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + } +}; +#endif /*--- #ifdef CONFIG_MIPS_UR8 ---*/ + static int __init ioresources_init(void) { struct proc_dir_entry *entry; + int i; + /*--------------------------------------------------------------------------------------*\ + \*--------------------------------------------------------------------------------------*/ +#ifdef CONFIG_GRKERNSEC_PROC_ADD +#ifdef CONFIG_GRKERNSEC_PROC_USER + entry = create_proc_entry("ioports", S_IRUSR, NULL); +#elif CONFIG_GRKERNSEC_PROC_USERGROUP + entry = create_proc_entry("ioports", S_IRUSR | S_IRGRP, NULL); +#endif +#else entry = create_proc_entry("ioports", 0, NULL); +#endif if (entry) entry->proc_fops = &proc_ioports_operations; + + /*--------------------------------------------------------------------------------------*\ + \*--------------------------------------------------------------------------------------*/ +#ifdef CONFIG_GRKERNSEC_PROC_ADD +#ifdef CONFIG_GRKERNSEC_PROC_USER + entry = create_proc_entry("iomem", S_IRUSR, NULL); +#elif CONFIG_GRKERNSEC_PROC_USERGROUP + entry = create_proc_entry("iomem", S_IRUSR | S_IRGRP, NULL); +#endif +#else entry = create_proc_entry("iomem", 0, NULL); +#endif if (entry) entry->proc_fops = &proc_iomem_operations; + +#ifdef CONFIG_MIPS_UR8 + /*--------------------------------------------------------------------------------------*\ + nwss_tx_queue_resource + nwss_tx_completion_queue_resource + nwss_rx_queue_resource + nwss_free_buffer_queue_resource + nwss_free_packet_queue_resource + \*--------------------------------------------------------------------------------------*/ + for(i = 0 ; i < sizeof(proc_nwss_operations) / sizeof(proc_nwss_operations[0]) ; i++) { +#ifdef CONFIG_GRKERNSEC_PROC_ADD +#ifdef CONFIG_GRKERNSEC_PROC_USER + entry = create_proc_entry(proc_nwss_names[i], S_IRUSR, NULL); +#elif CONFIG_GRKERNSEC_PROC_USERGROUP + entry = create_proc_entry(proc_nwss_names[i], S_IRUSR | S_IRGRP, NULL); +#endif +#else + entry = create_proc_entry(proc_nwss_names[i], 0, NULL); +#endif + if (entry) + entry->proc_fops = &proc_nwss_operations[i]; + } +#endif /*--- #ifdef CONFIG_MIPS_UR8 ---*/ +#if defined(CONFIG_MIPS_UR8) || defined(CONFIG_ARCH_DAVINCI) + /*--------------------------------------------------------------------------------------*\ + \*--------------------------------------------------------------------------------------*/ +#ifdef CONFIG_GRKERNSEC_PROC_ADD +#ifdef CONFIG_GRKERNSEC_PROC_USER + entry = create_proc_entry("gpio", S_IRUSR, NULL); +#elif CONFIG_GRKERNSEC_PROC_USERGROUP + entry = create_proc_entry("gpio", S_IRUSR | S_IRGRP, NULL); +#endif +#else + entry = create_proc_entry("gpio", 0, NULL); +#endif + if (entry) + entry->proc_fops = &proc_gpio_operations; + + /*--------------------------------------------------------------------------------------*\ + \*--------------------------------------------------------------------------------------*/ +#ifdef CONFIG_GRKERNSEC_PROC_ADD +#ifdef CONFIG_GRKERNSEC_PROC_USER + entry = create_proc_entry("hw_timer", S_IRUSR, NULL); +#elif CONFIG_GRKERNSEC_PROC_USERGROUP + entry = create_proc_entry("hw_timer", S_IRUSR | S_IRGRP, NULL); +#endif +#else + entry = create_proc_entry("hw_timer", 0, NULL); +#endif + if (entry) + entry->proc_fops = &proc_timer_operations; +#endif /*--- #if defined(CONFIG_MIPS_UR8) || defined(CONFIG_ARCH_DAVINCI) ---*/ return 0; } __initcall(ioresources_init); #endif /* CONFIG_PROC_FS */ +static int __release_resource(struct resource *old); + /* Return the conflict entry if you can't request it */ static struct resource * __request_resource(struct resource *root, struct resource *new) { @@ -170,6 +462,14 @@ p = &tmp->sibling; if (tmp->end < start) continue; +#if defined(CONFIG_MIPS_UR8) || defined(CONFIG_ARCH_DAVINCI) + if(root->alloc) { + if(root->alloc(new->start, new->end, new->flags)) { + __release_resource(new); + return NULL; + } + } +#endif /*--- #if defined(CONFIG_MIPS_UR8) || defined(CONFIG_ARCH_DAVINCI) ---*/ return tmp; } }