Commit Graph

178 Commits

Author SHA1 Message Date
Byron Lathi
9dd460a47f Add preliminary bootloader
This bootloader right now just prints the letter A, but should be
capable of reading blocks from the SD card into memory.
2022-04-18 20:25:08 -05:00
Byron Lathi
54328722ab Rename boot to bios, add sd call
Adds a call that you can make to the BIOS to read sd blocks. Useful for
the bootloader where there is not much space
2022-04-18 20:24:29 -05:00
Byron Lathi
64f6f0b397 Add top level makefile for sw 2022-04-18 12:50:19 -05:00
Byron Lathi
12284d19a9 Create boot environment
The boot environment will read the boot sector from the sd card, verify
that it has the boot signature at the end, then jump to the start of it.

From there, there should be a bootloader written to the boot segment
that can handle the rest.

It might be tight to fit everything into the boot sector but do remember
that you do not have to initialize or select the sd card, and those
functions take up a lot of space.
2022-04-18 12:43:29 -05:00
Byron Lathi
2ff3caccc6 Change user programs to use super6502 target
The target library is a copy of `none` right now but will be built out
later.
2022-04-18 12:12:43 -05:00
Byron Lathi
373fade79f Merge branch 'filesystem' into 'master'
Improve file system code

See merge request bslathi19/super6502!15
2022-04-18 17:10:09 +00:00
Byron Lathi
a9d9bc0619 Allow subdirectories
Can now break apart a filepath into the parent directories and search
for each one of them (not recursively!).
2022-04-17 20:18:43 -05:00
Byron Lathi
52f631e558 Allow finding files in the root directory
This allows you to find the cluster number of a file in the root
directory by name. The main program is a simple demo where you can type
in a filename and it will tell you the cluster number.
2022-04-17 18:12:13 -05:00
Byron Lathi
edd13e9b71 Remove debug information 2022-04-17 18:11:45 -05:00
Byron Lathi
6844c48a3b Update ci 2022-04-16 22:07:19 -05:00
Byron Lathi
8495f1f002 Update ci 2022-04-16 22:02:18 -05:00
Byron Lathi
c6098f2d1f Separate kernel code from test code
Eventually I want the kernel to be loaded from the SD card as well, but
it still needs to separate from user programs.

At some point there should be a folder just for the BIOS, which should
read from the boot block of the SD card and start executing, and thats
it.
2022-04-16 21:58:37 -05:00
Byron Lathi
238a4b6f98 Move devices into devices folder 2022-04-16 21:47:54 -05:00
Byron Lathi
c5f1b64cba Move filesystem code into its own directory
Step one into cleaning up the codebase a little bit.
2022-04-16 21:43:26 -05:00
Byron Lathi
c8ce675d2b Merge branch 'exec' into 'master'
Move code out of main and into their own files

See merge request bslathi19/super6502!14
2022-04-17 02:29:13 +00:00
Byron Lathi
8c9ae78040 Fix file endings 2022-04-16 21:04:39 -05:00
Byron Lathi
f1e71a9461 Move code out of main and into their own files
All of the SD card commands are moved into their own file, with
functions sd_init, sd_get_rca, sd_select_card, sd_get_status, and
sd_readblock.

The FAT functions are movied into fat.c and give functions fat_init and
fat_read. Note that the filename is ignored for now, it always reads the
first file in the root directory.

The loading of o65 files is done in o65.c, and executing is done in
exec.c

This cleans up the main file signifigantly and leaves the project open
to expansion.
2022-04-16 20:52:50 -05:00
Byron Lathi
c02d03bd99 Rename sd_card.s to sd_card_asm.s 2022-04-16 20:52:10 -05:00
Byron Lathi
44fb4cd0d5 Merge branch 'exec' into 'master'
Add reading, parsing, and basic executing of o65 files

See merge request bslathi19/super6502!13
2022-04-17 00:34:40 +00:00
Byron Lathi
a94b26dc3c Change code and data base to be pointers
These are technically pointers, so lets type them as such.
2022-04-16 19:24:21 -05:00
Byron Lathi
2786ec0940 Execute code read from the SD card
This will read the data from the sd card, copy it to the originally
linked address (no relocation), then execute it.

I am lazy and wrote it in C using weird function pointer casting but
this would probably be more efficient if it were to be written in
assembly instead.

The test program simply returns 'A', but that is enough to prove that it
is actually running.
2022-04-16 14:56:41 -05:00
Byron Lathi
585faa023f Remove compilation output files
These were used to help understand the o65 file format, but are not
needed and shouldn't have been commited anyway.
2022-04-16 14:30:34 -05:00
Byron Lathi
4be5366aee Do not track o65 files
These are object files still, which means we do not want to track them.
2022-04-16 14:28:40 -05:00
Byron Lathi
7e7bdd3b4a Use the system cl65, don't use verbose mode
I had used these to try and help figure out the structure of the o65
file but this is not needed anymore
2022-04-16 14:27:18 -05:00
Byron Lathi
016e9edee7 More o65 parsing
Prints out the options now too.
2022-04-16 14:22:26 -05:00
Byron Lathi
e30768d4c2 Rename o65_opt to o65_opt_t 2022-04-16 14:22:16 -05:00
Byron Lathi
f15b7876fe Add parsing of o65 files
Prints out information about the first file found on the SD card, if it
is an o65 file.
2022-04-16 14:10:54 -05:00
Byron Lathi
59da06c509 Add basic test program
This adds a test program which can be loaded and executed by the host.
It simply returns a value in the `a` register.

