From: Tormod Volden Date: Sun, 12 Apr 2015 21:31:41 +0000 (+0200) Subject: Library: Build 6809 C library X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=56b1b1c948b3ab1f528c94c01627600ba9a4d1a1;p=FUZIX.git Library: Build 6809 C library The crt0_6809.s still needs some filling in. Signed-off-by: Tormod Volden --- diff --git a/Library/Makefile b/Library/Makefile index 4e45b6ca..49cbf251 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -6,6 +6,7 @@ all: tools/syscall tools/binman tools/fcc clean: rm -f tools/syscall tools/binman tools/fcc + rm -f tools/syscall-z88dk tools/syscall_6502 tools/syscall_6809 tools/syscall: tools/syscall.c ../Kernel/include/syscall_name.h tools/syscall-z88dk: tools/syscall-z88dk.c ../Kernel/include/syscall_name.h diff --git a/Library/libs/Makefile.6809 b/Library/libs/Makefile.6809 new file mode 100644 index 00000000..7346b2ab --- /dev/null +++ b/Library/libs/Makefile.6809 @@ -0,0 +1,98 @@ +CC = m6809-unknown-gcc +ASM = m6809-unknown-as +AR = m6809-unknown-ar +LINKER = m6809-unknown-ld +PLATFORM = 6809 +export PLATFORM +CC_OPT = -c -Os -I../include -I../include/6502 +# for stuff that gives sdcc nightmares +CC_NOOPT = $(CC_OPT) +ASM_OPT = -o +LINKER_OPT = +SRC_CRT0 = crt0_$(PLATFORM).s +OBJ_CRT0 = $(SRC_CRT0:.s=.o) +SRC_ASM = +OBJ_ASM = $(SRC_ASM:.s=.o) +SRC_C = __argv.c abort.c asctime.c assert.c atexit.c +SRC_C += bcmp.c bcopy.c bsearch.c bzero.c calloc.c cfree.c clock.c closedir.c +SRC_C += clock_gettime.c clock_getres.c clock_settime.c +SRC_C += creat.c crypt.c ctime.c difftime.c err.c errno.c error.c +SRC_C += execl.c execv.c execvp.c exit.c +SRC_C += fclose.c fflush.c fgetc.c fgetgrent.c fgetpwent.c +SRC_C += fgetpos.c fgets.c fopen.c fprintf.c fputc.c fputs.c fread.c free.c +SRC_C += fsetpos.c ftell.c fwrite.c getcwd.c +SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getopt.c +SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c +SRC_C += gmtime.c gmtime_r.c grent.c index.c isatty.c killpg.c +SRC_C += libintl.c +SRC_C += localtim.c localtim_r.c lseek.c lsearch.c lstat.c ltoa.c ltostr.c +SRC_C += malloc.c mkfifo.c mkstemps.c nanosleep.c opendir.c pause.c perror.c +SRC_C += popen.c printf.c putenv.c putgetch.c putpwent.c pwent.c qsort.c +SRC_C += raise.c rand.c readdir.c readlink.c realloc.c regerror.c +SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c +SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c +SRC_C += stat.c stdio0.c stime.c +SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c +SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c +SRC_C += strtod.c strtol.c system.c time.c tmpfile.c tmpnam.c ttyname.c +SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c +SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c +SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c +# ctype +SRC_C += isalnum.c isalpha.c isascii.c isblank.c iscntrl.c isdigit.c +SRC_C += isgraph.c islower.c isprint.c ispunct.c isspace.c isupper.c +SRC_C += isxdigit.c toupper.c tolower.c +# tty layer +SRC_C += tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c +SRC_C += cfmakeraw.c cfspeed.c revoke.c +# scanf +SRC_C += fscanf.c scanf.c sscanf.c vfscanf.c vscanf.c vsscanf.c +# Seems to give the compiler a hard time +SRC_HARD += regexp.c +# Not supported yet +#SRC_C += initgroups.c +# Pieces we inherit in this case from the compiler library instead +#SRC_C += strcpy.c strlen.c abs.c atof.c atoi.c atol.c labs.c +#SRC_C += strcat.c strchr.c strcmp.c strcspn.c strncat.c strncmp.c +#SRC_C += strncpy.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c +#SRC_C += memchr.c memcmp.c memcpy.c memset.c + +OBJ_C = $(SRC_C:.c=.o) +OBJ_HARD = $(SRC_HARD:.c=.o) +OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) + +all: syslib$(PLATFORM).lib $(OBJ_CRT0) + +libc.l:%.l:$(OBJ_ALL) + ls $(OBJ_ALL) > libc.l + +syscall.l: fuzix$(PLATFORM)/syslib.l + ../tools/syscall_$(PLATFORM) + (cd fuzix$(PLATFORM); make) + cat fuzix$(PLATFORM)/syslib.l | tr " " "\\n" | sed -e "s/^/fuzix$(PLATFORM)\//" >syscall.l + +syslib$(PLATFORM).lib: syscall.l libc.l + cat libc.l syscall.l >syslib.l + $(AR) -c -m syslib$(PLATFORM).lib syslib.l + ln -sf syslib$(PLATFORM).lib c$(PLATFORM).lib + +fuzix$(PLATFORM)/syslib.l: + ../tools/syscall_$(PLATFORM) + make -C fuzix$(PLATFORM) + +$(OBJ_ASM):%.o: %.s + $(ASM) $(ASM_OPT) $@ $(@:.o=.s) + +$(OBJ_CRT0):%.o: %.s + $(ASM) $(ASM_OPT) $@ $(@:.o=.s) + +$(OBJ_C):%.o: %.c + $(CC) $(CC_OPT) $(@:.o=.c) + +$(OBJ_HARD):%.o: %.c + $(CC) $(CC_NOOPT) $(@:.o=.c) + +clean: + rm -rf *.o *.asm *.sym *.lst *.lib *~ syscall.l libc.l syslib.l + (cd fuzix$(PLATFORM); make clean) + rm -rf fuzix$(PLATFORM)/Makefile diff --git a/Library/libs/crt0_6809.s b/Library/libs/crt0_6809.s new file mode 100644 index 00000000..c71eea59 --- /dev/null +++ b/Library/libs/crt0_6809.s @@ -0,0 +1,35 @@ + .module crt0 + + .globl _main + .globl _exit + .globl _environ + .globl ___argv + + .area .text + +start: jmp start2 + .db 'F' + .db 'Z' + .db 'X' + .db '1' + +; +; FIXME: we need to automate the load page setting +; + .db 0x01 ; page to load at + .dw 0 ; chmem ("0 - 'all'") + .dw __sectionlen_.text ; gives us code size info + .dw __sectionlen_.data ; gives us data size info + .dw __sectionlen_.bss ; bss size info + .dw 0 ; spare + +start2: + ; FIXME clear BSS + + ; FIXME get environ, argc and argv + + ldx #_exit ; return vector + pshs x + jmp _main ; go + +_environ: .dw 0 diff --git a/Library/libs/fuzix6809/syscall.s b/Library/libs/fuzix6809/syscall6809.s similarity index 100% rename from Library/libs/fuzix6809/syscall.s rename to Library/libs/fuzix6809/syscall6809.s