Changeset b50b5af2 in mainline for boot/genarch/ofw.c


Ignore:
Timestamp:
2009-08-22T10:48:00Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
04803bf
Parents:
1ea99cc (diff), a71c158 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/ofw.c

    r1ea99cc rb50b5af2  
    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
    3540uintptr_t ofw_cif;
    3641
     
    8590/** Perform a call to OpenFirmware client interface.
    8691 *
    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 *
    95101 */
    96102unsigned long
     
    221227}
    222228
    223 void *ofw_claim_virt(const void *virt, const int len)
     229void *ofw_claim_virt(const void *virt, const unsigned int len)
    224230{
    225231        ofw_arg_t retaddr;
     
    234240}
    235241
    236 void *ofw_claim_phys(const void *phys, const int len)
    237 {
    238         ofw_arg_t retaddr[2];
    239         int shift;
    240 
     242static 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       
    241256        if (sizeof(unative_t) == 8) {
    242                 shift = 32;
     257                ofw_arg_t retaddr[2];
     258                int shift = 32;
     259               
    243260                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,
    245262                    ((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                          */
    257263                        puts("Error: memory method claim() failed, halting.\n");
    258264                        halt();
    259265                }
     266               
     267                return (void *) ((retaddr[0] << shift) | retaddr[1]);
    260268        } 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
     281void *ofw_claim_phys(const void *phys, const unsigned int len)
     282{
     283        return ofw_claim_phys_internal(phys, len, 0);
     284}
     285
     286void *ofw_claim_phys_any(const unsigned int len, const unsigned int alignment)
     287{
     288        return ofw_claim_phys_internal(NULL, len, alignment);
     289}
     290
     291int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode)
    273292{
    274293        uintptr_t phys_hi, phys_lo;
     
    314333
    315334                /*
    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.
     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.
    321340                 */
    322341                if ((map->count > 0) && (map->zones[map->count - 1].start +
     
    335354}
    336355
    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 
    381356/**
    382357 * Sets up the palette for the 8-bit color depth configuration so that the
     
    392367        char device_name[BUF_SIZE];
    393368       
    394         /* resolve alias */
     369        /* Resolve alias */
    395370        if (ofw_get_property(ofw_aliases, "screen", device_name,
    396371            sizeof(device_name)) <= 0)
    397372                return false;
    398373       
    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 */
    400375        uint32_t depth;
    401376        phandle device = ofw_find_device(device_name);
     
    407382                return false;
    408383       
    409         /* required in order to be able to make a method call */
     384        /* Required in order to be able to make a method call */
    410385        ihandle screen = ofw_open(device_name);
    411386        if (screen == -1)
    412387                return false;
    413388       
    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 */
    415390        unsigned int i;
    416391        for (i = 0; i < 256; i++)
Note: See TracChangeset for help on using the changeset viewer.