diff --git a/debug/debug.txt b/debug/debug.txt new file mode 100644 index 0000000..260fe48 --- /dev/null +++ b/debug/debug.txt @@ -0,0 +1,10 @@ +dreamcast | pc + +break 1 → [break state] + ← ackn 1 + +regs 2 → + ← ackn 2 + + ← regs -1 +regs -1 → diff --git a/debug/debug_protocol.hpp b/debug/debug_protocol.hpp new file mode 100644 index 0000000..dc41701 --- /dev/null +++ b/debug/debug_protocol.hpp @@ -0,0 +1,59 @@ +#include +#include + +namespace debug_protocol { + +consteval uint32_t gen_cmd(const char * s) +{ + uint32_t x = 0 + | s[0] << 0 + | s[1] << 8 + | s[2] << 16 + | s[3] << 24; + + x ^= x << 13; + x ^= x >> 17; + x ^= x << 5; + + return x; +} + +template +struct frame { + uint32_t command; + uint32_t sequence; + T data; + uint32_t crc; +}; + +static_assert((sizeof (frame)) == 4 * 3); +static_assert((offsetof (frame, crc)) == 4 * 2); + +struct register_state { + uint32_t r[16]; + uint32_t sr; + uint32_t gbr; + uint32_t mach; + uint32_t macl; + uint32_t pr; + uint32_t pc; +}; + +struct read_u32 { + uint32_t start; + uint32_t length; +}; + +namespace command { + constexpr uint32_t _register_state = gen_cmd("REGS"); + constexpr uint32_t _read_u32 = gen_cmd("RU32"); +} + +namespace reply { + constexpr uint32_t _register_state = gen_cmd("regs"); + constexpr uint32_t _read_u32 = gen_cmd("ru32"); + + constexpr uint32_t _acknowledge = gen_cmd("ackn"); +} + +} diff --git a/example/example.mk b/example/example.mk index bb10bf6..94ec557 100644 --- a/example/example.mk +++ b/example/example.mk @@ -643,3 +643,10 @@ SHEIK_VQ_OBJ = \ example/sheik_vq.elf: LDSCRIPT = $(LIB)/main.lds example/sheik_vq.elf: $(START_OBJ) $(SHEIK_VQ_OBJ) + +VGA_TIMING_OBJ = \ + example/vga_timing.o \ + holly/video_output.o + +example/vga_timing.elf: LDSCRIPT = $(LIB)/main.lds +example/vga_timing.elf: $(START_OBJ) $(VGA_TIMING_OBJ) diff --git a/example/interrupt.cpp b/example/interrupt.cpp index ed8bc94..b0e720e 100644 --- a/example/interrupt.cpp +++ b/example/interrupt.cpp @@ -59,18 +59,28 @@ void dbr() uint32_t spc; uint32_t ssr; + uint32_t sgr; + uint32_t r15; asm volatile ("stc spc,%0" : "=r" (spc) ); asm volatile ("stc ssr,%0" : "=r" (ssr) ); + asm volatile ("stc sgr,%0" : "=r" (sgr) ); + asm volatile ("mov r15,%0" : "=r" (r15) ); serial::string("spc "); serial::integer(spc); serial::string("ssr "); serial::integer(ssr); + serial::string("sgr "); + serial::integer(sgr); + serial::string("r15 "); + serial::integer(r15); uint32_t sr; asm volatile ("stc sr,%0" : "=r" (sr) ); serial::string("sr "); serial::integer(sr); + while (1); + return; } @@ -178,6 +188,10 @@ void main() serial::string("brcr "); serial::integer(sh7091.UBC.BRCR); + uint32_t r15; + asm volatile ("mov r15,%0" : "=r" (r15) ); + serial::string("r15 "); + serial::integer(r15); int res = do_stuff(1, 2); (void)res; diff --git a/example/vga_timing.cpp b/example/vga_timing.cpp new file mode 100644 index 0000000..ce4f601 --- /dev/null +++ b/example/vga_timing.cpp @@ -0,0 +1,21 @@ +#include "holly/video_output.hpp" +#include "holly/texture_memory_alloc.hpp" +#include "holly/holly.hpp" +#include "memorymap.hpp" + +void main() +{ + video_output::set_mode_vga(); + + uint32_t frame_address = texture_memory_alloc::framebuffer[0].start; + volatile uint16_t * framebuffer = reinterpret_cast(&texture_memory32[frame_address/4]); + + for (int i = 0; i < 640 * 480; i++) { + if (i % 2) + framebuffer[i] = 31 << 11; + else + framebuffer[i] = 0; + } + + holly.FB_R_SOF1 = frame_address; +} diff --git a/ftdi.conf b/ftdi.conf new file mode 100644 index 0000000..33cbb63 --- /dev/null +++ b/ftdi.conf @@ -0,0 +1,133 @@ +#see http://developer.intra2net.com/git/?p=libftdi;a=blob;f=src/ftdi.c +#and http://developer.intra2net.com/git/?p=libftdi;a=blob;f=src/ftdi.h +#and http://developer.intra2net.com/git/?p=libftdi;a=tree;f=ftdi_eeprom +#and http://developer.intra2net.com/git/?p=libftdi;a=blob;f=ftdi_eeprom/example.conf +#and http://developer.intra2net.com/git/?p=libftdi;a=blob;f=ftdi_eeprom/main.c + +############ +# Filename # +############ +filename=eeprom.new # Filename of the EE file to be generated. Leave empty to skip file writing +#flash_raw=false # Boolean: + +## Include another config file? +#include + +############ +# IDs # +############ +# Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC + +vendor_id="0x0403" +product_id="0x6014" + +############################## +# Device and Serial Strings # +############################## +manufacturer="FTDI" # String: Manufacturer. FT245R factory default FTDI +product="FT232H Single HS USB-UART/FIFO" # String: Product. FT245R factory default FT245R USB FIFO +serial="00-00" +use_serial=true + +############ +# Options # +############ +max_power=500 # Integer: Max. power consumption: value * 2 mA(?). Use 0 if self_powered = true. FT245R factory default 90 +self_powered=false # Boolean: Turn this off for bus powered +remote_wakeup=true # Boolean: Turn this on for remote wakeup feature + +# Normally you don't have to change one of these flags +#in_is_isochronous=false # Boolean: In Endpoint is Isochronous +#out_is_isochronous=false # Boolean: Out Endpoint is Isochronous +#suspend_pull_downs=false # Boolean: Enable suspend pull downs for lower power +#change_usb_version=false # Boolean: Change USB Version +#usb_version=0x00 # Integer: Only used when change_usb_version is enabled + +#default_pid=0x6001 # Integer: Default Pid. + +eeprom_type=6 # Integer: Chip Type / EEPROM Type. Corresponds to ftdi_chip_type struct in ftdi.h +#high_current=false # Boolean: High Current Drive + +##Type_R chips +# Only used on FT-R chips (when omitted, use chip defaults) +# Possible values correspond to enum ftdi_cbus_func in ftdi.h and strings are defined in function parse_cbus in ftdi_eeprom/main.c +# Values in the struct are (see current ftid.h for an up to date list): +# CBUS_TXDEN = 0, CBUS_PWREN = 1, CBUS_RXLED = 2, CBUS_TXLED = 3, CBUS_TXRXLED = 4, CBUS_SLEEP = 5, CBUS_CLK48 = 6, CBUS_CLK24 = 7, CBUS_CLK12 = 8, CBUS_CLK6 = 9, CBUS_IOMODE = 0xa, CBUS_BB_WR = 0xb, CBUS_BB_RD = 0xc +# Strings to be used here are: +# "TXDEN", "PWREN", "RXLED", "TXLED", "TXRXLED", "SLEEP", "CLK48", "CLK24", "CLK12", "CLK6", "IOMODE", "BB_WR", "BB_RD" +#cbus0=TXLED # String parsed to integer: FT245R factory default TXLED +#cbus1=RXLED # String parsed to integer: FT245R factory default RXLED +#cbus2=TXDEN # String parsed to integer: FT245R factory default TXDEN +#cbus3=PWREN # String parsed to integer: FT245R factory default PWREN +#cbus4=SLEEP # String parsed to integer: FT245R factory default SLEEP + +## Only used on FT232H chips (when omitted, use chip defaults) +# Possible values correspond to enum ftdi_cbush_func in ftdi.h and strings are defined in function parse_cbush in ftdi_eeprom/main.c. +# Values are (see current ftid.h for an up to date list): +# CBUSH_TRISTATE = 0, CBUSH_TXLED = 1, CBUSH_RXLED = 2, CBUSH_TXRXLED = 3, CBUSH_PWREN = 4, CBUSH_SLEEP = 5, CBUSH_DRIVE_0 = 6, CBUSH_DRIVE1 = 7, CBUSH_IOMODE = 8, CBUSH_TXDEN = 9, CBUSH_CLK30 = 10, CBUSH_CLK15 = 11, CBUSH_CLK7_5 = 12 +# Strings to be used in this config file are: +# "TRISTATE", "TXLED", "RXLED", "TXRXLED", "PWREN", "SLEEP", "DRIVE_0", "DRIVE1", "IOMODE", "TXDEN", "CLK30", "CLK15", "CLK7_5" +##Type_232H Chips +#cbush0=TRISTATE # String parsed to integer: +#cbush1=TRISTATE # String parsed to integer: +#cbush2=TRISTATE # String parsed to integer: +#cbush3=TRISTATE # String parsed to integer: +#cbush4=TRISTATE # String parsed to integer: +#cbush5=TRISTATE # String parsed to integer: +#cbush6=TRISTATE # String parsed to integer: +#cbush7=TRISTATE # String parsed to integer: +cbush8=TXLED # String parsed to integer: +cbush9=RXLED # String parsed to integer: +# Group Drive +# Strings to be used in this config file are: +# "4MA", "8MA", "12MA", "16MA" +#group0_drive # Integer: + +# Only used on FT230X chips (when omitted, use chip defaults) +# Possible values correspond to enum ftdi_cbusx_func in ftdi.h and strings are defined in function parse_cbusx in ftdi_eeprom/main.c. +# Values are (see current ftid.h for an up to date list): +# CBUSX_TRISTATE = 0, CBUSX_TXLED = 1, CBUSX_RXLED = 2, CBUSX_TXRXLED = 3, CBUSX_PWREN = 4, CBUSX_SLEEP = 5, CBUSX_DRIVE_0 = 6, CBUSX_DRIVE1 = 7, CBUSX_IOMODE = 8, CBUSX_TXDEN = 9, CBUSX_CLK24 = 10, CBUSX_CLK12 = 11, CBUSX_CLK6 = 12, CBUSX_BAT_DETECT = 13, CBUSX_BAT_DETECT_NEG = 14, CBUSX_I2C_TXE = 15, CBUSX_I2C_RXF = 16, CBUSX_VBUS_SENSE = 17, CBUSX_BB_WR = 18, CBUSX_BB_RD = 19, CBUSX_TIME_STAMP = 20, CBUSX_AWAKE = 21 +# Strings to be used in this config file are: +# "TRISTATE", "TXLED", "RXLED", "TXRXLED", "PWREN", "SLEEP", "DRIVE_0", "DRIVE1", "IOMODE", "TXDEN", "CLK24", "CLK12", "CLK6", "BAT_DETECT", "BAT_DETECT_NEG", "I2C_TXE", "I2C_RXF", "VBUS_SENSE", "BB_WR", "BB_RD", "TIME_STAMP", "AWAKE" +#cbusx0=TXDEN # String parsed to integer: +#cbusx1=RXLED # String parsed to integer: +#cbusx2=TXLED # String parsed to integer: +#cbusx3=SLEEP # String parsed to integer: + +######## +# Misc # +######## + +## Pin Configuration +#invert_txd # Boolean: Invert TXD signal +#invert_rxd # Boolean: Invert RXD signal +#invert_rts # Boolean: Invert RTS signal +#invert_cts # Boolean: Invert CTS signal +#invert_dtr # Boolean: Invert DTR signal +#invert_dsr # Boolean: Invert DSR signal +#invert_dcd # Boolean: Invert DCD signal +#invert_ri # Boolean: Invert RI signal + +## Channel Types and Drivers +# Possible values are (see current ftid.h (Interface Mode macros) and ftdi.c "channel_mode" for an up to date list). They are parsed in fucntion parse_chtype in ftdi_eeprom/main.c. +# (from ftid.h): UART= 0x0, FIFO = 0x1, OPTO = 0x2, CPU = 0x4, FT1284 = 0x8, RS485 = 0x10 +# (from ftdi.c): UART = 0x0, FIOF = 0x1, CPU = 0x2, OPTO = 0x3, FT1284 = 0x3 +# Strings to be used in this config file are: +# "UART", "FIFO", "OPTO", "CPU", "FT1284" +cha_type=UART +# String parsed to integer: +#chb_type +# String parsed to integer: + +cha_vcp=false # Boolean: +#chb_vcp=false # Boolean: +#chc_vcp=false # Boolean: +#chd_vcp=false # Boolean: +#cha_rs485 # Boolean: +#chb_rs485 # Boolean: +#chc_rs485 # Boolean: +#chd_rs485 # Boolean: + +## Include user defined binary data into the the eeprom at address? +#user_data_addr # Integer: +#user_data_file # String: Filename of the data file to be used