Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1764 → Rev 1771

/boot/trunk/genarch/ofw.h
29,16 → 29,12
#ifndef __OFW_H__
#define __OFW_H__
 
#define NULL 0
#define MEMMAP_MAX_RECORDS 32
#define false 0
#define true 1
#include <types.h>
#include <stdarg.h>
 
typedef __builtin_va_list va_list;
#define BUF_SIZE 1024
 
#define va_start(ap, last) __builtin_va_start(ap, last)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_end(ap) __builtin_va_end(ap)
#define MEMMAP_MAX_RECORDS 32
 
typedef struct {
void *start;
64,10 → 60,30
unsigned int size;
} keyboard_t;
 
typedef struct {
unsigned int info;
unsigned int addr_hi;
unsigned int addr_lo;
} pci_addr_t;
 
typedef struct {
pci_addr_t addr;
unsigned int size_hi;
unsigned int size_lo;
} pci_reg_t;
 
typedef unsigned long ofw_arg_t;
typedef unsigned int ihandle;
typedef unsigned int phandle;
 
extern phandle ofw_aliases;
 
extern void init(void);
extern void ofw_write(const char *str, const int len);
 
extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
extern phandle ofw_find_device(const char *name);
 
extern void *ofw_translate(const void *virt);
extern int ofw_map(const void *phys, const void *virt, const int size, const int mode);
extern int ofw_memmap(memmap_t *map);
/boot/trunk/genarch/ofw.c
31,12 → 31,7
#include <asm.h>
 
#define MAX_OFW_ARGS 10
#define BUF_SIZE 1024
 
typedef unsigned int ofw_arg_t;
typedef unsigned int ihandle;
typedef unsigned int phandle;
 
/** OpenFirmware command structure
*
*/
49,20 → 44,6
 
typedef void (*ofw_entry)(ofw_args_t *);
 
 
typedef struct {
unsigned int info;
unsigned int addr_hi;
unsigned int addr_lo;
} pci_addr_t;
 
typedef struct {
pci_addr_t addr;
unsigned int size_hi;
unsigned int size_lo;
} pci_reg_t;
 
 
ofw_entry ofw;
 
phandle ofw_chosen;
99,13 → 80,13
}
 
 
static phandle ofw_find_device(const char *name)
phandle ofw_find_device(const char *name)
{
return ofw_call("finddevice", 1, 1, NULL, name);
}
 
 
static int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
{
return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
}
204,8 → 185,8
 
int ofw_memmap(memmap_t *map)
{
unsigned int buf[BUF_SIZE];
int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned int) * BUF_SIZE);
unsigned long buf[BUF_SIZE];
int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
if (ret <= 0)
return false;
215,7 → 196,7
int pos;
map->total = 0;
map->count = 0;
for (pos = 0; (pos < ret / sizeof(unsigned int)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
void * start = (void *) buf[pos + ac - 1];
unsigned int size = buf[pos + ac + sc - 1];
233,7 → 214,7
{
char device_name[BUF_SIZE];
if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(char) * BUF_SIZE) <= 0)
if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
return false;
phandle device = ofw_find_device(device_name);
258,24 → 239,3
return true;
}
 
 
int ofw_keyboard(keyboard_t *keyboard)
{
char device_name[BUF_SIZE];
if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(char) * BUF_SIZE) <= 0)
return false;
phandle device = ofw_find_device(device_name);
if (device == -1)
return false;
pci_reg_t macio;
if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
return false;
keyboard->addr = (void *) macio.addr.addr_lo;
keyboard->size = macio.size_lo;
return true;
}