Changeset b7b5f83 in mainline for genarch/ofw.c
- Timestamp:
- 2006-07-03T19:46:13Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b95b717
- Parents:
- d22645e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
genarch/ofw.c
rd22645e rb7b5f83 32 32 33 33 #define MAX_OFW_ARGS 10 34 #define BUF_SIZE 102435 36 typedef unsigned int ofw_arg_t;37 typedef unsigned int ihandle;38 typedef unsigned int phandle;39 34 40 35 /** OpenFirmware command structure … … 50 45 typedef void (*ofw_entry)(ofw_args_t *); 51 46 52 53 typedef struct {54 unsigned int info;55 unsigned int addr_hi;56 unsigned int addr_lo;57 } pci_addr_t;58 59 typedef struct {60 pci_addr_t addr;61 unsigned int size_hi;62 unsigned int size_lo;63 } pci_reg_t;64 65 66 47 ofw_entry ofw; 67 48 … … 100 81 101 82 102 staticphandle ofw_find_device(const char *name)83 phandle ofw_find_device(const char *name) 103 84 { 104 85 return ofw_call("finddevice", 1, 1, NULL, name); … … 106 87 107 88 108 staticint ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)89 int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen) 109 90 { 110 91 return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen); … … 205 186 int ofw_memmap(memmap_t *map) 206 187 { 207 unsigned intbuf[BUF_SIZE];208 int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof( unsigned int) * BUF_SIZE);188 unsigned long buf[BUF_SIZE]; 189 int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); 209 190 if (ret <= 0) 210 191 return false; … … 216 197 map->total = 0; 217 198 map->count = 0; 218 for (pos = 0; (pos < ret / sizeof(unsigned int)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {199 for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) { 219 200 void * start = (void *) buf[pos + ac - 1]; 220 201 unsigned int size = buf[pos + ac + sc - 1]; … … 234 215 char device_name[BUF_SIZE]; 235 216 236 if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof( char) * BUF_SIZE) <= 0)217 if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0) 237 218 return false; 238 219 … … 259 240 } 260 241 261 262 int ofw_keyboard(keyboard_t *keyboard)263 {264 char device_name[BUF_SIZE];265 266 if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(char) * BUF_SIZE) <= 0)267 return false;268 269 phandle device = ofw_find_device(device_name);270 if (device == -1)271 return false;272 273 pci_reg_t macio;274 if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)275 return false;276 277 keyboard->addr = (void *) macio.addr.addr_lo;278 keyboard->size = macio.size_lo;279 280 return true;281 }
Note:
See TracChangeset
for help on using the changeset viewer.