diff --git a/sys/kernel/sys_generic.c b/sys/kernel/sys_generic.c index 6f88f2e..197aa49 100644 --- a/sys/kernel/sys_generic.c +++ b/sys/kernel/sys_generic.c @@ -228,7 +228,7 @@ selscan(ibits, obits, nfd, retval) fd_set *ibits, *obits; int nfd, *retval; { - register int i, j, flag; + register int i, j, flag = 0; fd_mask bits; struct file *fp; int which, n = 0; diff --git a/sys/pic32/Makefile.kconf b/sys/pic32/Makefile.kconf index 5ccb5c5..0a0a188 100644 --- a/sys/pic32/Makefile.kconf +++ b/sys/pic32/Makefile.kconf @@ -3,49 +3,23 @@ # # DEBUG is set to -g by kconfig if debugging is requested (kconfig -g). # PROF is set to -pg by kconfig if profiling is requested (kconfig -p). - -ifndef MIPS_GCC_ROOT - ifeq (/usr/local/mips-2014.05,$(wildcard /usr/local/mips-2014.05)) - MIPS_GCC_ROOT = /usr/local/mips-2014.05 - endif - ifeq (/usr/local/mips-gcc-4.8.1,$(wildcard /usr/local/mips-gcc-4.8.1)) - MIPS_GCC_ROOT = /usr/local/mips-gcc-4.8.1 - endif - ifeq (/usr/local/pic32-tools,$(wildcard /usr/local/pic32-tools)) - MIPS_GCC_ROOT = /usr/local/pic32-tools - endif - ifdef UECIDE - MIPS_GCC_ROOT = ${UECIDE}/compilers/pic32-tools - endif -endif - -ifeq (${MIPS_GCC_ROOT}/bin/mips-sde-elf-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/mips-sde-elf-gcc)) - MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/mips-sde-elf- -endif -ifeq (${MIPS_GCC_ROOT}/bin/mips-elf-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/mips-elf-gcc)) - MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/mips-elf- -endif -ifeq (${MIPS_GCC_ROOT}/bin/pic32-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/pic32-gcc)) - MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/pic32- -endif +# +include ../gcc-config.mk AS = ${MIPS_GCC_PREFIX}as ${DEBUG} -mips32r2 -EL CC = ${MIPS_GCC_PREFIX}gcc ${DEBUG} -mips32r2 -EL -nostdinc -fno-builtin -Werror -Wall CPP = ${MIPS_GCC_PREFIX}cpp LD = ${MIPS_GCC_PREFIX}gcc -mips32r2 -EL -LDFLAGS = -nostdlib -T $S/pic32/${LDSCRIPT} -Wl,-Map=unix.map +LDFLAGS = -nostdlib -T ../${LDSCRIPT} -Wl,-Map=unix.map SIZE = ${MIPS_GCC_PREFIX}size OBJCOPY = ${MIPS_GCC_PREFIX}objcopy OBJDUMP = ${MIPS_GCC_PREFIX}objdump -ifeq (${MIPS_GCC_ROOT}/bin/mips-elf-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/mips-elf-gcc)) - LDFLAGS += -Wl,--oformat=elf32-littlemips -endif -ifeq (${MIPS_GCC_ROOT}/bin/pic32-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/pic32-gcc)) - LDFLAGS += -Wl,--oformat=elf32-tradlittlemips +ifneq (${MIPS_GCC_FORMAT},) + LDFLAGS += -Wl,--oformat=${MIPS_GCC_FORMAT} endif -# source tree is located via $S relative to the compilation directory +# sources are located via $S relative to the compilation directory S = ../.. COPTS = -I. ${IDENT} -DKERNEL @@ -81,7 +55,7 @@ ifeq (devcfg.c,$(wildcard devcfg.c)) SYSTEM_OBJ += devcfg.o endif SYSTEM_DEP = Makefile ioconf.c swapunix.c machine sys ${SYSTEM_OBJ} -SYSTEM_LD_HEAD = sh $S/pic32/newvers.sh > vers.c; ${CC} $(CFLAGS) -c vers.c; rm -f $@ +SYSTEM_LD_HEAD = sh ../newvers.sh > vers.c; ${CC} $(CFLAGS) -c vers.c; rm -f $@ SYSTEM_LD = -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -o unix.elf; \ ${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -o unix.elf SYSTEM_LD_TAIL = ${SIZE} unix.elf; \ @@ -104,7 +78,7 @@ reconfig ioconf.c swapunix.c: Config ../../../tools/kconfig/kconfig load: unix.elf pic32prog unix.hex -startup.o: $S/pic32/startup.S +startup.o: ../startup.S ${NORMAL_S} # the following are necessary because the files depend on the types of @@ -112,10 +86,10 @@ startup.o: $S/pic32/startup.S clock.o machdep.o conf.o: Makefile machine: - ln -s $S/pic32 $@ + ln -s .. $@ sys: - ln -s $S/include $@ + ln -s ../../include $@ depend: machine mkdep ${COPTS} ${CFILES} ioconf.c diff --git a/sys/pic32/cfg/bare.ld b/sys/pic32/cfg/bare.ld index adc7434..69bab8d 100644 --- a/sys/pic32/cfg/bare.ld +++ b/sys/pic32/cfg/bare.ld @@ -82,6 +82,9 @@ SECTIONS *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) + __abiflags = . ; + *(.MIPS.abiflags) + *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; diff --git a/sys/pic32/cfg/bootloader-max32.ld b/sys/pic32/cfg/bootloader-max32.ld index 54bc462..a5ce399 100644 --- a/sys/pic32/cfg/bootloader-max32.ld +++ b/sys/pic32/cfg/bootloader-max32.ld @@ -42,6 +42,8 @@ SECTIONS *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) + __abiflags = . ; + *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); diff --git a/sys/pic32/cfg/bootloader-maxcolor.ld b/sys/pic32/cfg/bootloader-maxcolor.ld index 84af529..62f0934 100644 --- a/sys/pic32/cfg/bootloader-maxcolor.ld +++ b/sys/pic32/cfg/bootloader-maxcolor.ld @@ -42,6 +42,8 @@ SECTIONS *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) + __abiflags = . ; + *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); diff --git a/sys/pic32/cfg/bootloader-sdram.ld b/sys/pic32/cfg/bootloader-sdram.ld index ba65550..c4f29e7 100644 --- a/sys/pic32/cfg/bootloader-sdram.ld +++ b/sys/pic32/cfg/bootloader-sdram.ld @@ -46,6 +46,8 @@ SECTIONS *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) + __abiflags = . ; + *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); diff --git a/sys/pic32/cfg/bootloader-ubw32.ld b/sys/pic32/cfg/bootloader-ubw32.ld index ac39fe0..5b856fe 100644 --- a/sys/pic32/cfg/bootloader-ubw32.ld +++ b/sys/pic32/cfg/bootloader-ubw32.ld @@ -42,6 +42,8 @@ SECTIONS *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) + __abiflags = . ; + *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); diff --git a/sys/pic32/gcc-config.mk b/sys/pic32/gcc-config.mk index 30c202d..f52eff6 100644 --- a/sys/pic32/gcc-config.mk +++ b/sys/pic32/gcc-config.mk @@ -1,9 +1,11 @@ # chipKIT PIC32 compiler from UECIDE -ifdef UECIDE -ifndef GCCPREFIX - GCCPREFIX = ${UECIDE}/compilers/pic32-tools/bin/pic32- - LDFLAGS = -Wl,--oformat=elf32-tradlittlemips -endif +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Use UECIDE package from http://uecide.org/download +ifndef MIPS_GCC_PREFIX + ifdef UECIDE + MIPS_GCC_PREFIX = $(UECIDE)/compilers/pic32-tools/bin/pic32- + MIPS_GCC_FORMAT = elf32-tradlittlemips + endif endif # chipKIT PIC32 compiler on Linux @@ -14,62 +16,53 @@ endif # to pic32-tools/lib/gcc/pic32mx/4.5.1/include. # MPLABX C32 compiler doesn't support some functionality # we need, so use chipKIT compiler by default. -ifndef GCCPREFIX -ifeq (/usr/local/pic32-tools/bin/pic32-gcc,$(wildcard /usr/local/pic32-tools/bin/pic32-gcc)) - GCCPREFIX = /usr/local/pic32-tools/bin/pic32- - LDFLAGS = -Wl,--oformat=elf32-tradlittlemips -endif +ifndef MIPS_GCC_PREFIX + ifeq (/usr/local/pic32-tools/bin/pic32-gcc,$(wildcard /usr/local/pic32-tools/bin/pic32-gcc)) + MIPS_GCC_PREFIX = /usr/local/pic32-tools/bin/pic32- + MIPS_GCC_FORMAT = elf32-tradlittlemips + endif endif # Generic MIPS toolchain # ~~~~~~~~~~~~~~~~~~~~~~ # You can build it from sources, as described on page # http://retrobsd.org/wiki/doku.php/doc/toolchain-mips -ifndef GCCPREFIX -ifeq (/usr/local/mips-gcc-4.8.1/bin/mips-elf-gcc,$(wildcard /usr/local/mips-gcc-4.8.1/bin/mips-elf-gcc)) - GCCPREFIX = /usr/local/mips-gcc-4.8.1/bin/mips-elf- - LDFLAGS = -endif +ifndef MIPS_GCC_PREFIX + ifeq (/usr/local/mips-gcc-4.8.1/bin/mips-elf-gcc,$(wildcard /usr/local/mips-gcc-4.8.1/bin/mips-elf-gcc)) + MIPS_GCC_PREFIX = /usr/local/mips-gcc-4.8.1/bin/mips-elf- + endif endif # Mentor Sourcery CodeBench Lite toolchain # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# You can download a Linux or Windows binary package from -# https://sourcery.mentor.com/GNUToolchain/release2641 -ifndef GCCPREFIX -ifeq (/usr/local/mips-2013.11/bin/mips-sde-elf-gcc,$(wildcard /usr/local/mips-2013.11/bin/mips-sde-elf-gcc)) - GCCPREFIX = /usr/local/mips-2013.11/bin/mips-sde-elf- - LDFLAGS = -Wl,--oformat=elf32-tradlittlemips -endif -endif -ifndef GCCPREFIX -ifeq (/usr/local/mips-2014.05/bin/mips-sde-elf-gcc,$(wildcard /usr/local/mips-2014.05/bin/mips-sde-elf-gcc)) - GCCPREFIX = /usr/local/mips-2014.05/bin/mips-sde-elf- - LDFLAGS = -Wl,--oformat=elf32-tradlittlemips +ifndef MIPS_GCC_PREFIX + # Download a Linux binary package from + # https://sourcery.mentor.com/GNUToolchain/release2641 + ifeq (/usr/local/mips-2013.11/bin/mips-sde-elf-gcc,$(wildcard /usr/local/mips-2013.11/bin/mips-sde-elf-gcc)) + MIPS_GCC_PREFIX = /usr/local/mips-2013.11/bin/mips-sde-elf- + MIPS_GCC_FORMAT = elf32-tradlittlemips + endif endif +ifndef MIPS_GCC_PREFIX + # Download a Linux binary package from + # https://sourcery.mentor.com/GNUToolchain/release2774 + ifeq (/usr/local/mips-2014.05/bin/mips-sde-elf-gcc,$(wildcard /usr/local/mips-2014.05/bin/mips-sde-elf-gcc)) + MIPS_GCC_PREFIX = /usr/local/mips-2014.05/bin/mips-sde-elf- + MIPS_GCC_FORMAT = elf32-tradlittlemips + endif endif -ifndef GCCPREFIX +# Imagination Codescape MIPS SDK Essentials +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Download a Linux binary package from: +# http://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/download-codescape-mips-sdk-essentials/ +ifndef MIPS_GCC_ROOT + ifeq (/opt/imgtec/Toolchains/mips-mti-elf/2015.01-7,$(wildcard /opt/imgtec/Toolchains/mips-mti-elf/2015.01-7)) + MIPS_GCC_ROOT = /opt/imgtec/Toolchains/mips-mti-elf/2015.01-7 + MIPS_GCC_FORMAT = elf32-tradlittlemips + endif +endif + +ifndef MIPS_GCC_PREFIX $(error Unable to locate any GCC MIPS toolchain!) endif - -# UECIDE on Linux -ifneq (,$(wildcard $UECIDE/cores/chipKIT)) - AVRDUDE = $UECIDE/cores/chipKIT/tools/linux64/avrdude \ - -C $UECIDE/cores/chipKIT/tools/linux64/avrdude.conf -V \ - -P /dev/ttyUSB* -endif - -# chipKIT MPIDE on Mac OS X -ifneq (,$(wildcard /Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr)) - AVRDUDE = /Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude \ - -C /Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf \ - -P /dev/tty.usbserial-* -endif - -# chipKIT MPIDE on Linux -ifneq (,$(wildcard /opt/mpide-0023-linux-20120903/hardware/tools/avrdude)) - AVRDUDE = /opt/mpide-0023-linux-20120903/hardware/tools/avrdude \ - -C /opt/mpide-0023-linux-20120903/hardware/tools/avrdude.conf \ - -P /dev/ttyUSB0 -endif diff --git a/sys/pic32/kernel-post.mk b/sys/pic32/kernel-post.mk index dff8579..44c0c5b 100644 --- a/sys/pic32/kernel-post.mk +++ b/sys/pic32/kernel-post.mk @@ -5,16 +5,19 @@ ASFLAGS = -I. -I$(H) $(DEFS) $(DEPFLAGS) include $(BUILDPATH)/gcc-config.mk -CC = $(GCCPREFIX)gcc -EL -g -mips32r2 +CC = $(MIPS_GCC_PREFIX)gcc -EL -g -mips32r2 CC += -nostdinc -fno-builtin -Werror -Wall -fno-dwarf2-cfi-asm -LDFLAGS += -nostdlib -SIZE = $(GCCPREFIX)size -OBJDUMP = $(GCCPREFIX)objdump -OBJCOPY = $(GCCPREFIX)objcopy -PROGTOOL = $(AVRDUDE) -c stk500v2 -p pic32 -b 115200 +LDFLAGS = -nostdlib +SIZE = $(MIPS_GCC_PREFIX)size +OBJDUMP = $(MIPS_GCC_PREFIX)objdump +OBJCOPY = $(MIPS_GCC_PREFIX)objcopy DEFS += -DCONFIG=$(CONFIG) +ifneq (${MIPS_GCC_FORMAT},) + LDFLAGS += -Wl,--oformat=${MIPS_GCC_FORMAT} +endif + all: .deps sys machine unix.elf $(SIZE) unix.elf @@ -44,9 +47,6 @@ unix.elf: $(KERNOBJ) $(LDSCRIPT) load: unix.hex pic32prog $(BLREBOOT) unix.hex -loadmax: unix.hex - $(PROGTOOL) -U flash:w:unix.hex:i - vers.o: $(BUILDPATH)/newvers.sh $(H)/*.h $(M)/*.[ch] $(S)/*.c sh $(BUILDPATH)/newvers.sh > vers.c $(CC) -c vers.c diff --git a/sys/pic32/max32/Makefile b/sys/pic32/max32/Makefile index b139e4d..09ba959 100644 --- a/sys/pic32/max32/Makefile +++ b/sys/pic32/max32/Makefile @@ -6,49 +6,23 @@ PARAM=-DTIMEZONE=480 -DDST=1 -DMAXUSERS=2 # # DEBUG is set to -g by kconfig if debugging is requested (kconfig -g). # PROF is set to -pg by kconfig if profiling is requested (kconfig -p). - -ifndef MIPS_GCC_ROOT - ifeq (/usr/local/mips-2014.05,$(wildcard /usr/local/mips-2014.05)) - MIPS_GCC_ROOT = /usr/local/mips-2014.05 - endif - ifeq (/usr/local/mips-gcc-4.8.1,$(wildcard /usr/local/mips-gcc-4.8.1)) - MIPS_GCC_ROOT = /usr/local/mips-gcc-4.8.1 - endif - ifeq (/usr/local/pic32-tools,$(wildcard /usr/local/pic32-tools)) - MIPS_GCC_ROOT = /usr/local/pic32-tools - endif - ifdef UECIDE - MIPS_GCC_ROOT = ${UECIDE}/compilers/pic32-tools - endif -endif - -ifeq (${MIPS_GCC_ROOT}/bin/mips-sde-elf-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/mips-sde-elf-gcc)) - MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/mips-sde-elf- -endif -ifeq (${MIPS_GCC_ROOT}/bin/mips-elf-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/mips-elf-gcc)) - MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/mips-elf- -endif -ifeq (${MIPS_GCC_ROOT}/bin/pic32-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/pic32-gcc)) - MIPS_GCC_PREFIX ?= ${MIPS_GCC_ROOT}/bin/pic32- -endif +# +include ../gcc-config.mk AS = ${MIPS_GCC_PREFIX}as ${DEBUG} -mips32r2 -EL CC = ${MIPS_GCC_PREFIX}gcc ${DEBUG} -mips32r2 -EL -nostdinc -fno-builtin -Werror -Wall CPP = ${MIPS_GCC_PREFIX}cpp LD = ${MIPS_GCC_PREFIX}gcc -mips32r2 -EL -LDFLAGS = -nostdlib -T $S/pic32/${LDSCRIPT} -Wl,-Map=unix.map +LDFLAGS = -nostdlib -T ../${LDSCRIPT} -Wl,-Map=unix.map SIZE = ${MIPS_GCC_PREFIX}size OBJCOPY = ${MIPS_GCC_PREFIX}objcopy OBJDUMP = ${MIPS_GCC_PREFIX}objdump -ifeq (${MIPS_GCC_ROOT}/bin/mips-elf-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/mips-elf-gcc)) - LDFLAGS += -Wl,--oformat=elf32-littlemips -endif -ifeq (${MIPS_GCC_ROOT}/bin/pic32-gcc,$(wildcard ${MIPS_GCC_ROOT}/bin/pic32-gcc)) - LDFLAGS += -Wl,--oformat=elf32-tradlittlemips +ifneq (${MIPS_GCC_FORMAT},) + LDFLAGS += -Wl,--oformat=${MIPS_GCC_FORMAT} endif -# source tree is located via $S relative to the compilation directory +# sources are located via $S relative to the compilation directory S = ../.. COPTS = -I. ${IDENT} -DKERNEL @@ -120,7 +94,7 @@ ifeq (devcfg.c,$(wildcard devcfg.c)) SYSTEM_OBJ += devcfg.o endif SYSTEM_DEP = Makefile ioconf.c swapunix.c machine sys ${SYSTEM_OBJ} -SYSTEM_LD_HEAD = sh $S/pic32/newvers.sh > vers.c; ${CC} $(CFLAGS) -c vers.c; rm -f $@ +SYSTEM_LD_HEAD = sh ../newvers.sh > vers.c; ${CC} $(CFLAGS) -c vers.c; rm -f $@ SYSTEM_LD = -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -o unix.elf; \ ${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -o unix.elf SYSTEM_LD_TAIL = ${SIZE} unix.elf; \ @@ -151,7 +125,7 @@ reconfig ioconf.c swapunix.c: Config ../../../tools/kconfig/kconfig load: unix.elf pic32prog unix.hex -startup.o: $S/pic32/startup.S +startup.o: ../startup.S ${NORMAL_S} # the following are necessary because the files depend on the types of @@ -159,10 +133,10 @@ startup.o: $S/pic32/startup.S clock.o machdep.o conf.o: Makefile machine: - ln -s $S/pic32 $@ + ln -s .. $@ sys: - ln -s $S/include $@ + ln -s ../../include $@ depend: machine mkdep ${COPTS} ${CFILES} ioconf.c diff --git a/tools/Makefile b/tools/Makefile index ae7452a..4218b65 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,4 +1,4 @@ -SUBDIR = elf2aout fsutil virtualmips mkrd configsys icache +SUBDIR = elf2aout fsutil virtualmips mkrd configsys kconfig icache all install depend: ${SUBDIR} -for i in ${SUBDIR}; do ${MAKE} -C $$i ${MFLAGS} DESTDIR=${DESTDIR} $@; done diff --git a/tools/kconfig/mkswapconf.c b/tools/kconfig/mkswapconf.c index abe3231..d93e302 100644 --- a/tools/kconfig/mkswapconf.c +++ b/tools/kconfig/mkswapconf.c @@ -61,7 +61,6 @@ do_swap(fl) FILE *fp; char swapname[80]; register struct file_list *swap; - dev_t dev; if (eq(fl->f_fn, "generic")) { fl = fl->f_next; @@ -95,7 +94,6 @@ do_swap(fl) devtoname(fl->f_dumpdev)); #if 1 /* Only one swap device is supported. */ - dev = swap->f_swapdev; fprintf(fp, "dev_t\tswapdev = makedev(%d, %d);\t/* %s */\n", major(swap->f_swapdev), minor(swap->f_swapdev), devtoname(swap->f_swapdev)); @@ -103,7 +101,7 @@ do_swap(fl) fprintf(fp, "\n"); fprintf(fp, "struct\tswdevt swdevt[] = {\n"); do { - dev = swap->f_swapdev; + int dev = swap->f_swapdev; fprintf(fp, "\t{ makedev(%d, %d), %d, %d },\t/* %s */\n", major(dev), minor(dev), swap->f_swapflag, swap->f_swapsize, swap->f_fn);