Changes in boot/genarch/ofw.c [fd375a8d:e731b0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/genarch/ofw.c
rfd375a8d re731b0d 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 35 40 uintptr_t ofw_cif; 36 41 … … 85 90 /** Perform a call to OpenFirmware client interface. 86 91 * 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. 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 * 95 101 */ 96 102 unsigned long … … 221 227 } 222 228 223 void *ofw_claim_virt(const void *virt, const int len)229 void *ofw_claim_virt(const void *virt, const unsigned int len) 224 230 { 225 231 ofw_arg_t retaddr; … … 234 240 } 235 241 236 void *ofw_claim_phys(const void *phys, const int len) 237 { 238 ofw_arg_t retaddr[2]; 239 int shift; 240 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 241 256 if (sizeof(unative_t) == 8) { 242 shift = 32; 257 ofw_arg_t retaddr[2]; 258 int shift = 32; 259 243 260 if (ofw_call("call-method", 6, 3, retaddr, "claim", 244 ofw_memory_prop, 0, len, ((uintptr_t) phys) >> shift,261 ofw_memory_prop, alignment, len, ((uintptr_t) phys) >> shift, 245 262 ((uintptr_t) phys) & ((uint32_t) -1)) != 0) { 246 /*247 * Note that this will help us to discover248 * conflicts between OpenFirmware allocations249 * and our use of physical memory.250 * It is better to detect collisions here251 * than to cope with weird errors later.252 *253 * So this is really not to make the loader254 * more generic; it is here for debugging255 * purposes.256 */257 263 puts("Error: memory method claim() failed, halting.\n"); 258 264 halt(); 259 265 } 266 267 return (void *) ((retaddr[0] << shift) | retaddr[1]); 260 268 } else { 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) 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) 273 292 { 274 293 uintptr_t phys_hi, phys_lo; … … 314 333 315 334 /* 316 317 318 319 320 335 * This is a hot fix of the issue which occurs on machines 336 * where there are holes in the physical memory (such as 337 * SunBlade 1500). Should we detect a hole in the physical 338 * memory, we will ignore any memory detected behind 339 * the hole and pretend the hole does not exist. 321 340 */ 322 341 if ((map->count > 0) && (map->zones[map->count - 1].start + … … 335 354 } 336 355 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 381 356 /** 382 357 * Sets up the palette for the 8-bit color depth configuration so that the … … 392 367 char device_name[BUF_SIZE]; 393 368 394 /* resolve alias */369 /* Resolve alias */ 395 370 if (ofw_get_property(ofw_aliases, "screen", device_name, 396 371 sizeof(device_name)) <= 0) 397 372 return false; 398 373 399 /* for depth greater than 8 it makes no sense to set up the palette */374 /* For depth greater than 8 it makes no sense to set up the palette */ 400 375 uint32_t depth; 401 376 phandle device = ofw_find_device(device_name); … … 407 382 return false; 408 383 409 /* required in order to be able to make a method call */384 /* Required in order to be able to make a method call */ 410 385 ihandle screen = ofw_open(device_name); 411 386 if (screen == -1) 412 387 return false; 413 388 414 /* setup the palette so that the (inverted) 3:2:3 scheme is usable */389 /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */ 415 390 unsigned int i; 416 391 for (i = 0; i < 256; i++)
Note:
See TracChangeset
for help on using the changeset viewer.