diff options
| author | cheapie <cheapiephp@gmail.com> | 2026-06-06 12:42:38 -0500 |
|---|---|---|
| committer | cheapie <cheapiephp@gmail.com> | 2026-06-06 12:42:38 -0500 |
| commit | 95311ab84fb8ea6a5509aaa909be825c74e691ca (patch) | |
| tree | 35f4753c0961fe223a352f07662244e548bea059 /assembly | |
| parent | 2b1c27b2b6ae78a043ecae25603939c76d63956e (diff) | |
| download | rvcontroller-95311ab84fb8ea6a5509aaa909be825c74e691ca.tar rvcontroller-95311ab84fb8ea6a5509aaa909be825c74e691ca.tar.gz rvcontroller-95311ab84fb8ea6a5509aaa909be825c74e691ca.tar.bz2 rvcontroller-95311ab84fb8ea6a5509aaa909be825c74e691ca.tar.xz rvcontroller-95311ab84fb8ea6a5509aaa909be825c74e691ca.zip | |
Add (experimental for now) mesecons I/O support
Diffstat (limited to 'assembly')
| -rw-r--r-- | assembly/meseconsio/Makefile | 24 | ||||
| -rw-r--r-- | assembly/meseconsio/meseconsio.S | 30 | ||||
| -rwxr-xr-x | assembly/meseconsio/meseconsio.elf | bin | 0 -> 5348 bytes | |||
| -rw-r--r-- | assembly/meseconsio/meseconsio.hex | 7 | ||||
| -rw-r--r-- | assembly/meseconsio/meseconsio.o | bin | 0 -> 1192 bytes | |||
| l--------- | assembly/meseconsio/rvcontroller.ld | 1 |
6 files changed, 62 insertions, 0 deletions
diff --git a/assembly/meseconsio/Makefile b/assembly/meseconsio/Makefile new file mode 100644 index 0000000..786418a --- /dev/null +++ b/assembly/meseconsio/Makefile @@ -0,0 +1,24 @@ +MARCH ?= rv32imacbzicntr_zicond_zicsr_zifencei_zihintpause_zilsd_zclsd_zabha_zacas_zawrs_zbkb_zbkx_zcb_zcmp_zcmt + +.PHONY: all dump load clean + +all: meseconsio.hex + +meseconsio.o: meseconsio.S + riscv32-none-elf-as -I../rvcontroller-libraries -march=${MARCH} -o meseconsio.o meseconsio.S + +meseconsio.elf: meseconsio.o + riscv32-none-elf-ld -T rvcontroller.ld --no-warn-rwx-segments -o meseconsio.elf meseconsio.o + +dump: meseconsio.elf + riscv32-none-elf-objdump -d meseconsio.elf + +meseconsio.hex: meseconsio.elf + riscv32-none-elf-objcopy -O ihex meseconsio.elf meseconsio.hex + +load: meseconsio.hex + bash -c "wl-copy < meseconsio.hex" + +clean: + rm -f meseconsio.bin meseconsio.elf meseconsio.o + diff --git a/assembly/meseconsio/meseconsio.S b/assembly/meseconsio/meseconsio.S new file mode 100644 index 0000000..f2a441f --- /dev/null +++ b/assembly/meseconsio/meseconsio.S @@ -0,0 +1,30 @@ + li s0,0xffff0000 + csrw 0x801,s0 # Set MMIO base address + + li t0,0x7 # Pin D input, others output + sb t0,0(s0) # Write to mesecons I/O direction register + +start: lr.w x0,0(s0) # Establish a reservation set on the mesecons I/O region + wrs.nto # Wait for it to become invalid + lb t0,1(s0) # Read the mesecons I/O data + andi t1,t0,0x8 # Is pin D on? + beqz t1,start # If not, go wait again + + li t0,1 # only A on + sb t0,1(s0) + pause + pause + pause + li t0,2 # only B on + sb t0,1(s0) + pause + pause + pause + li t0,4 # only C on + sb t0,1(s0) + pause + pause + pause + li t0,0 # all off + sb t0,1(s0) + j start diff --git a/assembly/meseconsio/meseconsio.elf b/assembly/meseconsio/meseconsio.elf Binary files differnew file mode 100755 index 0000000..09468fe --- /dev/null +++ b/assembly/meseconsio/meseconsio.elf diff --git a/assembly/meseconsio/meseconsio.hex b/assembly/meseconsio/meseconsio.hex new file mode 100644 index 0000000..5feb581 --- /dev/null +++ b/assembly/meseconsio/meseconsio.hex @@ -0,0 +1,7 @@ +:100000004174731014809D42230054002F2004106B
+:100010007300D0008302140013F38200E30803FE90
+:100020008542A30054000F0000010F0000010F00E3
+:1000300000018942A30054000F0000010F000001DD
+:100040000F0000019142A30054000F0000010F00B7
+:0E00500000010F0000018142A300540045BFD3
+:00000001FF
diff --git a/assembly/meseconsio/meseconsio.o b/assembly/meseconsio/meseconsio.o Binary files differnew file mode 100644 index 0000000..33ce2df --- /dev/null +++ b/assembly/meseconsio/meseconsio.o diff --git a/assembly/meseconsio/rvcontroller.ld b/assembly/meseconsio/rvcontroller.ld new file mode 120000 index 0000000..bc01402 --- /dev/null +++ b/assembly/meseconsio/rvcontroller.ld @@ -0,0 +1 @@ +../../rvcontroller.ld
\ No newline at end of file |
