Adding to a definition
by Programmingkid
Is there a way to add words to the end of a definition? If my word is declared like this:
: myword
firstWord
secondWord
;
is there a way to append a word to the end of this word so it looks like this:
: myword
firstWord
secondWord
thirdWord
;
7 years, 6 months
MS word
by Programmingkid
The MS word is suppose to wait a specified amount of milliseconds before allowing a program to continue. Yet when a simple line of code like this is run: "1000 MS ." hi" ", the message is printed immediately. This happens no matter how high the top value on the stack is. Is this a bug or am I missing something?
7 years, 7 months
[commit] r1056 - trunk/openbios-devel/arch/sparc32
by repository service
Author: mcayland
Date: Sat Apr 28 15:35:06 2012
New Revision: 1056
URL: http://tracker.coreboot.org/trac/openbios/changeset/1056
Log:
SPARC32: Swap Forth machine memory allocation over to OFMEM memory pool.
Instead of using our internal memory pool to run the Forth machine,
allocate the memory using OFMEM. This enables us to dramatically increase
the memory available to Forth clients whilst reducing the memory requirement
for the resulting image.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
trunk/openbios-devel/arch/sparc32/openbios.c
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Apr 28 15:35:03 2012 (r1055)
+++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Apr 28 15:35:06 2012 (r1056)
@@ -21,7 +21,7 @@
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
-#define MEMSIZE (384 * 1024)
+#define MEMSIZE (256 * 1024)
static union {
char memory[MEMSIZE];
ofmem_t ofmem;
Modified: trunk/openbios-devel/arch/sparc32/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/openbios.c Sat Apr 28 15:35:03 2012 (r1055)
+++ trunk/openbios-devel/arch/sparc32/openbios.c Sat Apr 28 15:35:06 2012 (r1056)
@@ -27,12 +27,10 @@
#include "arch/common/fw_cfg.h"
#include "libopenbios/ofmem.h"
-#define MEMORY_SIZE (128*1024) /* 128K ram for hosted system */
+#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
#define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
-static ucell *memory;
-
int qemu_machine_type;
struct hwdef {
@@ -807,17 +805,28 @@
static void init_memory(void)
{
- memory = malloc(MEMORY_SIZE);
- if (!memory)
- printk("panic: not enough memory on host system.\n");
+ phys_addr_t phys;
+ ucell virt;
+
+ /* Claim the memory from OFMEM */
+ phys = ofmem_claim_phys(-1, MEMORY_SIZE, PAGE_SIZE);
+ if (!phys)
+ printk("panic: not enough physical memory on host system.\n");
+
+ virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE);
+ if (!virt)
+ printk("panic: not enough virtual memory on host system.\n");
+
+ /* Generate the mapping (and lock translation into the TLBs) */
+ ofmem_map(phys, virt, MEMORY_SIZE, ofmem_arch_default_translation_mode(phys));
/* we push start and end of memory to the stack
* so that it can be used by the forth word QUIT
* to initialize the memory allocator
*/
-
- PUSH((ucell)memory);
- PUSH((ucell)memory + MEMORY_SIZE);
+
+ PUSH(virt);
+ PUSH(virt + MEMORY_SIZE);
}
static void
7 years, 7 months
[commit] r1055 - trunk/openbios-devel/arch/sparc64
by repository service
Author: mcayland
Date: Sat Apr 28 15:35:03 2012
New Revision: 1055
URL: http://tracker.coreboot.org/trac/openbios/changeset/1055
Log:
SPARC64: Swap Forth machine memory allocation over to OFMEM memory pool.
Instead of using our internal memory pool to run the Forth machine,
allocate the memory using OFMEM. This enables us to dramatically increase
the memory available to Forth clients whilst substantially reducing the
memory requirement for the resulting image.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
trunk/openbios-devel/arch/sparc64/openbios.c
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:35:00 2012 (r1054)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:35:03 2012 (r1055)
@@ -20,7 +20,7 @@
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
-#define MEMSIZE ((256 + 512) * 1024)
+#define MEMSIZE (128 * 1024)
static union {
char memory[MEMSIZE];
ofmem_t ofmem;
Modified: trunk/openbios-devel/arch/sparc64/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/openbios.c Sat Apr 28 15:35:00 2012 (r1054)
+++ trunk/openbios-devel/arch/sparc64/openbios.c Sat Apr 28 15:35:03 2012 (r1055)
@@ -21,7 +21,8 @@
#include "../../drivers/timer.h" // XXX
#define NO_QEMU_PROTOS
#include "arch/common/fw_cfg.h"
-#include "libopenbios/ofmem.h"
+#include "arch/sparc64/ofmem_sparc64.h"
+#include "spitfire.h"
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
@@ -34,8 +35,6 @@
#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */
-static ucell *memory;
-
// XXX
#define NVRAM_SIZE 0x2000
#define NVRAM_IDPROM 0x1fd8
@@ -553,17 +552,28 @@
static void init_memory(void)
{
- memory = malloc(MEMORY_SIZE);
- if (!memory)
- printk("panic: not enough memory on host system.\n");
+ phys_addr_t phys;
+ ucell virt;
+
+ /* Claim the memory from OFMEM (align to 512K so we only take 1 TLB slot) */
+ phys = ofmem_claim_phys(-1, MEMORY_SIZE, PAGE_SIZE_512K);
+ if (!phys)
+ printk("panic: not enough physical memory on host system.\n");
+
+ virt = ofmem_claim_virt(-1, MEMORY_SIZE, PAGE_SIZE_512K);
+ if (!virt)
+ printk("panic: not enough virtual memory on host system.\n");
+
+ /* Generate the mapping (and lock translation into the TLBs) */
+ ofmem_map(phys, virt, MEMORY_SIZE, ofmem_arch_default_translation_mode(phys) | SPITFIRE_TTE_LOCKED);
/* we push start and end of memory to the stack
* so that it can be used by the forth word QUIT
* to initialize the memory allocator
*/
-
- PUSH((ucell)memory);
- PUSH((ucell)memory + (ucell)MEMORY_SIZE);
+
+ PUSH(virt);
+ PUSH(virt + MEMORY_SIZE);
}
static void
7 years, 7 months
[commit] r1054 - in trunk/openbios-devel: arch/sparc64 drivers include/arch/sparc64 packages
by repository service
Author: mcayland
Date: Sat Apr 28 15:35:00 2012
New Revision: 1054
URL: http://tracker.coreboot.org/trac/openbios/changeset/1054
Log:
SPARC64: Remove majority of the video initialisation hack.
Now that we have OFMEM, as long as we have a PCI bus then we can configure
the address of the framebuffer automatically without having an
architecture-specific hack. The only thing we need to do is override the
virtual address from the OFMEM phys == virt default.
Similarly we can remove all reference to the video memory variables _vmem
and _evmem since the memory is allocated outside of the OpenBIOS image.
This commit also fixes another couple of issues: switch video.c to use virtual
instead of physical addresses for architectures that require it (the default
is the existing behaviour where phys_addr == virt_addr) and also correct the
framebuffer size calculation which was also adding the framebuffer start address
to size of the framebuffer to be mapped.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc64/ldscript
trunk/openbios-devel/drivers/vga_vbe.c
trunk/openbios-devel/include/arch/sparc64/io.h
trunk/openbios-devel/packages/video.c
Modified: trunk/openbios-devel/arch/sparc64/ldscript
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ldscript Sat Apr 28 15:34:57 2012 (r1053)
+++ trunk/openbios-devel/arch/sparc64/ldscript Sat Apr 28 15:35:00 2012 (r1054)
@@ -12,7 +12,6 @@
/* 16KB stack */
STACK_SIZE = 16384;
-VMEM_SIZE = 128 * 1024;
IOMEM_SIZE = 256 * 1024 + 768 * 1024;
SECTIONS
@@ -51,11 +50,6 @@
*(.bss.*)
*(COMMON)
- . = ALIGN(4096);
- _vmem = .;
- . += VMEM_SIZE;
- _evmem = .;
-
_stack = .;
. += STACK_SIZE;
. = ALIGN(16);
Modified: trunk/openbios-devel/drivers/vga_vbe.c
==============================================================================
--- trunk/openbios-devel/drivers/vga_vbe.c Sat Apr 28 15:34:57 2012 (r1053)
+++ trunk/openbios-devel/drivers/vga_vbe.c Sat Apr 28 15:35:00 2012 (r1054)
@@ -133,7 +133,7 @@
int depth = VGA_DEFAULT_DEPTH;
int linebytes = VGA_DEFAULT_LINEBYTES;
-#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC64))
+#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64))
int w, h, d;
w = fw_cfg_read_i16(FW_CFG_ARCH_WIDTH);
h = fw_cfg_read_i16(FW_CFG_ARCH_HEIGHT);
@@ -144,13 +144,6 @@
depth = d;
linebytes = (width * ((depth + 7) / 8));
}
-#ifdef CONFIG_SPARC64
-#define VGA_VADDR 0xfe000000
- ofmem_claim_phys(fb, fb_size, 0);
- ofmem_claim_virt(VGA_VADDR, fb_size, 0);
- ofmem_map(fb, VGA_VADDR, fb_size, 0x76);
- fb = VGA_VADDR;
-#endif
#endif
vga_vbe_set_mode(width, height, depth);
Modified: trunk/openbios-devel/include/arch/sparc64/io.h
==============================================================================
--- trunk/openbios-devel/include/arch/sparc64/io.h Sat Apr 28 15:34:57 2012 (r1053)
+++ trunk/openbios-devel/include/arch/sparc64/io.h Sat Apr 28 15:35:00 2012 (r1054)
@@ -9,7 +9,7 @@
extern unsigned long va_shift; // Set in entry.S
// Defined in ldscript
-extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem;
+extern char _start, _data, _stack, _estack, _end, _iomem;
// XXX check use and merge
#define phys_to_virt(phys) ((void *) ((unsigned long) (phys)))
Modified: trunk/openbios-devel/packages/video.c
==============================================================================
--- trunk/openbios-devel/packages/video.c Sat Apr 28 15:34:57 2012 (r1053)
+++ trunk/openbios-devel/packages/video.c Sat Apr 28 15:35:00 2012 (r1054)
@@ -25,6 +25,7 @@
typedef struct osi_fb_info {
unsigned long mphys;
+ unsigned long mvirt;
int rb, w, h, depth;
} osi_fb_info_t;
@@ -79,7 +80,7 @@
dx = (video.fb.w - width)/2;
dy = (video.fb.h - height)/3;
- pp = (char*)video.fb.mphys + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2);
+ pp = (char*)video.fb.mvirt + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2);
for( y=0 ; y<height; y++, pp += video.fb.rb ) {
if( video.fb.depth >= 24 ) {
@@ -121,7 +122,7 @@
void
draw_pixel( int x, int y, int colind )
{
- char *p = (char*)video.fb.mphys + video.fb.rb * y;
+ char *p = (char*)video.fb.mvirt + video.fb.rb * y;
int color, d = video.fb.depth;
if( x < 0 || y < 0 || x >= video.fb.w || y >=video.fb.h )
@@ -146,7 +147,7 @@
x + w > video.fb.w || y + h > video.fb.h)
return;
- pp = (char*)video.fb.mphys + video.fb.rb * y;
+ pp = (char*)video.fb.mvirt + video.fb.rb * y;
for( ; h--; pp += video.fb.rb ) {
int ww = w;
if( video.fb.depth == 24 || video.fb.depth == 32 ) {
@@ -209,8 +210,8 @@
}
offs = video.fb.rb * height;
size = (video.fb.h * video.fb.rb - offs)/16;
- dest = (int*)video.fb.mphys;
- src = (int*)(video.fb.mphys + offs);
+ dest = (int*)video.fb.mvirt;
+ src = (int*)(video.fb.mvirt + offs);
for( i=0; i<size; i++ ) {
dest[0] = src[0];
@@ -309,15 +310,21 @@
/************************************************************************/
void
-init_video( unsigned long fb, int width, int height, int depth, int rb )
+init_video( unsigned long fb, int width, int height, int depth, int rb )
{
int i;
-#ifdef CONFIG_PPC
- int s, size;
+#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI)
+ int size;
#endif
phandle_t ph=0;
- video.fb.mphys = fb;
+ video.fb.mphys = video.fb.mvirt = fb;
+
+#if defined(CONFIG_SPARC64)
+ /* Fix virtual address on SPARC64 somewhere else */
+ video.fb.mvirt = 0xfe000000;
+#endif
+
video.fb.w = width;
video.fb.h = height;
video.fb.depth = depth;
@@ -327,18 +334,17 @@
set_int_property( ph, "height", video.fb.h );
set_int_property( ph, "depth", video.fb.depth );
set_int_property( ph, "linebytes", video.fb.rb );
- set_int_property( ph, "address", video.fb.mphys );
+ set_int_property( ph, "address", video.fb.mvirt );
}
video.has_video = 1;
video.pal = malloc( 256 * sizeof(unsigned long) );
-#ifdef CONFIG_PPC
- s = (video.fb.mphys & 0xfff);
- size = ((video.fb.h * video.fb.rb + s) + 0xfff) & ~0xfff;
+#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI)
+ size = ((video.fb.h * video.fb.rb) + 0xfff) & ~0xfff;
ofmem_claim_phys( video.fb.mphys, size, 0 );
- ofmem_claim_virt( video.fb.mphys, size, 0 );
- ofmem_map( video.fb.mphys, video.fb.mphys, size, -1 );
+ ofmem_claim_virt( video.fb.mvirt, size, 0 );
+ ofmem_map( video.fb.mphys, video.fb.mvirt, size, ofmem_arch_io_translation_mode(video.fb.mphys) );
#endif
for( i=0; i<256; i++ )
7 years, 7 months
[commit] r1053 - in trunk/openbios-devel: arch/ppc/qemu arch/sparc32 arch/sparc64 drivers include/arch/sparc32 include/arch/sparc64 include/libopenbios
by repository service
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(a)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(a)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(a)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)
7 years, 7 months
[commit] r1052 - in trunk/openbios-devel: arch/sparc64 include/libopenbios
by repository service
Author: mcayland
Date: Sat Apr 28 15:34:52 2012
New Revision: 1052
URL: http://tracker.coreboot.org/trac/openbios/changeset/1052
Log:
SPARC64: Move ofmem_arch_map_pages()/ofmem_arch_unmap_pages() into
ofmem_sparc64.c with all the other architecture-specific code.
Note that we also take some of the ITLB/DTLB helpers with us.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc64/lib.c
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.h
trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/sparc64/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:48 2012 (r1051)
+++ trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:52 2012 (r1052)
@@ -70,15 +70,6 @@
ofmem_free(ptr);
}
-#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)
-
static void
mmu_open(void)
{
@@ -180,37 +171,6 @@
PUSH(0);
}
-static void
-dtlb_load2(unsigned long vaddr, unsigned long tte_data)
-{
- asm("stxa %0, [%1] %2\n"
- "stxa %3, [%%g0] %4\n"
- : : "r" (vaddr), "r" (48), "i" (ASI_DMMU),
- "r" (tte_data), "i" (ASI_DTLB_DATA_IN));
-}
-
-static void
-dtlb_load3(unsigned long vaddr, unsigned long tte_data,
- unsigned long tte_index)
-{
- asm("stxa %0, [%1] %2\n"
- "stxa %3, [%4] %5\n"
- : : "r" (vaddr), "r" (48), "i" (ASI_DMMU),
- "r" (tte_data), "r" (tte_index << 3), "i" (ASI_DTLB_DATA_ACCESS));
-}
-
-static unsigned long
-dtlb_faultva(void)
-{
- unsigned long faultva;
-
- asm("ldxa [%1] %2, %0\n"
- : "=r" (faultva)
- : "r" (48), "i" (ASI_DMMU));
-
- return faultva;
-}
-
/*
( index tte_data vaddr -- ? )
*/
@@ -267,25 +227,6 @@
}
-static void
-itlb_load2(unsigned long vaddr, unsigned long tte_data)
-{
- asm("stxa %0, [%1] %2\n"
- "stxa %3, [%%g0] %4\n"
- : : "r" (vaddr), "r" (48), "i" (ASI_IMMU),
- "r" (tte_data), "i" (ASI_ITLB_DATA_IN));
-}
-
-static void
-itlb_load3(unsigned long vaddr, unsigned long tte_data,
- unsigned long tte_index)
-{
- asm("stxa %0, [%1] %2\n"
- "stxa %3, [%4] %5\n"
- : : "r" (vaddr), "r" (48), "i" (ASI_IMMU),
- "r" (tte_data), "r" (tte_index << 3), "i" (ASI_ITLB_DATA_ACCESS));
-}
-
/*
( index tte_data vaddr -- ? )
*/
@@ -300,18 +241,6 @@
itlb_load3(vaddr, tte_data, idx);
}
-static unsigned long
-itlb_faultva(void)
-{
- unsigned long faultva;
-
- asm("ldxa [%1] %2, %0\n"
- : "=r" (faultva)
- : "r" (48), "i" (ASI_IMMU));
-
- return faultva;
-}
-
/* MMU I-TLB miss handler */
void
itlb_miss_handler(void)
@@ -353,49 +282,6 @@
}
}
-void ofmem_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
-{
- unsigned long tte_data, currsize;
-
- /* aligned to 8k page */
- size = (size + PAGE_MASK_8K) & ~PAGE_MASK_8K;
-
- while (size > 0) {
- currsize = size;
- if (currsize >= PAGE_SIZE_4M &&
- (virt & PAGE_MASK_4M) == 0 &&
- (phys & PAGE_MASK_4M) == 0) {
- currsize = PAGE_SIZE_4M;
- tte_data = 6ULL << 60;
- } else if (currsize >= PAGE_SIZE_512K &&
- (virt & PAGE_MASK_512K) == 0 &&
- (phys & PAGE_MASK_512K) == 0) {
- currsize = PAGE_SIZE_512K;
- tte_data = 4ULL << 60;
- } else if (currsize >= PAGE_SIZE_64K &&
- (virt & PAGE_MASK_64K) == 0 &&
- (phys & PAGE_MASK_64K) == 0) {
- currsize = PAGE_SIZE_64K;
- tte_data = 2ULL << 60;
- } else {
- currsize = PAGE_SIZE_8K;
- tte_data = 0;
- }
-
- tte_data |= phys | mode | SPITFIRE_TTE_VALID;
-
- if (mode & SPITFIRE_TTE_LOCKED) {
- // install locked tlb entries now
- itlb_load2(virt, tte_data);
- dtlb_load2(virt, tte_data);
- }
-
- size -= currsize;
- phys += currsize;
- virt += currsize;
- }
-}
-
/*
3.6.5 map
( phys.lo ... phys.hi virt size mode -- )
@@ -416,47 +302,6 @@
ofmem_map(phys, virt, size, mode);
}
-static void
-itlb_demap(unsigned long vaddr)
-{
- asm("stxa %0, [%0] %1\n"
- : : "r" (vaddr), "i" (ASI_IMMU_DEMAP));
-}
-
-static void
-dtlb_demap(unsigned long vaddr)
-{
- asm("stxa %0, [%0] %1\n"
- : : "r" (vaddr), "i" (ASI_DMMU_DEMAP));
-}
-
-static void
-unmap_pages(ucell virt, ucell size)
-{
- ucell va;
-
- /* align address to 8k */
- virt &= ~PAGE_MASK_8K;
-
- /* align size to 8k */
- size = (size + PAGE_MASK_8K) & ~PAGE_MASK_8K;
-
- for (va = virt; va < virt + size; va += PAGE_SIZE_8K) {
- itlb_demap(va);
- dtlb_demap(va);
- }
-}
-
-void ofmem_arch_unmap_pages(ucell virt, ucell size)
-{
- unmap_pages(virt, size);
-}
-
-void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
-{
- ofmem_map_pages(phys, virt, size, mode);
-}
-
/*
3.6.5 unmap
( virt size -- )
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:34:48 2012 (r1051)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:34:52 2012 (r1052)
@@ -135,6 +135,68 @@
availentry[i] = size;
}
+/* Unmap a set of pages */
+void ofmem_arch_unmap_pages(ucell virt, ucell size)
+{
+ ucell va;
+
+ /* align address to 8k */
+ virt &= ~PAGE_MASK_8K;
+
+ /* align size to 8k */
+ size = (size + PAGE_MASK_8K) & ~PAGE_MASK_8K;
+
+ for (va = virt; va < virt + size; va += PAGE_SIZE_8K) {
+ itlb_demap(va);
+ dtlb_demap(va);
+ }
+}
+
+/* Map a set of pages */
+void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
+{
+ unsigned long tte_data, currsize;
+
+ /* Install locked tlb entries now */
+ if (mode & SPITFIRE_TTE_LOCKED) {
+
+ /* aligned to 8k page */
+ size = (size + PAGE_MASK_8K) & ~PAGE_MASK_8K;
+
+ while (size > 0) {
+ currsize = size;
+ if (currsize >= PAGE_SIZE_4M &&
+ (virt & PAGE_MASK_4M) == 0 &&
+ (phys & PAGE_MASK_4M) == 0) {
+ currsize = PAGE_SIZE_4M;
+ tte_data = 6ULL << 60;
+ } else if (currsize >= PAGE_SIZE_512K &&
+ (virt & PAGE_MASK_512K) == 0 &&
+ (phys & PAGE_MASK_512K) == 0) {
+ currsize = PAGE_SIZE_512K;
+ tte_data = 4ULL << 60;
+ } else if (currsize >= PAGE_SIZE_64K &&
+ (virt & PAGE_MASK_64K) == 0 &&
+ (phys & PAGE_MASK_64K) == 0) {
+ currsize = PAGE_SIZE_64K;
+ tte_data = 2ULL << 60;
+ } else {
+ currsize = PAGE_SIZE_8K;
+ tte_data = 0;
+ }
+
+ tte_data |= phys | mode | SPITFIRE_TTE_VALID;
+
+ itlb_load2(virt, tte_data);
+ dtlb_load2(virt, tte_data);
+
+ size -= currsize;
+ phys += currsize;
+ virt += currsize;
+ }
+ }
+}
+
/************************************************************************/
/* misc */
/************************************************************************/
@@ -163,7 +225,7 @@
return SPITFIRE_TTE_CV | SPITFIRE_TTE_WRITABLE;
}
-/* Architecture-specific helpers */
+/* Architecture-specific OFMEM helpers */
unsigned long
find_tte(unsigned long va)
{
@@ -194,6 +256,84 @@
return -1;
}
+/* ITLB handlers */
+void
+itlb_load2(unsigned long vaddr, unsigned long tte_data)
+{
+ asm("stxa %0, [%1] %2\n"
+ "stxa %3, [%%g0] %4\n"
+ : : "r" (vaddr), "r" (48), "i" (ASI_IMMU),
+ "r" (tte_data), "i" (ASI_ITLB_DATA_IN));
+}
+
+void
+itlb_load3(unsigned long vaddr, unsigned long tte_data,
+ unsigned long tte_index)
+{
+ asm("stxa %0, [%1] %2\n"
+ "stxa %3, [%4] %5\n"
+ : : "r" (vaddr), "r" (48), "i" (ASI_IMMU),
+ "r" (tte_data), "r" (tte_index << 3), "i" (ASI_ITLB_DATA_ACCESS));
+}
+
+unsigned long
+itlb_faultva(void)
+{
+ unsigned long faultva;
+
+ asm("ldxa [%1] %2, %0\n"
+ : "=r" (faultva)
+ : "r" (48), "i" (ASI_IMMU));
+
+ return faultva;
+}
+
+void
+itlb_demap(unsigned long vaddr)
+{
+ asm("stxa %0, [%0] %1\n"
+ : : "r" (vaddr), "i" (ASI_IMMU_DEMAP));
+}
+
+/* DTLB handlers */
+void
+dtlb_load2(unsigned long vaddr, unsigned long tte_data)
+{
+ asm("stxa %0, [%1] %2\n"
+ "stxa %3, [%%g0] %4\n"
+ : : "r" (vaddr), "r" (48), "i" (ASI_DMMU),
+ "r" (tte_data), "i" (ASI_DTLB_DATA_IN));
+}
+
+void
+dtlb_load3(unsigned long vaddr, unsigned long tte_data,
+ unsigned long tte_index)
+{
+ asm("stxa %0, [%1] %2\n"
+ "stxa %3, [%4] %5\n"
+ : : "r" (vaddr), "r" (48), "i" (ASI_DMMU),
+ "r" (tte_data), "r" (tte_index << 3), "i" (ASI_DTLB_DATA_ACCESS));
+}
+
+unsigned long
+dtlb_faultva(void)
+{
+ unsigned long faultva;
+
+ asm("ldxa [%1] %2, %0\n"
+ : "=r" (faultva)
+ : "r" (48), "i" (ASI_DMMU));
+
+ return faultva;
+}
+
+void
+dtlb_demap(unsigned long vaddr)
+{
+ asm("stxa %0, [%0] %1\n"
+ : : "r" (vaddr), "i" (ASI_DMMU_DEMAP));
+}
+
/************************************************************************/
/* init / cleanup */
/************************************************************************/
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.h
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.h Sat Apr 28 15:34:48 2012 (r1051)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.h Sat Apr 28 15:34:52 2012 (r1052)
@@ -18,8 +18,7 @@
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);
+typedef int (*translation_entry_cb)(ucell phys, ucell virt, ucell size, ucell mode);
extern void ofmem_walk_boot_map(translation_entry_cb cb);
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:48 2012 (r1051)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:52 2012 (r1052)
@@ -147,9 +147,27 @@
#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
7 years, 7 months
[commit] r1051 - in trunk/openbios-devel: arch/sparc64 include/libopenbios
by repository service
Author: mcayland
Date: Sat Apr 28 15:34:48 2012
New Revision: 1051
URL: http://tracker.coreboot.org/trac/openbios/changeset/1051
Log:
SPARC64: Refactor tte-data code in preparation for moving architecture-specific
code to ofmem_sparc64.c.
Note we also change pgmap@ so it explicitly searches for a TTE entry using
architecture-specific code, plus add the code to detect whether a page is
marked as locked or not into the main page mapping function.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc64/lib.c
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/sparc64/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:46 2012 (r1050)
+++ trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:48 2012 (r1051)
@@ -16,8 +16,6 @@
#include "ofmem_sparc64.h"
-static ucell *va2ttedata = 0;
-
/* Format a string and print it on the screen, just like the libc
* function printf.
*/
@@ -165,35 +163,21 @@
static void
pgmap_fetch(void)
{
- translation_t *t = *g_ofmem_translations;
- unsigned long va, tte_data;
-
- va = POP();
-
- /* Search the ofmem linked list for this virtual address */
- while (t != NULL) {
- /* Find the correct range */
- if (va >= t->virt && va < (t->virt + t->size)) {
+ unsigned long va, tte_data;
- /* valid tte, 8k size */
- tte_data = SPITFIRE_TTE_VALID;
+ va = POP();
- /* mix in phys address mode */
- tte_data |= t->mode;
+ tte_data = find_tte(va);
+ if (tte_data == -1)
+ goto error;
- /* mix in page physical address = t->phys + offset */
- tte_data |= t->phys + (va - t->virt);
-
- /* return tte_data */
- PUSH(tte_data);
-
- return;
- }
- t = t->next;
- }
+ /* return tte_data */
+ PUSH(tte_data);
+ return;
- /* If we get here, there was no entry */
- PUSH(0);
+error:
+ /* If we get here, there was no entry */
+ PUSH(0);
}
static void
@@ -270,9 +254,7 @@
}
} else {
/* Search the ofmem linked list for this virtual address */
- PUSH(faultva);
- pgmap_fetch();
- tte_data = POP();
+ tte_data = find_tte(faultva);
}
if (tte_data) {
@@ -359,9 +341,7 @@
}
} else {
/* Search the ofmem linked list for this virtual address */
- PUSH(faultva);
- pgmap_fetch();
- tte_data = POP();
+ tte_data = find_tte(faultva);
}
if (tte_data) {
@@ -373,16 +353,14 @@
}
}
-static void
-map_pages(phys_addr_t phys, unsigned long virt,
- unsigned long size, unsigned long mode)
+void ofmem_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
{
- unsigned long tte_data, currsize;
+ unsigned long tte_data, currsize;
- /* aligned to 8k page */
- size = (size + PAGE_MASK_8K) & ~PAGE_MASK_8K;
+ /* aligned to 8k page */
+ size = (size + PAGE_MASK_8K) & ~PAGE_MASK_8K;
- while (size > 0) {
+ while (size > 0) {
currsize = size;
if (currsize >= PAGE_SIZE_4M &&
(virt & PAGE_MASK_4M) == 0 &&
@@ -406,20 +384,18 @@
tte_data |= phys | mode | SPITFIRE_TTE_VALID;
- itlb_load2(virt, tte_data);
- dtlb_load2(virt, tte_data);
-
+ if (mode & SPITFIRE_TTE_LOCKED) {
+ // install locked tlb entries now
+ itlb_load2(virt, tte_data);
+ dtlb_load2(virt, tte_data);
+ }
+
size -= currsize;
phys += currsize;
virt += currsize;
}
}
-void ofmem_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
-{
- return map_pages(phys, virt, size, mode);
-}
-
/*
3.6.5 map
( phys.lo ... phys.hi virt size mode -- )
@@ -457,7 +433,7 @@
static void
unmap_pages(ucell virt, ucell size)
{
- ucell va;
+ ucell va;
/* align address to 8k */
virt &= ~PAGE_MASK_8K;
@@ -478,10 +454,7 @@
void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
{
- if (mode & SPITFIRE_TTE_LOCKED) {
- // install locked tlb entries now
- ofmem_map_pages(phys, virt, size, mode);
- }
+ ofmem_map_pages(phys, virt, size, mode);
}
/*
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:34:46 2012 (r1050)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sat Apr 28 15:34:48 2012 (r1051)
@@ -31,6 +31,7 @@
translation_t **g_ofmem_translations = &s_ofmem_data.ofmem.trans;
+ucell *va2ttedata = 0;
extern uint64_t qemu_mem_size;
static inline size_t ALIGN_SIZE(size_t x, size_t a)
@@ -162,6 +163,37 @@
return SPITFIRE_TTE_CV | SPITFIRE_TTE_WRITABLE;
}
+/* Architecture-specific helpers */
+unsigned long
+find_tte(unsigned long va)
+{
+ translation_t *t = *g_ofmem_translations;
+ unsigned long tte_data;
+
+ /* Search the ofmem linked list for this virtual address */
+ while (t != NULL) {
+ /* Find the correct range */
+ if (va >= t->virt && va < (t->virt + t->size)) {
+
+ /* valid tte, 8k size */
+ tte_data = SPITFIRE_TTE_VALID;
+
+ /* mix in phys address mode */
+ tte_data |= t->mode;
+
+ /* mix in page physical address = t->phys + offset */
+ tte_data |= t->phys + (va - t->virt);
+
+ /* return tte_data */
+ return tte_data;
+ }
+ t = t->next;
+ }
+
+ /* Couldn't find tte */
+ return -1;
+}
+
/************************************************************************/
/* init / cleanup */
/************************************************************************/
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:46 2012 (r1050)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:48 2012 (r1051)
@@ -144,6 +144,12 @@
void mem_init(struct mem *t, char *begin, char *limit);
void *mem_alloc(struct mem *t, int size, int align);
+
+#elif defined(CONFIG_SPARC64)
+
+extern ucell *va2ttedata;
+extern unsigned long find_tte(unsigned long va);
+
#endif
#ifdef PAGE_SHIFT
7 years, 7 months
[commit] r1050 - in trunk/openbios-devel: arch/sparc32 include/libopenbios
by repository service
Author: mcayland
Date: Sat Apr 28 15:34:46 2012
New Revision: 1050
URL: http://tracker.coreboot.org/trac/openbios/changeset/1050
Log:
SPARC32: Move ofmem_arch_map_pages() into ofmem_sparc32.c with all the other
architecture-specific code.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/lib.c
trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c Sat Apr 28 15:34:42 2012 (r1049)
+++ trunk/openbios-devel/arch/sparc32/lib.c Sat Apr 28 15:34:46 2012 (r1050)
@@ -56,8 +56,8 @@
struct mem cdvmem; /* Current device virtual memory space */
unsigned int va_shift;
+unsigned long *l1;
static unsigned long *context_table;
-static unsigned long *l1;
static ucell *mem_reg = 0;
static ucell *mem_avail = 0;
@@ -141,78 +141,6 @@
return p;
}
-static unsigned long
-find_pte(unsigned long va, int alloc)
-{
- uint32_t pte;
- void *p;
- unsigned long pa;
- int ret;
-
- pte = l1[(va >> SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD - 1)];
- if ((pte & SRMMU_ET_MASK) == SRMMU_ET_INVALID) {
- if (alloc) {
- ret = ofmem_posix_memalign(&p, SRMMU_PTRS_PER_PMD * sizeof(int),
- SRMMU_PTRS_PER_PMD * sizeof(int));
- if (ret != 0)
- return ret;
- pte = SRMMU_ET_PTD | ((va2pa((unsigned long)p)) >> 4);
- l1[(va >> SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD - 1)] = pte;
- /* barrier() */
- } else {
- return -1;
- }
- }
-
- pa = (pte & 0xFFFFFFF0) << 4;
- pa += ((va >> SRMMU_PMD_SHIFT) & (SRMMU_PTRS_PER_PMD - 1)) << 2;
- pte = *(uint32_t *)pa2va(pa);
- if ((pte & SRMMU_ET_MASK) == SRMMU_ET_INVALID) {
- if (alloc) {
- ret = ofmem_posix_memalign(&p, SRMMU_PTRS_PER_PTE * sizeof(void *),
- SRMMU_PTRS_PER_PTE * sizeof(void *));
- if (ret != 0)
- return ret;
- pte = SRMMU_ET_PTD | ((va2pa((unsigned int)p)) >> 4);
- *(uint32_t *)pa2va(pa) = pte;
- } else {
- return -2;
- }
- }
-
- pa = (pte & 0xFFFFFFF0) << 4;
- pa += ((va >> PAGE_SHIFT) & (SRMMU_PTRS_PER_PTE - 1)) << 2;
-
- return pa2va(pa);
-}
-
-static void
-map_pages(phys_addr_t phys, unsigned long virt,
- unsigned long size, unsigned long mode)
-{
- unsigned long npages, off;
- uint32_t pte;
- unsigned long pa;
-
- DPRINTF("map_pages: va 0x%lx, pa 0x%llx, size 0x%lx\n", virt, phys, size);
-
- off = phys & (PAGE_SIZE - 1);
- npages = (off + (size - 1) + (PAGE_SIZE - 1)) / PAGE_SIZE;
- phys &= ~(uint64_t)(PAGE_SIZE - 1);
-
- while (npages-- != 0) {
- pa = find_pte(virt, 1);
-
- pte = SRMMU_ET_PTE | ((phys & PAGE_MASK) >> 4);
- pte |= mode;
-
- *(uint32_t *)pa = pte;
-
- virt += PAGE_SIZE;
- phys += PAGE_SIZE;
- }
-}
-
/*
* D5.3 pgmap@ ( va -- pte )
*/
@@ -269,8 +197,7 @@
pa <<= 32;
pa |= POP() & 0xffffffff;
- map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
- DPRINTF("map-page: va 0x%lx pa 0x%llx size 0x%x\n", va, pa, size);
+ ofmem_arch_map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
}
static void
@@ -327,7 +254,7 @@
{
uint64_t mpa = ((uint64_t)which_io << 32) | (uint64_t)pa;
- map_pages(mpa, (unsigned long)va, size, ofmem_arch_default_translation_mode(mpa));
+ ofmem_arch_map_pages(mpa, (unsigned long)va, size, ofmem_arch_default_translation_mode(mpa));
return va;
}
@@ -337,16 +264,6 @@
DPRINTF("obp_dumb_munmap: virta 0x%x, sz %d\n", (unsigned int)va, size);
}
-void ofmem_arch_unmap_pages(ucell virt, ucell size)
-{
- /* Currently do nothing */
-}
-
-void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
-{
- map_pages(phys, virt, size, mode);
-}
-
char *obp_memalloc(char *va, unsigned int size, unsigned int align)
{
phys_addr_t phys;
@@ -483,10 +400,10 @@
va = (unsigned long)&_start;
size = (unsigned long)&_end - (unsigned long)&_start;
pa = va2pa(va);
- map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
+ ofmem_arch_map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
// 1:1 mapping for RAM
- map_pages(0, 0, LOWMEMSZ, ofmem_arch_default_translation_mode(0));
+ ofmem_arch_map_pages(0, 0, LOWMEMSZ, ofmem_arch_default_translation_mode(0));
/*
* Flush cache
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Apr 28 15:34:42 2012 (r1049)
+++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Apr 28 15:34:46 2012 (r1050)
@@ -133,12 +133,88 @@
/* Generate memory available property entry for Sparc32 */
void ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size)
{
- int i = 0;
+ int i = 0;
i += ofmem_arch_encode_physaddr(availentry, start);
availentry[i] = size;
}
+/* Unmap a set of pages */
+void ofmem_arch_unmap_pages(ucell virt, ucell size)
+{
+ /* Currently do nothing */
+}
+
+/* Map a set of pages */
+void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
+{
+ unsigned long npages, off;
+ uint32_t pte;
+ unsigned long pa;
+
+ off = phys & (PAGE_SIZE - 1);
+ npages = (off + (size - 1) + (PAGE_SIZE - 1)) / PAGE_SIZE;
+ phys &= ~(uint64_t)(PAGE_SIZE - 1);
+
+ while (npages-- != 0) {
+ pa = find_pte(virt, 1);
+
+ pte = SRMMU_ET_PTE | ((phys & PAGE_MASK) >> 4);
+ pte |= mode;
+
+ *(uint32_t *)pa = pte;
+
+ virt += PAGE_SIZE;
+ phys += PAGE_SIZE;
+ }
+}
+
+/* Architecture-specific OFMEM helpers */
+unsigned long
+find_pte(unsigned long va, int alloc)
+{
+ uint32_t pte;
+ void *p;
+ unsigned long pa;
+ int ret;
+
+ pte = l1[(va >> SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD - 1)];
+ if ((pte & SRMMU_ET_MASK) == SRMMU_ET_INVALID) {
+ if (alloc) {
+ ret = ofmem_posix_memalign(&p, SRMMU_PTRS_PER_PMD * sizeof(int),
+ SRMMU_PTRS_PER_PMD * sizeof(int));
+ if (ret != 0)
+ return ret;
+ pte = SRMMU_ET_PTD | ((va2pa((unsigned long)p)) >> 4);
+ l1[(va >> SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD - 1)] = pte;
+ /* barrier() */
+ } else {
+ return -1;
+ }
+ }
+
+ pa = (pte & 0xFFFFFFF0) << 4;
+ pa += ((va >> SRMMU_PMD_SHIFT) & (SRMMU_PTRS_PER_PMD - 1)) << 2;
+ pte = *(uint32_t *)pa2va(pa);
+ if ((pte & SRMMU_ET_MASK) == SRMMU_ET_INVALID) {
+ if (alloc) {
+ ret = ofmem_posix_memalign(&p, SRMMU_PTRS_PER_PTE * sizeof(void *),
+ SRMMU_PTRS_PER_PTE * sizeof(void *));
+ if (ret != 0)
+ return ret;
+ pte = SRMMU_ET_PTD | ((va2pa((unsigned int)p)) >> 4);
+ *(uint32_t *)pa2va(pa) = pte;
+ } else {
+ return -2;
+ }
+ }
+
+ pa = (pte & 0xFFFFFFF0) << 4;
+ pa += ((va >> PAGE_SHIFT) & (SRMMU_PTRS_PER_PTE - 1)) << 2;
+
+ return pa2va(pa);
+}
+
/************************************************************************/
/* misc */
/************************************************************************/
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:42 2012 (r1049)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:46 2012 (r1050)
@@ -139,6 +139,9 @@
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
7 years, 7 months
[commit] r1049 - in trunk/openbios-devel: arch/ppc arch/ppc/qemu arch/sparc32 arch/sparc64 drivers include/libopenbios libopenbios
by repository service
Author: mcayland
Date: Sat Apr 28 15:34:42 2012
New Revision: 1049
URL: http://tracker.coreboot.org/trac/openbios/changeset/1049
Log:
Rename ofmem_arch_early_map_pages() to ofmem_arch_map_pages().
This OFMEM call does actually map the page for the architectures that
require it, so let's change its name so that we now have a symmetrical
ofmem_arch_map_pages() and ofmem_arch_unmap_pages() API.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/ppc/ofmem.c
trunk/openbios-devel/arch/ppc/qemu/ofmem.c
trunk/openbios-devel/arch/sparc32/lib.c
trunk/openbios-devel/arch/sparc64/lib.c
trunk/openbios-devel/drivers/iommu.c
trunk/openbios-devel/include/libopenbios/ofmem.h
trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/arch/ppc/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/ofmem.c Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/arch/ppc/ofmem.c Sat Apr 28 15:34:42 2012 (r1049)
@@ -121,7 +121,7 @@
/* kill page mappings in provided range */
}
-void ofmem_arch_early_map_pages(ucell phys, ucell virt, ucell size, ucell mode)
+void ofmem_arch_map_pages(ucell phys, ucell virt, ucell size, ucell mode)
{
/* none yet */
}
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sat Apr 28 15:34:42 2012 (r1049)
@@ -129,7 +129,7 @@
/* kill page mappings in provided range */
}
-void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
+void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
{
/* none yet */
}
Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/arch/sparc32/lib.c Sat Apr 28 15:34:42 2012 (r1049)
@@ -342,7 +342,7 @@
/* Currently do nothing */
}
-void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
+void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
{
map_pages(phys, virt, size, mode);
}
Modified: trunk/openbios-devel/arch/sparc64/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/lib.c Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/arch/sparc64/lib.c Sat Apr 28 15:34:42 2012 (r1049)
@@ -476,7 +476,7 @@
unmap_pages(virt, size);
}
-void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
+void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode)
{
if (mode & SPITFIRE_TTE_LOCKED) {
// install locked tlb entries now
Modified: trunk/openbios-devel/drivers/iommu.c
==============================================================================
--- trunk/openbios-devel/drivers/iommu.c Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/drivers/iommu.c Sat Apr 28 15:34:42 2012 (r1049)
@@ -68,7 +68,7 @@
*/
mva = (unsigned int) va;
mpa = (unsigned int) pa;
- ofmem_arch_early_map_pages(mpa, mva, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(mpa));
+ ofmem_arch_map_pages(mpa, mva, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(mpa));
/*
* Map into IOMMU page table.
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Sat Apr 28 15:34:42 2012 (r1049)
@@ -67,15 +67,15 @@
extern ucell ofmem_arch_get_iomem_base(void);
extern ucell ofmem_arch_get_iomem_top(void);
extern retain_t* ofmem_arch_get_retained(void);
-extern int ofmem_arch_get_physaddr_cellsize(void);
-extern int ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value);
+extern int ofmem_arch_get_physaddr_cellsize(void);
+extern int ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value);
extern int ofmem_arch_get_available_entry_size(phandle_t ph);
extern void ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size);
extern int ofmem_arch_get_translation_entry_size(void);
extern void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t);
extern ucell ofmem_arch_default_translation_mode( phys_addr_t phys );
extern ucell ofmem_arch_io_translation_mode( phys_addr_t phys );
-extern void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size,
+extern void ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size,
ucell mode);
extern void ofmem_arch_unmap_pages(ucell virt, ucell size);
/* sparc64 uses this method */
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/ofmem_common.c Sat Mar 17 17:34:21 2012 (r1048)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c Sat Apr 28 15:34:42 2012 (r1049)
@@ -794,8 +794,8 @@
/* install translations */
ofmem_map_page_range(phys, virt, size, mode);
- /* allow arch to install mappings early, e.g. for locked mappings */
- ofmem_arch_early_map_pages(phys, virt, size, mode);
+ /* allow arch to map the pages */
+ ofmem_arch_map_pages(phys, virt, size, mode);
return 0;
}
@@ -836,7 +836,7 @@
mode = ofmem_arch_io_translation_mode(off);
ofmem_map_page_range(phys, virt, npages * PAGE_SIZE, mode);
- ofmem_arch_early_map_pages(phys, virt, npages * PAGE_SIZE, mode);
+ ofmem_arch_map_pages(phys, virt, npages * PAGE_SIZE, mode);
return (virt + off);
}
7 years, 7 months