Changes in boot/genarch/src/ofw.c [de1712e:a35b458] in mainline
- File:
-
- 1 edited
-
boot/genarch/src/ofw.c (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/src/ofw.c
rde1712e ra35b458 62 62 if (ofw_chosen == (phandle) -1) 63 63 halt(); 64 64 65 65 if ((ofw_ret_t) ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, 66 66 sizeof(ofw_stdout)) <= 0) 67 67 ofw_stdout = 0; 68 68 69 69 ofw_root = ofw_find_device("/"); 70 70 if (ofw_root == (phandle) -1) { … … 72 72 halt(); 73 73 } 74 74 75 75 if ((ofw_ret_t) ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, 76 76 sizeof(ofw_mmu)) <= 0) { … … 83 83 halt(); 84 84 } 85 85 86 86 ofw_memory = ofw_find_device("/memory"); 87 87 if (ofw_memory == (phandle) -1) { … … 110 110 args.nargs = nargs; 111 111 args.nret = nret; 112 112 113 113 va_list list; 114 114 va_start(list, rets); 115 115 116 116 size_t i; 117 117 for (i = 0; i < nargs; i++) 118 118 args.args[i] = va_arg(list, ofw_arg_t); 119 119 120 120 va_end(list); 121 121 122 122 for (i = 0; i < nret; i++) 123 123 args.args[i + nargs] = 0; 124 124 125 125 (void) ofw(&args); 126 126 127 127 for (i = 1; i < nret; i++) 128 128 rets[i - 1] = args.args[i + nargs]; 129 129 130 130 return args.args[nargs]; 131 131 } … … 161 161 { 162 162 ofw_prop_t ret = 1; 163 163 164 164 if ((ofw_ret_t) ofw_get_property(device, "#address-cells", &ret, 165 165 sizeof(ret)) <= 0) … … 167 167 sizeof(ret)) <= 0) 168 168 ret = OFW_ADDRESS_CELLS; 169 169 170 170 return (size_t) ret; 171 171 } … … 174 174 { 175 175 ofw_prop_t ret = 1; 176 176 177 177 if ((ofw_ret_t) ofw_get_property(device, "#size-cells", &ret, 178 178 sizeof(ret)) <= 0) … … 180 180 sizeof(ret)) <= 0) 181 181 ret = OFW_SIZE_CELLS; 182 182 183 183 return (size_t) ret; 184 184 } … … 198 198 if (ofw_stdout == 0) 199 199 return; 200 200 201 201 ofw_call("write", 3, 1, NULL, ofw_stdout, &ch, 1); 202 202 } … … 210 210 halt(); 211 211 } 212 212 213 213 if (result[0] == false) { 214 214 printf("Error: Unable to translate virtual address %p, halting.\n", … … 216 216 halt(); 217 217 } 218 218 219 219 #ifdef __32_BITS__ 220 220 return (void *) result[2]; 221 221 #endif 222 222 223 223 #ifdef __64_BITS__ 224 224 return (void *) ((result[2] << 32) | result[3]); … … 235 235 halt(); 236 236 } 237 237 238 238 return (void *) addr; 239 239 } … … 252 252 { 253 253 void *addr = ofw_claim_virt_internal(NULL, len, alignment); 254 254 255 255 if (addr == NULL) { 256 256 printf("Error: Unable to claim %zu bytes in virtual memory, halting.\n", … … 258 258 halt(); 259 259 } 260 260 261 261 return addr; 262 262 } … … 276 276 * purposes. 277 277 */ 278 278 279 279 #ifdef __32_BITS__ 280 280 ofw_arg_t retaddr[1]; … … 284 284 halt(); 285 285 } 286 286 287 287 return (void *) retaddr[0]; 288 288 #endif 289 289 290 290 #ifdef __64_BITS__ 291 291 ofw_arg_t retaddr[2]; … … 296 296 halt(); 297 297 } 298 298 299 299 return (void *) ((retaddr[0] << 32) | retaddr[1]); 300 300 #endif … … 319 319 halt(); 320 320 } 321 321 322 322 return addr; 323 323 } … … 328 328 ofw_arg_t phys_hi; 329 329 ofw_arg_t phys_lo; 330 330 331 331 #ifdef __32_BITS__ 332 332 phys_hi = (ofw_arg_t) phys; 333 333 phys_lo = 0; 334 334 #endif 335 335 336 336 #ifdef __64_BITS__ 337 337 phys_hi = (ofw_arg_t) phys >> 32; 338 338 phys_lo = (ofw_arg_t) phys & 0xffffffff; 339 339 #endif 340 340 341 341 ofw_arg_t ret = ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, 342 342 ALIGN_UP(size, PAGE_SIZE), virt, phys_hi, phys_lo); 343 343 344 344 if (ret != 0) { 345 345 printf("Error: Unable to map %p to %p (size %zu), halting.\n", … … 360 360 size_t sc = ofw_get_size_cells(ofw_memory) / 361 361 (sizeof(uintptr_t) / sizeof(uint32_t)); 362 362 363 363 uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; 364 364 365 365 /* The number of bytes read */ 366 366 ofw_ret_t ret = (ofw_ret_t) ofw_get_property(ofw_memory, "reg", buf, … … 370 370 halt(); 371 371 } 372 372 373 373 size_t pos; 374 374 map->total = 0; … … 378 378 void *start = (void *) (buf[pos + ac - 1]); 379 379 uintptr_t size = buf[pos + ac + sc - 1]; 380 380 381 381 /* 382 382 * This is a hot fix of the issue which occurs on machines … … 389 389 map->zones[map->cnt - 1].size < start)) 390 390 break; 391 391 392 392 if (size > 0) { 393 393 map->zones[map->cnt].start = start; … … 397 397 } 398 398 } 399 399 400 400 if (map->total == 0) { 401 401 printf("Error: No physical memory detected, halting.\n"); … … 421 421 *base_pa = ofw_claim_phys_any(size, PAGE_SIZE); 422 422 } while (*base_pa <= min_pa); 423 423 424 424 *base = ofw_claim_virt_any(size, PAGE_SIZE); 425 425 ofw_map(*base_pa, *base, ALIGN_UP(size, PAGE_SIZE), (ofw_arg_t) -1); … … 433 433 OFW_TREE_PROPERTY_MAX_VALUELEN) <= 0) 434 434 return; 435 435 436 436 device_type[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = '\0'; 437 437 if (str_cmp(device_type, "display") != 0) 438 438 return; 439 439 440 440 /* Check for 8 bit depth */ 441 441 ofw_prop_t depth; … … 443 443 sizeof(depth)) <= 0) 444 444 depth = 0; 445 445 446 446 /* Get device path */ 447 447 ofw_arg_t len = ofw_package_to_path(handle, path, OFW_TREE_PATH_MAX_LEN); 448 448 if (len == (ofw_arg_t) -1) 449 449 return; 450 450 451 451 path[len] = '\0'; 452 452 453 453 /* Open the display to initialize it */ 454 454 ihandle screen = ofw_open(path); 455 455 if (screen == (ihandle) -1) 456 456 return; 457 457 458 458 if (depth == 8) { 459 459 /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */ … … 470 470 while ((current != 0) && (current != (phandle) -1)) { 471 471 ofw_setup_screen(current); 472 472 473 473 /* 474 474 * Recursively process the potential child node. … … 477 477 if ((child != 0) && (child != (phandle) -1)) 478 478 ofw_setup_screens_internal(child); 479 479 480 480 /* 481 481 * Iteratively process the next peer node. … … 493 493 continue; 494 494 } 495 495 496 496 /* 497 497 * No more peers on this level.
Note:
See TracChangeset
for help on using the changeset viewer.
