Changeset b7b5f83 in mainline


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).

Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • arch/ppc32/loader/ofw.c

    rd22645e rb7b5f83  
    3434        ofw_write(str, len);
    3535}
     36
     37int ofw_keyboard(keyboard_t *keyboard)
     38{
     39        char device_name[BUF_SIZE];
     40       
     41        if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
     42                return false;
     43                               
     44        phandle device = ofw_find_device(device_name);
     45        if (device == -1)
     46                return false;
     47                                                               
     48        pci_reg_t macio;
     49        if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
     50                return false;
     51        keyboard->addr = (void *) macio.addr.addr_lo;
     52        keyboard->size = macio.size_lo;
     53
     54        return true;
     55}
  • arch/ppc64/loader/ofw.c

    rd22645e rb7b5f83  
    3030#include <printf.h>
    3131
    32 void write(const char *str, const long len)
     32void write(const char *str, const int len)
    3333{
    3434        ofw_write(str, len);
    3535}
     36
     37int ofw_keyboard(keyboard_t *keyboard)
     38{
     39        char device_name[BUF_SIZE];
     40       
     41        if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
     42                return false;
     43                               
     44        phandle device = ofw_find_device(device_name);
     45        if (device == -1)
     46                return false;
     47                                                               
     48        pci_reg_t macio;
     49        if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
     50                return false;
     51        keyboard->addr = (void *) macio.addr.addr_lo;
     52        keyboard->size = macio.size_lo;
     53
     54        return true;
     55}
  • arch/sparc64/Makefile.inc

    rd22645e rb7b5f83  
    3232
    3333image.iso: kernel
     34        make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(CONFIG_IMAGE)
    3435        mkdir -p $(TMP)/boot
    3536        mkdir -p $(TMP)/kernel
  • 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 }
  • genarch/ofw.h

    rd22645e rb7b5f83  
    3030#define __OFW_H__
    3131
    32 #define NULL 0
    33 #define MEMMAP_MAX_RECORDS 32
    34 #define false 0
    35 #define true 1
     32#include <types.h>
     33#include <stdarg.h>
    3634
    37 typedef __builtin_va_list va_list;
     35#define BUF_SIZE                1024
    3836
    39 #define va_start(ap, last)              __builtin_va_start(ap, last)
    40 #define va_arg(ap, type)                __builtin_va_arg(ap, type)
    41 #define va_end(ap)                      __builtin_va_end(ap)
     37#define MEMMAP_MAX_RECORDS      32
    4238
    4339typedef struct {
     
    6561} keyboard_t;
    6662
     63typedef struct {
     64        unsigned int info;
     65        unsigned int addr_hi;
     66        unsigned int addr_lo;
     67} pci_addr_t;
     68
     69typedef struct {
     70        pci_addr_t addr;
     71        unsigned int size_hi;
     72        unsigned int size_lo;
     73} pci_reg_t;
     74
     75typedef unsigned long ofw_arg_t;
     76typedef unsigned int ihandle;
     77typedef unsigned int phandle;
     78
     79extern phandle ofw_aliases;
    6780
    6881extern void init(void);
    6982extern void ofw_write(const char *str, const int len);
     83
     84extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
     85extern phandle ofw_find_device(const char *name);
    7086
    7187extern void *ofw_translate(const void *virt);
Note: See TracChangeset for help on using the changeset viewer.