diff options
| author | Christian Cunningham <cc@localhost> | 2022-03-16 22:28:33 -0700 | 
|---|---|---|
| committer | Christian Cunningham <cc@localhost> | 2022-03-16 22:28:33 -0700 | 
| commit | a9f63b8cdb930d079cc69d492fe44dc8224c1e03 (patch) | |
| tree | c97c9f84f5caa2b0cc77850c21f33b9f5cefaecb /src | |
| parent | a3732c11ad3bcd2c01a36d0a82a6f310fe8557af (diff) | |
More comments
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/uart.c | 2 | ||||
| -rw-r--r-- | src/exceptions/data.S | 19 | ||||
| -rw-r--r-- | src/exceptions/fiq.S | 7 | ||||
| -rw-r--r-- | src/exceptions/irq.S | 1 | ||||
| -rw-r--r-- | src/exceptions/prefetch.S | 8 | ||||
| -rw-r--r-- | src/exceptions/svc.S | 12 | ||||
| -rw-r--r-- | src/exceptions/undefined.S | 16 | ||||
| -rw-r--r-- | src/globals.c | 5 | ||||
| -rw-r--r-- | src/graphics/lfb.c | 2 | ||||
| -rw-r--r-- | src/lib/kmem.c | 2 | ||||
| -rw-r--r-- | src/util/lock.c | 7 | 
11 files changed, 40 insertions, 41 deletions
| diff --git a/src/drivers/uart.c b/src/drivers/uart.c index deaa84a..68c70d6 100644 --- a/src/drivers/uart.c +++ b/src/drivers/uart.c @@ -57,7 +57,7 @@ void* uart_print(char* s)  		ptr += 1;  	}  	// Low priority flush run whenever -	add_thread(uart_flush, 0, PRIORITIES-1); +	add_thread_without_duplicate(uart_flush, 0, PRIORITIES-1);  	unlock(&ubuffer.l);  	return 0;  } diff --git a/src/exceptions/data.S b/src/exceptions/data.S index 656ba96..e3add71 100644 --- a/src/exceptions/data.S +++ b/src/exceptions/data.S @@ -9,21 +9,24 @@ data:  	ldr r2, =data_msg  	bl draw_string  	// Output return address -	mov r0, #13 -	mov r1, #15 +	mov r0, #80 +	mov r1, #0  	mov r2, r4  	sub r2, #8  	bl draw_hex32 -	mov r0, #22 -	mov r1, #15 +	// Output the data at the address +	mov r0, #80 +	mov r1, #1  	ldr r2, [r4, #-8]  	bl draw_hex32 -	mov r0, #32 -	mov r1, #15 +	// Output the Program Status +	mov r0, #80 +	mov r1, #2  	mrs r2, spsr  	bl draw_hex32 -	mov r0, #41 -	mov r1, #15 +	// Output the data-fault register +	mov r0, #80 +	mov r1, #3  	mrc p15, 0, r2, c5, c0, 0 //// https://developer.arm.com/documentation/ddi0464/d/System-Control/Register-descriptions/Data-Fault-Status-Register?lang=en  	bl draw_hex32  	ldmfd sp!, {r0-r12,lr} diff --git a/src/exceptions/fiq.S b/src/exceptions/fiq.S index f323a02..005ed76 100644 --- a/src/exceptions/fiq.S +++ b/src/exceptions/fiq.S @@ -6,13 +6,17 @@ fiq:  	bl c_fiq_handler  	cmp r0, #1  	bne 1f +	// Schedule if interrupted a thread  	mrs r1, spsr  	and r1, r1, #0x1f  	cmp r1, #0x10  	bne 1f  	ldmfd sp!, {r0-r12,lr} +	// Don't skip missed instruction upon return  	sub lr, #4  	push {r3} +	// Store the instruction in a special area for +	//  future processing  	ldr r3, =irqlr  	str lr, [r3, #0]  	pop {r3} @@ -21,6 +25,3 @@ fiq:  1:  	ldmfd sp!, {r0-r12,lr}  	subs pc, lr, #4 - -.section .data -fiq_msg:	.asciz "FIQ\n" diff --git a/src/exceptions/irq.S b/src/exceptions/irq.S index 025fc41..db8b4cd 100644 --- a/src/exceptions/irq.S +++ b/src/exceptions/irq.S @@ -3,6 +3,7 @@  irq:  	cpsid aif  	push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} +	// Run IRQ handler  	bl c_irq_handler  	pop  {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr}  	subs pc, lr, #4 diff --git a/src/exceptions/prefetch.S b/src/exceptions/prefetch.S index 1aeba10..5166d00 100644 --- a/src/exceptions/prefetch.S +++ b/src/exceptions/prefetch.S @@ -4,13 +4,13 @@ prefetch:  	cpsid aif  	stmfd sp!, {r0-r12,lr}  	mov r4, lr -	mov r0, #0 -	mov r1, #16 +	mov r0, #98 +	mov r1, #0  	ldr r2, =prefetch_msg  	bl draw_string  	// Output return address -	mov r0, #17 -	mov r1, #16 +	mov r0, #98 +	mov r1, #1  	mov r2, r4  	bl draw_hex32  	ldmfd sp!, {r0-r12,lr} diff --git a/src/exceptions/svc.S b/src/exceptions/svc.S index 3fb534e..7c8a9cc 100644 --- a/src/exceptions/svc.S +++ b/src/exceptions/svc.S @@ -3,8 +3,10 @@  svc:  	cpsid aif  	stmfd sp!, {r0-r12,lr} +	// Get the SVC Exception #  	ldr r0, [lr, #-4]  	bic r0, #0xFF000000 +	// Jump to the appropriate Call  	cmp r0, #5  	bgt svc_exit  	beq svc_000005 @@ -18,11 +20,11 @@ svc:  	beq svc_000001  	cmp r0, #0  	beq svc_000000 -svc_000000: +svc_000000: // SYS_YIELD  	bl yield  	ldmfd sp!, {r0-r12,lr}  	b schedule -svc_000001: // Get time +svc_000001: // SYS_TIME  	mov r2, #0x3004  	movt r2, #0x3F00  	ldr r0, [r2, #4] // <- SYS_TIMER_CLO @@ -50,13 +52,15 @@ svc_000004: // Lock Lock (usr_r0 = struct Lock*)  1:	clrex  	ldrex r2, [r0, #0]  	cmp r2, #0 +	// If it is not available, wait-queue the thread  	bne svc_000004_delay_mutex +	// Otherwise lock it  	strexeq r2, r1, [r0, #0]  	teq r2, #0  	bne 1b  	dmb  	b svc_exit -svc_000004_delay_mutex: +svc_000004_delay_mutex: // Wait-queue the current thread  	// r0 = struct Lock* m  	bl sched_mutex_yield  	ldmfd sp!, {r0-r12,lr} @@ -65,9 +69,11 @@ svc_000005: // Release Lock  	ldr r0, [sp, #0] // struct Lock* m  	mov r1, #0  	dmb +	// Unlock  	str r1, [r0, #0]  	dsb  	sev +	// Awake any threads waiting for this lock  	bl sched_mutex_resurrect  	ldmfd sp!, {r0-r12,lr}  	b schedule diff --git a/src/exceptions/undefined.S b/src/exceptions/undefined.S index ef00735..2d4b90a 100644 --- a/src/exceptions/undefined.S +++ b/src/exceptions/undefined.S @@ -4,23 +4,19 @@ undefined:  	cpsid aif  	stmfd sp!, {r0-r12,lr}  	ldr r4, [lr, #-4] -	mov r0, #0 -	mov r1, #17 +	mov r0, #62 +	mov r1, #0  	ldr r2, =undefined_msg  	bl draw_string -	mov r0, #18 -	mov r1, #17 +	mov r0, #62 +	mov r1, #1  	mov r2, r4  	bl draw_hex32 -	mov r0, #27 -	mov r1, #17 -	ldr r2, =undefined_at -	bl draw_string  	// Output lr  	ldr r0, [sp, #0x34]  	sub r2, r0, #4 -	mov r0, #31 -	mov r1, #17 +	mov r0, #62 +	mov r1, #2  	bl draw_hex32  	// Skip instruction for now  	// In future,  diff --git a/src/globals.c b/src/globals.c index 37853cd..a8cb47b 100644 --- a/src/globals.c +++ b/src/globals.c @@ -19,11 +19,6 @@ __attribute__((section(".bss"))) unsigned int gpitch;  __attribute__((section(".bss"))) unsigned int gisrgb;  __attribute__((section(".bss.mutexl"))) unsigned long mutex_table[MAX_MUTEXS];  __attribute__((section(".bss.mutexs"))) struct Mutex mutexs[MAX_MUTEXS]; -// 0 - Free -// 1 - Ready -// 2 - Waiting for Mutex -// 3 - Waiting for Signal -// 4+ - Reserved  __attribute__((section(".bss.threadl"))) unsigned char thread_table[MAX_THREADS];  __attribute__((section(".bss.threads"))) struct Thread threads[MAX_THREADS];  __attribute__((section(".bss.threade"))) struct ThreadEntry thread_entries[MAX_THREADS]; diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c index a01c344..8c41b1c 100644 --- a/src/graphics/lfb.c +++ b/src/graphics/lfb.c @@ -11,7 +11,7 @@ unsigned char *lfb;                         /* raw frame buffer address */  #define SCR_HEIGHT 1080  /** - * Set screen resolution to 1024x768 + * Set screen resolution   */  void lfb_init(void)  { diff --git a/src/lib/kmem.c b/src/lib/kmem.c index 0419662..9861f12 100644 --- a/src/lib/kmem.c +++ b/src/lib/kmem.c @@ -2,6 +2,7 @@  #include <drivers/uart.h>  #include <lib/kmem.h> +// Output longs at address  void kmemshow32(void* data, unsigned long length)  {  	unsigned long* ptr = data; @@ -14,6 +15,7 @@ void kmemshow32(void* data, unsigned long length)  	uart_char('\n');  } +// Output bytes at address  void kmemshow(void* data, unsigned long length)  {  	unsigned char* ptr = data; diff --git a/src/util/lock.c b/src/util/lock.c index eaeb5a8..50091b0 100644 --- a/src/util/lock.c +++ b/src/util/lock.c @@ -4,15 +4,12 @@  #include <util/lock.h>  // TODO: Improve locking for system -//  1. Return code rather than hang? -//  2. Specific core PID rather than CORE0 +//  1. Deadlock prevention by going through mutex list  void lock(struct Lock* l)  {  	unsigned long mode = getmode() & 0x1F;  	if (mode == 0x10) {  		sys1(SYS_LOCK, l); -	} else { -		atm_lock(CORE0_PID, (unsigned long*)l);  	}  } @@ -21,7 +18,5 @@ void unlock(struct Lock* l)  	unsigned long mode = getmode() & 0x1F;  	if (mode == 0x10) {  		sys1(SYS_UNLOCK, l); -	} else { -		atm_release((unsigned long*)l);  	}  } | 
