From 311771892b63be31d211fc527cb746a094c331e8 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 18 Feb 2018 14:15:03 +0000 Subject: [PATCH] pdp11: Add another missing piece and turn on library building --- Library/libs/Makefile.pdp11 | 156 ++++++++++++++++++++++++++++++++++++ Library/libs/divsi3_pdp11.S | 25 ++++++ 2 files changed, 181 insertions(+) create mode 100644 Library/libs/Makefile.pdp11 create mode 100644 Library/libs/divsi3_pdp11.S diff --git a/Library/libs/Makefile.pdp11 b/Library/libs/Makefile.pdp11 new file mode 100644 index 00000000..c12f008c --- /dev/null +++ b/Library/libs/Makefile.pdp11 @@ -0,0 +1,156 @@ +CC = pdp11-aout-gcc +ASM = pdp11-aout-as +AR = pdp11-aout-ar +PLATFORM = pdp11 +export PLATFORM +CC_OPT = -c -Os -I../include -I../include/pdp11 +# for stuff that gives gcc nightmares +CC_NOOPT = $(CC_OPT) +ASM_OPT = -o +# copied in from kernel tree +KRN_HEADERS = userstructs.h drivewire.h +KRN_HEADERS_SRC = $(addprefix ../../Kernel/include/,$(KRN_HEADERS)) +KRN_HEADERS_COPY = $(addprefix ../include/sys/,$(KRN_HEADERS)) +SRC_CRT0 = crt0_$(PLATFORM).s crt0nostdio_$(PLATFORM).s +OBJ_CRT0 = $(SRC_CRT0:.s=.o) +SRC_ASM = setjmp_pdp11.S udivhi3_pdp11.S divsi3_pdp11.S +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 += closedir_r.c clock_gettime.c clock_getres.c clock_settime.c +SRC_C += creat.c crypt.c ctermid.c ctime.c cuserid.c +SRC_C += difftime.c err.c errno.c error.c +SRC_C += execl.c execv.c execvp.c exit.c +SRC_C += fclose.c fdatasync.c fflush.c fgetc.c fgetgrent.c fgetpwent.c +SRC_C += fgetpos.c fgets.c fopen.c fork.c fprintf.c fputc.c fputs.c fread.c +SRC_C += free.c fsetpos.c fsync.c ftell.c fwrite.c getcwd.c +SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getlogin.c +SRC_C += getopt.c +SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c +SRC_C += getw.c gmtime.c gmtime_r.c grent.c +SRC_C += inet_addr.c inet_aton.c inet_network.c inet_ntoa.c inet_ntop.c inet_pton.c +SRC_C += index.c initgroups.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 mntent.o nanosleep.c +SRC_C += opendir.c opendir_r.c pause.c perror.c +SRC_C += popen.c printf.c putenv.c putchar.c putpwent.c putw.c pwent.c qsort.c +SRC_C += raise.c rand.c readdir.c readlink.c realloc.c regerror.c +SRC_C += regsub.c remount.c remove.c rewind.c rewinddir.c rindex.c +SRC_C += seekdir.c setbuffer.c setenv.c +SRC_C += setlocale.c setvbuf.c settimeofday.c sgetl.c sleep.c sprintf.c +SRC_C += sputl.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 strsignal.c +SRC_C += strtod.c strtol.c swab.c system.c telldir.c time.c tmpfile.c tmpnam.c ttyname.c +SRC_C += tzset.c umount.c ungetc.c usleep.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 +# 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 memmove.c + +SRC_CT += termcap.c tgetent.c + +SRC_CURS = $(shell find curses -name '*.c') + +SRC_LM = vfscanf.c vfprintf.c +OBJ_LM = vfscanf-libm.o vfprintf-libm.o + +OBJ_C = $(SRC_C:.c=.o) +OBJ_CURS = $(SRC_CURS:.c=.o) +OBJ_CT = $(SRC_CT:.c=.o) +OBJ_HARD = $(SRC_HARD:.c=.o) +OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) + +all: syslib$(PLATFORM).lib liberror.txt $(OBJ_CRT0) curses$(PLATFORM).lib termcap$(PLATFORM).lib m$(PLATFORM).lib + +$(OBJ_ALL): $(KRN_HEADERS_COPY) + +$(KRN_HEADERS_COPY): $(KRN_HEADERS_SRC) + cp ../../Kernel/include/$(notdir $@) $@ + +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) rc syslib$(PLATFORM).lib $$(cat syslib.l) + ln -sf syslib$(PLATFORM).lib libc$(PLATFORM).a + +fuzix$(PLATFORM)/syslib.l: ../tools/syscall_$(PLATFORM) + $< + make -C fuzix$(PLATFORM) + +../tools/syscall_$(PLATFORM): ../tools/syscall_$(PLATFORM).c + make -C .. tools/syscall_$(PLATFORM) + +liberror.txt: ../tools/liberror + $< -X > $@ + +../tools/liberror: ../tools/liberror.c + make -C .. tools/liberror + +curses$(PLATFORM).lib: $(OBJ_CURS) + $(AR) rc curses$(PLATFORM).lib $(OBJ_CURS) + ln -sf curses$(PLATFORM).lib libcurses$(PLATFORM).a + +termcap$(PLATFORM).lib: $(OBJ_CT) + $(AR) rc termcap$(PLATFORM).lib $(OBJ_CT) + ln -sf termcap$(PLATFORM).lib libtermcap$(PLATFORM).a + +m$(PLATFORM).lib: $(OBJ_LM) + $(AR) rc m$(PLATFORM).lib $(OBJ_LM) + ln -sf m$(PLATFORM).lib libm$(PLATFORM).a + +$(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_CT):%.o: %.c + $(CC) $(CC_OPT) $(@:.o=.c) + +$(OBJ_CURS):%.o: %.c + $(CC) $(CC_OPT) $(@:.o=.c) -o $@ + +vfscanf-libm.o: vfscanf.c + $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@ + +vfprintf-libm.o: vfprintf.c + $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@ + +$(OBJ_HARD):%.o: %.c + $(CC) $(CC_NOOPT) $(@:.o=.c) + +clean: + rm -rf *.o *.asm *.sym *.lst *.lib *~ syscall.l libc.l syslib.l \ + libc$(PLATFORM).a liberror.txt + -cd fuzix$(PLATFORM) && make clean + rm -rf fuzix$(PLATFORM)/Makefile + rm -f $(KRN_HEADERS_COPY) + -cd curses && rm -rf *.o *.asm *.sym *.lst *~ + +install: ; diff --git a/Library/libs/divsi3_pdp11.S b/Library/libs/divsi3_pdp11.S new file mode 100644 index 00000000..ce54d766 --- /dev/null +++ b/Library/libs/divsi3_pdp11.S @@ -0,0 +1,25 @@ + .text + .even + + .globl ___divsi3 + .globl ___modsi3 + + +___divsi3: + mov r2,-(sp) + mov 4(sp),r1 + mov 6(sp),r2 + clr r0 + div r0,r2 + mov (sp)+,r2 + rts pc + +___modsi3: + mov r2,-(sp) + mov 4(sp),r1 + mov 6(sp),r2 + clr r0 + div r0,r2 + mov (sp)+,r2 + mov r1,r0 + rts pc -- 2.34.1