Changeset b7b5f83 in mainline for genarch/ofw.c


Ignore:
Timestamp:
2006-07-03T19:46:13Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b95b717
Parents:
d22645e
Message:

Cleanup OpenFirmware driver and prepare it for integration with sparc64 bootloader.
Start sparc64 boot loader (now inactive and unfunctional).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • genarch/ofw.c

    rd22645e rb7b5f83  
    3232
    3333#define MAX_OFW_ARGS            10
    34 #define BUF_SIZE                1024
    35 
    36 typedef unsigned int ofw_arg_t;
    37 typedef unsigned int ihandle;
    38 typedef unsigned int phandle;
    3934
    4035/** OpenFirmware command structure
     
    5045typedef void (*ofw_entry)(ofw_args_t *);
    5146
    52 
    53 typedef struct {
    54         unsigned int info;
    55         unsigned int addr_hi;
    56     unsigned int addr_lo;
    57 } pci_addr_t;
    58 
    59 typedef struct {
    60         pci_addr_t addr;
    61     unsigned int size_hi;
    62     unsigned int size_lo;
    63 } pci_reg_t;
    64 
    65 
    6647ofw_entry ofw;
    6748
     
    10081
    10182
    102 static phandle ofw_find_device(const char *name)
     83phandle ofw_find_device(const char *name)
    10384{
    10485        return ofw_call("finddevice", 1, 1, NULL, name);
     
    10687
    10788
    108 static int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
     89int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
    10990{
    11091        return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
     
    205186int ofw_memmap(memmap_t *map)
    206187{
    207         unsigned int buf[BUF_SIZE];
    208         int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned int) * BUF_SIZE);
     188        unsigned long buf[BUF_SIZE];
     189        int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
    209190        if (ret <= 0)
    210191                return false;
     
    216197        map->total = 0;
    217198        map->count = 0;
    218         for (pos = 0; (pos < ret / sizeof(unsigned int)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
     199        for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
    219200                void * start = (void *) buf[pos + ac - 1];
    220201                unsigned int size = buf[pos + ac + sc - 1];
     
    234215        char device_name[BUF_SIZE];
    235216       
    236         if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(char) * BUF_SIZE) <= 0)
     217        if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
    237218                return false;
    238219       
     
    259240}
    260241
    261 
    262 int ofw_keyboard(keyboard_t *keyboard)
    263 {
    264         char device_name[BUF_SIZE];
    265        
    266         if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(char) * BUF_SIZE) <= 0)
    267                 return false;
    268        
    269         phandle device = ofw_find_device(device_name);
    270         if (device == -1)
    271                 return false;
    272        
    273         pci_reg_t macio;
    274         if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
    275                 return false;
    276        
    277         keyboard->addr = (void *) macio.addr.addr_lo;
    278         keyboard->size = macio.size_lo;
    279        
    280         return true;
    281 }
Note: See TracChangeset for help on using the changeset viewer.