Main Page | Directories | File List | Globals

adi_resources.c File Reference

#include <agnix/agnix.h>
#include <agnix/adi/adi.h>
#include <agnix/list.h>
#include <agnix/spinlock.h>
#include <agnix/console.h>

Include dependency graph for adi_resources.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "ADI: "
#define MAX_GLOBAL_RESOURCES   16

Functions

 LIST_HEAD (adi_resources_mem_list)
 LIST_HEAD (adi_resources_io_list)
int adi_register_resource (struct adi_resource_s *adi_resource)
int adi_unregister_resource (struct adi_resource_s *adi_resource)
int adi_check_resource (struct adi_resource_s *adi_resource)
int adi_print_resources (int res_flags_mask)
int adi_print_mem_resources (void)
int adi_print_io_resources (void)
int adi_register_global_resources (void)
int adi_resources_init (void)

Variables

spinlock_t adi_resources_mem_lock
spinlock_t adi_resources_io_lock
adi_resource_s global_io_resources [MAX_GLOBAL_RESOURCES]


Define Documentation

#define MAX_GLOBAL_RESOURCES   16
 

Definition at line 21 of file adi_resources.c.

#define MOD_NAME   "ADI: "
 

Definition at line 20 of file adi_resources.c.


Function Documentation

int adi_check_resource struct adi_resource_s *  adi_resource  ) 
 

Definition at line 102 of file adi_resources.c.

00103 {
00104     return 0;
00105 }

int adi_print_io_resources void   ) 
 

Definition at line 146 of file adi_resources.c.

References adi_print_resources().

00147 {
00148     return adi_print_resources(ADI_RES_FLAG_IO);
00149 }

Here is the call graph for this function:

int adi_print_mem_resources void   ) 
 

Definition at line 141 of file adi_resources.c.

References adi_print_resources().

00142 {
00143     return adi_print_resources(ADI_RES_FLAG_MEM);
00144 }

Here is the call graph for this function:

int adi_print_resources int  res_flags_mask  ) 
 

Definition at line 107 of file adi_resources.c.

References adi_resources_io_lock, adi_resources_mem_lock, flags, MOD_NAME, and printk().

Referenced by adi_print_io_resources(), and adi_print_mem_resources().

00108 {
00109     struct list_head *tmp;
00110     struct list_head *res_head;
00111     struct adi_resource_s *res;
00112     spinlock_t *res_lock;
00113     u32 flags;
00114 
00115     if (res_flags_mask & ADI_RES_FLAG_MEM) {
00116         res_head = &adi_resources_mem_list;
00117         res_lock = &adi_resources_mem_lock;
00118         printk(MOD_NAME "ADI memory resources: \n");
00119     } else {
00120         res_head = &adi_resources_io_list;
00121         res_lock = &adi_resources_io_lock;
00122         printk(MOD_NAME "ADI io resources: \n");
00123     }
00124 
00125     spin_lock_irqsave(res_lock, flags);
00126 
00127     list_for_each(tmp, res_head) {
00128         res = list_entry(tmp, struct adi_resource_s, res_list);
00129         
00130         if (res_flags_mask & ADI_RES_FLAG_MEM)
00131             printk(MOD_NAME "%08x-%08x %s\n", res->res_start, res->res_end, res->res_name);
00132         else
00133             printk(MOD_NAME "%04x-%04x %s\n", res->res_start, res->res_end, res->res_name);
00134     }
00135         
00136     spin_unlock_irqrestore(res_lock, flags);
00137 
00138     return 0;
00139 }

Here is the call graph for this function:

int adi_register_global_resources void   ) 
 

Definition at line 151 of file adi_resources.c.

References adi_register_resource(), and global_io_resources.

Referenced by adi_resources_init().

00152 {
00153     int i = 0;
00154     int ret;
00155 
00156     while (global_io_resources[i].res_name != NULL) {
00157         ret = adi_register_resource(&global_io_resources[i]);   
00158         if (ret < 0)
00159             return ret;
00160             
00161         i++;
00162     }
00163     
00164     return 0;
00165 }

Here is the call graph for this function:

int adi_register_resource struct adi_resource_s *  adi_resource  ) 
 

Definition at line 40 of file adi_resources.c.

