void of1275_prominit(prom_entry entry) { promptr = entry; chosen_handle = of1275_finddevice("/chosen"); if (chosen_handle == (phandle) (-1)) { chosen_handle = of1275_finddevice("/chosen@0"); if (chosen_handle == (phandle) (-1)) of1275_exit(); } if (of1275_getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4) of1275_exit(); stderr = stdout; if (of1275_getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4) of1275_exit(); if (!check_of_version()) return; claim_needs_map = 1; if (of1275_getprop(chosen_handle, "mmu", &mmu, sizeof(mmu)) != 4) of1275_exit(); }
int of_find_integer_property(const char *device, const char *property) { int phandle; int integer; int size; /* find the device's phandle */ if (of1275_finddevice(device, &phandle) < 0) { //printk("of1275: no such device '%s'\n", device); exit(1); } /* find the device's property */ of1275_getprop(phandle, property, &integer, sizeof(integer), &size); if (size < sizeof(integer)) { //printk("of1275: unknown integer property '%s'\n", property); exit(1); } return ntohl(integer); }
void of_find_string_property(const char *device, const char *property, char *string, int sizeof_string) { int phandle; int size; /* find the device's phandle */ if (of1275_finddevice(device, &phandle) < 0) { //printk("of1275: no such device '%s'\n", device); exit(1); } /* find the device's property */ of1275_getprop(phandle, property, string, sizeof_string, &size); if (size == 0 || size >= sizeof_string) { //printk("of1275: unknown string property '%s'\n", property); exit(1); } }
/* * Older OF's require that when claiming a specific range of addresses, * we claim the physical space in the /memory node and the virtual * space in the chosen mmu node, and then do a map operation to * map virtual to physical. */ static int check_of_version(void) { phandle oprom; char version[20]; oprom = of1275_finddevice("/openprom"); if (oprom == (phandle) (-1)) return 0; if (of1275_getprop(oprom, "model", version, sizeof(version)) <= 0) return 0; if (!string_match(version, "Open Firmware, 1.") && !string_match(version, "FirmWorks,3.")) return 0; memory = (ihandle) call_prom("open", 1, 1, "/memory"); if (memory == (ihandle) (-1)) { memory = (ihandle) call_prom("open", 1, 1, "/memory@0"); if (memory == (ihandle) (-1)) return 0; } return 1; }