The linker script is modified so that it will output an o65 file, and
the memory sgments are changed as well. There is no STARTUP segment
defined, so it uses the default `none` crt0, which sets up the stack
and does initialization and deconstruction.

The Makefile is modified to not turn the output into an intel hex file,
and instead keep it as the o65 file.
2022-04-16 14:10:39 -05:00
Byron Lathi
0cecf166c7 Add definitions and structures for o65 files
These can be used to read and parse o65 files.
2022-04-16 14:02:57 -05:00
Byron Lathi
2c6f333966 Remove unused char c 2022-04-16 14:02:43 -05:00
Byron Lathi
7c2aab59dc Merge branch 'sdcard' into 'master'
Read data from a file

See merge request bslathi19/super6502!12
2022-04-14 22:16:28 +00:00
Byron Lathi
246d7a5e6f Print out more information, read a file
Prints out information about the drive, now inside its own function.

Also changes the read function to take in a 32 bit address instead of a
16 bit one.

Attempts to read the first file on the disk
2022-04-14 17:04:47 -05:00
Byron Lathi
380550c77d Add more struct definitions
Adds filesystem info struct and directory entry structs
2022-04-14 17:04:08 -05:00
Byron Lathi
7df0b67b12 Print out information about the sd card filesystem.
Prints out all of the parameter blocks for the SD card.
2022-04-14 13:50:14 -05:00
Byron Lathi
3c68e4584f Add some definitions for FAT32 file system
Adds some struct types for the FAT32 file system.

This just includes the information in the parameter blocks, not any
actual files.
2022-04-14 13:49:11 -05:00
Byron Lathi
d140928148 Add testing function for reading sd blocks
Add a simple function which reads a 512 block from the SD card and then
prints it to the console.
2022-04-14 11:23:44 -05:00
Byron Lathi
ee95a592cd Reset bit count upon entering RXDATA
The but count should be set to 7 when entering RXDATA. previously it was
not reset or left at 0, which caused the first byte to only have the lsb
set and all other bits to be read incorrectly.
2022-04-14 11:20:48 -05:00
Byron Lathi
3a59de2947 Change data count to have proper width (9)
This was probably an off-by-one mistage, with the width set to 10
instead of 9. The width should be 9 since the buffer is 512 bytes.
2022-04-14 11:19:08 -05:00
Byron Lathi
b025e90151 Merge branch 'sdcard' into 'master'
Add SD Card Controller

See merge request bslathi19/super6502!11
2022-04-11 22:38:48 +00:00
Byron Lathi
c9269b2fb8 Fix some warnings
Adds some missing cases, length specifiers.
2022-04-11 16:13:38 -05:00
Byron Lathi
68a422d5e3 Disable signal tap 2022-04-11 16:03:50 -05:00
Byron Lathi
f4e16c0c12 Add software interface for reading SD card data
Adds functions to wait for data to be read, and to read data form the sd
card controller.
2022-04-11 14:03:42 -05:00
Byron Lathi
87d1457d94 Add logic to store and readback data from SD card
After a data read (e.g. CMD17) the data received from the SD card is
stored into a buffer which can be read back one byte at a time by the
CPU through address 5.

There is also a flag which is set when data is received. This can be
checked by reading the CMD register, which doubles as the status
register.
2022-04-11 13:57:56 -05:00
Byron Lathi
51c348bc7c Increase sd card addr width by 1
Adds a new memory location for data accesses.
2022-04-11 13:57:07 -05:00
Byron Lathi
9eaa6c49f9 Add software support for sd response codes
Polls the sd controller until the read flag is set, at which point it
reads 32 bits of data from the controller.

long response codes (such as CID) are not supported in hw or sw.
2022-04-10 23:18:26 -05:00
Byron Lathi
f5f1d7ccc6 Add read flag to sd controller
Read flag is set when the sd controller reads response data in from the
sd card. When the cpu reads from the controller, the flag is reset.

This flag does not trigger an interrupt, it mmust be polled.
2022-04-10 23:16:10 -05:00
Byron Lathi
385efb2511 Read some data off of the sd card
These series of commands are enough to read the first 512b block off of
the sd card. The RCA is hard coded to the sd card that I have on hand,
since response codes are not supported
2022-04-10 19:34:38 -05:00
Byron Lathi
7092cc8f77 Add SD card software interface
Adds a function to send a command to the sd card.
2022-04-10 17:55:51 -05:00
Byron Lathi
cd11670fb1 Add sd controller to top level
Also adds the logic required for the bidirectional sd lines and attaches
the controller to the cpu.
2022-04-10 17:54:08 -05:00
Byron Lathi
1128b986eb Fix state transitions with regard to clock
The SD card expects data to transition on falling edges and be stable on
rising edges.

Additionally, writes from the CPU were not handled with correct timing.

Now, there is an extra state when writing to the command register so
that the command is properly latched before the CRC is calculated.
2022-04-10 17:52:07 -05:00