From 3994a78ce5711aa6c40625f523d78fbfe0f4c112 Mon Sep 17 00:00:00 2001 From: Kyle Cardoza Date: Wed, 27 Mar 2024 21:37:59 -0400 Subject: [PATCH] Added initial interupt handlers --- build.lst | 813 +++++++++++++++++++++++++++++++++---------- config/memory.scm | 7 + include/config.h | 6 + include/interrupts.h | 35 ++ src/interrupts.c | 217 ++++++++++++ src/stubs.c | 28 +- 6 files changed, 915 insertions(+), 191 deletions(-) create mode 100644 include/interrupts.h create mode 100644 src/interrupts.c diff --git a/build.lst b/build.lst index fe625c4..17b6498 100644 --- a/build.lst +++ b/build.lst @@ -1,11 +1,11 @@ ############################################################################### # # # Calypsi linker for 65816 version 5.1 # -# 27/Mar/2024 20:41:26 # +# 27/Mar/2024 21:37:37 # # Command line: -o build/kernel.bin config/memory.scm # # --no-data-init-table-section --rtattr cstartup=turaco # # --list-file build.lst --verbose --output-format pgz # -# src/main.o src/stubs.o # +# src/interrupts.o src/main.o src/stubs.o # # # ############################################################################### @@ -20,19 +20,18 @@ Name Range Size Used Checksum Largest unal DirectPage 000000-0000ff 000100 7.8% none 0000e8 stack 000200-000fff 000e00 42.9% none 000800 LowData 001000-007fff 007000 0.0% none 007000 -LowCode 008800-00ffe3 0077e4 0.1% none 0077dc +LowCode 008800-00ffe3 0077e4 3.8% none 00730b IOSpace 00df00-00dfff 000100 0.0% none 000100 LowCode-vector 00ffe4-00ffff 00001c 7.1% none 0077fc -HighData-01 010000-01ffff 010000 12.7% none 00df7a - > HighData-01-huge-nobits 010000-010085 000086 100.0% none 00ff7a +HighData-01 010000-01ffff 010000 12.8% none 00df46 + > HighData-01-huge-nobits 010000-0100b9 0000ba 100.0% none 00ff46 HighData-02 020000-02ffff 010000 0.0% none 010000 HighData-03 030000-03ffff 010000 0.0% none 010000 HighData-04 040000-04ffff 010000 0.0% none 010000 HighData-05 050000-05ffff 010000 0.0% none 010000 HighData-06 060000-06ffff 010000 0.0% none 010000 HighData-07 070000-07ffff 010000 0.0% none 010000 -HighCode-c0 c00000-c0ffff 010000 0.3% none 00ff44 - > HighCode-c0-farcode c00000-c000bb 0000bc 100.0% none 00ff44 +HighCode-c0 c00000-c0ffff 010000 0.5% none 00fe9b HighCode-c1 c10000-c1ffff 010000 0.0% none 010000 HighCode-c2 c20000-c2ffff 010000 0.0% none 010000 HighCode-c3 c30000-c3ffff 010000 0.0% none 010000 @@ -48,16 +47,29 @@ HighCode-c7 c70000-c7ffff 010000 0.0% none 010000 # # #################### -Name Range Size Memory Fragments ------------------------------------------------------------------- -registers 000004-000017 000014 DirectPage 1 -stack 000200-0003ff 000200 stack 1 -cstack 000400-0007ff 000400 stack 1 -code 008800-008823 000024 LowCode 2 -reset 00fffc-00fffd 000002 LowCode-vector 1 -zhuge 010000-010085 000086 HighData-01-huge-nobits 3 -heap 010086-012085 002000 HighData-01 1 -farcode c00000-c000bb 0000bc HighCode-c0-farcode 18 +Name Range Size Memory Fragments +----------------------------------------------------------------------------------- +registers 000004-000017 000014 DirectPage 1 +stack 000200-0003ff 000200 stack 1 +cstack 000400-0007ff 000400 stack 1 +code 008800-008c74 000475 LowCode 15 +$$interruptVector_0x00ff80 00ff80-00ff81 000002 LowCode 1 +$$interruptVector_0x00ff82 00ff82-00ff83 000002 LowCode 1 +$$interruptVector_0x00ff84 00ff84-00ff85 000002 LowCode 1 +$$interruptVector_0x00ff86 00ff86-00ff87 000002 LowCode 1 +$$interruptVector_0x00ff88 00ff88-00ff89 000002 LowCode 1 +$$interruptVector_0x00ff8a 00ff8a-00ff8b 000002 LowCode 1 +$$interruptVector_0x00ff8c 00ff8c-00ff8d 000002 LowCode 1 +$$interruptVector_0x00ff8e 00ff8e-00ff8f 000002 LowCode 1 +$$interruptVector_0x00ff98 00ff98-00ff99 000002 LowCode 1 +$$interruptVector_0x00ff9e 00ff9e-00ff9f 000002 LowCode 1 +$$interruptVector_0x00ffb4 00ffb4-00ffb5 000002 LowCode 1 +$$interruptVector_0x00ffb6 00ffb6-00ffb7 000002 LowCode 1 +$$interruptVector_0x00ffba 00ffba-00ffbb 000002 LowCode 1 +reset 00fffc-00fffd 000002 LowCode-vector 1 +zhuge 010000-0100b9 0000ba HighData-01-huge-nobits 16 +heap 0100ba-0120b9 002000 HighData-01 1 +farcode c00000-c00164 000165 HighCode-c0 31 ################### @@ -72,29 +84,37 @@ DirectPage 000000-0000ff Plain > (registers 000004) > ztiny HighCode-c0 c00000-c0ffff Far - HighCode-c0-farcode c00000-c0ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c1 c10000-c1ffff Far - HighCode-c1-farcode c10000-c1ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c2 c20000-c2ffff Far - HighCode-c2-farcode c20000-c2ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c3 c30000-c3ffff Far - HighCode-c3-farcode c30000-c3ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c4 c40000-c4ffff Far - HighCode-c4-farcode c40000-c4ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c5 c50000-c5ffff Far - HighCode-c5-farcode c50000-c5ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c6 c60000-c6ffff Far - HighCode-c6-farcode c60000-c6ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighCode-c7 c70000-c7ffff Far - HighCode-c7-farcode c70000-c7ffff FarFunction and TEXT - > farcode + > farcode + > ifar + > ihuge HighData-01 010000-01ffff Far > heap HighData-01-huge-nobits 010000-01ffff Huge and BSS @@ -129,11 +149,19 @@ LowCode-vector 00ffe4-00ffff Plain > (reset 00fffc) > code > cdata + > idata + > inear > switch + > data_init_table LowCode 008800-00ffe3 Plain > code > cdata + > idata + > inear > switch + > data_init_table + LowCode-cbits 008800-00ffe3 Plain and RODATA + LowCode-code 008800-00ffe3 PlainFunction and TEXT LowData 001000-007fff Plain > near > data @@ -162,24 +190,41 @@ _NearBaseAddress LowData 000000 Unit Filename Archive -------------------------------------------- - 0 src/main.o - + 0 src/interrupts.o - + > $$interruptVector_0x00ff80 000002 + > $$interruptVector_0x00ff82 000002 + > $$interruptVector_0x00ff84 000002 + > $$interruptVector_0x00ff86 000002 + > $$interruptVector_0x00ff88 000002 + > $$interruptVector_0x00ff8a 000002 + > $$interruptVector_0x00ff8c 000002 + > $$interruptVector_0x00ff8e 000002 + > $$interruptVector_0x00ff98 000002 + > $$interruptVector_0x00ff9e 000002 + > $$interruptVector_0x00ffb4 000002 + > $$interruptVector_0x00ffb6 000002 + > $$interruptVector_0x00ffba 000002 + > code 000451 + > farcode 0000a9 + > zhuge 000034 + 1 src/main.o - > farcode 000002 - 1 src/stubs.o - + 2 src/stubs.o - > farcode 000034 - 3 cstartup.o clib-lc-hd-double64.a + 4 cstartup.o clib-lc-hd-double64.a # picked based on cstartup=normal (built-in default) > code 000024 > farcode 000001 > reset 000002 - 4 exit.o clib-lc-hd-double64.a + 5 exit.o clib-lc-hd-double64.a # picked based on exit=stdexit (built-in default) > farcode 000072 > zhuge 000086 - 6 controlFlow.o clib-lc-hd-double64.a + 7 controlFlow.o clib-lc-hd-double64.a > farcode 00000e - 7 pseudoRegisters.o clib-lc-hd-double64.a + 8 pseudoRegisters.o clib-lc-hd-double64.a > registers 000014 - 8 exitC99.o clib-lc-hd-double64.a + 9 exitC99.o clib-lc-hd-double64.a > farcode 000005 ################### @@ -189,193 +234,605 @@ Unit Filename Archive ################### _Dp in section 'registers' placed at address 000004-000017 of size 000014 -(pseudoRegisters.o (from clib-lc-hd-double64.a) unit 7 section index 2) +(pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) Defines: _Vfp = 000014 _Dp = 000004 Referenced from: - __program_start (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 2) - exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) - _JmpIndLong (controlFlow.o (from clib-lc-hd-double64.a) unit 6 section index 3) + nmi_handler (src/interrupts.o unit 0 section index 15) + brk_handler (src/interrupts.o unit 0 section index 16) + cop_handler (src/interrupts.o unit 0 section index 17) + irq_handler (src/interrupts.o unit 0 section index 18) + int_vera_irq_handler (src/interrupts.o unit 0 section index 19) + int_t7_handler (src/interrupts.o unit 0 section index 20) + int_t6_handler (src/interrupts.o unit 0 section index 21) + int_t5_handler (src/interrupts.o unit 0 section index 22) + int_t4_handler (src/interrupts.o unit 0 section index 23) + int_t3_handler (src/interrupts.o unit 0 section index 24) + int_t2_handler (src/interrupts.o unit 0 section index 25) + int_t1_handler (src/interrupts.o unit 0 section index 26) + int_t0_handler (src/interrupts.o unit 0 section index 27) + set_user_nmi_handler (src/interrupts.o unit 0 section index 28) + set_user_brk_handler (src/interrupts.o unit 0 section index 29) + set_user_cop_handler (src/interrupts.o unit 0 section index 30) + set_user_irq_handler (src/interrupts.o unit 0 section index 31) + set_user_vera_irq_handler (src/interrupts.o unit 0 section index 32) + set_user_t7_handler (src/interrupts.o unit 0 section index 33) + set_user_t6_handler (src/interrupts.o unit 0 section index 34) + set_user_t5_handler (src/interrupts.o unit 0 section index 35) + set_user_t4_handler (src/interrupts.o unit 0 section index 36) + set_user_t3_handler (src/interrupts.o unit 0 section index 37) + set_user_t2_handler (src/interrupts.o unit 0 section index 38) + set_user_t1_handler (src/interrupts.o unit 0 section index 39) + set_user_t0_handler (src/interrupts.o unit 0 section index 40) + __program_start (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 2) + exit (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) + _JmpIndLong (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) -_Stub_exit in section 'farcode' placed at address c00000-c00000 of size 000001 -(src/stubs.o unit 1 section index 12) +exit in section 'farcode' placed at address c00000-c00071 of size 000072 +(exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) Defines: - _Stub_exit = c00000 - Referenced from: - _Exit (exitC99.o (from clib-lc-hd-double64.a) unit 8 section index 2) - -_Stub_assert in section 'farcode' - placed at address c00001-c00001 of size 000001 -(src/stubs.o unit 1 section index 14) - Defines: - _Stub_assert = c00001 - -__low_level_init in section 'farcode' - placed at address c00002-c00002 of size 000001 -(cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 8) - Defines: - __low_level_init = c00002 - Referenced from: - __program_start (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 2) - -main in section 'farcode' placed at address c00003-c00004 of size 000002 -(src/main.o unit 0 section index 2) - Defines: - main = c00003 - Referenced from: - (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 6) - -_Stub_open in section 'farcode' placed at address c00005-c00008 of size 000004 -(src/stubs.o unit 1 section index 2) - Defines: - _Stub_open = c00005 - -_Stub_close in section 'farcode' - placed at address c00009-c0000c of size 000004 -(src/stubs.o unit 1 section index 3) - Defines: - _Stub_close = c00009 - -_Stub_access in section 'farcode' - placed at address c0000d-c00010 of size 000004 -(src/stubs.o unit 1 section index 4) - Defines: - _Stub_access = c0000d - -_Stub_fgetpos in section 'farcode' - placed at address c00011-c00014 of size 000004 -(src/stubs.o unit 1 section index 6) - Defines: - _Stub_fgetpos = c00011 - -_Stub_fsetpos in section 'farcode' - placed at address c00015-c00018 of size 000004 -(src/stubs.o unit 1 section index 7) - Defines: - _Stub_fsetpos = c00015 - -_Stub_read in section 'farcode' placed at address c00019-c0001c of size 000004 -(src/stubs.o unit 1 section index 8) - Defines: - _Stub_read = c00019 - -_Stub_write in section 'farcode' - placed at address c0001d-c00020 of size 000004 -(src/stubs.o unit 1 section index 9) - Defines: - _Stub_write = c0001d - -_Stub_rename in section 'farcode' - placed at address c00021-c00024 of size 000004 -(src/stubs.o unit 1 section index 10) - Defines: - _Stub_rename = c00021 - -_Stub_remove in section 'farcode' - placed at address c00025-c00028 of size 000004 -(src/stubs.o unit 1 section index 11) - Defines: - _Stub_remove = c00025 - -_Exit in section 'farcode' placed at address c00029-c0002d of size 000005 -(exitC99.o (from clib-lc-hd-double64.a) unit 8 section index 2) - Defines: - _Exit = c00029 + exit = c00000 References: - _Stub_exit in (src/stubs.o unit 1 section index 12) + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _Exit in (exitC99.o (from clib-lc-hd-double64.a) unit 9 section index 2) + _ExitCloseStreams in (exit.o (from clib-lc-hd-double64.a) unit 5 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + __atexit in (exit.o (from clib-lc-hd-double64.a) unit 5 section index 3) + __atexit_index in (exit.o (from clib-lc-hd-double64.a) unit 5 section index 4) Referenced from: - exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) - -_Stub_lseek in section 'farcode' - placed at address c0002e-c00034 of size 000007 -(src/stubs.o unit 1 section index 5) - Defines: - _Stub_lseek = c0002e - -_Stub_environ in section 'farcode' - placed at address c00035-c0003b of size 000007 -(src/stubs.o unit 1 section index 13) - Defines: - _Stub_environ = c00035 + (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 6) _JmpIndLong in section 'farcode' - placed at address c0003c-c00049 of size 00000e -(controlFlow.o (from clib-lc-hd-double64.a) unit 6 section index 3) + placed at address c00072-c0007f of size 00000e +(controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) Defines: - _JmpIndLong = c0003c + _JmpIndLong = c00072 References: - _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 7 section index 2) + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) Referenced from: - exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) + nmi_handler (src/interrupts.o unit 0 section index 15) + brk_handler (src/interrupts.o unit 0 section index 16) + cop_handler (src/interrupts.o unit 0 section index 17) + irq_handler (src/interrupts.o unit 0 section index 18) + int_vera_irq_handler (src/interrupts.o unit 0 section index 19) + int_t7_handler (src/interrupts.o unit 0 section index 20) + int_t6_handler (src/interrupts.o unit 0 section index 21) + int_t5_handler (src/interrupts.o unit 0 section index 22) + int_t4_handler (src/interrupts.o unit 0 section index 23) + int_t3_handler (src/interrupts.o unit 0 section index 24) + int_t2_handler (src/interrupts.o unit 0 section index 25) + int_t1_handler (src/interrupts.o unit 0 section index 26) + int_t0_handler (src/interrupts.o unit 0 section index 27) + exit (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) -exit in section 'farcode' placed at address c0004a-c000bb of size 000072 -(exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) +set_user_t0_handler in section 'farcode' + placed at address c00080-c0008c of size 00000d +(src/interrupts.o unit 0 section index 40) Defines: - exit = c0004a + set_user_t0_handler = c00080 References: - _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 7 section index 2) - _Exit in (exitC99.o (from clib-lc-hd-double64.a) unit 8 section index 2) - _ExitCloseStreams in (exit.o (from clib-lc-hd-double64.a) unit 4 section index 2) - _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 6 section index 3) - __atexit in (exit.o (from clib-lc-hd-double64.a) unit 4 section index 3) - __atexit_index in (exit.o (from clib-lc-hd-double64.a) unit 4 section index 4) - Referenced from: - (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 6) + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) -Section 'heap' placed at address 010086-012085 of size 002000 +set_user_t1_handler in section 'farcode' + placed at address c0008d-c00099 of size 00000d +(src/interrupts.o unit 0 section index 39) + Defines: + set_user_t1_handler = c0008d + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_t2_handler in section 'farcode' + placed at address c0009a-c000a6 of size 00000d +(src/interrupts.o unit 0 section index 38) + Defines: + set_user_t2_handler = c0009a + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_t3_handler in section 'farcode' + placed at address c000a7-c000b3 of size 00000d +(src/interrupts.o unit 0 section index 37) + Defines: + set_user_t3_handler = c000a7 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_t4_handler in section 'farcode' + placed at address c000b4-c000c0 of size 00000d +(src/interrupts.o unit 0 section index 36) + Defines: + set_user_t4_handler = c000b4 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_t5_handler in section 'farcode' + placed at address c000c1-c000cd of size 00000d +(src/interrupts.o unit 0 section index 35) + Defines: + set_user_t5_handler = c000c1 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_t6_handler in section 'farcode' + placed at address c000ce-c000da of size 00000d +(src/interrupts.o unit 0 section index 34) + Defines: + set_user_t6_handler = c000ce + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_t7_handler in section 'farcode' + placed at address c000db-c000e7 of size 00000d +(src/interrupts.o unit 0 section index 33) + Defines: + set_user_t7_handler = c000db + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_vera_irq_handler in section 'farcode' + placed at address c000e8-c000f4 of size 00000d +(src/interrupts.o unit 0 section index 32) + Defines: + set_user_vera_irq_handler = c000e8 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_irq_handler in section 'farcode' + placed at address c000f5-c00101 of size 00000d +(src/interrupts.o unit 0 section index 31) + Defines: + set_user_irq_handler = c000f5 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_cop_handler in section 'farcode' + placed at address c00102-c0010e of size 00000d +(src/interrupts.o unit 0 section index 30) + Defines: + set_user_cop_handler = c00102 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_brk_handler in section 'farcode' + placed at address c0010f-c0011b of size 00000d +(src/interrupts.o unit 0 section index 29) + Defines: + set_user_brk_handler = c0010f + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +set_user_nmi_handler in section 'farcode' + placed at address c0011c-c00128 of size 00000d +(src/interrupts.o unit 0 section index 28) + Defines: + set_user_nmi_handler = c0011c + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + +_Stub_environ in section 'farcode' + placed at address c00129-c0012f of size 000007 +(src/stubs.o unit 2 section index 13) + Defines: + _Stub_environ = c00129 + +_Stub_lseek in section 'farcode' + placed at address c00130-c00136 of size 000007 +(src/stubs.o unit 2 section index 5) + Defines: + _Stub_lseek = c00130 + +_Exit in section 'farcode' placed at address c00137-c0013b of size 000005 +(exitC99.o (from clib-lc-hd-double64.a) unit 9 section index 2) + Defines: + _Exit = c00137 + References: + _Stub_exit in (src/stubs.o unit 2 section index 12) + Referenced from: + exit (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) + +_Stub_remove in section 'farcode' + placed at address c0013c-c0013f of size 000004 +(src/stubs.o unit 2 section index 11) + Defines: + _Stub_remove = c0013c + +_Stub_rename in section 'farcode' + placed at address c00140-c00143 of size 000004 +(src/stubs.o unit 2 section index 10) + Defines: + _Stub_rename = c00140 + +_Stub_write in section 'farcode' + placed at address c00144-c00147 of size 000004 +(src/stubs.o unit 2 section index 9) + Defines: + _Stub_write = c00144 + +_Stub_read in section 'farcode' placed at address c00148-c0014b of size 000004 +(src/stubs.o unit 2 section index 8) + Defines: + _Stub_read = c00148 + +_Stub_fsetpos in section 'farcode' + placed at address c0014c-c0014f of size 000004 +(src/stubs.o unit 2 section index 7) + Defines: + _Stub_fsetpos = c0014c + +_Stub_fgetpos in section 'farcode' + placed at address c00150-c00153 of size 000004 +(src/stubs.o unit 2 section index 6) + Defines: + _Stub_fgetpos = c00150 + +_Stub_access in section 'farcode' + placed at address c00154-c00157 of size 000004 +(src/stubs.o unit 2 section index 4) + Defines: + _Stub_access = c00154 + +_Stub_close in section 'farcode' + placed at address c00158-c0015b of size 000004 +(src/stubs.o unit 2 section index 3) + Defines: + _Stub_close = c00158 + +_Stub_open in section 'farcode' placed at address c0015c-c0015f of size 000004 +(src/stubs.o unit 2 section index 2) + Defines: + _Stub_open = c0015c + +main in section 'farcode' placed at address c00160-c00161 of size 000002 +(src/main.o unit 1 section index 2) + Defines: + main = c00160 + Referenced from: + (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 6) + +__low_level_init in section 'farcode' + placed at address c00162-c00162 of size 000001 +(cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 8) + Defines: + __low_level_init = c00162 + Referenced from: + __program_start (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 2) + +_Stub_assert in section 'farcode' + placed at address c00163-c00163 of size 000001 +(src/stubs.o unit 2 section index 14) + Defines: + _Stub_assert = c00163 + +_Stub_exit in section 'farcode' placed at address c00164-c00164 of size 000001 +(src/stubs.o unit 2 section index 12) + Defines: + _Stub_exit = c00164 + Referenced from: + _Exit (exitC99.o (from clib-lc-hd-double64.a) unit 9 section index 2) + +Section 'heap' placed at address 0100ba-0120b9 of size 002000 (linker generated) __atexit_index in section 'zhuge' placed at address 010000-010001 of size 000002 -(exit.o (from clib-lc-hd-double64.a) unit 4 section index 4) +(exit.o (from clib-lc-hd-double64.a) unit 5 section index 4) Defines: __atexit_index = 010000 Referenced from: - exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) + exit (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) __atexit in section 'zhuge' placed at address 010002-010081 of size 000080 -(exit.o (from clib-lc-hd-double64.a) unit 4 section index 3) +(exit.o (from clib-lc-hd-double64.a) unit 5 section index 3) Defines: __atexit = 010002 Referenced from: - exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) + exit (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) _ExitCloseStreams in section 'zhuge' placed at address 010082-010085 of size 000004 -(exit.o (from clib-lc-hd-double64.a) unit 4 section index 2) +(exit.o (from clib-lc-hd-double64.a) unit 5 section index 2) Defines: _ExitCloseStreams = 010082 Referenced from: - exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) + exit (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) + +user_t0_handler in section 'zhuge' + placed at address 010086-010089 of size 000004 +(src/interrupts.o unit 0 section index 14) + +user_t1_handler in section 'zhuge' + placed at address 01008a-01008d of size 000004 +(src/interrupts.o unit 0 section index 13) + +user_t2_handler in section 'zhuge' + placed at address 01008e-010091 of size 000004 +(src/interrupts.o unit 0 section index 12) + +user_t3_handler in section 'zhuge' + placed at address 010092-010095 of size 000004 +(src/interrupts.o unit 0 section index 11) + +user_t4_handler in section 'zhuge' + placed at address 010096-010099 of size 000004 +(src/interrupts.o unit 0 section index 10) + +user_t5_handler in section 'zhuge' + placed at address 01009a-01009d of size 000004 +(src/interrupts.o unit 0 section index 9) + +user_t6_handler in section 'zhuge' + placed at address 01009e-0100a1 of size 000004 +(src/interrupts.o unit 0 section index 8) + +user_t7_handler in section 'zhuge' + placed at address 0100a2-0100a5 of size 000004 +(src/interrupts.o unit 0 section index 7) + +user_vera_irq_handler in section 'zhuge' + placed at address 0100a6-0100a9 of size 000004 +(src/interrupts.o unit 0 section index 6) + +user_irq_handler in section 'zhuge' + placed at address 0100aa-0100ad of size 000004 +(src/interrupts.o unit 0 section index 5) + +user_cop_handler in section 'zhuge' + placed at address 0100ae-0100b1 of size 000004 +(src/interrupts.o unit 0 section index 4) + +user_brk_handler in section 'zhuge' + placed at address 0100b2-0100b5 of size 000004 +(src/interrupts.o unit 0 section index 3) + +user_nmi_handler in section 'zhuge' + placed at address 0100b6-0100b9 of size 000004 +(src/interrupts.o unit 0 section index 2) + +int_t0_handler in section 'code' + placed at address 008800-008854 of size 000055 +(src/interrupts.o unit 0 section index 27) + Defines: + int_t0_handler = 008800 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 53) + +int_t1_handler in section 'code' + placed at address 008855-0088a9 of size 000055 +(src/interrupts.o unit 0 section index 26) + Defines: + int_t1_handler = 008855 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 52) + +int_t2_handler in section 'code' + placed at address 0088aa-0088fe of size 000055 +(src/interrupts.o unit 0 section index 25) + Defines: + int_t2_handler = 0088aa + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 51) + +int_t3_handler in section 'code' + placed at address 0088ff-008953 of size 000055 +(src/interrupts.o unit 0 section index 24) + Defines: + int_t3_handler = 0088ff + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 50) + +int_t4_handler in section 'code' + placed at address 008954-0089a8 of size 000055 +(src/interrupts.o unit 0 section index 23) + Defines: + int_t4_handler = 008954 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 49) + +int_t5_handler in section 'code' + placed at address 0089a9-0089fd of size 000055 +(src/interrupts.o unit 0 section index 22) + Defines: + int_t5_handler = 0089a9 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 48) + +int_t6_handler in section 'code' + placed at address 0089fe-008a52 of size 000055 +(src/interrupts.o unit 0 section index 21) + Defines: + int_t6_handler = 0089fe + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 47) + +int_t7_handler in section 'code' + placed at address 008a53-008aa7 of size 000055 +(src/interrupts.o unit 0 section index 20) + Defines: + int_t7_handler = 008a53 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 46) + +int_vera_irq_handler in section 'code' + placed at address 008aa8-008afc of size 000055 +(src/interrupts.o unit 0 section index 19) + Defines: + int_vera_irq_handler = 008aa8 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 45) + +irq_handler in section 'code' placed at address 008afd-008b51 of size 000055 +(src/interrupts.o unit 0 section index 18) + Defines: + irq_handler = 008afd + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 44) + +cop_handler in section 'code' placed at address 008b52-008ba6 of size 000055 +(src/interrupts.o unit 0 section index 17) + Defines: + cop_handler = 008b52 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 43) + +brk_handler in section 'code' placed at address 008ba7-008bfb of size 000055 +(src/interrupts.o unit 0 section index 16) + Defines: + brk_handler = 008ba7 + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 42) + +nmi_handler in section 'code' placed at address 008bfc-008c50 of size 000055 +(src/interrupts.o unit 0 section index 15) + Defines: + nmi_handler = 008bfc + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + _JmpIndLong in (controlFlow.o (from clib-lc-hd-double64.a) unit 7 section index 3) + Referenced from: + (src/interrupts.o unit 0 section index 41) __program_start in section 'code' - placed at address 008800-008818 of size 000019 -(cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 2) + placed at address 008c51-008c69 of size 000019 +(cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 2) Defines: - __program_start = 008800 + __program_start = 008c51 References: _DirectPageStart _NearBaseAddress .sectionEnd(stack) - _Vfp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 7 section index 2) - __low_level_init in (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 8) + _Vfp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 8 section index 2) + __low_level_init in (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 8) Referenced from: - __program_root_section (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 7) + __program_root_section (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 7) -Section 'code' placed at address 008819-008823 of size 00000b -(cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 6) +Section 'code' placed at address 008c6a-008c74 of size 00000b +(cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 6) References: - exit in (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) - main in (src/main.o unit 0 section index 2) + exit in (exit.o (from clib-lc-hd-double64.a) unit 5 section index 5) + main in (src/main.o unit 1 section index 2) + +Section '$$interruptVector_0x00ff80' + placed at address 00ff80-00ff81 of size 000002 +(src/interrupts.o unit 0 section index 53) + References: + int_t0_handler in (src/interrupts.o unit 0 section index 27) + +Section '$$interruptVector_0x00ff82' + placed at address 00ff82-00ff83 of size 000002 +(src/interrupts.o unit 0 section index 52) + References: + int_t1_handler in (src/interrupts.o unit 0 section index 26) + +Section '$$interruptVector_0x00ff84' + placed at address 00ff84-00ff85 of size 000002 +(src/interrupts.o unit 0 section index 51) + References: + int_t2_handler in (src/interrupts.o unit 0 section index 25) + +Section '$$interruptVector_0x00ff86' + placed at address 00ff86-00ff87 of size 000002 +(src/interrupts.o unit 0 section index 50) + References: + int_t3_handler in (src/interrupts.o unit 0 section index 24) + +Section '$$interruptVector_0x00ff88' + placed at address 00ff88-00ff89 of size 000002 +(src/interrupts.o unit 0 section index 49) + References: + int_t4_handler in (src/interrupts.o unit 0 section index 23) + +Section '$$interruptVector_0x00ff8a' + placed at address 00ff8a-00ff8b of size 000002 +(src/interrupts.o unit 0 section index 48) + References: + int_t5_handler in (src/interrupts.o unit 0 section index 22) + +Section '$$interruptVector_0x00ff8c' + placed at address 00ff8c-00ff8d of size 000002 +(src/interrupts.o unit 0 section index 47) + References: + int_t6_handler in (src/interrupts.o unit 0 section index 21) + +Section '$$interruptVector_0x00ff8e' + placed at address 00ff8e-00ff8f of size 000002 +(src/interrupts.o unit 0 section index 46) + References: + int_t7_handler in (src/interrupts.o unit 0 section index 20) + +Section '$$interruptVector_0x00ff98' + placed at address 00ff98-00ff99 of size 000002 +(src/interrupts.o unit 0 section index 45) + References: + int_vera_irq_handler in (src/interrupts.o unit 0 section index 19) + +Section '$$interruptVector_0x00ff9e' + placed at address 00ff9e-00ff9f of size 000002 +(src/interrupts.o unit 0 section index 44) + References: + irq_handler in (src/interrupts.o unit 0 section index 18) + +Section '$$interruptVector_0x00ffb4' + placed at address 00ffb4-00ffb5 of size 000002 +(src/interrupts.o unit 0 section index 43) + References: + cop_handler in (src/interrupts.o unit 0 section index 17) + +Section '$$interruptVector_0x00ffb6' + placed at address 00ffb6-00ffb7 of size 000002 +(src/interrupts.o unit 0 section index 42) + References: + brk_handler in (src/interrupts.o unit 0 section index 16) + +Section '$$interruptVector_0x00ffba' + placed at address 00ffba-00ffbb of size 000002 +(src/interrupts.o unit 0 section index 41) + References: + nmi_handler in (src/interrupts.o unit 0 section index 15) __program_root_section in section 'reset' placed at address 00fffc-00fffd of size 000002 -(cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 7) +(cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 7) Defines: __program_root_section = 00fffc References: - __program_start in (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 2) + __program_start in (cstartup.o (from clib-lc-hd-double64.a) unit 4 section index 2) Section 'stack' placed at address 000200-0003ff of size 000200 (linker generated) @@ -389,6 +846,6 @@ Section 'cstack' placed at address 000400-0007ff of size 000400 # # ########################## -Executable (Text): 226 bytes -Data : 134 bytes +Executable (Text): 1526 bytes +Data : 186 bytes Non-initialized : 9748 bytes diff --git a/config/memory.scm b/config/memory.scm index da0ab80..1fab83c 100644 --- a/config/memory.scm +++ b/config/memory.scm @@ -2,6 +2,9 @@ (memory HighCode (address (#xC00000 . #xC7FFFF)) + (section farcode) + (section ifar) + (section ihuge) (type rom) ) @@ -15,7 +18,11 @@ (address (#x008800 . #x00FFFF)) (section code) (section cdata) + (section idata) + (section inear) (section switch) + (section data_init_table) + (type rom) ) (memory IOSpace diff --git a/include/config.h b/include/config.h index ae11266..9b5f162 100644 --- a/include/config.h +++ b/include/config.h @@ -5,3 +5,9 @@ //***************************************************************************** #pragma once + +#define far __far + +#define near __near + +#define interrupt_handler(X) __attribute__((interrupt((X)))) diff --git a/include/interrupts.h b/include/interrupts.h new file mode 100644 index 0000000..4a539c4 --- /dev/null +++ b/include/interrupts.h @@ -0,0 +1,35 @@ +//***************************************************************************** +// Sentinel 65X Kernel +// +// include/interrupts.h +//***************************************************************************** + +#pragma once + +#include "config.h" + +far void set_user_nmi_handler(void (*f)(void)); + +far void set_user_brk_handler(void (*f)(void)); + +far void set_user_cop_handler(void (*f)(void)); + +far void set_user_irq_handler(void (*f)(void)); + +far void set_user_vera_irq_handler(void (*f)(void)); + +far void set_user_t7_handler(void (*f)(void)); + +far void set_user_t6_handler(void (*f)(void)); + +far void set_user_t5_handler(void (*f)(void)); + +far void set_user_t4_handler(void (*f)(void)); + +far void set_user_t3_handler(void (*f)(void)); + +far void set_user_t2_handler(void (*f)(void)); + +far void set_user_t1_handler(void (*f)(void)); + +far void set_user_t0_handler(void (*f)(void)); diff --git a/src/interrupts.c b/src/interrupts.c new file mode 100644 index 0000000..219cffb --- /dev/null +++ b/src/interrupts.c @@ -0,0 +1,217 @@ +//***************************************************************************** +// Sentinel 65X Kernel +// +// src/interrupts.c +//***************************************************************************** + +#include + +#include "config.h" + +static void (*user_nmi_handler)(void) = NULL; + +static void (*user_brk_handler)(void) = NULL; + +static void (*user_cop_handler)(void) = NULL; + +static void (*user_irq_handler)(void) = NULL; + +static void (*user_vera_irq_handler)(void) = NULL; + +static void (*user_t7_handler)(void) = NULL; + +static void (*user_t6_handler)(void) = NULL; + +static void (*user_t5_handler)(void) = NULL; + +static void (*user_t4_handler)(void) = NULL; + +static void (*user_t3_handler)(void) = NULL; + +static void (*user_t2_handler)(void) = NULL; + +static void (*user_t1_handler)(void) = NULL; + +static void (*user_t0_handler)(void) = NULL; + +far void +set_user_nmi_handler(void (*f)(void)) +{ + user_nmi_handler = f; +} + +far void +set_user_brk_handler(void (*f)(void)) +{ + user_brk_handler = f; +} + +far void +set_user_cop_handler(void (*f)(void)) +{ + user_cop_handler = f; +} + +far void +set_user_irq_handler(void (*f)(void)) +{ + user_irq_handler = f; +} + +far void +set_user_vera_irq_handler(void (*f)(void)) +{ + user_vera_irq_handler = f; +} + +far void +set_user_t7_handler(void (*f)(void)) +{ + user_t7_handler = f; +} + +far void +set_user_t6_handler(void (*f)(void)) +{ + user_t6_handler = f; +} + +far void +set_user_t5_handler(void (*f)(void)) +{ + user_t5_handler = f; +} + +far void +set_user_t4_handler(void (*f)(void)) +{ + user_t4_handler = f; +} + +far void +set_user_t3_handler(void (*f)(void)) +{ + user_t3_handler = f; +} + +far void +set_user_t2_handler(void (*f)(void)) +{ + user_t2_handler = f; +} + +far void +set_user_t1_handler(void (*f)(void)) +{ + user_t1_handler = f; +} + +far void +set_user_t0_handler(void (*f)(void)) +{ + user_t0_handler = f; +} + +interrupt_handler(0x00FFBA) void +nmi_handler(void) +{ + if (user_nmi_handler != NULL) { + user_nmi_handler(); + } +} + +interrupt_handler(0x00FFB6) void +brk_handler(void) +{ + if (user_brk_handler != NULL) { + user_brk_handler(); + } +} + +interrupt_handler(0x00FFB4) void +cop_handler(void) +{ + if (user_cop_handler != NULL) { + user_cop_handler(); + } +} + +interrupt_handler(0x00FF9E) void +irq_handler(void) +{ + if (user_irq_handler != NULL) { + user_irq_handler(); + } +} + +interrupt_handler(0x00FF98) void +int_vera_irq_handler(void) +{ + if (user_vera_irq_handler != NULL) { + user_vera_irq_handler(); + } +} + +interrupt_handler(0x00FF8E) void +int_t7_handler(void) +{ + if (user_t7_handler != NULL) { + user_t7_handler(); + } +} + +interrupt_handler(0x00FF8C) void +int_t6_handler(void) +{ + if (user_t6_handler != NULL) { + user_t6_handler(); + } +} + +interrupt_handler(0x00FF8A) void +int_t5_handler(void) +{ + if (user_t5_handler != NULL) { + user_t5_handler(); + } +} + +interrupt_handler(0x00FF88) void +int_t4_handler(void) +{ + if (user_t4_handler != NULL) { + user_t4_handler(); + } +} + +interrupt_handler(0x00FF86) void +int_t3_handler(void) +{ + if (user_t3_handler != NULL) { + user_t3_handler(); + } +} + +interrupt_handler(0x00FF84) void +int_t2_handler(void) +{ + if (user_t2_handler != NULL) { + user_t2_handler(); + } +} + +interrupt_handler(0x00FF82) void +int_t1_handler(void) +{ + if (user_t1_handler != NULL) { + user_t1_handler(); + } +} + +interrupt_handler(0x00FF80) void +int_t0_handler(void) +{ + if (user_t0_handler != NULL) { + user_t0_handler(); + } +} diff --git a/src/stubs.c b/src/stubs.c index f0a59c6..b162bb1 100644 --- a/src/stubs.c +++ b/src/stubs.c @@ -9,7 +9,9 @@ #include #include -int +#include "config.h" + +far int _Stub_open(const char *path, int oflag, ...) { (void) path; @@ -17,14 +19,14 @@ _Stub_open(const char *path, int oflag, ...) return -1; } -int +far int _Stub_close(int fd) { (void) fd; return -1; } -int +far int _Stub_access(const char *path, int mode) { (void) path; @@ -32,7 +34,7 @@ _Stub_access(const char *path, int mode) return -1; } -long +far long _Stub_lseek(int fd, long offset, int whence) { (void) fd; @@ -41,7 +43,7 @@ _Stub_lseek(int fd, long offset, int whence) return -1; } -int +far int _Stub_fgetpos(int fd, fpos_t *pos) { (void) fd; @@ -49,7 +51,7 @@ _Stub_fgetpos(int fd, fpos_t *pos) return -1; } -int +far int _Stub_fsetpos(int fd, const fpos_t *pos) { (void) fd; @@ -57,7 +59,7 @@ _Stub_fsetpos(int fd, const fpos_t *pos) return -1; } -size_t +far size_t _Stub_read(int fd, void *buf, size_t count) { (void) fd; @@ -66,7 +68,7 @@ _Stub_read(int fd, void *buf, size_t count) return 0; } -size_t +far size_t _Stub_write(int fd, const void *buf, size_t count) { (void) fd; @@ -75,7 +77,7 @@ _Stub_write(int fd, const void *buf, size_t count) return 0; } -int +far int _Stub_rename(const char *oldpath, const char *newpath) { (void) oldpath; @@ -83,27 +85,27 @@ _Stub_rename(const char *oldpath, const char *newpath) return -1; } -int +far int _Stub_remove(const char *path) { (void) path; return -1; } -void +far void _Stub_exit(int exitCode) { (void) exitCode; return; } -char** +far char** _Stub_environ(void) { return NULL; } -void +far void _Stub_assert(const char *filename, int linenum) { (void) filename;