References adi_resources_io_lock, adi_resources_mem_lock, flags, MOD_NAME, and printk().

Referenced by adi_register_global_resources(), and pcibus_scan_card_memory().

00041 {
00042     struct list_head *tmp;
00043     struct list_head *res_head;
00044     struct adi_resource_s *res;
00045     int ret = 0;
00046     spinlock_t *res_lock;
00047     u32 flags;
00048     
00049     if ((adi_resource->res_end - adi_resource->res_start) == 0) {
00050         printk(MOD_NAME "zero size resource adding probe\n");
00051         return -1;
00052     }
00053     
00054     if (adi_resource->res_flags & ADI_RES_FLAG_MEM) {
00055         res_head = &adi_resources_mem_list;
00056         res_lock = &adi_resources_mem_lock;
00057     } else {
00058         res_head = &adi_resources_io_list;
00059         res_lock = &adi_resources_io_lock;
00060     }
00061     
00062     spin_lock_irqsave(res_lock, flags);
00063     
00064     if (!list_empty(res_head)) {   
00065         list_for_each(tmp, res_head) {
00066             res = list_entry(tmp, struct adi_resource_s, res_list);
00067 
00068             if ((res->res_start > adi_resource->res_start) && (res->res_start <= adi_resource->res_end)) {
00069                 ret = -1;
00070                 goto register_end;
00071             }
00072             if ((res->res_end >= adi_resource->res_start) && (res->res_end < adi_resource->res_end)) {
00073                 ret = -1;
00074                 goto register_end;
00075             }
00076 
00077             if (res->res_start > adi_resource->res_end) {
00078                 __list_add(&adi_resource->res_list, res->res_list.prev, &res->res_list);
00079                 ret = 0;
00080                 goto register_end;
00081             }
00082         }
00083     } else {
00084         list_add(&(adi_resource->res_list), res_head);
00085         ret = 0;
00086         goto register_end;
00087     }
00088     
00089     list_add_tail(&(adi_resource->res_list), res_head);
00090         
00091 register_end:
00092     spin_unlock_irqrestore(res_lock, flags);
00093 
00094     return ret;
00095 }

Here is the call graph for this function:

int adi_resources_init void   ) 
 

Definition at line 167 of file adi_resources.c.

References adi_register_global_resources(), adi_resources_io_lock, adi_resources_mem_lock, MOD_NAME, and printk().

Referenced by adi_drivers_init().

00168 {
00169     printk(MOD_NAME "initializing adi resources\n");
00170     
00171     spin_lock_init(&adi_resources_io_lock);
00172     spin_lock_init(&adi_resources_mem_lock);
00173 
00174     adi_register_global_resources();
00175 
00176     return 0;
00177 }

Here is the call graph for this function:

int adi_unregister_resource struct adi_resource_s *  adi_resource  ) 
 

Definition at line 97 of file adi_resources.c.

00098 {
00099     return 0;
00100 }

LIST_HEAD adi_resources_io_list   ) 
 

LIST_HEAD adi_resources_mem_list   ) 
 


Variable Documentation

spinlock_t adi_resources_io_lock
 

Definition at line 27 of file adi_resources.c.

Referenced by adi_print_resources(), adi_register_resource(), and adi_resources_init().

spinlock_t adi_resources_mem_lock
 

Definition at line 24 of file adi_resources.c.

Referenced by adi_print_resources(), adi_register_resource(), and adi_resources_init().

struct adi_resource_s global_io_resources[MAX_GLOBAL_RESOURCES]
 

Initial value:

 {
    { "dma",      0x00, 0x1f, ADI_RES_FLAG_IO },
    { "pic",      0x20, 0x3f, ADI_RES_FLAG_IO },
    { "pit",      0x40, 0x5f, ADI_RES_FLAG_IO },
    { "kbd",      0x60, 0x6f, ADI_RES_FLAG_IO },
    { "dma page", 0x80, 0x8f, ADI_RES_FLAG_IO },
    { "pic2",     0xa0, 0xbf, ADI_RES_FLAG_IO },
    { "dma2",     0xc0, 0xdf, ADI_RES_FLAG_IO },
    { NULL, }
}

Definition at line 29 of file adi_resources.c.

Referenced by adi_register_global_resources().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix