1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2026-03-14 08:16:24 +00:00
Files
rk65c02/examples/Makefile
Radosław Kujawa d3bafd5892 Add Tiny OS example: scheduler with extended physical RAM
- examples/tinyos.c: host with 64K system RAM, 3x32KB task regions above 64K
  (bus_device_add_phys), MMU translate (virtual 32KB per task), console at
  , cooperative yield ( + JMP cd /home/rkujawa/repos/rk65c02 && git commit --trailer "Made-with: Cursor" -m "Add Tiny OS example: scheduler with extended physical RAM

- examples/tinyos.c: host with 64K system RAM, 3x32KB task regions above 64K
  (bus_device_add_phys), MMU translate (virtual 32KB per task), console at
  $DE00, cooperative yield ($FF00 + JMP $1000) and WAI + idle_wait + IRQ
  yield, vectors at $FFFC-$FFFF
- examples/tinyos_kernel.s: entry at $8000, IRQ handler at $8010 (JMP $1000)
- examples/tinyos_task.s: per-task loop printing task id, round-robin yield,
  optional WAI, STP after 3 runs
- Makefile: tinyos target, run-tinyos with timeout
- README.md, doc/MMU.md: document Tiny OS (64K virtual + expanded physical)
- .gitignore: /examples/tinyos"000) and WAI + idle_wait + IRQ
  yield, vectors at -
- examples/tinyos_kernel.s: entry at 000, IRQ handler at 010 (JMP cd /home/rkujawa/repos/rk65c02 && git commit --trailer "Made-with: Cursor" -m "Add Tiny OS example: scheduler with extended physical RAM

- examples/tinyos.c: host with 64K system RAM, 3x32KB task regions above 64K
  (bus_device_add_phys), MMU translate (virtual 32KB per task), console at
  $DE00, cooperative yield ($FF00 + JMP $1000) and WAI + idle_wait + IRQ
  yield, vectors at $FFFC-$FFFF
- examples/tinyos_kernel.s: entry at $8000, IRQ handler at $8010 (JMP $1000)
- examples/tinyos_task.s: per-task loop printing task id, round-robin yield,
  optional WAI, STP after 3 runs
- Makefile: tinyos target, run-tinyos with timeout
- README.md, doc/MMU.md: document Tiny OS (64K virtual + expanded physical)
- .gitignore: /examples/tinyos"000)
- examples/tinyos_task.s: per-task loop printing task id, round-robin yield,
  optional WAI, STP after 3 runs
- Makefile: tinyos target, run-tinyos with timeout
- README.md, doc/MMU.md: document Tiny OS (64K virtual + expanded physical)
- .gitignore: /examples/tinyos

Made-with: Cursor
2026-03-09 22:11:41 +01:00

108 lines
2.9 KiB
Makefile

UNAME_S := $(shell uname -s)
CFLAGS=-Wall -pedantic -I../src -g -MMD -MP
# When linking against library built without JIT: make NO_LIGHTNING=1
LDFLAGS=-lgc $(if $(NO_LIGHTNING),,-llightning)
LDFLAGS_MACOSX=-L/opt/local/lib
CFLAGS_MACOSX=-I/opt/local/include
ifeq ($(UNAME_S),Darwin)
CFLAGS+=$(CFLAGS_MACOSX)
LDFLAGS+=$(LDFLAGS_MACOSX)
endif
RK6502LIB=../src/librk65c02.a
VASM=vasm6502_std
VASMFLAGS=-Fbin -wdc02
EXAMPLES=min3 mul_8bit_to_8bits host_control idle_wait interrupts hello_serial stepper jit_bench breakpoints mmu_cart mmu_multitasking mmu_pae mmu_mpu tinyos
EXAMPLES_ROMS:=$(addsuffix .rom,$(basename $(wildcard *.s)))
all : $(EXAMPLES) $(EXAMPLES_ROMS)
msbasic : $(RK6502LIB)
$(MAKE) -C msbasic all
min3 : min3.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
mul_8bit_to_8bits : mul_8bit_to_8bits.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
host_control : host_control.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
idle_wait : idle_wait.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
interrupts : interrupts.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
hello_serial : hello_serial.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
stepper : stepper.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
jit_bench : jit_bench.o min3.rom $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
breakpoints : breakpoints.o min3.rom $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
mmu_cart : mmu_cart.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
mmu_multitasking : mmu_multitasking.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
mmu_pae : mmu_pae.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
mmu_mpu : mmu_mpu.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
tinyos : tinyos.o $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(RK6502LIB)
%.rom : %.s
$(VASM) $(VASMFLAGS) -o $@ $<
# Run examples under timeout so they never hang (use: make run-<name>)
TIMEOUT ?= 5
run-mmu_mpu: mmu_mpu mmu_mpu.rom
timeout $(TIMEOUT) ./mmu_mpu
run-mmu_pae: mmu_pae mmu_pae.rom
timeout $(TIMEOUT) ./mmu_pae
run-mmu_multitasking: mmu_multitasking mmu_multitasking_kernel.rom mmu_multitasking_task.rom
timeout $(TIMEOUT) ./mmu_multitasking
run-tinyos: tinyos tinyos_kernel.rom tinyos_task.rom
timeout $(TIMEOUT) ./tinyos
run-mmu_cart: mmu_cart mmu_cart_bank0.rom mmu_cart_bank1.rom
timeout $(TIMEOUT) ./mmu_cart
run-min3: min3 min3.rom
timeout $(TIMEOUT) ./min3
run-interrupts: interrupts interrupts.rom
timeout $(TIMEOUT) ./interrupts
run-hello_serial: hello_serial hello_serial.rom
./hello_serial
run-stepper: stepper stepper.rom
./stepper
run-jit_bench: jit_bench min3.rom
./jit_bench
run-breakpoints: breakpoints min3.rom
./breakpoints
run-msbasic: msbasic
cd msbasic && ./run_msbasic
%.o : %.c
$(CC) $(CFLAGS) -c $<
clean :
rm -f *.o
rm -f *.d
rm -f $(EXAMPLES) $(EXAMPLES_ROMS)
-include $(wildcard *.d)