This cleans up the OFMEM interface by allowing us to keep all of the architecture-specific code in separate header files; in particular ofmem_sparc32.h and ofmem_sparc64.h. PPC doesn't reference the variables from ofmem.h outside of ofmem.c, so simply redefine them as static variables.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/qemu/ofmem.c | 4 +- openbios-devel/arch/sparc32/lib.c | 2 +- openbios-devel/arch/sparc32/ofmem_sparc32.c | 2 +- openbios-devel/arch/sparc64/lib.c | 2 +- openbios-devel/arch/sparc64/ofmem_sparc64.c | 2 +- openbios-devel/arch/sparc64/ofmem_sparc64.h | 31 ------------ openbios-devel/drivers/iommu.c | 2 +- .../include/arch/sparc32/ofmem_sparc32.h | 28 +++++++++++ .../include/arch/sparc64/ofmem_sparc64.h | 50 ++++++++++++++++++++ openbios-devel/include/libopenbios/ofmem.h | 43 ----------------- 10 files changed, 85 insertions(+), 81 deletions(-) delete mode 100644 openbios-devel/arch/sparc64/ofmem_sparc64.h create mode 100644 openbios-devel/include/arch/sparc32/ofmem_sparc32.h create mode 100644 openbios-devel/include/arch/sparc64/ofmem_sparc64.h
diff --git a/openbios-devel/arch/ppc/qemu/ofmem.c b/openbios-devel/arch/ppc/qemu/ofmem.c index fbade1e..25555a0 100644 --- a/openbios-devel/arch/ppc/qemu/ofmem.c +++ b/openbios-devel/arch/ppc/qemu/ofmem.c @@ -75,13 +75,13 @@ get_rom_base(void) return ofmem->ramsize - OF_CODE_SIZE; }
-unsigned long +static unsigned long get_ram_top(void) { return get_hash_base() - (32 + 64 + 64) * 1024 - OFMEM_SIZE; }
-unsigned long +static unsigned long get_ram_bottom(void) { return FREE_BASE; diff --git a/openbios-devel/arch/sparc32/lib.c b/openbios-devel/arch/sparc32/lib.c index 799399c..483069c 100644 --- a/openbios-devel/arch/sparc32/lib.c +++ b/openbios-devel/arch/sparc32/lib.c @@ -9,7 +9,7 @@
#include "libc/vsprintf.h" #include "libopenbios/bindings.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc32/ofmem_sparc32.h" #include "asm/asi.h" #include "pgtsrmmu.h" #include "openprom.h" diff --git a/openbios-devel/arch/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c index 19d0d8e..20eab20 100644 --- a/openbios-devel/arch/sparc32/ofmem_sparc32.c +++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c @@ -15,7 +15,7 @@ #include "config.h" #include "libopenbios/bindings.h" #include "libc/string.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc32/ofmem_sparc32.h" #include "asm/asi.h" #include "pgtsrmmu.h"
diff --git a/openbios-devel/arch/sparc64/lib.c b/openbios-devel/arch/sparc64/lib.c index abcac9f..e9101af 100644 --- a/openbios-devel/arch/sparc64/lib.c +++ b/openbios-devel/arch/sparc64/lib.c @@ -14,7 +14,7 @@ #include "libopenbios/sys_info.h" #include "boot.h"
-#include "ofmem_sparc64.h" +#include "arch/sparc64/ofmem_sparc64.h"
/* Format a string and print it on the screen, just like the libc * function printf. diff --git a/openbios-devel/arch/sparc64/ofmem_sparc64.c b/openbios-devel/arch/sparc64/ofmem_sparc64.c index 5445d60..984eae4 100644 --- a/openbios-devel/arch/sparc64/ofmem_sparc64.c +++ b/openbios-devel/arch/sparc64/ofmem_sparc64.c @@ -15,7 +15,7 @@ #include "config.h" #include "libopenbios/bindings.h" #include "libc/string.h" -#include "ofmem_sparc64.h" +#include "arch/sparc64/ofmem_sparc64.h" #include "spitfire.h"
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8)) diff --git a/openbios-devel/arch/sparc64/ofmem_sparc64.h b/openbios-devel/arch/sparc64/ofmem_sparc64.h deleted file mode 100644 index ad67f71..0000000 --- a/openbios-devel/arch/sparc64/ofmem_sparc64.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * <ofmem_sparc64.h> - * - * OF Memory manager - * - * Copyright (C) 1999, 2002 Samuel Rydh (samuel@ibrium.se) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation - * - */ - -#ifndef _H_OFMEM_SPARC64 -#define _H_OFMEM_SPARC64 - -#include "libopenbios/ofmem.h" - -extern void ofmem_map_pages(ucell phys, ucell virt, ucell size, ucell mode); - -typedef int (*translation_entry_cb)(ucell phys, ucell virt, ucell size, ucell mode); - -extern void ofmem_walk_boot_map(translation_entry_cb cb); - -extern translation_t **g_ofmem_translations; - -extern void dtlb_miss_handler(void); -extern void itlb_miss_handler(void); -extern void bug(void); - -#endif /* _H_OFMEM_SPARC64 */ diff --git a/openbios-devel/drivers/iommu.c b/openbios-devel/drivers/iommu.c index 47c6130..45005c1 100644 --- a/openbios-devel/drivers/iommu.c +++ b/openbios-devel/drivers/iommu.c @@ -8,7 +8,7 @@ #include "libopenbios/bindings.h" #include "drivers/drivers.h" #include "iommu.h" -#include "libopenbios/ofmem.h" +#include "arch/sparc32/ofmem_sparc32.h"
#ifdef CONFIG_DEBUG_IOMMU #define DPRINTF(fmt, args...) \ diff --git a/openbios-devel/include/arch/sparc32/ofmem_sparc32.h b/openbios-devel/include/arch/sparc32/ofmem_sparc32.h new file mode 100644 index 0000000..7a35b44 --- /dev/null +++ b/openbios-devel/include/arch/sparc32/ofmem_sparc32.h @@ -0,0 +1,28 @@ +/* + * <ofmem_sparc32.h> + * + * OF Memory manager + * + * Copyright (C) 1999, 2002 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#ifndef _H_OFMEM_SPARC32 +#define _H_OFMEM_SPARC32 + +#include "libopenbios/ofmem.h" + +struct mem; +extern struct mem cdvmem; + +extern unsigned long *l1; +extern unsigned long find_pte(unsigned long va, int alloc); + +void mem_init(struct mem *t, char *begin, char *limit); +void *mem_alloc(struct mem *t, int size, int align); + +#endif /* _H_OFMEM_SPARC32 */ \ No newline at end of file diff --git a/openbios-devel/include/arch/sparc64/ofmem_sparc64.h b/openbios-devel/include/arch/sparc64/ofmem_sparc64.h new file mode 100644 index 0000000..7ff24ae --- /dev/null +++ b/openbios-devel/include/arch/sparc64/ofmem_sparc64.h @@ -0,0 +1,50 @@ +/* + * <ofmem_sparc64.h> + * + * OF Memory manager + * + * Copyright (C) 1999, 2002 Samuel Rydh (samuel@ibrium.se) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation + * + */ + +#ifndef _H_OFMEM_SPARC64 +#define _H_OFMEM_SPARC64 + +#include "libopenbios/ofmem.h" + +#define PAGE_SIZE_4M (4 * 1024 * 1024) +#define PAGE_SIZE_512K (512 * 1024) +#define PAGE_SIZE_64K (64 * 1024) +#define PAGE_SIZE_8K (8 * 1024) +#define PAGE_MASK_4M (4 * 1024 * 1024 - 1) +#define PAGE_MASK_512K (512 * 1024 - 1) +#define PAGE_MASK_64K (64 * 1024 - 1) +#define PAGE_MASK_8K (8 * 1024 - 1) + +extern ucell *va2ttedata; +extern unsigned long find_tte(unsigned long va); + +void itlb_load2(unsigned long vaddr, unsigned long tte_data); +void itlb_load3(unsigned long vaddr, unsigned long tte_data, unsigned long tte_index); +unsigned long itlb_faultva(void); +void itlb_demap(unsigned long vaddr); +void dtlb_load2(unsigned long vaddr, unsigned long tte_data); +void dtlb_load3(unsigned long vaddr, unsigned long tte_data, unsigned long tte_index); +unsigned long dtlb_faultva(void); +void dtlb_demap(unsigned long vaddr); + +typedef int (*translation_entry_cb)(ucell phys, ucell virt, ucell size, ucell mode); + +extern void ofmem_walk_boot_map(translation_entry_cb cb); + +extern translation_t **g_ofmem_translations; + +extern void dtlb_miss_handler(void); +extern void itlb_miss_handler(void); +extern void bug(void); + +#endif /* _H_OFMEM_SPARC64 */ diff --git a/openbios-devel/include/libopenbios/ofmem.h b/openbios-devel/include/libopenbios/ofmem.h index 85c6912..ec21c2e 100644 --- a/openbios-devel/include/libopenbios/ofmem.h +++ b/openbios-devel/include/libopenbios/ofmem.h @@ -129,52 +129,9 @@ extern phandle_t s_phandle_mmu; /* Currently the same for all architectures */ #define PAGE_SHIFT 12
-#ifdef CONFIG_PPC -unsigned long get_ram_top( void ); -unsigned long get_ram_bottom( void ); - -#elif defined(CONFIG_SPARC32) - -/* arch/sparc32/lib.c */ -struct mem; -extern struct mem cdvmem; - -extern unsigned long *l1; -extern unsigned long find_pte(unsigned long va, int alloc); - -void mem_init(struct mem *t, char *begin, char *limit); -void *mem_alloc(struct mem *t, int size, int align); - -#elif defined(CONFIG_SPARC64) - -#define PAGE_SIZE_4M (4 * 1024 * 1024) -#define PAGE_SIZE_512K (512 * 1024) -#define PAGE_SIZE_64K (64 * 1024) -#define PAGE_SIZE_8K (8 * 1024) -#define PAGE_MASK_4M (4 * 1024 * 1024 - 1) -#define PAGE_MASK_512K (512 * 1024 - 1) -#define PAGE_MASK_64K (64 * 1024 - 1) -#define PAGE_MASK_8K (8 * 1024 - 1) - -extern ucell *va2ttedata; -extern unsigned long find_tte(unsigned long va); - -void itlb_load2(unsigned long vaddr, unsigned long tte_data); -void itlb_load3(unsigned long vaddr, unsigned long tte_data, unsigned long tte_index); -unsigned long itlb_faultva(void); -void itlb_demap(unsigned long vaddr); -void dtlb_load2(unsigned long vaddr, unsigned long tte_data); -void dtlb_load3(unsigned long vaddr, unsigned long tte_data, unsigned long tte_index); -unsigned long dtlb_faultva(void); -void dtlb_demap(unsigned long vaddr); - -#endif - -#ifdef PAGE_SHIFT #define PAGE_SIZE (1 << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE - 1)) #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) -#endif
#if defined(CONFIG_DEBUG_OFMEM) # define OFMEM_TRACE(fmt, ...) do { printk("OFMEM: " fmt, ## __VA_ARGS__); } while (0)