From 44a3be8be2c142d695ea61cfac7a55aa7a923f47 Mon Sep 17 00:00:00 2001 From: Kyle Cardoza Date: Wed, 27 Mar 2024 20:41:56 -0400 Subject: [PATCH] Added initial (empty) implementations for Calypsi C library stub functions. --- build.lst | 394 +++++++++++++++++++++++++++++++++++++++++++ config/sdk-config.mk | 2 - src/stubs.c | 112 ++++++++++++ 3 files changed, 506 insertions(+), 2 deletions(-) create mode 100644 build.lst create mode 100644 src/stubs.c diff --git a/build.lst b/build.lst new file mode 100644 index 0000000..fe625c4 --- /dev/null +++ b/build.lst @@ -0,0 +1,394 @@ +############################################################################### +# # +# Calypsi linker for 65816 version 5.1 # +# 27/Mar/2024 20:41:26 # +# 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 # +# # +############################################################################### + +#################### +# # +# Memories summary # +# # +#################### + +Name Range Size Used Checksum Largest unallocated +--------------------------------------------------------------------------------------- +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 +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-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-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 +HighCode-c4 c40000-c4ffff 010000 0.0% none 010000 +HighCode-c5 c50000-c5ffff 010000 0.0% none 010000 +HighCode-c6 c60000-c6ffff 010000 0.0% none 010000 +HighCode-c7 c70000-c7ffff 010000 0.0% none 010000 + + +#################### +# # +# Sections summary # +# # +#################### + +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 + + +################### +# # +# Placement rules # +# # +################### + +Name Address range Key +---------------------------------------------------------------------- +DirectPage 000000-0000ff Plain + > (registers 000004) + > ztiny +HighCode-c0 c00000-c0ffff Far + HighCode-c0-farcode c00000-c0ffff FarFunction and TEXT + > farcode +HighCode-c1 c10000-c1ffff Far + HighCode-c1-farcode c10000-c1ffff FarFunction and TEXT + > farcode +HighCode-c2 c20000-c2ffff Far + HighCode-c2-farcode c20000-c2ffff FarFunction and TEXT + > farcode +HighCode-c3 c30000-c3ffff Far + HighCode-c3-farcode c30000-c3ffff FarFunction and TEXT + > farcode +HighCode-c4 c40000-c4ffff Far + HighCode-c4-farcode c40000-c4ffff FarFunction and TEXT + > farcode +HighCode-c5 c50000-c5ffff Far + HighCode-c5-farcode c50000-c5ffff FarFunction and TEXT + > farcode +HighCode-c6 c60000-c6ffff Far + HighCode-c6-farcode c60000-c6ffff FarFunction and TEXT + > farcode +HighCode-c7 c70000-c7ffff Far + HighCode-c7-farcode c70000-c7ffff FarFunction and TEXT + > farcode +HighData-01 010000-01ffff Far + > heap + HighData-01-huge-nobits 010000-01ffff Huge and BSS + > zhuge +HighData-02 020000-02ffff Far + > heap + HighData-02-huge-nobits 020000-02ffff Huge and BSS + > zhuge +HighData-03 030000-03ffff Far + > heap + HighData-03-huge-nobits 030000-03ffff Huge and BSS + > zhuge +HighData-04 040000-04ffff Far + > heap + HighData-04-huge-nobits 040000-04ffff Huge and BSS + > zhuge +HighData-05 050000-05ffff Far + > heap + HighData-05-huge-nobits 050000-05ffff Huge and BSS + > zhuge +HighData-06 060000-06ffff Far + > heap + HighData-06-huge-nobits 060000-06ffff Huge and BSS + > zhuge +HighData-07 070000-07ffff Far + > heap + HighData-07-huge-nobits 070000-07ffff Huge and BSS + > zhuge +IOSpace 00df00-00dfff Plain + > (VERAIOPort 00df00) +LowCode-vector 00ffe4-00ffff Plain + > (reset 00fffc) + > code + > cdata + > switch +LowCode 008800-00ffe3 Plain + > code + > cdata + > switch +LowData 001000-007fff Plain + > near + > data + > znear + > zdata +stack 000200-000fff Plain + > (stack 000200) + > (cstack 000400) + +Name Size Align +-------------------- +cstack 000400 no +stack 000200 no +heap 002000 no + +Name Memory Offset +----------------------------------- +_DirectPageStart DirectPage 000000 +_NearBaseAddress LowData 000000 + +################ +# # +# Object files # +# # +################ + +Unit Filename Archive +-------------------------------------------- + 0 src/main.o - + > farcode 000002 + 1 src/stubs.o - + > farcode 000034 + 3 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 + # picked based on exit=stdexit (built-in default) + > farcode 000072 + > zhuge 000086 + 6 controlFlow.o clib-lc-hd-double64.a + > farcode 00000e + 7 pseudoRegisters.o clib-lc-hd-double64.a + > registers 000014 + 8 exitC99.o clib-lc-hd-double64.a + > farcode 000005 + +################### +# # +# Cross reference # +# # +################### + +_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) + 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) + +_Stub_exit in section 'farcode' placed at address c00000-c00000 of size 000001 +(src/stubs.o unit 1 section index 12) + 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 + References: + _Stub_exit in (src/stubs.o unit 1 section index 12) + 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 + +_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) + Defines: + _JmpIndLong = c0003c + References: + _Dp in (pseudoRegisters.o (from clib-lc-hd-double64.a) unit 7 section index 2) + Referenced from: + exit (exit.o (from clib-lc-hd-double64.a) unit 4 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) + Defines: + exit = c0004a + 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) + +Section 'heap' placed at address 010086-012085 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) + Defines: + __atexit_index = 010000 + Referenced from: + exit (exit.o (from clib-lc-hd-double64.a) unit 4 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) + Defines: + __atexit = 010002 + Referenced from: + exit (exit.o (from clib-lc-hd-double64.a) unit 4 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) + Defines: + _ExitCloseStreams = 010082 + Referenced from: + exit (exit.o (from clib-lc-hd-double64.a) unit 4 section index 5) + +__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) + Defines: + __program_start = 008800 + 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) + Referenced from: + __program_root_section (cstartup.o (from clib-lc-hd-double64.a) unit 3 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) + 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) + +__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) + Defines: + __program_root_section = 00fffc + References: + __program_start in (cstartup.o (from clib-lc-hd-double64.a) unit 3 section index 2) + +Section 'stack' placed at address 000200-0003ff of size 000200 +(linker generated) + +Section 'cstack' placed at address 000400-0007ff of size 000400 +(linker generated) + +########################## +# # +# Memory sizes (decimal) # +# # +########################## + +Executable (Text): 226 bytes +Data : 134 bytes +Non-initialized : 9748 bytes diff --git a/config/sdk-config.mk b/config/sdk-config.mk index a1d4b98..e591962 100644 --- a/config/sdk-config.mk +++ b/config/sdk-config.mk @@ -42,12 +42,10 @@ ASFLAGS += --debug endif LDFLAGS := $(MEMORY_MAP) \ - --hosted \ --no-data-init-table-section \ --rtattr cstartup=turaco \ --list-file build.lst \ --verbose \ - --no-auto-libraries \ --output-format pgz ifeq ($(ENABLE_RELEASE_BUILD), "true") diff --git a/src/stubs.c b/src/stubs.c new file mode 100644 index 0000000..f0a59c6 --- /dev/null +++ b/src/stubs.c @@ -0,0 +1,112 @@ +//***************************************************************************** +// Sentinel 65X Kernel +// +// src/stubs.c +//***************************************************************************** + +// Stub functions which the C library needs in order to function. + +#include +#include + +int +_Stub_open(const char *path, int oflag, ...) +{ + (void) path; + (void) oflag; + return -1; +} + +int +_Stub_close(int fd) +{ + (void) fd; + return -1; +} + +int +_Stub_access(const char *path, int mode) +{ + (void) path; + (void) mode; + return -1; +} + +long +_Stub_lseek(int fd, long offset, int whence) +{ + (void) fd; + (void) offset; + (void) whence; + return -1; +} + +int +_Stub_fgetpos(int fd, fpos_t *pos) +{ + (void) fd; + (void) pos; + return -1; +} + +int +_Stub_fsetpos(int fd, const fpos_t *pos) +{ + (void) fd; + (void) pos; + return -1; +} + +size_t +_Stub_read(int fd, void *buf, size_t count) +{ + (void) fd; + (void) buf; + (void) count; + return 0; +} + +size_t +_Stub_write(int fd, const void *buf, size_t count) +{ + (void) fd; + (void) buf; + (void) count; + return 0; +} + +int +_Stub_rename(const char *oldpath, const char *newpath) +{ + (void) oldpath; + (void) newpath; + return -1; +} + +int +_Stub_remove(const char *path) +{ + (void) path; + return -1; +} + +void +_Stub_exit(int exitCode) +{ + (void) exitCode; + return; +} + +char** +_Stub_environ(void) +{ + return NULL; +} + +void +_Stub_assert(const char *filename, int linenum) +{ + (void) filename; + (void) linenum; + return; +}