diff options
-rw-r--r-- | Common.mk | 51 | ||||
-rw-r--r-- | include/usr/main.h | 6 | ||||
-rw-r--r-- | kernel/boot.S (renamed from src/boot.S) | 0 | ||||
-rw-r--r-- | kernel/cpu/irq.c (renamed from src/cpu/irq.c) | 22 | ||||
-rw-r--r-- | kernel/drivers/uart.S (renamed from src/drivers/uart.S) | 0 | ||||
-rw-r--r-- | kernel/drivers/uart.c (renamed from src/drivers/uart.c) | 0 | ||||
-rw-r--r-- | kernel/exceptions/data.S (renamed from src/exceptions/data.S) | 0 | ||||
-rw-r--r-- | kernel/exceptions/fiq.S (renamed from src/exceptions/fiq.S) | 0 | ||||
-rw-r--r-- | kernel/exceptions/irq.S (renamed from src/exceptions/irq.S) | 0 | ||||
-rw-r--r-- | kernel/exceptions/prefetch.S (renamed from src/exceptions/prefetch.S) | 0 | ||||
-rw-r--r-- | kernel/exceptions/svc.S (renamed from src/exceptions/svc.S) | 0 | ||||
-rw-r--r-- | kernel/exceptions/undefined.S (renamed from src/exceptions/undefined.S) | 0 | ||||
-rw-r--r-- | kernel/globals.S (renamed from src/globals.S) | 0 | ||||
-rw-r--r-- | kernel/globals.c (renamed from src/globals.c) | 0 | ||||
-rw-r--r-- | kernel/graphics/lfb.c (renamed from src/graphics/lfb.c) | 0 | ||||
-rw-r--r-- | kernel/graphics/mbox.c (renamed from src/graphics/mbox.c) | 0 | ||||
-rw-r--r-- | kernel/lib/kmem.c (renamed from src/lib/kmem.c) | 0 | ||||
-rw-r--r-- | kernel/lib/mmu.S (renamed from src/lib/mmu.S) | 0 | ||||
-rw-r--r-- | kernel/lib/mmu.c (renamed from src/lib/mmu.c) | 0 | ||||
-rw-r--r-- | kernel/lib/queue.c (renamed from src/lib/queue.c) | 0 | ||||
-rw-r--r-- | kernel/lib/strings.c (renamed from src/lib/strings.c) | 0 | ||||
-rw-r--r-- | kernel/sys/core.c (renamed from src/sys/core.c) | 0 | ||||
-rw-r--r-- | kernel/sys/kernel.S (renamed from src/sys/kernel.S) | 0 | ||||
-rw-r--r-- | kernel/sys/power.c (renamed from src/sys/power.c) | 0 | ||||
-rw-r--r-- | kernel/sys/schedule.S (renamed from src/sys/schedule.S) | 0 | ||||
-rw-r--r-- | kernel/sys/schedule.c (renamed from src/sys/schedule.c) | 0 | ||||
-rw-r--r-- | kernel/tests/test.S (renamed from src/tests/test.S) | 0 | ||||
-rw-r--r-- | kernel/tests/test.c (renamed from src/tests/test.c) | 0 | ||||
-rw-r--r-- | kernel/util/lock.c (renamed from src/util/lock.c) | 0 | ||||
-rw-r--r-- | kernel/util/mutex.c (renamed from src/util/mutex.c) | 0 | ||||
-rw-r--r-- | kernel/util/status.c (renamed from src/util/status.c) | 0 | ||||
-rw-r--r-- | kernel/util/time.c (renamed from src/util/time.c) | 0 | ||||
-rw-r--r-- | usr/main.c (renamed from src/usr/main.c) | 9 |
33 files changed, 61 insertions, 27 deletions
@@ -1,13 +1,26 @@ -C_SOURCES = $(wildcard src/*.c src/**/*.c) -C_OBJECTS = ${C_SOURCES:.c=.co} -C_OBJECTD = ${subst src,obj,${C_OBJECTS}} -A_SOURCES = $(wildcard src/*.S src/**/*.S) -A_OBJECTS = ${A_SOURCES:.S=.ao} -A_OBJECTD = ${subst src,obj,${A_OBJECTS}} +# Kernel Sources/Objects +C_SOURCEK = $(wildcard kernel/*.c kernel/**/*.c) +C_OBJECTk = ${C_SOURCEK:.c=.co} +C_OBJECTK = ${subst kernel/,obj/kernel/,${C_OBJECTk}} +A_SOURCEK = $(wildcard kernel/*.S kernel/**/*.S) +A_OBJECTk = ${A_SOURCEK:.S=.ao} +A_OBJECTK = ${subst kernel/,obj/kernel/,${A_OBJECTk}} +# User Sources/Objects +C_SOURCEU = $(wildcard usr/*.c usr/**/*.c) +C_OBJECTu = ${C_SOURCEU:.c=.co} +C_OBJECTU = ${subst usr/,obj/usr/,${C_OBJECTu}} +A_SOURCEU = $(wildcard usr/*.S usr/**/*.S) +A_OBJECTu = ${A_SOURCEU:.S=.ao} +A_OBJECTU = ${subst usr/,obj/usr/,${A_OBJECTu}} +# Combined Objects +C_OBJECTD = $(C_OBJECTK) $(C_OBJECTU) +A_OBJECTD = $(A_OBJECTK) $(A_OBJECTU) ATTACH_USB ?= 0 AUTO ?= 0 BSP ?= 2 +BUILD ?= 0 +GDEBUG ?= 0 DEBUG ?= 0 SILENT ?= 0 DISK ?= /dev/sdc1 @@ -43,11 +56,22 @@ ifeq ($(BSP),2) CFLAGS += -DBSP23 endif +# Use Correct Hardware Timing +ifneq ($(BUILD),0) + RPI_BUILD = 1 + CFLAGS += -DRPI_BUILD +endif + # Pause and wait for GDB if requested -ifneq ($(DEBUG),0) +ifneq ($(GDEBUG),0) QFLAGS += -s -S endif +# Debugging Flag +ifneq ($(DEBUG),0) + CFLAGS += -DDEBUG +endif + # Don't use screen if requested ifneq ("$(SILENT)","0") QFLAGS += -nographic @@ -75,13 +99,22 @@ dump: build/kernel.list build/kernel.elf: ${A_OBJECTD} ${C_OBJECTD} @tput setaf 6 2> /dev/null || true; echo Linking Kernel; tput sgr0 2> /dev/null || true @mkdir -p $(@D) + @echo ${C_SOURCEK} ${CC} -T linker.ld -o $@ -ffreestanding -O3 -nostdlib $^ -obj/%.co: src/%.c +obj/kernel/%.co: kernel/%.c + @mkdir -p $(@D) + ${CC} ${CFLAGS} -c $< -o $@ + +obj/kernel/%.ao: kernel/%.S + @mkdir -p $(@D) + ${AS} ${AFLAGS} -c $< -o $@ + +obj/usr/%.co: usr/%.c @mkdir -p $(@D) ${CC} ${CFLAGS} -c $< -o $@ -obj/%.ao: src/%.S +obj/usr/%.ao: usr/%.S @mkdir -p $(@D) ${AS} ${AFLAGS} -c $< -o $@ diff --git a/include/usr/main.h b/include/usr/main.h index 9d0b76b..5fd29f9 100644 --- a/include/usr/main.h +++ b/include/usr/main.h @@ -1,6 +1,12 @@ #ifndef USR_MAIN_H #define USR_MAIN_H +#ifdef RPI_BUILD + #define USR_TIME 40 +#else + #define USR_TIME 2000 +#endif + void main(void); #endif diff --git a/src/boot.S b/kernel/boot.S index 46ef3d0..46ef3d0 100644 --- a/src/boot.S +++ b/kernel/boot.S diff --git a/src/cpu/irq.c b/kernel/cpu/irq.c index d3eefa2..f89bba9 100644 --- a/src/cpu/irq.c +++ b/kernel/cpu/irq.c @@ -29,27 +29,15 @@ unsigned long c_irq_handler(void) unsigned long data = load32(UART0_DR); // Handle the recieved data +#ifdef DEBUG // Ctrl+G to output scheduler debug info if (data == 0x7) { uart_scheduler(); uart_mutexes(); } - //// Ctrl+T to toggle timer - //else if(data == 0x14) { - // unsigned long timer_status; - // asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r"(timer_status)); - // if(timer_status == 0) { - // cntfrq = read_cntfrq(); - // write_cntv_tval(cntfrq/CPS); - // enablecntv(); - // draw_cstring(0, 3, "TIMER", 0x00FF00); - // } else { - // disablecntv(); - // draw_cstring(0, 3, "TIMER", 0xFF0000); - // } - //} +#endif // Add task to handle the data - else { + { add_thread(handle_data, (void*)data, PRIORITIES-1); return 1; } @@ -61,7 +49,7 @@ unsigned long c_irq_handler(void) volatile unsigned long* timer_chi = (volatile unsigned long*)SYS_TIMER_CHI; volatile unsigned long* nexttime = (volatile unsigned long*)SYS_TIMER_C0; add_thread_without_duplicate(main, 0, 0); - *nexttime = *timer_chi + 40; + *nexttime = *timer_chi + USR_TIME; *timer_cs = SYS_TIMER_SC_M0; return 1; } @@ -69,7 +57,7 @@ unsigned long c_irq_handler(void) // Check if CNTV triggered the interrupt else if (source & (1 << 3)) { // Reset the counter - write_cntv_tval(cntfrq/CPS); + write_cntv_tval(cntfrq); counter++; if (counter % 0x6000 == 0) counter = 0; diff --git a/src/drivers/uart.S b/kernel/drivers/uart.S index 38957c2..38957c2 100644 --- a/src/drivers/uart.S +++ b/kernel/drivers/uart.S diff --git a/src/drivers/uart.c b/kernel/drivers/uart.c index 68c70d6..68c70d6 100644 --- a/src/drivers/uart.c +++ b/kernel/drivers/uart.c diff --git a/src/exceptions/data.S b/kernel/exceptions/data.S index fe33215..fe33215 100644 --- a/src/exceptions/data.S +++ b/kernel/exceptions/data.S diff --git a/src/exceptions/fiq.S b/kernel/exceptions/fiq.S index 005ed76..005ed76 100644 --- a/src/exceptions/fiq.S +++ b/kernel/exceptions/fiq.S diff --git a/src/exceptions/irq.S b/kernel/exceptions/irq.S index a7e78bc..a7e78bc 100644 --- a/src/exceptions/irq.S +++ b/kernel/exceptions/irq.S diff --git a/src/exceptions/prefetch.S b/kernel/exceptions/prefetch.S index 59674bd..59674bd 100644 --- a/src/exceptions/prefetch.S +++ b/kernel/exceptions/prefetch.S diff --git a/src/exceptions/svc.S b/kernel/exceptions/svc.S index a24bac9..a24bac9 100644 --- a/src/exceptions/svc.S +++ b/kernel/exceptions/svc.S diff --git a/src/exceptions/undefined.S b/kernel/exceptions/undefined.S index 856e30f..856e30f 100644 --- a/src/exceptions/undefined.S +++ b/kernel/exceptions/undefined.S diff --git a/src/globals.S b/kernel/globals.S index b808053..b808053 100644 --- a/src/globals.S +++ b/kernel/globals.S diff --git a/src/globals.c b/kernel/globals.c index 5118e96..5118e96 100644 --- a/src/globals.c +++ b/kernel/globals.c diff --git a/src/graphics/lfb.c b/kernel/graphics/lfb.c index 8c41b1c..8c41b1c 100644 --- a/src/graphics/lfb.c +++ b/kernel/graphics/lfb.c diff --git a/src/graphics/mbox.c b/kernel/graphics/mbox.c index 0dac497..0dac497 100644 --- a/src/graphics/mbox.c +++ b/kernel/graphics/mbox.c diff --git a/src/lib/kmem.c b/kernel/lib/kmem.c index 9861f12..9861f12 100644 --- a/src/lib/kmem.c +++ b/kernel/lib/kmem.c diff --git a/src/lib/mmu.S b/kernel/lib/mmu.S index faca3cc..faca3cc 100644 --- a/src/lib/mmu.S +++ b/kernel/lib/mmu.S diff --git a/src/lib/mmu.c b/kernel/lib/mmu.c index e9dda7a..e9dda7a 100644 --- a/src/lib/mmu.c +++ b/kernel/lib/mmu.c diff --git a/src/lib/queue.c b/kernel/lib/queue.c index 1fc35f6..1fc35f6 100644 --- a/src/lib/queue.c +++ b/kernel/lib/queue.c diff --git a/src/lib/strings.c b/kernel/lib/strings.c index 674af19..674af19 100644 --- a/src/lib/strings.c +++ b/kernel/lib/strings.c diff --git a/src/sys/core.c b/kernel/sys/core.c index d76b712..d76b712 100644 --- a/src/sys/core.c +++ b/kernel/sys/core.c diff --git a/src/sys/kernel.S b/kernel/sys/kernel.S index 71b22a1..71b22a1 100644 --- a/src/sys/kernel.S +++ b/kernel/sys/kernel.S diff --git a/src/sys/power.c b/kernel/sys/power.c index c4f12a9..c4f12a9 100644 --- a/src/sys/power.c +++ b/kernel/sys/power.c diff --git a/src/sys/schedule.S b/kernel/sys/schedule.S index a47252c..a47252c 100644 --- a/src/sys/schedule.S +++ b/kernel/sys/schedule.S diff --git a/src/sys/schedule.c b/kernel/sys/schedule.c index 9b6d46e..9b6d46e 100644 --- a/src/sys/schedule.c +++ b/kernel/sys/schedule.c diff --git a/src/tests/test.S b/kernel/tests/test.S index e80b6be..e80b6be 100644 --- a/src/tests/test.S +++ b/kernel/tests/test.S diff --git a/src/tests/test.c b/kernel/tests/test.c index d954ade..d954ade 100644 --- a/src/tests/test.c +++ b/kernel/tests/test.c diff --git a/src/util/lock.c b/kernel/util/lock.c index c9fe654..c9fe654 100644 --- a/src/util/lock.c +++ b/kernel/util/lock.c diff --git a/src/util/mutex.c b/kernel/util/mutex.c index 8e85f8f..8e85f8f 100644 --- a/src/util/mutex.c +++ b/kernel/util/mutex.c diff --git a/src/util/status.c b/kernel/util/status.c index 456e89d..456e89d 100644 --- a/src/util/status.c +++ b/kernel/util/status.c diff --git a/src/util/time.c b/kernel/util/time.c index abb9c8d..abb9c8d 100644 --- a/src/util/time.c +++ b/kernel/util/time.c diff --git a/src/usr/main.c b/usr/main.c index 67b9c3a..7091580 100644 --- a/src/usr/main.c +++ b/usr/main.c @@ -20,6 +20,13 @@ char* ulong_to_string(unsigned long value, char* data) void main(void) { static char str[13]; - char* start = ulong_to_string(*(volatile unsigned long*)SYS_TIMER_CHI, str); + static unsigned long previous = 0; + char* start; + unsigned long current = *(volatile unsigned long*)SYS_TIMER_CHI; + start = ulong_to_string(current, str); draw_string(0, 10, start); + start = ulong_to_string(current - previous, str); + draw_string(0, 11, " "); + draw_string(0, 11, start); + previous = current; } |