Skip to content

Commit

Permalink
Implement support for filesystem calls
Browse files Browse the repository at this point in the history
This includes stdio fopen/fread/fseek/fclose, as well as the
posix open/read/lseek/close/fstat.
These use a very simple read only filesystem format. A tool
is included to create these filesystem images.

I've changed sceneview and DOOM to use this instead of reading
directly from the block device. w_wad from DOOM is just pulled
from the mainline (with a few tweaks), replacing the heavily
hacked version I was using previously.
  • Loading branch information
jbush001 committed May 10, 2015
1 parent 0acde19 commit fc89fed
Show file tree
Hide file tree
Showing 16 changed files with 748 additions and 212 deletions.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -20,6 +20,7 @@ JAVAC := $(shell which javac)
all:
cd tools/emulator && make
cd tools/serial_boot && make
cd tools/mkfs && make
cd rtl/ && make
cd software/libs/libc && make
cd software/libs/librender && make
Expand All @@ -36,6 +37,7 @@ test: all FORCE
clean:
cd tools/emulator && make clean
cd tools/serial_boot && make clean
cd tools/mkfs && make clean
cd software/libs/libc && make clean
cd software/libs/librender && make clean
cd software/libs/libos && make clean
Expand Down
15 changes: 9 additions & 6 deletions software/apps/doom/Makefile
Expand Up @@ -94,19 +94,22 @@ $(O)/doom.hex: $(OBJS)
$(ELF2HEX) -o $(O)/doom.hex -b 0 $(O)/doom.elf
$(OBJDUMP) --disassemble $(O)/doom.elf > doom.lst 2> /dev/null

run: $(O) $(O)/doom.hex
../../../bin/emulator -f 640x400 -b doom1.wad obj/doom.hex
run: $(O) $(O)/doom.hex fsimage.bin
../../../bin/emulator -f 640x400 -b fsimage.bin obj/doom.hex

debug: $(O) $(O)/doom.hex
../../../bin/emulator -m gdb -f 640x400 -b doom1.wad obj/doom.hex &
debug: $(O) $(O)/doom.hex fsimage.bin
../../../bin/emulator -m gdb -f 640x400 -b fsimage.bin obj/doom.hex &
/usr/local/llvm-nyuzi/bin/lldb --arch nyuzi $(O)/doom.elf -o "gdb-remote 8000"

verirun: $(O) $(O)/doom.hex
../../../bin/verilator_model +bin=obj/doom.hex +block=doom1.wad
verirun: $(O) $(O)/doom.hex fsimage.bin
../../../bin/verilator_model +bin=obj/doom.hex +block=fsimage.bin

fpgarun: $(O)/doom.hex
../../../bin/serial_boot $(SERIAL_PORT) $(O)/doom.hex

fsimage.bin: doom1.wad
../../../bin/mkfs fsimage.bin DOOM1.WAD

$(O)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

Expand Down
12 changes: 3 additions & 9 deletions software/apps/doom/README.md
Expand Up @@ -6,22 +6,16 @@ compiled to 300k).

A shareware WAD file is required to use this. This is not included in this
repository, but can be found pretty easily with a Google search. It should be
named "doom1.wad" and placed in this directory.
named "DOOM1.WAD" (case sensitive) and placed in this directory.

To run (in the emulator) type 'make run'. This does not currently run on FPGA
because there isn't a mass storage device to store the WAD.

The primary changes I made for the port were:

* In w_wad.c, read the WAD file directly from a simulated block device. Since
this is running on bare metal with a minimal libc, there is no filesystem layer.
I commented out other code that interacted with the filesystem (for example,
saving and restoring games). The size of the WAD file is hardcoded in this file.
* in i_video.c, added code to copy the screen to the framebuffer, expanding
from an 8 bit paletted format to the 32 bit per pixel framebuffer format.
* in i_video.c, reads from a virtual keyboard device for input.
* Fixed some places that made bad assumptions that the hardware supported
unaligned memory accesses.
* Code from i_net and i_sound mostly removed, since there's no support for
them.
* W_CheckNumForName assumes support for unaligned accesses, changed to use memcmp.
* Code from i_net and i_sound removed, since there's no support for them.

0 comments on commit fc89fed

Please sign in to comment.