summaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/kernel')
-rw-r--r--arch/sh/kernel/entry.S11
-rw-r--r--arch/sh/kernel/irq_onchip.c8
-rw-r--r--arch/sh/kernel/setup.c157
3 files changed, 146 insertions, 30 deletions
diff --git a/arch/sh/kernel/entry.S b/arch/sh/kernel/entry.S
index bd9c7bb39..ac5a075c0 100644
--- a/arch/sh/kernel/entry.S
+++ b/arch/sh/kernel/entry.S
@@ -149,7 +149,7 @@ initial_page_write:
/* Unwind the stack and jmp to the debug entry */
debug:
add #4,r15 ! skip syscall number
- ldc.l @r15+,ssr
+ mov.l @r15+,r11 ! SSR
mov.l @r15+,r10 ! original stack
mov.l @r15+,r0
mov.l @r15+,r1
@@ -164,6 +164,7 @@ debug:
or r9,r14
ldc r14,sr ! here, change the register bank
mov r10,k0
+ mov r11,k1
mov.l @r15+,r8
mov.l @r15+,r9
mov.l @r15+,r10
@@ -180,7 +181,7 @@ debug:
!
mov.l 9f,k0
jmp @k0
- nop
+ ldc k1,ssr
.balign 4
8: .long 0x300000f0
9: .long 0xa0000100
@@ -371,7 +372,7 @@ ret_with_reschedule:
!
restore_all:
add #4,r15 ! skip syscall number
- ldc.l @r15+,ssr
+ mov.l @r15+,r11 ! SSR
mov.l @r15+,r10 ! original stack
mov.l @r15+,r0
mov.l @r15+,r1
@@ -386,6 +387,7 @@ restore_all:
or r9,r14
ldc r14,sr ! here, change the register bank
mov r10,k0
+ mov r11,k1
mov.l @r15+,r8
mov.l @r15+,r9
mov.l @r15+,r10
@@ -399,6 +401,7 @@ restore_all:
lds.l @r15+,pr
ldc.l @r15+,spc
mov k0,r15
+ ldc k1,ssr
rte
nop
@@ -515,7 +518,7 @@ none:
.data
ENTRY(exception_handling_table)
- .long none /* XXX: Avoid spurious interrupt */
+ .long error
.long error
.long tlb_miss_load
.long tlb_miss_store
diff --git a/arch/sh/kernel/irq_onchip.c b/arch/sh/kernel/irq_onchip.c
index b4ba54f31..0ed3400ef 100644
--- a/arch/sh/kernel/irq_onchip.c
+++ b/arch/sh/kernel/irq_onchip.c
@@ -89,29 +89,33 @@ static struct hw_interrupt_type onChip_irq_type = {
void disable_onChip_irq(unsigned int irq)
{
+ unsigned long val, flags;
/* Set priority in IPR to 0 */
int offset = ipr_data[irq-TIMER_IRQ].offset;
unsigned long intc_ipr_address = INTC_IPR + (offset/16*INTC_SIZE);
unsigned short mask = 0xffff ^ (0xf << (offset%16));
- unsigned long val;
+ save_and_cli(flags);
val = ctrl_inw(intc_ipr_address);
val &= mask;
ctrl_outw(val, intc_ipr_address);
+ restore_flags(flags);
}
static void enable_onChip_irq(unsigned int irq)
{
+ unsigned long val, flags;
/* Set priority in IPR back to original value */
int offset = ipr_data[irq-TIMER_IRQ].offset;
int priority = ipr_data[irq-TIMER_IRQ].priority;
unsigned long intc_ipr_address = INTC_IPR + (offset/16*INTC_SIZE);
unsigned short value = (priority << (offset%16));
- unsigned long val;
+ save_and_cli(flags);
val = ctrl_inw(intc_ipr_address);
val |= value;
ctrl_outw(val, intc_ipr_address);
+ restore_flags(flags);
}
void make_onChip_irq(unsigned int irq)
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 59c97a66b..deb532300 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -28,14 +28,17 @@
#ifdef CONFIG_BLK_DEV_RAM
#include <linux/blk.h>
#endif
-#include <asm/processor.h>
+#include <linux/bootmem.h>
#include <linux/console.h>
+#include <asm/processor.h>
+#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/smp.h>
+
/*
* Machine setup..
*/
@@ -62,7 +65,6 @@ extern int _text, _etext, _edata, _end;
#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
#define INITRD_START (*(unsigned long *) (PARAM+0x010))
#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
-#define MEMORY_END (*(unsigned long *) (PARAM+0x018))
/* ... */
#define COMMAND_LINE ((char *) (PARAM+0x100))
#define COMMAND_LINE_SIZE 256
@@ -105,11 +107,67 @@ static struct resource rom_resources[MAXROMS] = {
{ "Video ROM", 0xc0000, 0xc7fff }
};
-void __init setup_arch(char **cmdline_p,
- unsigned long * memory_start_p,
- unsigned long * memory_end_p)
+static unsigned long memory_start, memory_end;
+
+unsigned long __init memparse(char *ptr, char **retptr)
{
- unsigned long memory_start, memory_end;
+ unsigned long ret;
+
+ ret = simple_strtoul(ptr, retptr, 0);
+
+ if (**retptr == 'K' || **retptr == 'k') {
+ ret <<= 10;
+ (*retptr)++;
+ }
+ else if (**retptr == 'M' || **retptr == 'm') {
+ ret <<= 20;
+ (*retptr)++;
+ }
+ return ret;
+} /* memparse */
+
+static inline void parse_mem_cmdline (char ** cmdline_p)
+{
+ char c = ' ', *to = command_line, *from = COMMAND_LINE;
+ int len = 0;
+
+ /* Save unparsed command line copy for /proc/cmdline */
+ memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
+ saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
+
+ memory_start = (unsigned long)__va(0)+__MEMORY_START;
+ /* Default is 4Mbyte. */
+ memory_end = (unsigned long)__va(0x00400000)+__MEMORY_START;
+
+ for (;;) {
+ /*
+ * "mem=XXX[kKmM]" defines a size of memory.
+ */
+ if (c == ' ' && !memcmp(from, "mem=", 4)) {
+ if (to != command_line)
+ to--;
+ {
+ unsigned long mem_size;
+
+ mem_size = memparse(from+4, &from);
+ memory_end = memory_start + mem_size;
+ }
+ }
+ c = *(from++);
+ if (!c)
+ break;
+ if (COMMAND_LINE_SIZE <= ++len)
+ break;
+ *(to++) = c;
+ }
+ *to = '\0';
+ *cmdline_p = command_line;
+}
+
+void __init setup_arch(char **cmdline_p)
+{
+ unsigned long bootmap_size;
+ unsigned long start_pfn, max_pfn, max_low_pfn;
ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV);
@@ -118,12 +176,9 @@ void __init setup_arch(char **cmdline_p,
rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
#endif
+
if (!MOUNT_ROOT_RDONLY)
root_mountflags &= ~MS_RDONLY;
-
- memory_start = (unsigned long) &_end;
- memory_end = MEMORY_END;
-
init_mm.start_code = (unsigned long)&_text;
init_mm.end_code = (unsigned long) &_etext;
init_mm.end_data = (unsigned long) &_edata;
@@ -134,21 +189,73 @@ void __init setup_arch(char **cmdline_p,
data_resource.start = virt_to_bus(&_etext);
data_resource.end = virt_to_bus(&_edata)-1;
- /* Save unparsed command line copy for /proc/cmdline */
- memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
- saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
+ parse_mem_cmdline(cmdline_p);
- memcpy(command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
- command_line[COMMAND_LINE_SIZE-1] = '\0';
+#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
+#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
+#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
- /* Not support "mem=XXX[kKmM]" command line option. */
- *cmdline_p = command_line;
+ /*
+ * partially used pages are not usable - thus
+ * we are rounding upwards:
+ */
+ start_pfn = PFN_UP(__pa(&_end)-__MEMORY_START);
- memory_end &= PAGE_MASK;
- ram_resources[1].end = memory_end-1;
+ /*
+ * Find the highest page frame number we have available
+ */
+ max_pfn = PFN_DOWN(__pa(memory_end)-__MEMORY_START);
- *memory_start_p = memory_start;
- *memory_end_p = memory_end;
+ /*
+ * Determine low and high memory ranges:
+ */
+ max_low_pfn = max_pfn;
+
+ /*
+ * Initialize the boot-time allocator (with low memory only):
+ */
+ bootmap_size = init_bootmem(start_pfn, max_low_pfn);
+
+ /*
+ * FIXME: what about high memory?
+ */
+ ram_resources[1].end = PFN_PHYS(max_low_pfn) + __MEMORY_START;
+
+ /*
+ * Register fully available low RAM pages with the bootmem allocator.
+ */
+ {
+ unsigned long curr_pfn, last_pfn, size;
+
+ /*
+ * We are rounding up the start address of usable memory:
+ */
+ curr_pfn = PFN_UP(0);
+ /*
+ * ... and at the end of the usable range downwards:
+ */
+ last_pfn = PFN_DOWN(memory_end-__MEMORY_START);
+
+ if (last_pfn > max_low_pfn)
+ last_pfn = max_low_pfn;
+
+ size = last_pfn - curr_pfn;
+ free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
+ }
+ /*
+ * Reserve the kernel text and
+ * Reserve the bootmem bitmap itself as well. We do this in two
+ * steps (first step was init_bootmem()) because this catches
+ * the (very unlikely) case of us accidentally initializing the
+ * bootmem allocator with an invalid RAM area.
+ */
+ reserve_bootmem(PAGE_SIZE, PFN_PHYS(start_pfn) + bootmap_size);
+
+ /*
+ * reserve physical page 0 - it's a special BIOS page on many boxes,
+ * enabling clean reboots, SMP operation, laptop functions.
+ */
+ reserve_bootmem(0, PAGE_SIZE);
#ifdef CONFIG_BLK_DEV_INITRD
if (LOADER_TYPE) {
@@ -156,10 +263,12 @@ void __init setup_arch(char **cmdline_p,
initrd_end = initrd_start+INITRD_SIZE;
if (initrd_end > memory_end) {
printk("initrd extends beyond end of memory "
- "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
- initrd_end,memory_end);
+ "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
+ initrd_end,memory_end);
initrd_start = 0;
- }
+ } else
+ reserve_bootmem(__pa(initrd_start)-__MEMORY_START,
+ INITRD_SIZE);
}
#endif