Skip to content

Commit

Permalink
more arm work
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Nyberg <jens.nyberg@gmail.com>
  • Loading branch information
jezze committed Apr 8, 2015
1 parent 790084c commit e84af6f
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 34 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ RAMDISK_NAME:=initrd
RAMDISK_TYPE:=tar
RAMDISK:=$(RAMDISK_NAME).$(RAMDISK_TYPE)

IMAGE_NAME:=$(KERNEL)
IMAGE_TYPE:=img
IMAGE=$(IMAGE_NAME).$(IMAGE_TYPE)

ALL:=$(LIBS_PATH) $(MODULES_PATH) $(PACKAGES_PATH) $(KERNEL) $(RAMDISK)
CLEAN:=$(BUILD_ROOT) $(KERNEL) $(RAMDISK)
CLEAN:=$(BUILD_ROOT) $(KERNEL) $(RAMDISK) $(IMAGE)

.PHONY: all clean install

Expand Down Expand Up @@ -125,6 +129,11 @@ $(RAMDISK_NAME).tar: $(BUILD_ROOT)
$(RAMDISK_NAME).cpio: $(BUILD_ROOT)
find $^ -depth | cpio -o > $@

$(IMAGE): $(KERNEL) $(RAMDISK)
dd if=/dev/zero of=$@ count=65536
dd if=$(KERNEL) of=$@ conv=notrunc
dd if=$(RAMDISK) of=$@ skip=4096 conv=notrunc

$(INSTALL_PATH)/$(KERNEL): $(KERNEL)
install -m 644 $^ $@

Expand Down
61 changes: 43 additions & 18 deletions libs/arch/arm/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ static unsigned int despawn(struct container *container, struct task *task, void

}

/*
static void debugnum(unsigned int value, unsigned int base)
{
char num[32];
memory_clear(num, 32);
ascii_wvalue(num, 32, value, base, 0);
uart_puts(num);
uart_puts("\n");
}
*/

void arch_undefined()
{

Expand All @@ -98,31 +112,25 @@ void arch_reset()

}

void arch_syscall()
__attribute__ ((interrupt ("SWI"))) void arch_swi()
{

uart_puts("ISR SYSCALL\n");

for (;;);

}

void arch_irq()
__attribute__ ((interrupt ("IRQ"))) void arch_irq()
{

uart_puts("ISR IRQ\n");

for (;;);

}

void arch_fiq()
__attribute__ ((interrupt ("FIQ"))) void arch_fiq()
{

uart_puts("ISR FIQ\n");

for (;;);

}

static void setupcontainer(struct arch_container *container, unsigned int i)
Expand Down Expand Up @@ -165,25 +173,40 @@ static struct task *setuptasks()

}

static void debugnum(unsigned int value, unsigned int base)
void pic_do()
{

char num[32];
unsigned int *mmio = (unsigned int *)0x14000000;

memory_clear(num, 32);
ascii_wvalue(num, 32, value, base, 0);
uart_puts(num);
uart_puts("\n");
mmio[0x02] = (1 << 5) | (1 << 6) | (1 << 7);

}

void timer_do()
{

unsigned int *mmio = (unsigned int *)0x13000000;

mmio[0x00] = 0xffffff;
mmio[0x06] = 0xffffff;
mmio[0x02] = 0x80 | 0x40 | 0x02 | 0x00 | (1 << 5);
mmio[0x02] = ~0;

}

void arch_setup()
{

pic_setup();
uart_setup();
pic_do();

/*
timer_do();
*/

uart_puts("Fudge Console\n");
debugnum(0x123456, 16);
swi_test();

vfs_initbackend(&backend, 1000, backend_read, backend_write, backend_getphysical);
kernel_setup(spawn, despawn);

Expand All @@ -193,8 +216,10 @@ void arch_setup()
kernel_setupramdisk(current.container, current.task, &backend);
kernel_copytask(current.task, current.task);
kernel_setuptask(current.task, TASKVSTACKLIMIT);

uart_puts("Loop forever...\n");
halt();

for (;;);

}

2 changes: 2 additions & 0 deletions libs/arch/arm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ unsigned int cpu_get_cpsr();
void cpu_set_cpsr(unsigned int value);
void cpu_disable_interrupts();
void cpu_enable_interrupts();
void ivt_enable();
void swi_test();
9 changes: 9 additions & 0 deletions libs/arch/arm/cpu.s
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ cpu_enable_interrupts:
msr cpsr_c, r0
bx lr

.global ivt_enable
ivt_enable:
cpsie i
bx lr

.global swi_test
swi_test:
swi #1234
bx lr
33 changes: 20 additions & 13 deletions libs/arch/arm/init.s
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
interrupt_vector_table:
b arch_reset
b arch_undefined
b arch_syscall
b arch_undefined
b arch_undefined
b arch_undefined
b arch_irq
b arch_fiq

.comm stack, 0x10000
.section .text.boot
b arch_reset
b arch_undefined
b arch_swi
b arch_undefined
b arch_undefined
b arch_undefined
b arch_irq
b arch_fiq

.section .text
.global init
init:
ldr sp, =stack+0x10000
mov r4, #0x10000
cps #0x13
mov sp, r4
cps #0x17
mov sp, r4
cps #0x12
mov sp, r4
cps #0x1f
mov sp, r4
bl arch_setup

.global halt
halt:
wfi
wfe
b halt

3 changes: 2 additions & 1 deletion libs/arch/arm/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ static void enableirq()

}

/*
static void enablefiq()
{
cpu_set_cpsr(cpu_get_cpsr() & ~(1 << 6));
}
*/

void pic_enableirq(unsigned int irq)
{
Expand Down Expand Up @@ -59,7 +61,6 @@ void pic_setup()
{

enableirq();
enablefiq();

}

3 changes: 2 additions & 1 deletion platform/integratorcp/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ ENTRY (init)
SECTIONS
{

. = 0x00100000;
. = 0x00000000;

.text :
{
*(.text.boot)
*(.text)
}

Expand Down

0 comments on commit e84af6f

Please sign in to comment.