mirror of
https://github.com/satoshinm/pill_6502.git
synced 2024-06-02 20:41:37 +00:00
Add ROM linked in read-only data section, at 6502's 0xc000-0xffff
This commit is contained in:
parent
5ed79b17bb
commit
fb7f66b717
|
@ -15,6 +15,8 @@ SRC = \
|
||||||
cdcacm.c \
|
cdcacm.c \
|
||||||
main.c \
|
main.c \
|
||||||
|
|
||||||
|
ROM = ../osi_bas/ROM.HEX
|
||||||
|
|
||||||
CROSS_COMPILE ?= arm-none-eabi-
|
CROSS_COMPILE ?= arm-none-eabi-
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
|
@ -38,6 +40,7 @@ host_clean:
|
||||||
-$(Q)$(RM) pill_6502.bin
|
-$(Q)$(RM) pill_6502.bin
|
||||||
|
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
OBJ += $(ROM:.HEX=.o)
|
||||||
|
|
||||||
pill_6502.elf: version.h $(OBJ)
|
pill_6502.elf: version.h $(OBJ)
|
||||||
@echo " LD $@"
|
@echo " LD $@"
|
||||||
|
@ -47,6 +50,12 @@ pill_6502.elf: version.h $(OBJ)
|
||||||
@echo " CC $<"
|
@echo " CC $<"
|
||||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.HEX
|
||||||
|
@echo " OBJCOPY $@.bin"
|
||||||
|
$(Q)$(OBJCOPY) -I ihex -O binary $^ $@.bin
|
||||||
|
@echo " OBJCOPY $@"
|
||||||
|
$(Q)$(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata,alloc,load,readonly,data,contents $@.bin $@
|
||||||
|
|
||||||
%.bin: %.elf
|
%.bin: %.elf
|
||||||
@echo " OBJCOPY $@"
|
@echo " OBJCOPY $@"
|
||||||
$(Q)$(OBJCOPY) -O binary $^ $@
|
$(Q)$(OBJCOPY) -O binary $^ $@
|
||||||
|
|
12
src/main.c
12
src/main.c
|
@ -30,6 +30,7 @@
|
||||||
#include <libopencm3/usb/cdc.h>
|
#include <libopencm3/usb/cdc.h>
|
||||||
|
|
||||||
#include "fake6502.h"
|
#include "fake6502.h"
|
||||||
|
#include "rom.h"
|
||||||
#include "cdcacm.h"
|
#include "cdcacm.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
@ -137,12 +138,19 @@ uint8_t usbd_control_buffer[128];
|
||||||
|
|
||||||
// 6502 processor memory, 16KB (< 20KB)
|
// 6502 processor memory, 16KB (< 20KB)
|
||||||
uint8_t ram[0x4000];
|
uint8_t ram[0x4000];
|
||||||
|
// TODO: serial interface, 0xa000-0xbfff
|
||||||
uint8_t read6502(uint16_t address) {
|
uint8_t read6502(uint16_t address) {
|
||||||
|
// RAM
|
||||||
if (address < sizeof(ram)) {
|
if (address < sizeof(ram)) {
|
||||||
return ram[address];
|
return ram[address];
|
||||||
}
|
}
|
||||||
// TODO: serial interface, 0xa000-0xbfff
|
|
||||||
// TODO: ROM, 0xc000-0xffff
|
// ROM
|
||||||
|
if (address >= 0xc000) {
|
||||||
|
const uint8_t *rom = &_binary____osi_bas_ROM_o_bin_start;
|
||||||
|
|
||||||
|
return rom[address - 0xc000];
|
||||||
|
}
|
||||||
|
|
||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
5
src/rom.h
Normal file
5
src/rom.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
// Symbols exported by rom.o, see https://balau82.wordpress.com/2012/02/19/linking-a-binary-blob-with-gcc/
|
||||||
|
extern unsigned char _binary____osi_bas_ROM_o_bin_end;
|
||||||
|
extern unsigned char _binary____osi_bas_ROM_o_bin_size;
|
||||||
|
extern unsigned char _binary____osi_bas_ROM_o_bin_start;
|
Loading…
Reference in New Issue
Block a user