Changeset 965dc18 in mainline for boot/genarch/ofw.c


Ignore:
Timestamp:
2008-12-05T19:59:03Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49093a4
Parents:
0258e67
Message:

Merge sparc branch to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/ofw.c

    r0258e67 r965dc18  
    4949                halt();
    5050       
    51         if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
     51        if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout,
     52            sizeof(ofw_stdout)) <= 0)
    5253                ofw_stdout = 0;
    5354       
     
    5859        }
    5960       
    60         if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
     61        if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu,
     62            sizeof(ofw_mmu)) <= 0) {
    6163                puts("\r\nError: Unable to get mmu property, halted.\r\n");
    6264                halt();
    6365        }
    64         if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, sizeof(ofw_memory_prop)) <= 0) {
     66        if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop,
     67            sizeof(ofw_memory_prop)) <= 0) {
    6568                puts("\r\nError: Unable to get memory property, halted.\r\n");
    6669                halt();
     
    8285/** Perform a call to OpenFirmware client interface.
    8386 *
    84  * @param service String identifying the service requested.
    85  * @param nargs Number of input arguments.
    86  * @param nret Number of output arguments. This includes the return value.
    87  * @param rets Buffer for output arguments or NULL. The buffer must accommodate nret - 1 items.
    88  *
    89  * @return Return value returned by the client interface.
     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.
    9095 */
    91 unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
     96unsigned long
     97ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets,
     98    ...)
    9299{
    93100        va_list list;
     
    120127}
    121128
    122 int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
     129int
     130ofw_get_property(const phandle device, const char *name, void *buf,
     131    const int buflen)
    123132{
    124133        return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
     
    145154       
    146155        if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0)
    147                 if (ofw_get_property(ofw_root, "#address-cells", &ret, sizeof(ret)) <= 0)
     156                if (ofw_get_property(ofw_root, "#address-cells", &ret,
     157                    sizeof(ret)) <= 0)
    148158                        ret = OFW_ADDRESS_CELLS;
    149159       
     
    157167       
    158168        if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0)
    159                 if (ofw_get_property(ofw_root, "#size-cells", &ret, sizeof(ret)) <= 0)
     169                if (ofw_get_property(ofw_root, "#size-cells", &ret,
     170                    sizeof(ret)) <= 0)
    160171                        ret = OFW_SIZE_CELLS;
    161172       
     
    193204        int shift;
    194205
    195         if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0) {
     206        if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu,
     207            virt) != 0) {
    196208                puts("Error: MMU method translate() failed, halting.\n");
    197209                halt();
     
    213225        ofw_arg_t retaddr;
    214226
    215         if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) {
     227        if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len,
     228            virt) != 0) {
    216229                puts("Error: MMU method claim() failed, halting.\n");
    217230                halt();
     
    270283        }
    271284
    272         return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, virt,
    273             phys_hi, phys_lo);
     285        return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size,
     286            virt, phys_hi, phys_lo);
    274287}
    275288
     
    282295int ofw_memmap(memmap_t *map)
    283296{
    284         unsigned int ac = ofw_get_address_cells(ofw_memory);
    285         unsigned int sc = ofw_get_size_cells(ofw_memory);
    286 
    287         uint32_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
     297        unsigned int ac = ofw_get_address_cells(ofw_memory) /
     298            (sizeof(uintptr_t) / sizeof(uint32_t));
     299        unsigned int sc = ofw_get_size_cells(ofw_memory) /
     300            (sizeof(uintptr_t) / sizeof(uint32_t));
     301        printf("address cells: %d, size cells: %d. ", ac, sc);
     302
     303        uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)];
    288304        int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
    289305        if (ret <= 0)           /* ret is the number of written bytes */
     
    293309        map->total = 0;
    294310        map->count = 0;
    295         for (pos = 0; (pos < ret / sizeof(uint32_t)) &&
     311        for (pos = 0; (pos < ret / sizeof(uintptr_t)) &&
    296312            (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
    297                 void * start = (void *) ((uintptr_t) buf[pos + ac - 1]);
     313                void *start = (void *) (buf[pos + ac - 1]);
    298314                unsigned int size = buf[pos + ac + sc - 1];
    299                
     315
     316                /*
     317                 * This is a hot fix of the issue which occurs on machines
     318                 * where there are holes in the physical memory (such as
     319                 * SunBlade 1500). Should we detect a hole in the physical
     320                 * memory, we will ignore any memory detected behind
     321                 * the hole and pretend the hole does not exist.
     322                 */
     323                if ((map->count > 0) && (map->zones[map->count - 1].start +
     324                    map->zones[map->count - 1].size < start))
     325                        break;
     326
    300327                if (size > 0) {
    301328                        map->zones[map->count].start = start;
     
    309336}
    310337
    311 
    312338int ofw_screen(screen_t *screen)
    313339{
     
    315341        uint32_t virtaddr;
    316342       
    317         if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
     343        if (ofw_get_property(ofw_aliases, "screen", device_name,
     344            sizeof(device_name)) <= 0)
    318345                return false;
    319346       
     
    322349                return false;
    323350       
    324         if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0)
     351        if (ofw_get_property(device, "address", &virtaddr,
     352            sizeof(virtaddr)) <= 0)
    325353                return false;
    326354
    327355        screen->addr = (void *) ((uintptr_t) virtaddr);
    328356
    329         if (ofw_get_property(device, "width", &screen->width, sizeof(screen->width)) <= 0)
    330                 return false;
    331        
    332         if (ofw_get_property(device, "height", &screen->height, sizeof(screen->height)) <= 0)
    333                 return false;
    334        
    335         if (ofw_get_property(device, "depth", &screen->bpp, sizeof(screen->bpp)) <= 0)
    336                 return false;
    337        
    338         if (ofw_get_property(device, "linebytes", &screen->scanline, sizeof(screen->scanline)) <= 0)
     357        if (ofw_get_property(device, "width", &screen->width,
     358            sizeof(screen->width)) <= 0)
     359                return false;
     360       
     361        if (ofw_get_property(device, "height", &screen->height,
     362            sizeof(screen->height)) <= 0)
     363                return false;
     364       
     365        if (ofw_get_property(device, "depth", &screen->bpp,
     366            sizeof(screen->bpp)) <= 0)
     367                return false;
     368       
     369        if (ofw_get_property(device, "linebytes", &screen->scanline,
     370            sizeof(screen->scanline)) <= 0)
    339371                return false;
    340372       
Note: See TracChangeset for help on using the changeset viewer.