00001
00009
00010
00011
00012
00013
00014
00015 #include <l4/generic_io/types.h>
00016 #include <l4/log/l4log.h>
00017
00018 #include <string.h>
00019 #include <stdio.h>
00020
00021
00022 #include "io.h"
00023 #include "res.h"
00024 #include "static_cfg.h"
00025 #include "__config.h"
00026 #include "__macros.h"
00027
00028
00029 static struct {
00030 const char *name;
00031 l4io_desc_device_t **devs;
00032 int num;
00033 } registered_devs[MAX_NUM_REGISTERED_DEVS];
00034
00035 static int num_devs;
00036
00037 void register_device_group_fn(const char *name, l4io_desc_device_t **devs, int num)
00038 {
00039 if (num_devs == MAX_NUM_REGISTERED_DEVS)
00040 {
00041 printf("WARNING: Number for storable devices descriptors exceeded. Skipping %s\n", name);
00042 return;
00043 }
00044
00045 registered_devs[num_devs].name = name;
00046 registered_devs[num_devs].devs = devs;
00047 registered_devs[num_devs].num = num;
00048
00049 num_devs++;
00050 }
00051
00052 int io_static_cfg_init(l4io_info_t *info, const char *requested_platform)
00053 {
00054 unsigned char *buffer = (unsigned char *) info->devices;
00055 int i, j;
00056 int found = 0;
00057
00058 for (i = 0; i < num_devs; ++i)
00059 {
00060 if (strcmp(requested_platform, registered_devs[i].name))
00061 continue;
00062
00063 found = 1;
00064 printf("Using platform configuration '%s'\n", registered_devs[i].name);
00065
00066 for (j = 0; j < registered_devs[i].num; ++j)
00067 {
00068 l4io_desc_device_t *dev = registered_devs[i].devs[j];
00069 LOGd(DEBUG_RES, "device \"%s\" found @ %p", dev->id, dev);
00070
00071
00072 unsigned dev_size = sizeof(*dev) + dev->num_resources * sizeof(*(dev->resources));
00073 Assert((buffer + dev_size) < (unsigned char *)(info + 1));
00074 memcpy(buffer, dev, dev_size);
00075 buffer += dev_size;
00076
00077 int k;
00078 l4io_desc_resource_t *r;
00079 for (k = dev->num_resources, r = dev->resources; k; k--, r++) {
00080
00081 if (r->type == L4IO_RESOURCE_MEM)
00082 callback_announce_mem_region(r->start, r->end - r->start + 1);
00083
00084 LOGd(DEBUG_RES, " %s: %08lx-%08lx",
00085 r->type == L4IO_RESOURCE_IRQ ? " IRQ" :
00086 r->type == L4IO_RESOURCE_MEM ? " MEM" :
00087 r->type == L4IO_RESOURCE_PORT ? "PORT" : "????",
00088 r->start, r->end);
00089 }
00090 }
00091
00092
00093 }
00094
00095 if (!found)
00096 printf("WARNING: No platform configuration for '%s' found.\n", requested_platform);
00097
00098
00099 ((l4io_desc_device_t *)buffer)->num_resources = 0;
00100
00101 return 0;
00102 }