- nemu/src/monitor/sdb/sdb.c
-
- added and tested in pa1.2
-
- added in pa1.3
-
generating sequence of expression using recursion, deal with buffer overflow, zero division, and unsigned int problem.
- nemu/tools/gen-expr/gen-expr.c
- nemu/tools/gen-expr/testout (10000 lines of generated unit test)
-
- nemu/src/nemu-main.c:42 test_expr()
-
extend EXPR evaluation functionality, support register value ($reg), ptr dereference (*), and other logic operator (!=,&&)
- nemu/src/monitor/sdb/sdb.c
-
- nemu/src/monitor/sdb/watchpoint.c
-
- nemu/src/cpu/cpu-exec.c
- add functions for printing and checking wp change in
nemu/src/monitor/sdb/watchpoint.c
.
-
- understand Kconfig and modify:
nemu/Kconfig
- set up config entry for watchpoint function and debug output;
- change setting by running
make menuconfig
innemu/
.
- understand Kconfig and modify:
- nemu/src/isa/riscv32/inst.c
-
- support integer arithmetic through I and R instruction decoding.
- support memory load and store through I/U and S instrucion decoding.
- support jumping and branching through B and J/I instrucion decoding.
-
- tests located in
am-kernels/tests/cpu-tests/tests
, and can be run though command:make ARCH=riscv32-nemu ALL={test program without .c suffix} run
- tests located in
-
- look through man pages and implement string functions:
strlen
,strcpy
,strncpy
,strcat
,strcmp
,strncmp
; (abstract-machine/klib/src/string.c
) - memory functions:
memset
,memmove
,memcmp
,memcpy
; (abstract-machine/klib/src/string.c
) - print functions:
sprintf
,vsprintf
,snprintf
,vsnprintf
. (abstract-machine/klib/src/stdio.c
)
- look through man pages and implement string functions:
-
- nemu/src/monitor/sdb/iringbuf.c
- nemu/include/monitor/iringbuf.h
-
- nemu/src/memory/paddr.c
- nemu/Kconfig
-
- add
-e
argument to main to parse elf file, modify makefile to load elf file- abstract-machine/scripts/platform/nemu.mk
- nemu/src/monitor/monitor.c
- detect function calling and return with
jal
andjalr
instruction, and print trace appropiately- nemu/src/isa/riscv32/inst.c
- modify Kconfig to add option on opening ftrace
- add
-
- add folder for klib testing:
am-kernels/tests/klib-tests
. - write testsuite for klib functions, and test on native.
- am-kernels/tests/klib-tests/src/tests/test_memory.c
- am-kernels/tests/klib-tests/src/tests/test_string.c
- am-kernels/tests/klib-tests/src/tests/test_printf.c
- am-kernels/tests/klib-tests/src/tests/test_test_setup.c
- add folder for klib testing:
-
- nemu/src/isa/riscv32/difftest/dut.c
- add differential testing for nemu,comparing with REF spike. Comparing only register each step!
-
- run benchmark at
/home/tom/ics2023/am-kernels/benchmarks
, get score ~200 / 100000 Marks (i9-9900K @ 3.60GHz)
- run benchmark at
-
- abstract-machine/am/src/platform/nemu/ioe/input.c
- nemu/src/device/keyboard.c
-
- NEMU part, include registering this device and register read write behaviors and maps:
nemu/src/device/vga.c
- AM part, include drawing rect and syncing through io_read/io_write:
abstract-machine/am/src/platform/nemu/ioe/gpu.c
- NEMU part, include registering this device and register read write behaviors and maps:
-
- Fix Bug
- Turing Complete, use the following command to run NEMU(no image) on NEMU, or run SNAKE on NEMU on NEMU... (Very Slow!)
- make ARCH=riscv32-nemu mainargs=/home/<username>/ics2023/am-kernels/kernels/snake/build/snake-riscv32-nemu.bin
-
- Implement the CSR registers in NEMU and
raise_intr
function forecall
. - implement atomic read/write csr instructions:
csrrw
,csrrs
,csrrc
,csrrwi
,csrrsi
,csrrci
,ecall
,mret
. - nemu/src/isa/riscv32/inst.c
- pass yield test:
~/ics2023/am-kernels/tests/am-tests$ make ARCH=riscv32-nemu mainargs=i run
- Implement the CSR registers in NEMU and
-
- save/restore context in
abstract-machine/am/src/riscv/nemu/trap.S
- note this is the OS define routine. Also: it should be adding 34 to the mepc CSR to avoid caughtup infinitely at
ecall
.
- note this is the OS define routine. Also: it should be adding 34 to the mepc CSR to avoid caughtup infinitely at
- handling event in
abstract-machine/am/src/riscv/nemu/cte.c:__am_irq_handle
, called bytrap.S
. - the journey:
- start with client software program calling yield,
- in assembly code, its doing ecall.
- our NEMU hardware translate this instruction to storing CSR and jump PC to
mtvec
(nemu/src/isa/riscv32/system/intr.c:isa_raise_intr
) - the code at mtvec is AM(OS) defined (
abstract-machine/am/src/riscv/nemu/trap.S:__am_asm_trap
), which store context, and handle events by callingabstract-machine/am/src/riscv/nemu/cte.c:__am_irq_handle
, and restore context, thenmret
. mret
, translated by NEMU: restore pc to CSR mepc, and continue program going on "user level". (returning control from OS)
- save/restore context in
-
- nemu/Kconfig
- nemu/src/isa/riscv32/system/intr.c
-
- fix instruction bug on yield. change mcause to store a7 register.
- handled YIELD event.
-
- load program that is Cmake into ramdisk.img
- read ELF file, extract segments, and memset/copy to virtual locations: 0x83000000.
- nanos-lite/src/loader.c
-
- implement syscall function on nanos level, used by navy.
- SYS_yield: handle yield event initiated by user program
- SYS_exit: exiting program, signify OS to change program.
- SYS_read, SYS_write (_read,_write): read and write from ramdisk.
- SYS_brk (_sbrk): set up sbrk for heap management, for malloc/free.
- strace: trace the syscall.
- implement syscall function on nanos level, used by navy.
-
-
- update loader to handled loading by filename.
- update syscall (open,read,write) to support fd argument, by calling:
- fs_open, fs_close
- fs_read, fs_write
- fs_lseek
-
- update fs_read and fs_write by implementing special read write functions for the virtual files.
- implement serial output as file write.
- implement gettimeofday as file read. (and implement the navy:NDL_GetTicks)
- impelment keyboard info as file read.
- impelment VGA display info as file read.
- impelment VGA display as file write.
-
NOTE: nanos user call syscall by calling ecall with param, the irq classify it as syscall event and hand to do_syscall, do_syscall (OS) delegate to am-yield, am yield do ecall/mtvec/... use do_event handler and return a value. do_syscall store the return val and hand it back to user
-
SDL: (navy-apps/libs/libminiSDL/)[https://www.libsdl.org/release/SDL-1.2.15/docs/]
- implement the SDL_updateRect function, upper level API update an area to VGA. (NSlider)
- SDL_FillRect(),SDL_BlitSurface(): GPU basic ability on VGA.(MENU)
- SDL_GetTicks(): calling NDL function.
- SDL_WaitEvent, SDL_PollEvent(): wait or poll an event, that is keyboard or user defined.(NTerm)
- IMG_Load: Load Image (Flappy bird)