v2: * Use phys_addr_t. --- NB: The use of phys_addr_t implies for ppc that the physical address width needs to be at least as large as the virtual address width.
On sparc32 due to sizeof(void*) < sizeof(phys_addr_t) we can't use phys_addr_t in some places, so I've used pointers instead.
drivers/cuda.c | 2 +- drivers/cuda.h | 4 ++-- drivers/escc.c | 40 ++++++++++++++++++++-------------------- drivers/escc.h | 4 ++-- drivers/macio.c | 8 ++++---- drivers/macio.h | 6 +++--- include/arch/ppc/io.h | 18 +++++++++--------- include/drivers/drivers.h | 6 +++--- 8 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/drivers/cuda.c b/drivers/cuda.c index c254720..e4319d5 100644 --- a/drivers/cuda.c +++ b/drivers/cuda.c @@ -369,7 +369,7 @@ rtc_init(char *path)
}
-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]; diff --git a/drivers/cuda.h b/drivers/cuda.h index 66662b5..d3818c0 100644 --- a/drivers/cuda.h +++ b/drivers/cuda.h @@ -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 @@ enum { CHARDEV_LAST, };
-cuda_t *cuda_init (const char *path, uint32_t base); +cuda_t *cuda_init (const char *path, phys_addr_t base); diff --git a/drivers/escc.c b/drivers/escc.c index 809cfa8..e22d245 100644 --- a/drivers/escc.c +++ b/drivers/escc.c @@ -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 @@ static volatile unsigned char *serial_dev; #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 @@ static void uart_init_line(volatile unsigned char *port, unsigned long baud)
}
-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 @@ int uart_init(uint64_t port, unsigned long speed)
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 @@ void serial_cls(void)
/* ( addr len -- actual ) */ static void -escc_read(unsigned long *address) +escc_read(phys_addr_t *address) { char *addr; int len; @@ -140,7 +140,7 @@ escc_read(unsigned long *address) 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 @@ escc_read(unsigned long *address)
/* ( 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 @@ escc_close(void) }
static void -escc_open(unsigned long *address) +escc_open(phys_addr_t *address) { #ifdef CONFIG_DRIVER_ESCC_SUN int len; @@ -199,7 +199,7 @@ escc_open(unsigned long *address) 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 @@ NODE_METHODS(escc) = { #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 @@ escc_read_keyboard(void) 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 @@ escc_read_keyboard(void) } }
-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 @@ NODE_METHODS(escc_keyboard) = { };
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 @@ ob_zs_init(uint64_t base, uint64_t offset, int intr, int slave, int keyboard) #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 @@ escc_add_channel(const char *path, const char *node, uint32_t addr, }
void -escc_init(const char *path, unsigned long addr) +escc_init(const char *path, phys_addr_t addr) { char buf[64]; int props[2]; diff --git a/drivers/escc.h b/drivers/escc.h index a5516db..caaf00d 100644 --- a/drivers/escc.h +++ b/drivers/escc.h @@ -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); diff --git a/drivers/macio.c b/drivers/macio.c index d6d1696..2baf295 100644 --- a/drivers/macio.c +++ b/drivers/macio.c @@ -43,7 +43,7 @@ arch_nvram_size( void ) 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 @@ arch_nvram_get( char *buf ) }
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 @@ NODE_METHODS(ob_macio) = { };
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 @@ ob_macio_heathrow_init(const char *path, uint32_t addr) }
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;
diff --git a/drivers/macio.h b/drivers/macio.h index d580387..925b881 100644 --- a/drivers/macio.h +++ b/drivers/macio.h @@ -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); diff --git a/include/arch/ppc/io.h b/include/arch/ppc/io.h index d7c78a0..e5180f2 100644 --- a/include/arch/ppc/io.h +++ b/include/arch/ppc/io.h @@ -22,15 +22,15 @@ extern uint32_t isa_io_base; * 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 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 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 *)(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. diff --git a/include/drivers/drivers.h b/include/drivers/drivers.h index 6829572..d139ace 100644 --- a/include/drivers/drivers.h +++ b/include/drivers/drivers.h @@ -113,9 +113,9 @@ char uart_getchar(int port); 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