Add some basic fat32 code

This commit is contained in:
Byron Lathi
2023-12-03 23:27:45 -08:00
parent 184c58b962
commit 5c74d161d4
11 changed files with 326 additions and 7 deletions

View File

@@ -0,0 +1,48 @@
CC=../../cc65/bin/cl65
LD=../../cc65/bin/cl65
SIM=../../cc65/bin/sim65
CFLAGS=-T -t sim65c02 -I.
LDFLAGS=-m $(NAME).map
NAME=fs_test
BIN=$(NAME).bin
FS=$(REPO_TOP)/sw/script/fs.fat
LISTS=lists
EXT_SRCS=$(REPO_TOP)/sw/kernel/filesystems/fat32.s
SRCS=$(wildcard *.s) $(wildcard *.c)
SRCS+=$(wildcard **/*.s) $(wildcard **/*.c)
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
run: all
$(SIM) $(BIN)
all: fs.fat fat32.s $(BIN)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
%.o: %.c $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
%.o: %.s $(LISTS)
$(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@
fat32.s: $(EXT_SRCS)
cp $^ .
fs.fat: $(FS)
cp $^ .
$(LISTS):
mkdir -p $(addprefix $(LISTS)/,$(sort $(dir $(SRCS))))
.PHONY: clean
clean:
rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) $(NAME).map fat32.s

View File

@@ -0,0 +1,5 @@
.import _printf
.export _cprintf
_cprintf:
jmp _printf

View File

@@ -0,0 +1,21 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define FILE_PATH "fs.fat"
uint32_t lmulii(uint16_t a, uint16_t b) {
printf("lmulii: %x * %x = %x\n", a, b, a*b);
return a * b;
}
uint16_t imulii(uint16_t a, uint16_t b) {
printf("imulii: %x * %x = %x\n", a, b, a*b);
return a * b;
}
uint8_t SD_readSingleBlock(uint32_t addr, uint8_t *buf, uint8_t *error) {
FILE* f = fopen(FILE_PATH, "rb");
// fseek(f, addr * 512, SEEK_SET);
fread(buf, 512, 1, f);
}

View File

@@ -0,0 +1,9 @@
#include <stdio.h>
void fat32_init(void);
int main(void) {
printf("Hello, world!\n");
fat32_init();
return 0;
}