Author: mcayland Date: Sat Apr 28 15:34:57 2012 New Revision: 1053 URL: http://tracker.coreboot.org/trac/openbios/changeset/1053
Log: Remove architecture-specific routines from ofmem.h.
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
Added: trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h trunk/openbios-devel/include/arch/sparc64/ofmem_sparc64.h Deleted: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.h Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c trunk/openbios-devel/arch/sparc32/lib.c trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c trunk/openbios-devel/arch/sparc64/lib.c trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c trunk/openbios-devel/drivers/iommu.c trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sat Apr 28 15:34:57 2012 (r1053) @@ -75,13 +75,13 @@ 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;
Modified: trunk/openbios-devel/arch/sparc32/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/lib.c Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/arch/sparc32/lib.c Sat Apr 28 15:34:57 2012 (r1053) @@ -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"
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Apr 28 15:34:57 2012 (r1053) @@ -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"
Modified: trunk/openbios-devel/arch/sparc64/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:57 2012 (r1053) @@ -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.
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:34:57 2012 (r1053) @@ -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))
Modified: trunk/openbios-devel/drivers/iommu.c ============================================================================== --- trunk/openbios-devel/drivers/iommu.c Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/drivers/iommu.c Sat Apr 28 15:34:57 2012 (r1053) @@ -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...) \
Added: trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/openbios-devel/include/arch/sparc32/ofmem_sparc32.h Sat Apr 28 15:34:57 2012 (r1053) @@ -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
Added: trunk/openbios-devel/include/arch/sparc64/ofmem_sparc64.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/openbios-devel/include/arch/sparc64/ofmem_sparc64.h Sat Apr 28 15:34:57 2012 (r1053) @@ -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 */
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:52 2012 (r1052) +++ trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:57 2012 (r1053) @@ -129,52 +129,9 @@ /* 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)