Author: afaerber Date: Sat Oct 30 18:26:02 2010 New Revision: 933 URL: http://tracker.coreboot.org/trac/openbios/changeset/933
Log: Don't make assumptions about device address size
Prefer phys_addr_t for physical addresses.
Resort to uintptr_t where a conversion to pointer occurs, since the physical address may be larger (e.g., sparc32).
v2: * Use phys_addr_t.
Signed-off-by: Andreas Färber andreas.faerber@web.de
Modified: trunk/openbios-devel/drivers/cuda.c trunk/openbios-devel/drivers/cuda.h trunk/openbios-devel/drivers/escc.c trunk/openbios-devel/drivers/escc.h trunk/openbios-devel/drivers/macio.c trunk/openbios-devel/drivers/macio.h trunk/openbios-devel/include/arch/ppc/io.h trunk/openbios-devel/include/drivers/drivers.h
Modified: trunk/openbios-devel/drivers/cuda.c ============================================================================== --- trunk/openbios-devel/drivers/cuda.c Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/drivers/cuda.c Sat Oct 30 18:26:02 2010 (r933) @@ -369,7 +369,7 @@
}
-cuda_t *cuda_init (const char *path, uint32_t base) +cuda_t *cuda_init (const char *path, phys_addr_t base) { cuda_t *cuda; char buf[64];
Modified: trunk/openbios-devel/drivers/cuda.h ============================================================================== --- trunk/openbios-devel/drivers/cuda.h Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/drivers/cuda.h Sat Oct 30 18:26:02 2010 (r933) @@ -1,7 +1,7 @@ #include "adb_bus.h"
struct cuda_t { - uint32_t base; + phys_addr_t base; adb_bus_t *adb_bus; }; typedef struct cuda_t cuda_t; @@ -14,4 +14,4 @@ CHARDEV_LAST, };
-cuda_t *cuda_init (const char *path, uint32_t base); +cuda_t *cuda_init (const char *path, phys_addr_t base);
Modified: trunk/openbios-devel/drivers/escc.c ============================================================================== --- trunk/openbios-devel/drivers/escc.c Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/drivers/escc.c Sat Oct 30 18:26:02 2010 (r933) @@ -13,11 +13,11 @@
static volatile unsigned char *serial_dev;
-#define CTRL(addr) (*(volatile unsigned char *)(addr)) +#define CTRL(addr) (*(volatile unsigned char *)(uintptr_t)(addr)) #ifdef CONFIG_DRIVER_ESCC_SUN -#define DATA(addr) (*(volatile unsigned char *)(addr + 2)) +#define DATA(addr) (*(volatile unsigned char *)(uintptr_t)(addr + 2)) #else -#define DATA(addr) (*(volatile unsigned char *)(addr + 16)) +#define DATA(addr) (*(volatile unsigned char *)(uintptr_t)(addr + 16)) #endif
/* Conversion routines to/from brg time constants from/to bits @@ -54,19 +54,19 @@ #define Rx_CH_AV 0x1 /* Rx Character Available */ #define Tx_BUF_EMP 0x4 /* Tx Buffer empty */
-int uart_charav(int port) +int uart_charav(uintptr_t port) { return (CTRL(port) & Rx_CH_AV) != 0; }
-char uart_getchar(int port) +char uart_getchar(uintptr_t port) { while (!uart_charav(port)) ; return DATA(port) & 0177; }
-static void uart_putchar(int port, unsigned char c) +static void uart_putchar(uintptr_t port, unsigned char c) { if (!serial_dev) return; @@ -102,13 +102,13 @@
}
-int uart_init(uint64_t port, unsigned long speed) +int uart_init(phys_addr_t port, unsigned long speed) { #ifdef CONFIG_DRIVER_ESCC_SUN serial_dev = map_io(port & ~7ULL, ZS_REGS); serial_dev += port & 7ULL; #else - serial_dev = (unsigned char *)(unsigned long)port; + serial_dev = (unsigned char *)(uintptr_t)port; #endif uart_init_line(serial_dev, speed); return -1; @@ -116,7 +116,7 @@
void serial_putchar(int c) { - uart_putchar((int)serial_dev, (unsigned char) (c & 0xff)); + uart_putchar((uintptr_t)serial_dev, (unsigned char) (c & 0xff)); }
void serial_cls(void) @@ -131,7 +131,7 @@
/* ( addr len -- actual ) */ static void -escc_read(unsigned long *address) +escc_read(phys_addr_t *address) { char *addr; int len; @@ -140,7 +140,7 @@ addr = (char *)cell2pointer(POP());
if (len < 1) - printk("escc_read: bad len, addr %x len %x\n", (unsigned int)addr, len); + printk("escc_read: bad len, addr %p len %x\n", addr, len);
if (uart_charav(*address)) { *addr = (char)uart_getchar(*address); @@ -152,7 +152,7 @@
/* ( addr len -- actual ) */ static void -escc_write(unsigned long *address) +escc_write(phys_addr_t *address) { unsigned char *addr; int i, len; @@ -172,7 +172,7 @@ }
static void -escc_open(unsigned long *address) +escc_open(phys_addr_t *address) { #ifdef CONFIG_DRIVER_ESCC_SUN int len; @@ -199,7 +199,7 @@ RET ( -1 ); }
-DECLARE_UNNAMED_NODE(escc, INSTALL_OPEN, sizeof(unsigned long)); +DECLARE_UNNAMED_NODE(escc, INSTALL_OPEN, sizeof(phys_addr_t));
NODE_METHODS(escc) = { { "open", escc_open }, @@ -211,7 +211,7 @@ #ifdef CONFIG_DRIVER_ESCC_SUN static volatile unsigned char *kbd_dev;
-void kbd_init(uint64_t base) +void kbd_init(phys_addr_t base) { kbd_dev = map_io(base, 2 * 4); kbd_dev += 4; @@ -295,7 +295,7 @@ addr = (unsigned char *)POP();
if (len < 1) - printk("escc_read: bad len, addr %x len %x\n", (unsigned int)addr, len); + printk("escc_read: bad len, addr %p len %x\n", addr, len);
if (keyboard_dataready()) { *addr = keyboard_readdata(); @@ -305,7 +305,7 @@ } }
-DECLARE_UNNAMED_NODE(escc_keyboard, INSTALL_OPEN, sizeof(unsigned long)); +DECLARE_UNNAMED_NODE(escc_keyboard, INSTALL_OPEN, sizeof(phys_addr_t));
NODE_METHODS(escc_keyboard) = { { "open", escc_open }, @@ -314,7 +314,7 @@ };
void -ob_zs_init(uint64_t base, uint64_t offset, int intr, int slave, int keyboard) +ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard) { char nodebuff[256]; phandle_t aliases; @@ -369,7 +369,7 @@ #else
static void -escc_add_channel(const char *path, const char *node, uint32_t addr, +escc_add_channel(const char *path, const char *node, phys_addr_t addr, uint32_t offset) { char buf[64], tty[32]; @@ -430,7 +430,7 @@ }
void -escc_init(const char *path, unsigned long addr) +escc_init(const char *path, phys_addr_t addr) { char buf[64]; int props[2];
Modified: trunk/openbios-devel/drivers/escc.h ============================================================================== --- trunk/openbios-devel/drivers/escc.h Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/drivers/escc.h Sat Oct 30 18:26:02 2010 (r933) @@ -4,6 +4,6 @@
#define ZS_REGS 8
-void escc_init(const char *path, unsigned long addr); -void ob_zs_init(uint64_t base, uint64_t offset, int intr, int slave, +void escc_init(const char *path, phys_addr_t addr); +void ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard);
Modified: trunk/openbios-devel/drivers/macio.c ============================================================================== --- trunk/openbios-devel/drivers/macio.c Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/drivers/macio.c Sat Oct 30 18:26:02 2010 (r933) @@ -43,7 +43,7 @@ return NW_IO_NVRAM_SIZE >> NW_IO_NVRAM_SHIFT; }
-void macio_nvram_init(const char *path, uint32_t addr) +void macio_nvram_init(const char *path, phys_addr_t addr) { phandle_t chosen, aliases; phandle_t dnode; @@ -145,7 +145,7 @@ }
static void -openpic_init(const char *path, uint32_t addr) +openpic_init(const char *path, phys_addr_t addr) { phandle_t target_node; phandle_t dnode; @@ -238,7 +238,7 @@ };
void -ob_macio_heathrow_init(const char *path, uint32_t addr) +ob_macio_heathrow_init(const char *path, phys_addr_t addr) { phandle_t aliases;
@@ -253,7 +253,7 @@ }
void -ob_macio_keylargo_init(const char *path, uint32_t addr) +ob_macio_keylargo_init(const char *path, phys_addr_t addr) { phandle_t aliases;
Modified: trunk/openbios-devel/drivers/macio.h ============================================================================== --- trunk/openbios-devel/drivers/macio.h Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/drivers/macio.h Sat Oct 30 18:26:02 2010 (r933) @@ -1,5 +1,5 @@ extern phandle_t pic_handle;
-void ob_macio_heathrow_init(const char *path, uint32_t addr); -void ob_macio_keylargo_init(const char *path, uint32_t addr); -void macio_nvram_init(const char *path, uint32_t addr); +void ob_macio_heathrow_init(const char *path, phys_addr_t addr); +void ob_macio_keylargo_init(const char *path, phys_addr_t addr); +void macio_nvram_init(const char *path, phys_addr_t addr);
Modified: trunk/openbios-devel/include/arch/ppc/io.h ============================================================================== --- trunk/openbios-devel/include/arch/ppc/io.h Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/include/arch/ppc/io.h Sat Oct 30 18:26:02 2010 (r933) @@ -22,15 +22,15 @@ * are arrays of bytes, and byte-swapping is not appropriate in * that case. - paulus */ -#define insw(port, buf, ns) _insw((uint16_t *)((port)+isa_io_base), (buf), (ns)) -#define outsw(port, buf, ns) _outsw((uint16_t *)((port)+isa_io_base), (buf), (ns)) +#define insw(port, buf, ns) _insw((uint16_t *)(uintptr_t)((port)+isa_io_base), (buf), (ns)) +#define outsw(port, buf, ns) _outsw((uint16_t *)(uintptr_t)((port)+isa_io_base), (buf), (ns))
-#define inb(port) in_8((uint8_t *)((port)+isa_io_base)) -#define outb(val, port) out_8((uint8_t *)((port)+isa_io_base), (val)) -#define inw(port) in_le16((uint16_t *)((port)+isa_io_base)) -#define outw(val, port) out_le16((uint16_t *)((port)+isa_io_base), (val)) -#define inl(port) in_le32((uint32_t *)((port)+isa_io_base)) -#define outl(val, port) out_le32((uint32_t *)((port)+isa_io_base), (val)) +#define inb(port) in_8((uint8_t *)(uintptr_t)((port)+isa_io_base)) +#define outb(val, port) out_8((uint8_t *)(uintptr_t)((port)+isa_io_base), (val)) +#define inw(port) in_le16((uint16_t *)(uintptr_t)((port)+isa_io_base)) +#define outw(val, port) out_le16((uint16_t *)(uintptr_t)((port)+isa_io_base), (val)) +#define inl(port) in_le32((uint32_t *)(uintptr_t)((port)+isa_io_base)) +#define outl(val, port) out_le32((uint32_t *)(uintptr_t)((port)+isa_io_base), (val))
/* * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
Modified: trunk/openbios-devel/include/drivers/drivers.h ============================================================================== --- trunk/openbios-devel/include/drivers/drivers.h Sat Oct 30 18:18:08 2010 (r932) +++ trunk/openbios-devel/include/drivers/drivers.h Sat Oct 30 18:26:02 2010 (r933) @@ -113,9 +113,9 @@ void serial_putchar(int c); #endif #ifdef CONFIG_DRIVER_ESCC -int uart_init(uint64_t port, unsigned long speed); -int uart_charav(int port); -char uart_getchar(int port); +int uart_init(phys_addr_t port, unsigned long speed); +int uart_charav(uintptr_t port); +char uart_getchar(uintptr_t port); void serial_putchar(int c); void serial_cls(void); #ifdef CONFIG_DRIVER_ESCC_SUN