Changeset 95b47c82 in mainline for boot/genarch/ofw.c


Ignore:
Timestamp:
2007-04-15T20:51:04Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9a7a970
Parents:
ddee708
Message:

Fix ticket #31.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/genarch/ofw.c

    rddee708 r95b47c82  
    3939phandle ofw_root;
    4040ihandle ofw_mmu;
     41ihandle ofw_memory_prop;
    4142phandle ofw_memory;
    4243phandle ofw_aliases;
     
    4849                halt();
    4950       
    50         if (ofw_get_property(ofw_chosen, "stdout",  &ofw_stdout, sizeof(ofw_stdout)) <= 0)
     51        if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0)
    5152                ofw_stdout = 0;
    5253       
     
    5758        }
    5859       
    59         if (ofw_get_property(ofw_chosen, "mmu",  &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
     60        if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
    6061                puts("\r\nError: Unable to get mmu property, halted.\r\n");
     62                halt();
     63        }
     64        if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, sizeof(ofw_memory_prop)) <= 0) {
     65                puts("\r\nError: Unable to get memory property, halted.\r\n");
    6166                halt();
    6267        }
     
    201206                shift = 0;
    202207
    203         return (void *) ((result[2]<<shift)|result[3]);
    204 }
    205 
    206 void *ofw_claim(const void *virt, const int len)
     208        return (void *) ((result[2] << shift) | result[3]);
     209}
     210
     211void *ofw_claim_virt(const void *virt, const int len)
    207212{
    208213        ofw_arg_t retaddr;
    209         int shift;
    210214
    211215        if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) {
     
    215219
    216220        return (void *) retaddr;
     221}
     222
     223void *ofw_claim_phys(const void *phys, const int len)
     224{
     225        ofw_arg_t retaddr[2];
     226        int shift;
     227
     228        if (sizeof(unative_t) == 8) {
     229                shift = 32;
     230                if (ofw_call("call-method", 6, 3, retaddr, "claim",
     231                    ofw_memory_prop, 0, len, ((uintptr_t) phys) >> shift,
     232                    ((uintptr_t) phys) & ((uint32_t) -1)) != 0) {
     233                        /*
     234                         * Note that this will help us to discover
     235                         * conflicts between OpenFirmware allocations
     236                         * and our use of physical memory.
     237                         * It is better to detect collisions here
     238                         * than to cope with weird errors later.
     239                         *
     240                         * So this is really not to make the loader
     241                         * more generic; it is here for debugging
     242                         * purposes.
     243                         */
     244                        puts("Error: memory method claim() failed, halting.\n");
     245                        halt();
     246                }
     247        } else {
     248                shift = 0;
     249                /*
     250                 * FIXME: the number of arguments is probably different...
     251                 */
     252                puts("Error: 32-bit ofw_claim_phys not implemented.\n");
     253                halt();
     254        }
     255
     256        return (void *) ((retaddr[0] << shift) | retaddr[1]);
    217257}
    218258
     
    231271
    232272        return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, virt,
    233                 phys_hi, phys_lo);
     273            phys_hi, phys_lo);
    234274}
    235275
     
    253293        map->total = 0;
    254294        map->count = 0;
    255         for (pos = 0; (pos < ret / sizeof(uint32_t)) && (map->count <
    256                 MEMMAP_MAX_RECORDS); pos += ac + sc) {
     295        for (pos = 0; (pos < ret / sizeof(uint32_t)) &&
     296            (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
    257297                void * start = (void *) ((uintptr_t) buf[pos + ac - 1]);
    258298                unsigned int size = buf[pos + ac + sc - 1];
Note: See TracChangeset for help on using the changeset viewer.