[mips]
- libsys multitarget - apps multitarget git-svn-id: http://moon:8086/svn/mips@67 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+62
-71
@@ -1,5 +1,5 @@
|
||||
ENDIAN='big'
|
||||
BOARD=ml402
|
||||
ENDIANESS ?=eb
|
||||
BOARD ?=ml402
|
||||
|
||||
ifeq ($(TLB),yes)
|
||||
SPECNAME=specs_tlb
|
||||
@@ -7,14 +7,18 @@ else
|
||||
SPECNAME=specs
|
||||
endif
|
||||
|
||||
ifeq ($(ENDIAN), 'big')
|
||||
ifeq ($(ENDIANESS),eb)
|
||||
ENDIAN_FLAGS=-EB
|
||||
CFLAGS=$(ENDIAN_FLAGS) -specs=specs/eb/$(SPECNAME) -msoft-float -O2 -march=r3000 -I. -Ilibsys -Ilibsys/boards/$(BOARD) -Wl,-M
|
||||
CFLAGS:=$(ENDIAN_FLAGS) -specs=specs/eb/$(SPECNAME)
|
||||
else
|
||||
ENDIAN_FLAGS=-EL
|
||||
CFLAGS=$(ENDIAN_FLAGS) -specs=specs/$(SPECNAME) -msoft-float -O2 -march=r3000 -I. -Ilibsys -Ilibsys/boards/$(BOARD) -Wl,-M
|
||||
CFLAGS:=$(ENDIAN_FLAGS) -specs=specs/$(SPECNAME)
|
||||
endif
|
||||
|
||||
BUILD_DIR=build/$(BOARD)/$(ENDIANESS)
|
||||
LSYS_BUILD_DIR=libsys/build/$(BOARD)/$(ENDIANESS)
|
||||
|
||||
CFLAGS+=-msoft-float -O2 -march=r3000 -I. -Ilibsys -Ilibsys/boards/$(BOARD) -L$(LSYS_BUILD_DIR) -Wl,-M
|
||||
ifeq ($(TLB),yes)
|
||||
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
||||
else
|
||||
@@ -37,20 +41,16 @@ LD=mipsel-elf-ld
|
||||
OBJDUMP=mipsel-elf-objdump
|
||||
OBJCOPY=mipsel-elf-objcopy
|
||||
|
||||
PROG = hello.elf testbench.elf test_irq.elf dhry.elf queens.elf stanford.elf paranoia.elf rmd160_test.elf Bessel.elf whet.elf phrasen.elf dttl.elf richards_benchmark.elf test_exception.elf life.elf r3.elf gunzip.elf basic_math.elf jman_patches.elf jman_patchmeshes.elf jman_polys.elf test_hpi.elf test_vga.elf test_fft.elf
|
||||
PROG-ml402 = $(addprefix $(BUILD_DIR)/, hello.elf testbench.elf test_irq.elf dhry.elf queens.elf stanford.elf paranoia.elf rmd160_test.elf Bessel.elf whet.elf phrasen.elf dttl.elf richards_benchmark.elf test_exception.elf life.elf r3.elf gunzip.elf basic_math.elf jman_patches.elf jman_patchmeshes.elf jman_polys.elf test_hpi.elf test_vga.elf test_fft.elf)
|
||||
|
||||
.PHONY : libsys.a libsys_sim.a
|
||||
PROG-denano = $(addprefix $(BUILD_DIR)/, hello.elf dhry.elf queens.elf stanford.elf paranoia.elf rmd160_test.elf Bessel.elf whet.elf phrasen.elf dttl.elf richards_benchmark.elf test_exception.elf)
|
||||
|
||||
all: $(PROG)
|
||||
all: $(PROG-$(BOARD))
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
libsys.a:
|
||||
$(MAKE) -C libsys BOARD=$(BOARD)
|
||||
|
||||
libsys_sim.a:
|
||||
$(MAKE) -C libsys
|
||||
|
||||
test_fft.elf: test_fft.c libsys.a
|
||||
$(BUILD_DIR)/test_fft.elf: $(BUILD_DIR) test_fft.c
|
||||
$(CC) $(CFLAGS) -o $@ -O2 fft.c test_fft.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -59,7 +59,7 @@ test_fft.elf: test_fft.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
hello.elf: hello.c libsys.a
|
||||
$(BUILD_DIR)/hello.elf: $(BUILD_DIR) hello.c
|
||||
$(CC) $(CFLAGS) -o $@ -Os hello.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -68,16 +68,7 @@ hello.elf: hello.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
hello_sim.elf: hello.c libsys_sim.a
|
||||
$(CC) $(CFLAGS) -o $@ -Os hello.c -lsys_sim >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
$(OBJCOPY) -O srec $@ $@.srec
|
||||
$(FLASHGEN) $@.bin $(ENDIAN_FLAGS)
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
blittertest.elf: blittertest.c libsys.a
|
||||
$(BUILD_DIR)/blittertest.elf: $(BUILD_DIR) blittertest.c
|
||||
$(CC) $(CFLAGS) -o $@ -Os blittertest.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -86,7 +77,7 @@ blittertest.elf: blittertest.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
blittertest_tb.elf: blittertest_tb.c libsys.a
|
||||
$(BUILD_DIR)/blittertest_tb.elf: $(BUILD_DIR) blittertest_tb.c
|
||||
$(CC) $(CFLAGS) -o $@ -Os blittertest_tb.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -95,7 +86,7 @@ blittertest_tb.elf: blittertest_tb.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
testbench.elf: testbench.c libsys.a
|
||||
$(BUILD_DIR)/testbench.elf: $(BUILD_DIR) testbench.c
|
||||
$(CC) $(CFLAGS) -O3 -o $@ -DHZ=1000 -DNOSIGNAL -DBATCHMODE -DNOMAIN -Os -g testbench.c paranoia.c delay_mips.c bogomips.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -104,7 +95,7 @@ testbench.elf: testbench.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_irq.elf: test_irq.c libsys.a
|
||||
$(BUILD_DIR)/test_irq.elf: $(BUILD_DIR) test_irq.c
|
||||
$(CC) $(CFLAGS) -o $@ test_irq.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -113,7 +104,7 @@ test_irq.elf: test_irq.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
dhry.elf: dhry_1.c dhry_2.c dhry.h libsys.a
|
||||
$(BUILD_DIR)/dhry.elf: $(BUILD_DIR) dhry_1.c dhry_2.c dhry.h
|
||||
$(CC) $(CFLAGS) -O3 -o $@ -DHZ=1000 dhry_1.c dhry_2.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -122,7 +113,7 @@ dhry.elf: dhry_1.c dhry_2.c dhry.h libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
queens.elf: queens.c libsys.a
|
||||
$(BUILD_DIR)/queens.elf: $(BUILD_DIR) queens.c
|
||||
$(CC) $(CFLAGS) -o $@ -DUNIX_Old -DHZ=1000 queens.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -131,7 +122,7 @@ queens.elf: queens.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
stanford.elf: stanford.c libsys.a
|
||||
$(BUILD_DIR)/stanford.elf: $(BUILD_DIR) stanford.c
|
||||
$(CC) $(CFLAGS) -O3 -o $@ -DHZ=1000 stanford.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -140,7 +131,7 @@ stanford.elf: stanford.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
paranoia.elf: paranoia.c libsys.a
|
||||
$(BUILD_DIR)/paranoia.elf: $(BUILD_DIR) paranoia.c
|
||||
$(CC) $(CFLAGS) -O3 -o $@ -DNOSIGNAL -DBATCHMODE paranoia.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -149,7 +140,7 @@ paranoia.elf: paranoia.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
rmd160_test.elf: rmd160_test.c rmd160.c rmd160.h libsys.a
|
||||
$(BUILD_DIR)/rmd160_test.elf: rmd160_test.c rmd160.c rmd160.h
|
||||
$(CC) $(CFLAGS) -O3 -o $@ rmd160_test.c rmd160.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -158,7 +149,7 @@ rmd160_test.elf: rmd160_test.c rmd160.c rmd160.h libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
hashtest.elf: hashtest.c rmd160.c rmd160.h libsys.a
|
||||
$(BUILD_DIR)/hashtest.elf: $(BUILD_DIR) hashtest.c rmd160.c rmd160.h
|
||||
$(CC) $(CFLAGS) -O3 -o $@ hashtest.c rmd160.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -167,7 +158,7 @@ hashtest.elf: hashtest.c rmd160.c rmd160.h libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
Bessel.elf: Bessel.c libsys.a
|
||||
$(BUILD_DIR)/Bessel.elf: $(BUILD_DIR) Bessel.c
|
||||
$(CC) $(CFLAGS) -o $@ Bessel.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -176,7 +167,7 @@ Bessel.elf: Bessel.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
whet.elf: whet.c libsys.a
|
||||
$(BUILD_DIR)/whet.elf: $(BUILD_DIR) whet.c
|
||||
$(CC) $(CFLAGS) -o $@ whet.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -185,7 +176,7 @@ whet.elf: whet.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
phrasen.elf: phrasen.c libsys.a
|
||||
$(BUILD_DIR)/phrasen.elf: $(BUILD_DIR) phrasen.c
|
||||
$(CC) $(CFLAGS) -o $@ phrasen.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -194,7 +185,7 @@ phrasen.elf: phrasen.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
dttl.elf: dttl.c random.c libsys.a
|
||||
$(BUILD_DIR)/dttl.elf: $(BUILD_DIR) dttl.c random.c
|
||||
$(CC) $(CFLAGS) -o $@ dttl.c random.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -203,7 +194,7 @@ dttl.elf: dttl.c random.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
richards_benchmark.elf: richards_benchmark.c libsys.a
|
||||
$(BUILD_DIR)/richards_benchmark.elf: $(BUILD_DIR) richards_benchmark.c
|
||||
$(CC) $(CFLAGS) -o $@ richards_benchmark.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -212,7 +203,7 @@ richards_benchmark.elf: richards_benchmark.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_exception.elf: test_exception.c libsys.a
|
||||
$(BUILD_DIR)/test_exception.elf: $(BUILD_DIR) test_exception.c
|
||||
$(CC) $(CFLAGS) -o $@ -O1 test_exception.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -221,7 +212,7 @@ test_exception.elf: test_exception.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
life.elf: life.c libsys.a
|
||||
$(BUILD_DIR)/life.elf: $(BUILD_DIR) life.c
|
||||
$(CC) $(CFLAGS) -o $@ -g life.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -230,7 +221,7 @@ life.elf: life.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
r3.elf: r3.c libsys.a
|
||||
$(BUILD_DIR)/r3.elf: $(BUILD_DIR) r3.c
|
||||
$(CC) $(CFLAGS) -O3 -o $@ -DJMIPS_VGA -O2 r3.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -239,7 +230,7 @@ r3.elf: r3.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
gunzip.elf: gunzip.c inflate.c crc32.c libsys.a
|
||||
$(BUILD_DIR)/gunzip.elf: $(BUILD_DIR) gunzip.c inflate.c crc32.c $(LSYS_BUILD_DIR)/libsys.a
|
||||
$(CC) $(CFLAGS) -o $@ -o $@ gunzip.c inflate.c crc32.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -248,7 +239,7 @@ gunzip.elf: gunzip.c inflate.c crc32.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
basic_math.elf: basicmath_small.c rad2deg.c cubic.c isqrt.c libsys.a
|
||||
$(BUILD_DIR)/basic_math.elf: $(BUILD_DIR) basicmath_small.c rad2deg.c cubic.c isqrt.c
|
||||
$(CC) $(CFLAGS) -o $@ -o $@ basicmath_small.c rad2deg.c cubic.c isqrt.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -273,7 +264,7 @@ JMAN_SRC= \
|
||||
jman/stack.c \
|
||||
jman/vars.c
|
||||
|
||||
jman_patches.elf: $(JMAN_SRC) jman/main_patches.c libsys.a
|
||||
$(BUILD_DIR)/jman_patches.elf: $(BUILD_DIR) $(JMAN_SRC) jman/main_patches.c
|
||||
$(CC) $(CFLAGS) -I../ -o $@ -o $@ jman/main_patches.c $(JMAN_SRC) $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -282,7 +273,7 @@ jman_patches.elf: $(JMAN_SRC) jman/main_patches.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
jman_patchmeshes.elf: $(JMAN_SRC) jman/main_patchmeshes.c jman/patches2.c libsys.a
|
||||
$(BUILD_DIR)/jman_patchmeshes.elf: $(BUILD_DIR) $(JMAN_SRC) jman/main_patchmeshes.c jman/patches2.c
|
||||
$(CC) $(CFLAGS) -I../ -o $@ -o $@ jman/main_patchmeshes.c jman/patches2.c $(JMAN_SRC) $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -291,7 +282,7 @@ jman_patchmeshes.elf: $(JMAN_SRC) jman/main_patchmeshes.c jman/patches2.c libsys
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
jman_polys.elf: $(JMAN_SRC) jman/main_polypin.c jman/polys.c libsys.a
|
||||
$(BUILD_DIR)/jman_polys.elf: $(BUILD_DIR) $(JMAN_SRC) jman/main_polypin.c jman/polys.c
|
||||
$(CC) $(CFLAGS) -I../ -o $@ -o $@ jman/main_polypin.c jman/polys.c $(JMAN_SRC) $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -300,7 +291,7 @@ jman_polys.elf: $(JMAN_SRC) jman/main_polypin.c jman/polys.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
serdump.elf: serdump.c libsys.a
|
||||
$(BUILD_DIR)/serdump.elf: $(BUILD_DIR) serdump.c
|
||||
$(CC) $(CFLAGS) -O3 -o $@ -O2 serdump.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -309,7 +300,7 @@ serdump.elf: serdump.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
pppi.elf: pppissue/test1.c pppissue/utils.c pppissue/pppd.h libsys.a
|
||||
$(BUILD_DIR)/pppi.elf: $(BUILD_DIR) pppissue/test1.c pppissue/utils.c pppissue/pppd.h
|
||||
$(CC) $(CFLAGS) -O2 -o $@ -O2 pppissue/test1.c pppissue/utils.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -318,7 +309,7 @@ pppi.elf: pppissue/test1.c pppissue/utils.c pppissue/pppd.h libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
lwl.elf: lwl.c libsys.a
|
||||
$(BUILD_DIR)/lwl.elf: $(BUILD_DIR) lwl.c
|
||||
$(CC) $(CFLAGS) -O2 -o $@ lwl.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -327,7 +318,7 @@ lwl.elf: lwl.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
ucb.elf: ucb.c libsys_sim.a
|
||||
$(BUILD_DIR)/ucb.elf: $(BUILD_DIR) ucb.c
|
||||
$(CC) $(CFLAGS) -O2 -o $@ ucb.c -lsys_sim >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -336,7 +327,7 @@ ucb.elf: ucb.c libsys_sim.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_timer.elf: test_timer.c libsys_sim.a
|
||||
$(BUILD_DIR)/test_timer.elf: $(BUILD_DIR) test_timer.c
|
||||
$(CC) $(CFLAGS) -O2 -o $@ test_timer.c -lsys_sim >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -345,7 +336,7 @@ test_timer.elf: test_timer.c libsys_sim.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_exception_sim.elf: test_exception_sim.c libsys_sim.a
|
||||
$(BUILD_DIR)/test_exception_sim.elf: $(BUILD_DIR) test_exception_sim.c
|
||||
$(CC) $(CFLAGS) -O2 -o $@ test_exception_sim.c -lsys_sim >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -354,7 +345,7 @@ test_exception_sim.elf: test_exception_sim.c libsys_sim.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_tlb_sim.elf: test_tlb_sim.c libsys_sim.a
|
||||
$(BUILD_DIR)/test_tlb_sim.elf: $(BUILD_DIR) test_tlb_sim.c
|
||||
$(CC) $(CFLAGS) -O2 -o $@ test_tlb_sim.c -lsys_sim >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -363,7 +354,7 @@ test_tlb_sim.elf: test_tlb_sim.c libsys_sim.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_dcache_sim.elf: test_dcache.c libsys_sim.a
|
||||
$(BUILD_DIR)/test_dcache_sim.elf: $(BUILD_DIR) test_dcache.c
|
||||
$(CC) $(CFLAGS) -O0 -o $@ test_dcache.c -lsys_sim >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -372,7 +363,7 @@ test_dcache_sim.elf: test_dcache.c libsys_sim.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_hpi.elf: hpi.c test_hpi.c cfiflash.c libsys.a
|
||||
$(BUILD_DIR)/test_hpi.elf: $(BUILD_DIR) hpi.c test_hpi.c cfiflash.c
|
||||
$(CC) $(CFLAGS) -o $@ -g hpi.c test_hpi.c cfiflash.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -381,7 +372,7 @@ test_hpi.elf: hpi.c test_hpi.c cfiflash.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_vga.elf: test_vga.c libsys.a
|
||||
$(BUILD_DIR)/test_vga.elf: $(BUILD_DIR) test_vga.c
|
||||
$(CC) $(CFLAGS) -o $@ test_vga.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -390,7 +381,7 @@ test_vga.elf: test_vga.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
barcode.elf: barcode.c libsys.a
|
||||
$(BUILD_DIR)/barcode.elf: $(BUILD_DIR) barcode.c
|
||||
$(CC) $(CFLAGS) -o $@ barcode.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -399,7 +390,7 @@ barcode.elf: barcode.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
lua.elf: lua_init.c libsys.a
|
||||
$(BUILD_DIR)/lua.elf: $(BUILD_DIR) lua_init.c
|
||||
$(CC) $(CFLAGS) -I./lua-5.1.4/etc -I./lua-5.1.4/src -o $@ lua_init.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -408,7 +399,7 @@ lua.elf: lua_init.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
mandelbrot.elf: mandelbrot.c libsys.a
|
||||
$(BUILD_DIR)/mandelbrot.elf: $(BUILD_DIR) mandelbrot.c
|
||||
$(CC) $(CFLAGS) -o $@ mandelbrot.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -417,7 +408,7 @@ mandelbrot.elf: mandelbrot.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
bogomips.elf: bogomips.c delay_mips.c libsys.a
|
||||
$(BUILD_DIR)/bogomips.elf: $(BUILD_DIR) bogomips.c delay_mips.c
|
||||
$(CC) $(CFLAGS) -DHZ=1000 -o $@ bogomips.c delay_mips.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -426,7 +417,7 @@ bogomips.elf: bogomips.c delay_mips.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_asm.elf: test_asm.S libsys.a
|
||||
$(BUILD_DIR)/test_asm.elf: $(BUILD_DIR) test_asm.S
|
||||
$(CC) $(CFLAGS) -DHZ=1000 -o $@ test_asm.S $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -435,7 +426,7 @@ test_asm.elf: test_asm.S libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_ac97.elf: test_ac97.c libsys.a
|
||||
$(BUILD_DIR)/test_ac97.elf: $(BUILD_DIR) test_ac97.c
|
||||
$(CC) $(CFLAGS) -o $@ test_ac97.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -444,7 +435,7 @@ test_ac97.elf: test_ac97.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
aes256_1.elf: aes256_1.c aes256.c aes256.h libsys.a
|
||||
$(BUILD_DIR)/aes256_1.elf: $(BUILD_DIR) aes256_1.c aes256.c aes256.h
|
||||
$(CC) $(CFLAGS) -O3 -o $@ aes256_1.c aes256.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -453,7 +444,7 @@ aes256_1.elf: aes256_1.c aes256.c aes256.h libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_gpio.elf: test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c emac.h ethernet.c ethernet.h arp.c arp.h icmp.c icmp.h ipv4.c ipv4.h udp.c udp.h dhcp.c dhcp.h fifo.c fifo.h libsys.a
|
||||
$(BUILD_DIR)/test_gpio.elf: $(BUILD_DIR) test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c emac.h ethernet.c ethernet.h arp.c arp.h icmp.c icmp.h ipv4.c ipv4.h udp.c udp.h dhcp.c dhcp.h fifo.c fifo.h
|
||||
$(CC) $(CFLAGS) -o $@ -O2 test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c ethernet.c arp.c icmp.c ipv4.c udp.c dhcp.c fifo.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -462,7 +453,7 @@ test_gpio.elf: test_gpio.c marvell_88e1111.c mii-bitbang.c emac.c emac.h etherne
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_emac_sim.elf: test_emac_sim.c emac.c emac.h libsys.a
|
||||
$(BUILD_DIR)/test_emac_sim.elf: $(BUILD_DIR) test_emac_sim.c emac.c emac.h
|
||||
$(CC) $(CFLAGS) -o $@ -Os test_emac_sim.c emac.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -471,7 +462,7 @@ test_emac_sim.elf: test_emac_sim.c emac.c emac.h libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
mips_io.elf: mips_io.c libsys.a
|
||||
$(BUILD_DIR)/mips_io.elf: $(BUILD_DIR) mips_io.c
|
||||
$(CC) $(CFLAGS) -o $@ mips_io.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -480,7 +471,7 @@ mips_io.elf: mips_io.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
mips_instr.elf: mips_instr.c libsys.a
|
||||
$(BUILD_DIR)/mips_instr.elf: $(BUILD_DIR) mips_instr.c
|
||||
$(CC) $(CFLAGS) -o $@ mips_instr.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -489,7 +480,7 @@ mips_instr.elf: mips_instr.c libsys.a
|
||||
cat $@.srec | $(PACKHEX) > $@.pack
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
test_endianess.elf: test_endianess.c libsys.a
|
||||
$(BUILD_DIR)/test_endianess.elf: $(BUILD_DIR) test_endianess.c
|
||||
$(CC) $(CFLAGS) -O0 -o $@ test_endianess.c $(LIBS) >$@.map
|
||||
$(OBJDUMP) -d $@ > $@.dis
|
||||
$(OBJCOPY) $@ -O binary $@.bin
|
||||
@@ -499,4 +490,4 @@ test_endianess.elf: test_endianess.c libsys.a
|
||||
$(OBJCOPY) -O ihex -I binary $@.flash.bin $@.hex
|
||||
|
||||
clean:
|
||||
rm -rf *.a *.o *.bin *.map *.dis *.srec *.pack *.elf $(PROG) > /dev/null
|
||||
rm -rf $(BUILD_DIR)/*.bin $(BUILD_DIR)/*.map $(BUILD_DIR)/*.dis $(BUILD_DIR)/*.srec $(BUILD_DIR)/*.pack $(BUILD_DIR)/*.elf $(BUILD_DIR)/*.hex $(PROG) > /dev/null
|
||||
|
||||
+36
-24
@@ -1,9 +1,19 @@
|
||||
# environment vaiables read:
|
||||
# BOARD
|
||||
# BOARD = {ml402, denano}
|
||||
# TLB = {no, yes}
|
||||
# ENDIANESS = {eb, el}
|
||||
BOARD ?= ml402
|
||||
TLB ?= no
|
||||
ENDIANESS ?= eb
|
||||
|
||||
ENDIAN_FLAGS=-EL
|
||||
|
||||
CFLAGS=$(ENDIAN_FLAGS) -msoft-float -O2 -march=r3000 -I. -Wl,-M -Iboards/$(BOARD)
|
||||
ifeq ($(ENDIANESS),el)
|
||||
ENDIAN_FLAGS=-EL
|
||||
else
|
||||
ENDIAN_FLAGS=-EB
|
||||
endif
|
||||
|
||||
CFLAGS=$(ENDIAN_FLAGS) -msoft-float -O2 -march=r3000 -I. -Wl,-M -Iboards/$(BOARD) -D$(BOARD)
|
||||
|
||||
ifeq ($(TLB),yes)
|
||||
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
||||
@@ -11,6 +21,8 @@ else
|
||||
CFLAGS+=-DSYS_IO_BASE=0xA0000000 -DSDRAM_BASE=0x40000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x00000000
|
||||
endif
|
||||
|
||||
BUILD_DIR=./build/$(BOARD)/$(ENDIANESS)
|
||||
|
||||
AS=mipsel-elf-as
|
||||
AR=mipsel-elf-ar
|
||||
CC=mipsel-elf-gcc
|
||||
@@ -19,31 +31,31 @@ OBJDUMP=mipsel-elf-objdump
|
||||
OBJCOPY=mipsel-elf-objcopy
|
||||
FLASHGEN=flashgen
|
||||
|
||||
SRCS=libsys.c xcpt.c syscalls.c irq.c mips_dbg.c mips_dis.c mips_gfx.c mips_ps2.c gpio.c
|
||||
OBJS=libsys.o xcpt.o syscalls.o irq.o mips_dbg.o mips_dis.o mips_gfx.o mips_ps2.o gpio.o
|
||||
OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o irq.o mips_dbg.o mips_dis.o mips_ps2.o mips_gfx.o console.o screen.o uart.o board.o gpio.o)
|
||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o)
|
||||
|
||||
.PHONY : libsys.a
|
||||
|
||||
all: libsys.a
|
||||
$(MAKE) -C eb BOARD=$(BOARD)
|
||||
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
|
||||
|
||||
$(OBJS): $(SRCS)
|
||||
$(CC) $(CFLAGS) -G 0 -c $(SRCS)
|
||||
$(BUILD_DIR)/%.o : %.c
|
||||
$(CC) $(CFLAGS) -G 0 -c -o $@ $<
|
||||
|
||||
libsys.a: $(OBJS) $(SRCS)
|
||||
$(AR) -r libsys.a $(OBJS)
|
||||
$(CC) $(CFLAGS) -G 0 -c startup.S
|
||||
$(CC) $(CFLAGS) -G 0 -c kernel.S
|
||||
$(BUILD_DIR)/%.o : %.S
|
||||
$(CC) $(CFLAGS) -G 0 -c -o $@ $<
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -G 0 -c *.c
|
||||
$(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
|
||||
$(CC) $(CFLAGS) -G 0 -c -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/libsys.a: $(OBJS-$(BOARD))
|
||||
$(AR) -r $(BUILD_DIR)/libsys.a $(OBJS-$(BOARD))
|
||||
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/startup.o startup.S
|
||||
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/kernel.o kernel.S
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
libsys_sim.a: libsys_sim.o xcpt.o syscalls.o irq.o gpio.o
|
||||
$(AR) -r libsys_sim.a libsys_sim.o xcpt.o syscalls.o irq.o gpio.o
|
||||
$(CC) $(CFLAGS) -G 0 -c startup.S
|
||||
$(CC) $(CFLAGS) -G 0 -c kernel.S
|
||||
|
||||
clean:
|
||||
rm -rf *.a *.o *.map *.dis *.elf > /dev/null
|
||||
$(MAKE) -C eb clean
|
||||
rm -rf $(BUILD_DIR)/*.a $(BUILD_DIR)/*.o > /dev/null
|
||||
|
||||
mrproper:
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
|
||||
extern uart_if_t uart_if[];
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
const con_if_entry_t con_if_entry[5] =
|
||||
{
|
||||
{"UART-0", &uart_if[0], NULL, NULL, UART_readchar, UART_writechar},
|
||||
{"UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar}
|
||||
};
|
||||
|
||||
con_if_t con_if =
|
||||
{
|
||||
con_if_entry, ARRAYSIZE(con_if_entry)
|
||||
};
|
||||
@@ -93,6 +93,29 @@
|
||||
#define SYS_UART1_STAT (SYS_IO_BASE + 0x10104)
|
||||
#define SYS_UART1_BAUD (SYS_IO_BASE + 0x10108)
|
||||
|
||||
// SPI
|
||||
#define SYS_SPI_STAT (SYS_IO_BASE + 0x20000)
|
||||
// Read
|
||||
#define SPI_STAT_CMDRDY (0x01)
|
||||
#define SPI_STAT_DINRDY (0x02)
|
||||
#define SPI_STAT_DOUTRDY (0x04)
|
||||
#define SPI_STAT_CMD_FIFO_FULL (0x0100)
|
||||
#define SPI_STAT_CMD_FIFO_EMPTY (0x0200)
|
||||
#define SPI_STAT_WRITE_FIFO_FULL (0x0400)
|
||||
#define SPI_STAT_WRITE_FIFO_EMPTY (0x0800)
|
||||
#define SPI_STAT_READ_FIFO_FULL (0x1000)
|
||||
#define SPI_STAT_READ_FIFO_EMPTY (0x2000)
|
||||
#define SPI_STAT_RX_VALID (0x4000)
|
||||
#define SPI_STAT_SPI_HOLD (0x8000)
|
||||
|
||||
// Write
|
||||
#define SPI_STAT_COMMIT (1)
|
||||
|
||||
#define SYS_SPI_XFER_SIZE (SYS_IO_BASE + 0x20004)
|
||||
#define SYS_SPI_DATA_SIZE (SYS_IO_BASE + 0x20008)
|
||||
#define SYS_SPI_DATA (SYS_IO_BASE + 0x2000C)
|
||||
#define SYS_SPI_CTRL (SYS_IO_BASE + 0x20010)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../mips_ps2.h"
|
||||
#include "../../screen.h"
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
|
||||
extern uart_if_t uart_if[];
|
||||
extern ps2_if_t ps2_if[];
|
||||
extern vga_if_t vga_if;
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
static const con_if_entry_t con_if_entry[5] =
|
||||
{
|
||||
{"UART-0", &uart_if[0], NULL, NULL, UART_readchar, UART_writechar},
|
||||
{"UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar},
|
||||
{"PS2-0", &ps2_if[0], PS2_open, PS2_close, PS2_readchar, NULL},
|
||||
{"PS2-1", &ps2_if[1], PS2_open, PS2_close, PS2_readchar, NULL},
|
||||
{"VGA-0", &vga_if, cg_open, cg_close, NULL, cg_writechar}
|
||||
};
|
||||
|
||||
con_if_t con_if =
|
||||
{
|
||||
con_if_entry, ARRAYSIZE(con_if_entry)
|
||||
};
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "console.h"
|
||||
|
||||
extern con_if_t con_if;
|
||||
|
||||
// Funcs
|
||||
con_if_entry_t const* con_getPort(int file)
|
||||
{
|
||||
assert(file < con_if.length);
|
||||
|
||||
return &con_if.con_if_entry[file];
|
||||
}
|
||||
|
||||
int con_open(char const *pName)
|
||||
{
|
||||
int i;
|
||||
assert(pName);
|
||||
|
||||
for (i=0; i < con_if.length; i++)
|
||||
{
|
||||
if (!strcmp(pName, con_if.con_if_entry->pName))
|
||||
{
|
||||
if (con_if.con_if_entry->openFunc)
|
||||
{
|
||||
con_if.con_if_entry->openFunc(&con_if.con_if_entry[i].pInst);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int con_close(int fd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void con_flush(int fd)
|
||||
{
|
||||
int c;
|
||||
con_if_entry_t const *pIF = con_getPort(fd);
|
||||
|
||||
do
|
||||
{
|
||||
c = pIF->readchar(pIF->pInst);
|
||||
|
||||
} while(c > 0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
int readchar(int fd)
|
||||
{
|
||||
int c;
|
||||
con_if_entry_t const *pIF = con_getPort(fd);
|
||||
|
||||
assert(pIF);
|
||||
|
||||
// busy read
|
||||
do
|
||||
{
|
||||
c = pIF->readchar(pIF->pInst);
|
||||
|
||||
} while(c < 0);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void writechar(int fd, char c)
|
||||
{
|
||||
con_if_entry_t const *pIF = con_getPort(fd);
|
||||
|
||||
assert(pIF);
|
||||
|
||||
pIF->writechar(pIF->pInst, c);
|
||||
|
||||
}
|
||||
|
||||
void _putchar(int fd, char c)
|
||||
{
|
||||
con_if_entry_t const *pIF = con_getPort(fd);
|
||||
|
||||
assert(pIF);
|
||||
if (c == 0x0A)
|
||||
{
|
||||
pIF->writechar(pIF->pInst, 0x0D);
|
||||
}
|
||||
pIF->writechar(pIF->pInst, c);
|
||||
|
||||
}
|
||||
|
||||
char _getchar(int fd)
|
||||
{
|
||||
return readchar(fd);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: console.h
|
||||
* Author: jens
|
||||
*
|
||||
* Created on 8. Januar 2017, 14:25
|
||||
*/
|
||||
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int (*read_func_t)(void const *pInst);
|
||||
typedef void (*write_func_t)(void const *pInst, char c);
|
||||
typedef void (*open_func_t)(void const *pInst);
|
||||
typedef void (*close_func_t)(void const *pInst);
|
||||
|
||||
typedef struct _scon_if_entry_t
|
||||
{
|
||||
char const *pName;
|
||||
void const *pInst;
|
||||
open_func_t openFunc;
|
||||
close_func_t closeFunc;
|
||||
read_func_t readchar;
|
||||
write_func_t writechar;
|
||||
} con_if_entry_t;
|
||||
|
||||
typedef struct _scon_if_t
|
||||
{
|
||||
con_if_entry_t const *con_if_entry;
|
||||
size_t length;
|
||||
} con_if_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
// ---------------------------------------------------------------------------------
|
||||
int con_open(char const *pName);
|
||||
int con_close(int fd);
|
||||
void con_flush(int file);
|
||||
con_if_entry_t const* con_getPort(int file);
|
||||
|
||||
int readchar(int file);
|
||||
void writechar(int file, char c);
|
||||
char _getchar(int fd);
|
||||
void _putchar(int fd, char c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONSOLE_H */
|
||||
|
||||
+13
-621
@@ -5,21 +5,15 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "console.h"
|
||||
#include "libsys.h"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
// ---------------------------------------------------------------------------------
|
||||
void flush(uint32_t port);
|
||||
uint32_t GetPort(int file);
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Types
|
||||
// ---------------------------------------------------------------------------------
|
||||
void libsys_init(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_ctrl = (uint32_t*)SYS_VGA_CTRL;
|
||||
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
|
||||
|
||||
// Screen_clr();
|
||||
@@ -40,27 +34,12 @@ void libsys_init(void)
|
||||
dbg_init();
|
||||
|
||||
// flush stdin
|
||||
// flush(GetPort(0));
|
||||
// flush(con_getPort(0));
|
||||
|
||||
// Do some initializations here
|
||||
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
PORT_IN_UART_0 = 0,
|
||||
PORT_IN_UART_1,
|
||||
PORT_IN_PS2_0,
|
||||
PORT_IN_PS2_1
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PORT_OUT_UART0 = 0,
|
||||
PORT_OUT_UART1,
|
||||
PORT_OUT_VGA
|
||||
};
|
||||
|
||||
#define CALC_BAUD(b) \
|
||||
((uint32_t)((float)CPU_FREQ_HZ/(16*b) + 0.5f) - 1);
|
||||
|
||||
@@ -74,97 +53,6 @@ void UART1_setbaud(uint32_t baudrate)
|
||||
*((uint32_t*)SYS_UART1_BAUD) = CALC_BAUD(baudrate);
|
||||
}
|
||||
|
||||
uint32_t GetPort(int file)
|
||||
{
|
||||
if (file == 0) // STDIN
|
||||
return PORT_IN_UART_0;
|
||||
|
||||
if (file == 1) // STDOUT
|
||||
return PORT_OUT_UART0;
|
||||
|
||||
if (file == 2) // STDERR
|
||||
return PORT_OUT_VGA;
|
||||
|
||||
if (file == 10) // AUX0
|
||||
return PORT_IN_UART_1;
|
||||
|
||||
if (file == 11) // AUX1
|
||||
return PORT_OUT_UART1;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
IF_TYPE_INVALID = 0,
|
||||
IF_TYPE_UART,
|
||||
IF_TYPE_PS2,
|
||||
IF_TYPE_VGA
|
||||
};
|
||||
|
||||
typedef struct _suart_if_t
|
||||
{
|
||||
volatile uint32_t *pCTRL;
|
||||
volatile uint32_t *pDATA;
|
||||
volatile uint32_t *pBAUD;
|
||||
} uart_if_t;
|
||||
|
||||
typedef struct _sps2_if_t
|
||||
{
|
||||
volatile uint32_t *pCTRL;
|
||||
volatile uint32_t *pDATA;
|
||||
} ps2_if_t;
|
||||
|
||||
typedef struct _svga_if_t
|
||||
{
|
||||
volatile uint32_t *pCTRL;
|
||||
volatile uint32_t *pDATA;
|
||||
volatile uint32_t *pCSRX;
|
||||
volatile uint32_t *pCSRY;
|
||||
} vga_if_t;
|
||||
|
||||
typedef struct _scon_if_in_t
|
||||
{
|
||||
uint32_t type;
|
||||
void *pIF;
|
||||
} con_if_in_t;
|
||||
|
||||
typedef struct _scon_if_out_t
|
||||
{
|
||||
uint32_t type;
|
||||
void *pIF;
|
||||
} con_if_out_t;
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Globals
|
||||
// ---------------------------------------------------------------------------------
|
||||
static uart_if_t uart_if[2] =
|
||||
{
|
||||
{(uint32_t*)SYS_UART0_STAT, (uint32_t*)SYS_UART0_DATA, (uint32_t*)SYS_UART0_BAUD},
|
||||
{(uint32_t*)SYS_UART1_STAT, (uint32_t*)SYS_UART1_DATA, (uint32_t*)SYS_UART1_BAUD}
|
||||
};
|
||||
|
||||
extern ps2_if_t ps2_if[];
|
||||
|
||||
static vga_if_t vga_if =
|
||||
{
|
||||
(uint32_t*)SYS_VGA_CTRL, (uint32_t*)SYS_VGA_ASCII, (uint32_t*)SYS_VGA_POSX, (uint32_t*)SYS_VGA_POSY
|
||||
};
|
||||
|
||||
static con_if_in_t con_if_in[4] =
|
||||
{
|
||||
{IF_TYPE_UART, &uart_if[0]},
|
||||
{IF_TYPE_UART, &uart_if[1]},
|
||||
{IF_TYPE_PS2, &ps2_if[0]},
|
||||
{IF_TYPE_PS2, &ps2_if[1]}
|
||||
};
|
||||
|
||||
static con_if_out_t con_if_out[4] =
|
||||
{
|
||||
{IF_TYPE_UART, &uart_if[0]},
|
||||
{IF_TYPE_UART, &uart_if[1]},
|
||||
{IF_TYPE_VGA, &vga_if},
|
||||
{IF_TYPE_INVALID, NULL}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// MIPS specific
|
||||
// ---------------------------------------------------------------------------------
|
||||
@@ -308,495 +196,6 @@ void DCACHE_invalidate_at(uint32_t* pPtr)
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// BEGIN QUICK AND DIRTY
|
||||
// -------------------------------------------------------------
|
||||
//keymap for the AT keyboard SG layout
|
||||
typedef struct
|
||||
{
|
||||
uint8_t scancode;
|
||||
uint8_t unshifted;
|
||||
uint8_t shifted;
|
||||
uint8_t altered;
|
||||
} libsys_key_entry_t;
|
||||
|
||||
#define SHIFTED (1<<0)
|
||||
#define ALTERED (1<<1)
|
||||
#define CONTROLLED (1<<2)
|
||||
|
||||
static const libsys_key_entry_t __keymap_german[] =
|
||||
{
|
||||
{0x1c, 'a', 'A', 'a'},
|
||||
{0x32, 'b', 'B', 'b'},
|
||||
{0x21, 'c', 'C', 'c'},
|
||||
{0x23, 'd', 'D', 'd'},
|
||||
{0x24, 'e', 'E', '€'},
|
||||
{0x2b, 'f', 'F', 'f'},
|
||||
{0x34, 'g', 'G', 'g'},
|
||||
{0x33, 'h', 'H', 'h'},
|
||||
{0x43, 'i', 'I', 'i'},
|
||||
{0x3b, 'j', 'J', 'j'},
|
||||
{0x42, 'k', 'K', 'k'},
|
||||
{0x4b, 'l', 'L', 'l'},
|
||||
{0x3a, 'm', 'M', 'µ'},
|
||||
{0x31, 'n', 'N', 'n'},
|
||||
{0x44, 'o', 'O', 'o'},
|
||||
{0x4d, 'p', 'P', 'p'},
|
||||
{0x15, 'q', 'Q', '@'},
|
||||
{0x2d, 'r', 'R', 'r'},
|
||||
{0x1b, 's', 'S', 's'},
|
||||
{0x2c, 't', 'T', 't'},
|
||||
{0x3c, 'u', 'U', 'u'},
|
||||
{0x2a, 'v', 'V', 'v'},
|
||||
{0x1d, 'w', 'W', 'w'},
|
||||
{0x22, 'x', 'X', 'x'},
|
||||
{0x1a, 'y', 'Y', 'y'},
|
||||
{0x35, 'z', 'Z', 'z'},
|
||||
{0x16, '1', '!', '1'},
|
||||
{0x1e, '2', '"', '2'},
|
||||
{0x26, '3', '§', '3'},
|
||||
{0x25, '4', '$', '4'},
|
||||
{0x2e, '5', '%', '5'},
|
||||
{0x36, '6', '&', '6'},
|
||||
{0x3d, '7', '/', '{'},
|
||||
{0x3e, '8', '(', '['},
|
||||
{0x46, '9', ')', ']'},
|
||||
{0x45, '0', '=', '}'},
|
||||
{0x4e, 'ß', '?', '\\'},
|
||||
{0x29, ' ', ' ', ' '},
|
||||
{0x41, ',', ';', ','},
|
||||
{0x49, '.', ':', '.'},
|
||||
{0x4a, '-', '_', '-'},
|
||||
{0x52, 'ä', 'Ä', 'ä'},
|
||||
{0x4c, 'ö', 'Ö', 'ö'},
|
||||
{0x54, 'ü', 'Ü', 'ü'},
|
||||
{0x5a, '\n', '\n', '\n'}, //RETURN
|
||||
{0x5b, '+', '*', '~'},
|
||||
{0x5d, '#', '\'', '#'},
|
||||
{0x0e, '^', '°', '^'},
|
||||
{0x61, '<', '>', '|'},
|
||||
{0x66, '\b', '\b', '\b'},
|
||||
{0} //sentinel
|
||||
|
||||
};
|
||||
|
||||
static char __findkey(char scancode, int mode)
|
||||
{
|
||||
const libsys_key_entry_t *p = __keymap_german;
|
||||
while (p->scancode)
|
||||
{
|
||||
if (p->scancode == scancode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case SHIFTED:
|
||||
return p->shifted;
|
||||
case ALTERED:
|
||||
return p->altered;
|
||||
case ALTERED|SHIFTED:
|
||||
default:
|
||||
return p->unshifted;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RELEASE 0x8000
|
||||
#define SPECIALKEY 0x4000
|
||||
#define EXTENDED 0x2000
|
||||
#define X_CONTROLLED 0x0400
|
||||
#define X_ALTERED 0x0200
|
||||
#define X_SHIFTED 0x0100
|
||||
#define CAPS (SPECIALKEY|0x58)
|
||||
#define F1 (SPECIALKEY|0x05)
|
||||
#define F2 (SPECIALKEY|0x06)
|
||||
#define F3 (SPECIALKEY|0x04)
|
||||
#define F4 (SPECIALKEY|0x0c)
|
||||
#define F5 (SPECIALKEY|0x03)
|
||||
#define F6 (SPECIALKEY|0x0b)
|
||||
#define F7 (SPECIALKEY|0x83)
|
||||
#define F8 (SPECIALKEY|0x0a)
|
||||
#define F9 (SPECIALKEY|0x01)
|
||||
#define F10 (SPECIALKEY|0x09)
|
||||
#define F11 (SPECIALKEY|0x78)
|
||||
#define F12 (SPECIALKEY|0x07)
|
||||
#define ARROW_UP (SPECIALKEY|EXTENDED|0x75)
|
||||
#define ARROW_DOWN (SPECIALKEY|EXTENDED|0x72)
|
||||
#define ARROW_LEFT (SPECIALKEY|EXTENDED|0x6b)
|
||||
#define ARROW_RIGHT (SPECIALKEY|EXTENDED|0x74)
|
||||
|
||||
uint32_t PS2_readchar(ps2_if_t *pIF)
|
||||
{
|
||||
if (!pIF)
|
||||
return -1;
|
||||
|
||||
while (!(SYS_PS2_BIT_RX_AVAIL & *pIF->pCTRL));
|
||||
|
||||
return (*pIF->pDATA & 0xFF);
|
||||
|
||||
}
|
||||
|
||||
uint32_t con_readchar(ps2_if_t *pIF)
|
||||
{
|
||||
uint8_t c;
|
||||
static char mode = 0;
|
||||
static char nextrelease = 0;
|
||||
static char extended = 0;
|
||||
int flags = 0;
|
||||
int char_valid = 0;
|
||||
uint8_t key;
|
||||
|
||||
key = PS2_readchar(pIF);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 0xf0: //release key
|
||||
nextrelease = 1;
|
||||
break;
|
||||
case 0x14: //control key
|
||||
if (nextrelease)
|
||||
{
|
||||
mode &= ~CONTROLLED;
|
||||
} else
|
||||
{
|
||||
mode |= CONTROLLED;
|
||||
}
|
||||
nextrelease = 0;
|
||||
break;
|
||||
case 0x12: //left SHIFT
|
||||
case 0x59: //right SHIFT
|
||||
if (nextrelease)
|
||||
{
|
||||
mode &= ~SHIFTED;
|
||||
} else
|
||||
{
|
||||
mode |= SHIFTED;
|
||||
}
|
||||
nextrelease = 0;
|
||||
break;
|
||||
case 0x11: //left and right ALT (right one also with E0)
|
||||
if (nextrelease)
|
||||
{
|
||||
mode &= ~ALTERED;
|
||||
} else
|
||||
{
|
||||
mode |= ALTERED;
|
||||
}
|
||||
nextrelease = 0;
|
||||
break;
|
||||
case 0xe0: //extended key following
|
||||
extended = 1;
|
||||
break;
|
||||
default:
|
||||
if (nextrelease) flags |= RELEASE;
|
||||
if (extended) flags |= EXTENDED;
|
||||
flags |= mode << 8;
|
||||
c = __findkey(key, mode);
|
||||
char_valid = (c && ((flags & RELEASE) != RELEASE));
|
||||
nextrelease = 0;
|
||||
extended = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (char_valid)
|
||||
{
|
||||
// fprintf(stderr, "c = %c (%d), flags = 0x%08X, mode = 0x%08X\n", c, c, flags, mode);
|
||||
return c;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
// -------------------------------------------------------------
|
||||
// END QUICK AND DIRTY
|
||||
// -------------------------------------------------------------
|
||||
|
||||
// ------------------------------------
|
||||
// Low-level I/O
|
||||
// ------------------------------------
|
||||
int UART_readchar(uart_if_t *pIF)
|
||||
{
|
||||
if (!pIF)
|
||||
return -1;
|
||||
|
||||
if (SYS_UART_BIT_RX_AVAIL & *pIF->pCTRL)
|
||||
return (*pIF->pDATA & 0xFF);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UART_writechar(uart_if_t *pIF, char c)
|
||||
{
|
||||
if (!pIF)
|
||||
return;
|
||||
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pIF->pCTRL) != 0);
|
||||
|
||||
*pIF->pDATA = (uint32_t)c;
|
||||
}
|
||||
|
||||
void cg_writechar(vga_if_t *pIF, char c)
|
||||
{
|
||||
uint32_t code;
|
||||
|
||||
if (!pIF)
|
||||
return;
|
||||
|
||||
// Output translation
|
||||
switch(c)
|
||||
{
|
||||
case 'Ä':
|
||||
code = 196;
|
||||
break;
|
||||
|
||||
case 'ä':
|
||||
code = 228;
|
||||
break;
|
||||
|
||||
case 'Ö':
|
||||
code = 214;
|
||||
break;
|
||||
|
||||
case 'ö':
|
||||
code = 246;
|
||||
break;
|
||||
|
||||
case 'Ü':
|
||||
code = 220;
|
||||
break;
|
||||
|
||||
case 'ü':
|
||||
code = 252;
|
||||
break;
|
||||
|
||||
case '&':
|
||||
code = 230;
|
||||
break;
|
||||
|
||||
case '§':
|
||||
code = 167;
|
||||
break;
|
||||
|
||||
case 'ß':
|
||||
code = 223;
|
||||
break;
|
||||
|
||||
case '°':
|
||||
code = 176;
|
||||
break;
|
||||
|
||||
case 'µ':
|
||||
code = 181;
|
||||
break;
|
||||
|
||||
default:
|
||||
code = (uint32_t)c;
|
||||
break;
|
||||
}
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pDATA = code;
|
||||
}
|
||||
|
||||
void cg_set_csr_x(vga_if_t *pIF, uint32_t coord)
|
||||
{
|
||||
if (!pIF)
|
||||
return;
|
||||
|
||||
// Set cursor
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRX = coord;
|
||||
}
|
||||
|
||||
void cg_set_csr_y(vga_if_t *pIF, uint32_t coord)
|
||||
{
|
||||
if (!pIF)
|
||||
return;
|
||||
|
||||
// Set cursor
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRY = coord;
|
||||
}
|
||||
|
||||
void cg_clr_line(vga_if_t *pIF)
|
||||
{
|
||||
if (!pIF)
|
||||
return;
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCTRL |= SYS_VGA_BIT_CLRLINE;
|
||||
}
|
||||
|
||||
void cg_clr_screen(vga_if_t *pIF)
|
||||
{
|
||||
|
||||
if (!pIF)
|
||||
return;
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCTRL |= SYS_VGA_BIT_CLRSCR;
|
||||
|
||||
// Cursor home
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRX = 0;
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRY = 0;
|
||||
|
||||
}
|
||||
|
||||
void Screen_clr(void)
|
||||
{
|
||||
cg_clr_screen(&vga_if);
|
||||
}
|
||||
|
||||
void Screen_line_clr(void)
|
||||
{
|
||||
cg_clr_line(&vga_if);
|
||||
}
|
||||
|
||||
void Screen_csr_set_x(uint32_t coord)
|
||||
{
|
||||
cg_set_csr_x(&vga_if, coord);
|
||||
}
|
||||
|
||||
void Screen_csr_set_y(uint32_t coord)
|
||||
{
|
||||
cg_set_csr_y(&vga_if, coord);
|
||||
}
|
||||
|
||||
uint32_t Screen_get_resx(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES;
|
||||
|
||||
return (0xFFF & (*pVGA_res >> 0));
|
||||
}
|
||||
|
||||
uint32_t Screen_get_resy(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES;
|
||||
|
||||
return (0xFFF & (*pVGA_res >> 12));
|
||||
}
|
||||
|
||||
uint32_t Screen_get_fps(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES;
|
||||
|
||||
return (0xFF & (*pVGA_res >> 24));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
void flush(uint32_t port)
|
||||
{
|
||||
int c;
|
||||
con_if_in_t *pIF;
|
||||
|
||||
pIF = &con_if_in[port];
|
||||
|
||||
do
|
||||
{
|
||||
switch(pIF->type)
|
||||
{
|
||||
case IF_TYPE_UART:
|
||||
c = UART_readchar((uart_if_t*)pIF->pIF);
|
||||
break;
|
||||
|
||||
case IF_TYPE_PS2:
|
||||
c = con_readchar((ps2_if_t*)pIF->pIF);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} while(c > 0);
|
||||
}
|
||||
|
||||
char readchar(uint32_t port)
|
||||
{
|
||||
int c;
|
||||
con_if_in_t *pIF;
|
||||
|
||||
pIF = &con_if_in[port];
|
||||
|
||||
do
|
||||
{
|
||||
switch(pIF->type)
|
||||
{
|
||||
case IF_TYPE_UART:
|
||||
c = UART_readchar((uart_if_t*)pIF->pIF);
|
||||
break;
|
||||
|
||||
case IF_TYPE_PS2:
|
||||
c = con_readchar((ps2_if_t*)pIF->pIF);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} while(c < 0);
|
||||
|
||||
return (char)c;
|
||||
}
|
||||
|
||||
void writechar(uint32_t port, char c)
|
||||
{
|
||||
con_if_out_t *pIF;
|
||||
|
||||
pIF = &con_if_out[port];
|
||||
|
||||
switch(pIF->type)
|
||||
{
|
||||
case IF_TYPE_UART:
|
||||
UART_writechar((uart_if_t*)pIF->pIF, c);
|
||||
break;
|
||||
|
||||
case IF_TYPE_VGA:
|
||||
cg_writechar((vga_if_t*)pIF->pIF, c);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _putchar(uint32_t port, char c)
|
||||
{
|
||||
|
||||
con_if_out_t *pIF;
|
||||
|
||||
pIF = &con_if_out[port];
|
||||
|
||||
switch(pIF->type)
|
||||
{
|
||||
case IF_TYPE_UART:
|
||||
if (c == 0x0A)
|
||||
UART_writechar((uart_if_t*)pIF->pIF, 0x0D);
|
||||
UART_writechar((uart_if_t*)pIF->pIF, c);
|
||||
break;
|
||||
|
||||
case IF_TYPE_VGA:
|
||||
cg_writechar((vga_if_t*)pIF->pIF, c);
|
||||
if (c == 0x0A)
|
||||
{
|
||||
cg_clr_line((vga_if_t*)pIF->pIF);
|
||||
cg_writechar((vga_if_t*)pIF->pIF, 0x0D);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char _getchar(void)
|
||||
{
|
||||
return readchar(GetPort(0));
|
||||
}
|
||||
|
||||
void _exit (int exitcode)
|
||||
{
|
||||
fflush(stdout);
|
||||
@@ -951,44 +350,39 @@ int lseek(int file, int ptr, int dir)
|
||||
|
||||
int open(const char *name, int flags, int mode)
|
||||
{
|
||||
// sputs("open (\""); sputs(name); sputs("\")\n");
|
||||
errno = EIO;
|
||||
return -1;
|
||||
return con_open(name);
|
||||
}
|
||||
|
||||
int close(int file)
|
||||
{
|
||||
// sputs("close ("); print_word(file); sputs(")\n");
|
||||
return 0;
|
||||
return con_close(file);
|
||||
}
|
||||
|
||||
int read(int file, char *ptr, int len)
|
||||
{
|
||||
uint32_t port;
|
||||
int i;
|
||||
char c;
|
||||
|
||||
// sputs("read (file="); print_word(file); sputs(", len ="); print_word(len); sputs(")\n");
|
||||
i = 0;
|
||||
port = GetPort(file);
|
||||
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
c = readchar(port);
|
||||
c = readchar(file);
|
||||
|
||||
if (c == 0x04)
|
||||
break;
|
||||
|
||||
if ((c == 0x0D) || (c == 0x0A))
|
||||
{
|
||||
writechar(port, 0x0D);
|
||||
writechar(file, 0x0D);
|
||||
ptr[i++] = 0x0D;
|
||||
writechar(port, 0x0A);
|
||||
writechar(file, 0x0A);
|
||||
ptr[i++] = 0x0A;
|
||||
break;
|
||||
}
|
||||
|
||||
writechar(port, c);
|
||||
writechar(file, c);
|
||||
ptr[i++] = c;
|
||||
|
||||
}
|
||||
@@ -997,14 +391,12 @@ int read(int file, char *ptr, int len)
|
||||
|
||||
int write(int file, char *ptr, int len)
|
||||
{
|
||||
uint32_t port;
|
||||
int i = 0;
|
||||
|
||||
// sputs("write ("); print_word(file); sputs(")\n");
|
||||
|
||||
port = GetPort(file);
|
||||
for (i=0; i < len; i++)
|
||||
_putchar(port, *ptr++);
|
||||
_putchar(file, *ptr++);
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -1052,7 +444,7 @@ int sputs(char const *pStr)
|
||||
char const *start = pStr;
|
||||
|
||||
while(*pStr)
|
||||
_putchar(GetPort(1), *(pStr++));
|
||||
_putchar(1, *(pStr++));
|
||||
|
||||
return pStr - start;
|
||||
}
|
||||
@@ -1072,7 +464,7 @@ void print_byte(char byte)
|
||||
else
|
||||
c = nibble + 'A' - 10;
|
||||
|
||||
_putchar(GetPort(1), c);
|
||||
_putchar(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1145,7 +537,7 @@ void memdump(uint8_t *pBuf, int print_offset_only, int num_bytes_per_row, int le
|
||||
if((c < 0x20) || (c > 0x7F))
|
||||
c = '.';
|
||||
|
||||
_putchar(GetPort(1), c);
|
||||
_putchar(1, c);
|
||||
cnt_asc--;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -85,10 +85,7 @@ void DCACHE_invalidate_at(uint32_t* pPtr);
|
||||
|
||||
void UART0_setbaud(uint32_t baudrate);
|
||||
void UART1_setbaud(uint32_t baudrate);
|
||||
void UART2_setbaud(uint32_t baudrate);
|
||||
|
||||
char readchar(uint32_t port);
|
||||
void writechar(uint32_t port, char c);
|
||||
int write(int file, char *ptr, int len);
|
||||
int sputs(char const *pStr);
|
||||
void print_byte(char byte);
|
||||
@@ -97,20 +94,8 @@ void _exit (int exitcode);
|
||||
void sleep(unsigned ms);
|
||||
void usleep(unsigned us);
|
||||
|
||||
char _getchar(void);
|
||||
|
||||
void PrintBuffer8(uint8_t *pBuf, int nbpr, int len);
|
||||
void memdump(uint8_t *pBuf, int print_offset_only, int num_bytes_per_row, int len);
|
||||
|
||||
void Screen_clr(void);
|
||||
void Screen_line_clr(void);
|
||||
void Screen_csr_set_x(uint32_t coord);
|
||||
void Screen_csr_set_y(uint32_t coord);
|
||||
uint32_t Screen_get_resx(void);
|
||||
uint32_t Screen_get_resy(void);
|
||||
uint32_t Screen_get_fps(void);
|
||||
|
||||
|
||||
|
||||
#endif // LIBSYS_H
|
||||
|
||||
|
||||
+266
-52
@@ -1,9 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "libsys.h"
|
||||
#include "mips_ps2.h"
|
||||
|
||||
uint32_t con_readchar(ps2_if_t *pIF);
|
||||
|
||||
ps2_if_t ps2_if[2] =
|
||||
{
|
||||
{ps2_type_unknown, (uint32_t*)SYS_PS2_0_STAT, (uint32_t*)SYS_PS2_0_DATA},
|
||||
@@ -15,30 +18,40 @@ uint32_t PS2_get_num_if(void)
|
||||
return (sizeof(ps2_if)/sizeof(ps2_if_t));
|
||||
}
|
||||
|
||||
ps2_if_t *PS2_get_if(uint32_t port)
|
||||
int PS2_readchar(void const *pInst)
|
||||
{
|
||||
if (port < PS2_get_num_if())
|
||||
return &ps2_if[port];
|
||||
assert(pInst);
|
||||
ps2_if_t *pIF = (ps2_if_t*)pInst;
|
||||
|
||||
return NULL;
|
||||
return (int)con_readchar(pIF);
|
||||
}
|
||||
|
||||
void PS2_byte_write(uint32_t port, uint8_t byte)
|
||||
void PS2_open(void const *pInst)
|
||||
{
|
||||
ps2_if_t *pIF;
|
||||
assert(pInst);
|
||||
ps2_if_t *pIF = (ps2_if_t*)pInst;
|
||||
|
||||
pIF = &ps2_if[port];
|
||||
PS2_init(pIF);
|
||||
|
||||
}
|
||||
|
||||
void PS2_close(void const *pInst)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PS2_byte_write(ps2_if_t *pIF, uint8_t byte)
|
||||
{
|
||||
assert(pIF);
|
||||
|
||||
while(!(*pIF->pCTRL & SYS_PS2_BIT_TX_EMPTY));
|
||||
|
||||
*pIF->pDATA = (uint32_t)byte;
|
||||
}
|
||||
|
||||
uint32_t PS2_byte_read(uint32_t port, uint32_t timeout_ms)
|
||||
uint32_t PS2_byte_read(ps2_if_t *pIF, uint32_t timeout_ms)
|
||||
{
|
||||
ps2_if_t *pIF;
|
||||
|
||||
pIF = &ps2_if[port];
|
||||
assert(pIF);
|
||||
|
||||
while(!(*pIF->pCTRL & SYS_PS2_BIT_RX_AVAIL))
|
||||
{
|
||||
@@ -51,32 +64,30 @@ uint32_t PS2_byte_read(uint32_t port, uint32_t timeout_ms)
|
||||
return (uint32_t)*pIF->pDATA;
|
||||
}
|
||||
|
||||
uint32_t PS2_cmd(uint32_t port, uint8_t cmd, uint32_t ack_timeout_ms)
|
||||
uint32_t PS2_cmd(ps2_if_t *pIF, uint8_t cmd, uint32_t ack_timeout_ms)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
PS2_byte_write(port, cmd);
|
||||
result = PS2_byte_read(port, ack_timeout_ms);
|
||||
PS2_byte_write(pIF, cmd);
|
||||
result = PS2_byte_read(pIF, ack_timeout_ms);
|
||||
if (0xFA != result)
|
||||
{
|
||||
printf ("PS2_cmd(%d): no ACK received. Result = %08X\n", port, result);
|
||||
printf ("PS2_cmd(%p): no ACK received. Result = %08X\n", pIF->pCTRL, result);
|
||||
return PS2_ERR_PS2_PREFIX | result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PS2_flush(uint32_t port)
|
||||
void PS2_flush(ps2_if_t *pIF)
|
||||
{
|
||||
while (!IS_ERROR(PS2_byte_read(port, 10)));
|
||||
while (!IS_ERROR(PS2_byte_read(pIF, 10)));
|
||||
}
|
||||
|
||||
uint32_t PS2_init(uint32_t port)
|
||||
uint32_t PS2_init(ps2_if_t *pIF)
|
||||
{
|
||||
int i;
|
||||
ps2_if_t *pIF;
|
||||
uint8_t id[2];
|
||||
|
||||
pIF = &ps2_if[port];
|
||||
pIF->type = ps2_type_unknown;
|
||||
|
||||
uint32_t result;
|
||||
@@ -84,13 +95,13 @@ uint32_t PS2_init(uint32_t port)
|
||||
// Disable RX-interrupt
|
||||
*pIF->pCTRL &= ~SYS_PS2_BIT_RX_INTEN;
|
||||
|
||||
printf ("PS2_init(%d) - Initialize... ", port);
|
||||
printf ("PS2_init(%p) - Initialize... ", pIF->pCTRL);
|
||||
|
||||
// Flush buffer
|
||||
PS2_flush(port);
|
||||
PS2_flush(pIF);
|
||||
|
||||
// send RESET
|
||||
result = PS2_cmd(port, 0xFF, 1000);
|
||||
result = PS2_cmd(pIF, 0xFF, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("Reset error %08X\n", result);
|
||||
@@ -98,7 +109,7 @@ uint32_t PS2_init(uint32_t port)
|
||||
}
|
||||
|
||||
// Read BAT
|
||||
result = PS2_byte_read(port, 1000);
|
||||
result = PS2_byte_read(pIF, 1000);
|
||||
if (0xAA != result)
|
||||
{
|
||||
printf ("BAT error %08X\n", result);
|
||||
@@ -110,53 +121,53 @@ uint32_t PS2_init(uint32_t port)
|
||||
while(1)
|
||||
{
|
||||
// Read ID
|
||||
result = PS2_byte_read(port, 10);
|
||||
result = PS2_byte_read(pIF, 10);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
// No ID => keyboard
|
||||
printf ("PS2_init(%d) - Keyboard detected\n", port);
|
||||
printf ("PS2_init(%p) - Keyboard detected\n", pIF->pCTRL);
|
||||
|
||||
// send Get Device-ID
|
||||
result = PS2_cmd(port, 0xF2, 1000);
|
||||
result = PS2_cmd(pIF, 0xF2, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("Get Device-ID error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
id[0] = PS2_byte_read(port, 1000);
|
||||
id[1] = PS2_byte_read(port, 1000);
|
||||
printf ("PS2_init(%d) - Device-ID: %02X%02X\n", port, id[0], id[1]);
|
||||
id[0] = PS2_byte_read(pIF, 1000);
|
||||
id[1] = PS2_byte_read(pIF, 1000);
|
||||
printf ("PS2_init(%p) - Device-ID: %02X%02X\n", pIF->pCTRL, id[0], id[1]);
|
||||
|
||||
// Get Scan code set (phase 1)
|
||||
result = PS2_cmd(port, 0xF0, 1000);
|
||||
result = PS2_cmd(pIF, 0xF0, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("1. Get Scan code error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
// Get Scan code set (phase 2)
|
||||
result = PS2_cmd(port, 0x00, 1000);
|
||||
result = PS2_cmd(pIF, 0x00, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("2. Get Scan code error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
result = PS2_byte_read(port, 1000);
|
||||
printf ("PS2_init(%d) - Current scan code set = %d\n", port, result);
|
||||
result = PS2_byte_read(pIF, 1000);
|
||||
printf ("PS2_init(%p) - Current scan code set = %d\n", pIF->pCTRL, result);
|
||||
|
||||
// if Scan code SET != 2
|
||||
if (result != 2)
|
||||
{
|
||||
printf ("PS2_init(%d) - Set scan code set = 2\n", port);
|
||||
printf ("PS2_init(%p) - Set scan code set = 2\n", pIF->pCTRL);
|
||||
// Set Scan code set (phase 1)
|
||||
result = PS2_cmd(port, 0xF0, 1000);
|
||||
result = PS2_cmd(pIF, 0xF0, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("1. Set Scan code error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
// Set Scan code set (phase 2)
|
||||
result = PS2_cmd(port, 0x02, 1000);
|
||||
result = PS2_cmd(pIF, 0x02, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("2. Set Scan code error %08X\n", result);
|
||||
@@ -167,39 +178,39 @@ uint32_t PS2_init(uint32_t port)
|
||||
// Test LEDs
|
||||
for (i=0; i < 4; i++)
|
||||
{
|
||||
result = PS2_cmd(port, 0xED, 1000);
|
||||
result = PS2_cmd(pIF, 0xED, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("1. LED error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
result = PS2_cmd(port, 0x02, 1000);
|
||||
result = PS2_cmd(pIF, 0x02, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("2. LED error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
sleep(100);
|
||||
result = PS2_cmd(port, 0xED, 1000);
|
||||
result = PS2_cmd(pIF, 0xED, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("1. LED error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
result = PS2_cmd(port, 0x04, 1000);
|
||||
result = PS2_cmd(pIF, 0x04, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("2. LED error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
sleep(100);
|
||||
result = PS2_cmd(port, 0xED, 1000);
|
||||
result = PS2_cmd(pIF, 0xED, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("1. LED error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
result = PS2_cmd(port, 0x01, 1000);
|
||||
result = PS2_cmd(pIF, 0x01, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("2. LED error %08X\n", result);
|
||||
@@ -207,13 +218,13 @@ uint32_t PS2_init(uint32_t port)
|
||||
}
|
||||
sleep(100);
|
||||
}
|
||||
result = PS2_cmd(port, 0xED, 1000);
|
||||
result = PS2_cmd(pIF, 0xED, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("1. LED error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
result = PS2_cmd(port, 0x00, 1000);
|
||||
result = PS2_cmd(pIF, 0x00, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("2. LED error %08X\n", result);
|
||||
@@ -229,19 +240,19 @@ uint32_t PS2_init(uint32_t port)
|
||||
if (result == 0)
|
||||
{
|
||||
// We got zero => yes, it's a mouse
|
||||
printf ("PS2_init(%d) - Mouse device detected\n", port);
|
||||
printf ("PS2_init(%p) - Mouse device detected\n", pIF->pCTRL);
|
||||
|
||||
// send Get Device-ID
|
||||
result = PS2_cmd(port, 0xF2, 1000);
|
||||
result = PS2_cmd(pIF, 0xF2, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("Get Device-ID error %08X\n", result);
|
||||
break;
|
||||
}
|
||||
id[0] = PS2_byte_read(port, 1000);
|
||||
printf ("PS2_init(%d) - Device-ID: %02X\n", port, id[0]);
|
||||
printf ("PS2_init(%d) - Enable stream mode...", port);
|
||||
result = PS2_cmd(port, 0xF4, 1000);
|
||||
id[0] = PS2_byte_read(pIF, 1000);
|
||||
printf ("PS2_init(%p) - Device-ID: %02X\n", pIF->pCTRL, id[0]);
|
||||
printf ("PS2_init(%p) - Enable stream mode...", pIF->pCTRL);
|
||||
result = PS2_cmd(pIF, 0xF4, 1000);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
printf ("error %08X\n", result);
|
||||
@@ -255,7 +266,7 @@ uint32_t PS2_init(uint32_t port)
|
||||
}
|
||||
|
||||
// Flush buffer
|
||||
PS2_flush(port);
|
||||
PS2_flush(pIF);
|
||||
|
||||
if (IS_ERROR(result))
|
||||
return result;
|
||||
@@ -264,5 +275,208 @@ uint32_t PS2_init(uint32_t port)
|
||||
*pIF->pCTRL |= SYS_PS2_BIT_RX_INTEN;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// BEGIN QUICK AND DIRTY
|
||||
// -------------------------------------------------------------
|
||||
//keymap for the AT keyboard SG layout
|
||||
typedef struct
|
||||
{
|
||||
uint8_t scancode;
|
||||
uint8_t unshifted;
|
||||
uint8_t shifted;
|
||||
uint8_t altered;
|
||||
} libsys_key_entry_t;
|
||||
|
||||
#define SHIFTED (1<<0)
|
||||
#define ALTERED (1<<1)
|
||||
#define CONTROLLED (1<<2)
|
||||
|
||||
static const libsys_key_entry_t __keymap_german[] =
|
||||
{
|
||||
{0x1c, 'a', 'A', 'a'},
|
||||
{0x32, 'b', 'B', 'b'},
|
||||
{0x21, 'c', 'C', 'c'},
|
||||
{0x23, 'd', 'D', 'd'},
|
||||
{0x24, 'e', 'E', '€'},
|
||||
{0x2b, 'f', 'F', 'f'},
|
||||
{0x34, 'g', 'G', 'g'},
|
||||
{0x33, 'h', 'H', 'h'},
|
||||
{0x43, 'i', 'I', 'i'},
|
||||
{0x3b, 'j', 'J', 'j'},
|
||||
{0x42, 'k', 'K', 'k'},
|
||||
{0x4b, 'l', 'L', 'l'},
|
||||
{0x3a, 'm', 'M', 'µ'},
|
||||
{0x31, 'n', 'N', 'n'},
|
||||
{0x44, 'o', 'O', 'o'},
|
||||
{0x4d, 'p', 'P', 'p'},
|
||||
{0x15, 'q', 'Q', '@'},
|
||||
{0x2d, 'r', 'R', 'r'},
|
||||
{0x1b, 's', 'S', 's'},
|
||||
{0x2c, 't', 'T', 't'},
|
||||
{0x3c, 'u', 'U', 'u'},
|
||||
{0x2a, 'v', 'V', 'v'},
|
||||
{0x1d, 'w', 'W', 'w'},
|
||||
{0x22, 'x', 'X', 'x'},
|
||||
{0x1a, 'y', 'Y', 'y'},
|
||||
{0x35, 'z', 'Z', 'z'},
|
||||
{0x16, '1', '!', '1'},
|
||||
{0x1e, '2', '"', '2'},
|
||||
{0x26, '3', '§', '3'},
|
||||
{0x25, '4', '$', '4'},
|
||||
{0x2e, '5', '%', '5'},
|
||||
{0x36, '6', '&', '6'},
|
||||
{0x3d, '7', '/', '{'},
|
||||
{0x3e, '8', '(', '['},
|
||||
{0x46, '9', ')', ']'},
|
||||
{0x45, '0', '=', '}'},
|
||||
{0x4e, 'ß', '?', '\\'},
|
||||
{0x29, ' ', ' ', ' '},
|
||||
{0x41, ',', ';', ','},
|
||||
{0x49, '.', ':', '.'},
|
||||
{0x4a, '-', '_', '-'},
|
||||
{0x52, 'ä', 'Ä', 'ä'},
|
||||
{0x4c, 'ö', 'Ö', 'ö'},
|
||||
{0x54, 'ü', 'Ü', 'ü'},
|
||||
{0x5a, '\n', '\n', '\n'}, //RETURN
|
||||
{0x5b, '+', '*', '~'},
|
||||
{0x5d, '#', '\'', '#'},
|
||||
{0x0e, '^', '°', '^'},
|
||||
{0x61, '<', '>', '|'},
|
||||
{0x66, '\b', '\b', '\b'},
|
||||
{0} //sentinel
|
||||
|
||||
};
|
||||
|
||||
static char __findkey(char scancode, int mode)
|
||||
{
|
||||
const libsys_key_entry_t *p = __keymap_german;
|
||||
while (p->scancode)
|
||||
{
|
||||
if (p->scancode == scancode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case SHIFTED:
|
||||
return p->shifted;
|
||||
case ALTERED:
|
||||
return p->altered;
|
||||
case ALTERED|SHIFTED:
|
||||
default:
|
||||
return p->unshifted;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RELEASE 0x8000
|
||||
#define SPECIALKEY 0x4000
|
||||
#define EXTENDED 0x2000
|
||||
#define X_CONTROLLED 0x0400
|
||||
#define X_ALTERED 0x0200
|
||||
#define X_SHIFTED 0x0100
|
||||
#define CAPS (SPECIALKEY|0x58)
|
||||
#define F1 (SPECIALKEY|0x05)
|
||||
#define F2 (SPECIALKEY|0x06)
|
||||
#define F3 (SPECIALKEY|0x04)
|
||||
#define F4 (SPECIALKEY|0x0c)
|
||||
#define F5 (SPECIALKEY|0x03)
|
||||
#define F6 (SPECIALKEY|0x0b)
|
||||
#define F7 (SPECIALKEY|0x83)
|
||||
#define F8 (SPECIALKEY|0x0a)
|
||||
#define F9 (SPECIALKEY|0x01)
|
||||
#define F10 (SPECIALKEY|0x09)
|
||||
#define F11 (SPECIALKEY|0x78)
|
||||
#define F12 (SPECIALKEY|0x07)
|
||||
#define ARROW_UP (SPECIALKEY|EXTENDED|0x75)
|
||||
#define ARROW_DOWN (SPECIALKEY|EXTENDED|0x72)
|
||||
#define ARROW_LEFT (SPECIALKEY|EXTENDED|0x6b)
|
||||
#define ARROW_RIGHT (SPECIALKEY|EXTENDED|0x74)
|
||||
|
||||
static uint32_t readchar(ps2_if_t *pIF)
|
||||
{
|
||||
if (!pIF)
|
||||
return -1;
|
||||
|
||||
while (!(SYS_PS2_BIT_RX_AVAIL & *pIF->pCTRL));
|
||||
|
||||
return (*pIF->pDATA & 0xFF);
|
||||
|
||||
}
|
||||
|
||||
uint32_t con_readchar(ps2_if_t *pIF)
|
||||
{
|
||||
uint8_t c;
|
||||
static char mode = 0;
|
||||
static char nextrelease = 0;
|
||||
static char extended = 0;
|
||||
int flags = 0;
|
||||
int char_valid = 0;
|
||||
uint8_t key;
|
||||
|
||||
key = readchar(pIF);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 0xf0: //release key
|
||||
nextrelease = 1;
|
||||
break;
|
||||
case 0x14: //control key
|
||||
if (nextrelease)
|
||||
{
|
||||
mode &= ~CONTROLLED;
|
||||
} else
|
||||
{
|
||||
mode |= CONTROLLED;
|
||||
}
|
||||
nextrelease = 0;
|
||||
break;
|
||||
case 0x12: //left SHIFT
|
||||
case 0x59: //right SHIFT
|
||||
if (nextrelease)
|
||||
{
|
||||
mode &= ~SHIFTED;
|
||||
} else
|
||||
{
|
||||
mode |= SHIFTED;
|
||||
}
|
||||
nextrelease = 0;
|
||||
break;
|
||||
case 0x11: //left and right ALT (right one also with E0)
|
||||
if (nextrelease)
|
||||
{
|
||||
mode &= ~ALTERED;
|
||||
} else
|
||||
{
|
||||
mode |= ALTERED;
|
||||
}
|
||||
nextrelease = 0;
|
||||
break;
|
||||
case 0xe0: //extended key following
|
||||
extended = 1;
|
||||
break;
|
||||
default:
|
||||
if (nextrelease) flags |= RELEASE;
|
||||
if (extended) flags |= EXTENDED;
|
||||
flags |= mode << 8;
|
||||
c = __findkey(key, mode);
|
||||
char_valid = (c && ((flags & RELEASE) != RELEASE));
|
||||
nextrelease = 0;
|
||||
extended = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (char_valid)
|
||||
{
|
||||
// fprintf(stderr, "c = %c (%d), flags = 0x%08X, mode = 0x%08X\n", c, c, flags, mode);
|
||||
return c;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
// -------------------------------------------------------------
|
||||
// END QUICK AND DIRTY
|
||||
// -------------------------------------------------------------
|
||||
|
||||
+10
-6
@@ -33,11 +33,15 @@ typedef struct _sps2_if_t
|
||||
// Functions
|
||||
// --------------------------------------------------
|
||||
uint32_t PS2_get_num_if(void);
|
||||
ps2_if_t *PS2_get_if(uint32_t port);
|
||||
uint32_t PS2_init(uint32_t port);
|
||||
void PS2_byte_write(uint32_t port, uint8_t byte);
|
||||
uint32_t PS2_byte_read(uint32_t port, uint32_t timeout_ms);
|
||||
uint32_t PS2_cmd(uint32_t port, uint8_t cmd, uint32_t ack_timeout_ms);
|
||||
void PS2_flush(uint32_t port);
|
||||
uint32_t PS2_init(ps2_if_t *pIF);
|
||||
void PS2_byte_write(ps2_if_t *pIF, uint8_t byte);
|
||||
uint32_t PS2_byte_read(ps2_if_t *pIF, uint32_t timeout_ms);
|
||||
|
||||
int PS2_readchar(void const *pInst);
|
||||
void PS2_open(void const *pInst);
|
||||
void PS2_close(void const *pInst);
|
||||
|
||||
uint32_t PS2_cmd(ps2_if_t *pIF, uint8_t cmd, uint32_t ack_timeout_ms);
|
||||
void PS2_flush(ps2_if_t *pIF);
|
||||
|
||||
#endif // PS2_H
|
||||
|
||||
Executable
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <board.h>
|
||||
#include "screen.h"
|
||||
|
||||
vga_if_t vga_if =
|
||||
{
|
||||
(uint32_t*)SYS_VGA_CTRL, (uint32_t*)SYS_VGA_ASCII, (uint32_t*)SYS_VGA_POSX, (uint32_t*)SYS_VGA_POSY
|
||||
};
|
||||
|
||||
void cg_open(void const *pInst)
|
||||
{
|
||||
assert (pInst);
|
||||
|
||||
vga_if_t *pIF = (vga_if_t*)pInst;
|
||||
cg_clr_screen(&vga_if);
|
||||
}
|
||||
|
||||
void cg_close(void const *pInst)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cg_writechar(void const *pInst, char c)
|
||||
{
|
||||
assert (pInst);
|
||||
|
||||
vga_if_t *pIF = (vga_if_t*)pInst;
|
||||
uint32_t code;
|
||||
|
||||
// Output translation
|
||||
switch(c)
|
||||
{
|
||||
case 'Ä':
|
||||
code = 196;
|
||||
break;
|
||||
|
||||
case 'ä':
|
||||
code = 228;
|
||||
break;
|
||||
|
||||
case 'Ö':
|
||||
code = 214;
|
||||
break;
|
||||
|
||||
case 'ö':
|
||||
code = 246;
|
||||
break;
|
||||
|
||||
case 'Ü':
|
||||
code = 220;
|
||||
break;
|
||||
|
||||
case 'ü':
|
||||
code = 252;
|
||||
break;
|
||||
|
||||
case '&':
|
||||
code = 230;
|
||||
break;
|
||||
|
||||
case '§':
|
||||
code = 167;
|
||||
break;
|
||||
|
||||
case 'ß':
|
||||
code = 223;
|
||||
break;
|
||||
|
||||
case '°':
|
||||
code = 176;
|
||||
break;
|
||||
|
||||
case 'µ':
|
||||
code = 181;
|
||||
break;
|
||||
|
||||
default:
|
||||
code = (uint32_t)c;
|
||||
break;
|
||||
}
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pDATA = code;
|
||||
|
||||
if (c == 0x0A)
|
||||
{
|
||||
cg_clr_line(pIF);
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pDATA = 0x0D;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void cg_set_csr_x(vga_if_t *pIF, uint32_t coord)
|
||||
{
|
||||
assert (pIF);
|
||||
|
||||
// Set cursor
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRX = coord;
|
||||
}
|
||||
|
||||
void cg_set_csr_y(vga_if_t *pIF, uint32_t coord)
|
||||
{
|
||||
assert (pIF);
|
||||
|
||||
// Set cursor
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRY = coord;
|
||||
}
|
||||
|
||||
void cg_clr_line(vga_if_t *pIF)
|
||||
{
|
||||
assert (pIF);
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCTRL |= SYS_VGA_BIT_CLRLINE;
|
||||
}
|
||||
|
||||
void cg_clr_screen(vga_if_t *pIF)
|
||||
{
|
||||
assert (pIF);
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCTRL |= SYS_VGA_BIT_CLRSCR;
|
||||
|
||||
// Cursor home
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRX = 0;
|
||||
|
||||
while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY));
|
||||
*pIF->pCSRY = 0;
|
||||
|
||||
}
|
||||
|
||||
uint32_t Screen_get_resx(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES;
|
||||
|
||||
return (0xFFF & (*pVGA_res >> 0));
|
||||
}
|
||||
|
||||
uint32_t Screen_get_resy(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES;
|
||||
|
||||
return (0xFFF & (*pVGA_res >> 12));
|
||||
}
|
||||
|
||||
uint32_t Screen_get_fps(void)
|
||||
{
|
||||
uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES;
|
||||
|
||||
return (0xFF & (*pVGA_res >> 24));
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: screen.h
|
||||
* Author: jens
|
||||
*
|
||||
* Created on 8. Januar 2017, 14:22
|
||||
*/
|
||||
|
||||
#ifndef SCREEN_H
|
||||
#define SCREEN_H
|
||||
|
||||
typedef struct _svga_if_t
|
||||
{
|
||||
volatile uint32_t *pCTRL;
|
||||
volatile uint32_t *pDATA;
|
||||
volatile uint32_t *pCSRX;
|
||||
volatile uint32_t *pCSRY;
|
||||
} vga_if_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void cg_set_csr_x(vga_if_t *pIF, uint32_t coord);
|
||||
void cg_set_csr_y(vga_if_t *pIF, uint32_t coord);
|
||||
void cg_clr_line(vga_if_t *pIF);
|
||||
void cg_clr_screen(vga_if_t *pIF);
|
||||
|
||||
uint32_t Screen_get_resx(void);
|
||||
uint32_t Screen_get_resy(void);
|
||||
uint32_t Screen_get_fps(void);
|
||||
|
||||
void cg_writechar(void const *pInst, char c);
|
||||
void cg_open(void const *pInst);
|
||||
void cg_close(void const *pInst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SCREEN_H */
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <board.h>
|
||||
#include "uart.h"
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Globals
|
||||
// ---------------------------------------------------------------------------------
|
||||
uart_if_t uart_if[2] =
|
||||
{
|
||||
{(uint32_t*)SYS_UART0_STAT, (uint32_t*)SYS_UART0_DATA, (uint32_t*)SYS_UART0_BAUD},
|
||||
{(uint32_t*)SYS_UART1_STAT, (uint32_t*)SYS_UART1_DATA, (uint32_t*)SYS_UART1_BAUD}
|
||||
};
|
||||
|
||||
// ------------------------------------
|
||||
// Low-level I/O
|
||||
// ------------------------------------
|
||||
int UART_readchar(void const *pInst)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
if (SYS_UART_BIT_RX_AVAIL & *pReg->pCTRL)
|
||||
return (*pReg->pDATA & 0xFF);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UART_writechar(void const *pInst, char c)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pReg->pCTRL) != 0);
|
||||
|
||||
*pReg->pDATA = (uint32_t)c;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: uart.h
|
||||
* Author: jens
|
||||
*
|
||||
* Created on 9. Januar 2017, 08:05
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef UART_H
|
||||
#define UART_H
|
||||
|
||||
typedef struct _suart_if_t
|
||||
{
|
||||
volatile uint32_t *pCTRL;
|
||||
volatile uint32_t *pDATA;
|
||||
volatile uint32_t *pBAUD;
|
||||
} uart_if_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int UART_readchar(void const *pInst);
|
||||
void UART_writechar(void const *pInst, char c);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* UART_H */
|
||||
|
||||
+12
-9
@@ -5,12 +5,14 @@
|
||||
#include <sys/times.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define CPU_FREQ_HZ 100000000
|
||||
#include <console.h>
|
||||
#include "libsys.h"
|
||||
#include "irq.h"
|
||||
#include "mips_gfx.h"
|
||||
#include "mips_ps2.h"
|
||||
#include "libsys/console.h"
|
||||
|
||||
#define PS2_NUM_IF 2
|
||||
char buffer[16384];
|
||||
char * volatile pPtr_r;
|
||||
char * volatile pPtr_w;
|
||||
@@ -21,6 +23,7 @@ static gfx_t gfx;
|
||||
static volatile int _g_posx, _g_posy;
|
||||
static volatile g_btn_l, g_btn_r;
|
||||
static volatile uint32_t g_color;
|
||||
static int ps2_fd[PS2_NUM_IF];
|
||||
|
||||
// -------------------------------------------------------------
|
||||
void handler0(void)
|
||||
@@ -82,15 +85,15 @@ void handler5(void)
|
||||
void handler6(void)
|
||||
{
|
||||
int p, i;
|
||||
ps2_if_t *pIF;
|
||||
ps2_if_t const *pIF;
|
||||
uint8_t mouse_rsp[3];
|
||||
uint32_t timeout_count, key;
|
||||
|
||||
int32_t dx, dy;
|
||||
|
||||
for (p=0; p < PS2_get_num_if(); p++)
|
||||
|
||||
for (p=0; p < PS2_NUM_IF; p++)
|
||||
{
|
||||
pIF = PS2_get_if(p);
|
||||
pIF = (ps2_if_t const *)con_getPort(ps2_fd[p])->pInst;
|
||||
if (SYS_PS2_BIT_RX_ERR_FLAG & *pIF->pCTRL)
|
||||
fprintf(stderr, "PS2[%d]: Status = 0x%08X\n", p, *pIF->pCTRL);
|
||||
|
||||
@@ -235,8 +238,8 @@ int main(void)
|
||||
printf("UART0 Status = 0x%8.8X\n", *pUART0_stat);
|
||||
printf("UART1 Status = 0x%8.8X\n", *pUART1_stat);
|
||||
|
||||
PS2_init(0);
|
||||
PS2_init(1);
|
||||
ps2_fd[0] = open("PS2-0", 0, 0);
|
||||
ps2_fd[1] = open("PS2-1", 0, 0);
|
||||
|
||||
sputs("r: "); print_word((int)pPtr_r); sputs("\n");
|
||||
sputs("w: "); print_word((int)pPtr_w); sputs("\n");
|
||||
@@ -253,8 +256,8 @@ int main(void)
|
||||
printf("Du schriebst: %s\n", string);
|
||||
|
||||
// Flush buffer
|
||||
PS2_flush(0);
|
||||
PS2_flush(1);
|
||||
PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[0])->pInst));
|
||||
PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[1])->pInst));
|
||||
|
||||
printf("Start:\n");
|
||||
|
||||
|
||||
+10
-8
@@ -5,12 +5,13 @@
|
||||
#include <sys/times.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define CPU_FREQ_HZ 100000000
|
||||
#include <console.h>
|
||||
#include "libsys.h"
|
||||
#include "irq.h"
|
||||
#include "mips_gfx.h"
|
||||
#include "mips_ps2.h"
|
||||
|
||||
#define PS2_NUM_IF 2
|
||||
static volatile int32_t mouse_x;
|
||||
static volatile int32_t mouse_y;
|
||||
static box_t box_even, box_odd, line_h_even, line_v_even, line_h_odd, line_v_odd, cross_v, cross_h;
|
||||
@@ -18,6 +19,7 @@ static gfx_t gfx;
|
||||
static volatile int _g_posx, _g_posy;
|
||||
static volatile g_btn_l, g_btn_r;
|
||||
static volatile uint32_t g_color;
|
||||
static int ps2_fd[PS2_NUM_IF];
|
||||
|
||||
// -------------------------------------------------------------
|
||||
void handler5(void)
|
||||
@@ -32,15 +34,15 @@ void handler5(void)
|
||||
void handler6(void)
|
||||
{
|
||||
int p, i;
|
||||
ps2_if_t *pIF;
|
||||
ps2_if_t const *pIF;
|
||||
uint8_t mouse_rsp[3];
|
||||
uint32_t timeout_count, key;
|
||||
|
||||
int32_t dx, dy;
|
||||
|
||||
for (p=0; p < PS2_get_num_if(); p++)
|
||||
for (p=0; p < PS2_NUM_IF; p++)
|
||||
{
|
||||
pIF = PS2_get_if(p);
|
||||
pIF = (ps2_if_t const *)con_getPort(ps2_fd[p])->pInst;
|
||||
if (SYS_PS2_BIT_RX_ERR_FLAG & *pIF->pCTRL)
|
||||
fprintf(stderr, "PS2[%d]: Status = 0x%08X\n", p, *pIF->pCTRL);
|
||||
|
||||
@@ -155,12 +157,12 @@ int main(void)
|
||||
GFX_show(&gfx);
|
||||
printf("VGA status = %08X\n", *pVGA_ctrl);
|
||||
|
||||
PS2_init(0);
|
||||
PS2_init(1);
|
||||
ps2_fd[0] = open("PS2-0", 0, 0);
|
||||
ps2_fd[1] = open("PS2-1", 0, 0);
|
||||
|
||||
// Flush buffer
|
||||
PS2_flush(0);
|
||||
PS2_flush(1);
|
||||
PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[0])->pInst));
|
||||
PS2_flush((ps2_if_t*)(con_getPort(ps2_fd[1])->pInst));
|
||||
|
||||
// interrupt_enable(5);
|
||||
interrupt_enable(6);
|
||||
|
||||
+1
-1
@@ -1058,7 +1058,7 @@ int main (void)
|
||||
memcpy(pPic, pFlashPicture, 800*600*sizeof(uint32_t));
|
||||
|
||||
g_cnt = 1;
|
||||
Screen_clr();
|
||||
int screen_fd = open("VGA-0", 0, 0);
|
||||
gpio_init(&gpio_if, SYS_GPIO_0_BASE);
|
||||
|
||||
*pVGA_cgcol = 0x00FFFFFF;
|
||||
|
||||
Reference in New Issue
Block a user