Changes in boot/genarch/ofw.c [e731b0d:fd375a8d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/ofw.c
re731b0d rfd375a8d 33 33 #include <types.h> 34 34 35 #define RED(i) (((i) >> 5) & ((1 << 3) - 1))36 #define GREEN(i) (((i) >> 3) & ((1 << 2) - 1))37 #define BLUE(i) ((i) & ((1 << 3) - 1))38 #define CLIP(i) ((i) <= 255 ? (i) : 255)39 40 35 uintptr_t ofw_cif; 41 36 … … 90 85 /** Perform a call to OpenFirmware client interface. 91 86 * 92 * @param service String identifying the service requested. 93 * @param nargs Number of input arguments. 94 * @param nret Number of output arguments. This includes the return 95 * value. 96 * @param rets Buffer for output arguments or NULL. The buffer must 97 * accommodate nret - 1 items. 98 * 99 * @return Return value returned by the client interface. 100 * 87 * @param service String identifying the service requested. 88 * @param nargs Number of input arguments. 89 * @param nret Number of output arguments. This includes the return 90 * value. 91 * @param rets Buffer for output arguments or NULL. The buffer must 92 * accommodate nret - 1 items. 93 * 94 * @return Return value returned by the client interface. 101 95 */ 102 96 unsigned long … … 227 221 } 228 222 229 void *ofw_claim_virt(const void *virt, const unsignedint len)223 void *ofw_claim_virt(const void *virt, const int len) 230 224 { 231 225 ofw_arg_t retaddr; … … 240 234 } 241 235 242 static void *ofw_claim_phys_internal(const void *phys, const unsigned int len, const unsigned int alignment) 243 { 244 /* 245 * Note that the return value check will help 246 * us to discover conflicts between OpenFirmware 247 * allocations and our use of physical memory. 248 * It is better to detect collisions here 249 * than to cope with weird errors later. 250 * 251 * So this is really not to make the loader 252 * more generic; it is here for debugging 253 * purposes. 254 */ 255 236 void *ofw_claim_phys(const void *phys, const int len) 237 { 238 ofw_arg_t retaddr[2]; 239 int shift; 240 256 241 if (sizeof(unative_t) == 8) { 257 ofw_arg_t retaddr[2]; 258 int shift = 32; 259 242 shift = 32; 260 243 if (ofw_call("call-method", 6, 3, retaddr, "claim", 261 ofw_memory_prop, alignment, len, ((uintptr_t) phys) >> shift,244 ofw_memory_prop, 0, len, ((uintptr_t) phys) >> shift, 262 245 ((uintptr_t) phys) & ((uint32_t) -1)) != 0) { 246 /* 247 * Note that this will help us to discover 248 * conflicts between OpenFirmware allocations 249 * and our use of physical memory. 250 * It is better to detect collisions here 251 * than to cope with weird errors later. 252 * 253 * So this is really not to make the loader 254 * more generic; it is here for debugging 255 * purposes. 256 */ 263 257 puts("Error: memory method claim() failed, halting.\n"); 264 258 halt(); 265 259 } 266 267 return (void *) ((retaddr[0] << shift) | retaddr[1]);268 260 } else { 269 ofw_arg_t retaddr[1]; 270 271 if (ofw_call("call-method", 5, 2, retaddr, "claim", 272 ofw_memory_prop, alignment, len, (uintptr_t) phys) != 0) { 273 puts("Error: memory method claim() failed, halting.\n"); 274 halt(); 275 } 276 277 return (void *) retaddr[0]; 278 } 279 } 280 281 void *ofw_claim_phys(const void *phys, const unsigned int len) 282 { 283 return ofw_claim_phys_internal(phys, len, 0); 284 } 285 286 void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment) 287 { 288 return ofw_claim_phys_internal(NULL, len, alignment); 289 } 290 291 int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode) 261 shift = 0; 262 /* 263 * FIXME: the number of arguments is probably different... 264 */ 265 puts("Error: 32-bit ofw_claim_phys not implemented.\n"); 266 halt(); 267 } 268 269 return (void *) ((retaddr[0] << shift) | retaddr[1]); 270 } 271 272 int ofw_map(const void *phys, const void *virt, const int size, const int mode) 292 273 { 293 274 uintptr_t phys_hi, phys_lo; … … 333 314 334 315 /* 335 * This is a hot fix of the issue which occurs on machines336 * where there are holes in the physical memory (such as337 * SunBlade 1500). Should we detect a hole in the physical338 * memory, we will ignore any memory detected behind339 * the hole and pretend the hole does not exist.316 * This is a hot fix of the issue which occurs on machines 317 * where there are holes in the physical memory (such as 318 * SunBlade 1500). Should we detect a hole in the physical 319 * memory, we will ignore any memory detected behind 320 * the hole and pretend the hole does not exist. 340 321 */ 341 322 if ((map->count > 0) && (map->zones[map->count - 1].start + … … 354 335 } 355 336 337 int ofw_screen(screen_t *screen) 338 { 339 char device_name[BUF_SIZE]; 340 uint32_t virtaddr; 341 342 if (ofw_get_property(ofw_aliases, "screen", device_name, 343 sizeof(device_name)) <= 0) 344 return false; 345 346 phandle device = ofw_find_device(device_name); 347 if (device == -1) 348 return false; 349 350 if (ofw_get_property(device, "address", &virtaddr, 351 sizeof(virtaddr)) <= 0) 352 return false; 353 354 screen->addr = (void *) ((uintptr_t) virtaddr); 355 356 if (ofw_get_property(device, "width", &screen->width, 357 sizeof(screen->width)) <= 0) 358 return false; 359 360 if (ofw_get_property(device, "height", &screen->height, 361 sizeof(screen->height)) <= 0) 362 return false; 363 364 if (ofw_get_property(device, "depth", &screen->bpp, 365 sizeof(screen->bpp)) <= 0) 366 return false; 367 368 if (ofw_get_property(device, "linebytes", &screen->scanline, 369 sizeof(screen->scanline)) <= 0) 370 return false; 371 372 return true; 373 } 374 375 #define RED(i) (((i) >> 5) & ((1 << 3) - 1)) 376 #define GREEN(i) (((i) >> 3) & ((1 << 2) - 1)) 377 #define BLUE(i) ((i) & ((1 << 3) - 1)) 378 #define CLIP(i) ((i) <= 255 ? (i) : 255) 379 380 356 381 /** 357 382 * Sets up the palette for the 8-bit color depth configuration so that the … … 367 392 char device_name[BUF_SIZE]; 368 393 369 /* Resolve alias */394 /* resolve alias */ 370 395 if (ofw_get_property(ofw_aliases, "screen", device_name, 371 396 sizeof(device_name)) <= 0) 372 397 return false; 373 398 374 /* For depth greater than 8 it makes no sense to set up the palette */399 /* for depth greater than 8 it makes no sense to set up the palette */ 375 400 uint32_t depth; 376 401 phandle device = ofw_find_device(device_name); … … 382 407 return false; 383 408 384 /* Required in order to be able to make a method call */409 /* required in order to be able to make a method call */ 385 410 ihandle screen = ofw_open(device_name); 386 411 if (screen == -1) 387 412 return false; 388 413 389 /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */414 /* setup the palette so that the (inverted) 3:2:3 scheme is usable */ 390 415 unsigned int i; 391 416 for (i = 0; i < 256; i++)
Note:
See TracChangeset
for help on using the changeset viewer.