Changes in boot/genarch/ofw.c [e731b0d:fd375a8d] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/ofw.c

    re731b0d rfd375a8d  
    3333#include <types.h>
    3434
    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 
    4035uintptr_t ofw_cif;
    4136
     
    9085/** Perform a call to OpenFirmware client interface.
    9186 *
    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.
    10195 */
    10296unsigned long
     
    227221}
    228222
    229 void *ofw_claim_virt(const void *virt, const unsigned int len)
     223void *ofw_claim_virt(const void *virt, const int len)
    230224{
    231225        ofw_arg_t retaddr;
     
    240234}
    241235
    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        
     236void *ofw_claim_phys(const void *phys, const int len)
     237{
     238        ofw_arg_t retaddr[2];
     239        int shift;
     240
    256241        if (sizeof(unative_t) == 8) {
    257                 ofw_arg_t retaddr[2];
    258                 int shift = 32;
    259                
     242                shift = 32;
    260243                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,
    262245                    ((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                         */
    263257                        puts("Error: memory method claim() failed, halting.\n");
    264258                        halt();
    265259                }
    266                
    267                 return (void *) ((retaddr[0] << shift) | retaddr[1]);
    268260        } 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
     272int ofw_map(const void *phys, const void *virt, const int size, const int mode)
    292273{
    293274        uintptr_t phys_hi, phys_lo;
     
    333314
    334315                /*
    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.
     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.
    340321                 */
    341322                if ((map->count > 0) && (map->zones[map->count - 1].start +
     
    354335}
    355336
     337int 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
    356381/**
    357382 * Sets up the palette for the 8-bit color depth configuration so that the
     
    367392        char device_name[BUF_SIZE];
    368393       
    369         /* Resolve alias */
     394        /* resolve alias */
    370395        if (ofw_get_property(ofw_aliases, "screen", device_name,
    371396            sizeof(device_name)) <= 0)
    372397                return false;
    373398       
    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 */
    375400        uint32_t depth;
    376401        phandle device = ofw_find_device(device_name);
     
    382407                return false;
    383408       
    384         /* Required in order to be able to make a method call */
     409        /* required in order to be able to make a method call */
    385410        ihandle screen = ofw_open(device_name);
    386411        if (screen == -1)
    387412                return false;
    388413       
    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 */
    390415        unsigned int i;
    391416        for (i = 0; i < 256; i++)
Note: See TracChangeset for help on using the changeset viewer.