Add some basic fat32 code
This commit is contained in:
48
sw/test_code/fs_test/Makefile
Normal file
48
sw/test_code/fs_test/Makefile
Normal 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
|
||||
|
||||
5
sw/test_code/fs_test/asm_harness.s
Normal file
5
sw/test_code/fs_test/asm_harness.s
Normal file
@@ -0,0 +1,5 @@
|
||||
.import _printf
|
||||
.export _cprintf
|
||||
|
||||
_cprintf:
|
||||
jmp _printf
|
||||
21
sw/test_code/fs_test/harness.c
Normal file
21
sw/test_code/fs_test/harness.c
Normal 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);
|
||||
}
|
||||
9
sw/test_code/fs_test/main.c
Normal file
9
sw/test_code/fs_test/main.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void fat32_init(void);
|
||||
|
||||
int main(void) {
|
||||
printf("Hello, world!\n");
|
||||
fat32_init();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user