Skip to content

Commit 2216418

Browse files
committed
Add FatFs submodule.
Now FAT file system in a separate library and I'll remove the original code from here. Unfortunately I had to sacrifice ext2 support, but it hasn't been in demand for all these years, so it's not a pity.
1 parent dd869de commit 2216418

File tree

8 files changed

+36
-335
lines changed

8 files changed

+36
-335
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/fatfs"]
2+
path = lib/fatfs
3+
url = https://github.com/DC-SWAT/FatFs.git

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TARGET_BIN_CD = 1$(TARGET_BIN)
1818
TRAGET_VERSION = -DVER_MAJOR=4 \
1919
-DVER_MINOR=0 \
2020
-DVER_MICRO=2 \
21-
-DVER_BUILD=0x11
21+
-DVER_BUILD=0x12
2222
# TARGET_DEBUG = 1 # or 2 for GDB
2323
# TARGET_EMU = 1
2424
# TARGET_PROF = 1
@@ -34,7 +34,8 @@ SRC_DIR = $(DS_BASE)/src
3434
LIB_DIR = $(DS_BASE)/lib
3535

3636
KOS_LDFLAGS += -L$(LIB_DIR)
37-
KOS_CFLAGS += -I$(INC_DIR) -I$(INC_DIR)/img -I$(INC_DIR)/SDL -I$(INC_DIR)/fatfs \
37+
KOS_CFLAGS += -I$(INC_DIR) -I$(INC_DIR)/img -I$(INC_DIR)/SDL \
38+
-I$(LIB_DIR)/fatfs/include \
3839
-I$(INC_DIR)/tsunami \
3940
-DHAVE_SDLIMAGE $(TRAGET_VERSION)
4041

@@ -57,7 +58,7 @@ TSUNAMI_VER = 2.0.0
5758
PARALLAX_VER = 2.0.0
5859
FREETYPE_VER = 2.4.4
5960

60-
EXTRA_LIBS = -lcfg -lmxml
61+
EXTRA_LIBS = -lcfg -lmxml -lfatfs
6162

6263
SDL_LIBS = -lSDL_$(SDL_VER) \
6364
-lSDL_image_$(SDL_IMAGE_VER) \
@@ -68,7 +69,7 @@ SDL_LIBS = -lSDL_$(SDL_VER) \
6869

6970
IMAGE_LIBS = -lkmg -ljpeg -lpng -lz
7071
LUA_LIBS = -llua_$(LUA_VER)
71-
KLIBS = -lkosext2fs -lpthread -lkosutils -lstdc++ -lm
72+
KLIBS = -lpthread -lkosutils -lstdc++ -lm
7273
GRAPHICS_LIBS = -ltsunami_$(TSUNAMI_VER) \
7374
-lparallax_$(PARALLAX_VER)
7475

@@ -96,10 +97,6 @@ DRIVERS_OBJ = $(SRC_DIR)/drivers/spi.o $(SRC_DIR)/drivers/sd.o \
9697
$(SRC_DIR)/drivers/enc28j60.o $(SRC_DIR)/drivers/asic.o \
9798
$(SRC_DIR)/drivers/rtc.o
9899

99-
FATFS_DIR = $(SRC_DIR)/fs/fat
100-
FATFS = $(FATFS_DIR)/option/ccsbcs.o $(FATFS_DIR)/option/syscall.o \
101-
$(FATFS_DIR)/ff.o $(FATFS_DIR)/dc.o
102-
103100
UTILS_DIR = $(SRC_DIR)/utils
104101
UTILS_OBJ = $(SRC_DIR)/utils.o $(UTILS_DIR)/gmtime.o $(UTILS_DIR)/strftime.o \
105102
$(UTILS_DIR)/debug_console.o $(UTILS_DIR)/memcpy.op \
@@ -117,7 +114,7 @@ OBJS = $(SRC_DIR)/main.o $(SRC_DIR)/video.o $(SRC_DIR)/console.o \
117114
$(SRC_DIR)/irq/exceptions.o $(SRC_DIR)/irq/setjmp.o \
118115
$(SRC_DIR)/settings.o $(SRC_DIR)/sfx.o \
119116
$(DRIVERS_OBJ) $(GUI_OBJS) $(CONSOLE_OBJ) \
120-
$(UTILS_OBJ) $(FATFS) $(SRC_DIR)/exports.o $(SRC_DIR)/exports_gcc.o \
117+
$(UTILS_OBJ) $(SRC_DIR)/exports.o $(SRC_DIR)/exports_gcc.o \
121118
romdisk.o
122119

123120
ifdef TARGET_PROF
@@ -216,6 +213,7 @@ release: build cdi
216213
update:
217214
@echo Fetching DreamShell from GitHub...
218215
@git fetch && git checkout origin/master
216+
@git submodule update --init --recursive
219217
@echo Fetching KallistiOS from GitHub...
220218
@cd $(KOS_BASE) && git fetch && git checkout `cat $(DS_BASE)/sdk/doc/KallistiOS.txt`
221219
@echo Fetching kos-ports from GitHub...
@@ -224,6 +222,7 @@ update:
224222
update-build:
225223
@echo Fetching DreamShell from GitHub...
226224
@git fetch && git checkout origin/master
225+
@git submodule update --init --recursive
227226
@echo Fetching and build KallistiOS from GitHub...
228227
@cd $(KOS_BASE) && git fetch && git checkout `cat $(DS_BASE)/sdk/doc/KallistiOS.txt` && make clean && make
229228
@echo Fetching and build kos-ports from GitHub...

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ git clone https://github.com/DC-SWAT/DreamShell.git ds
3636
git checkout `cat ds/sdk/doc/KallistiOS.txt`
3737
cp ds/sdk/toolchain/environ.sh environ.sh
3838
cp ds/sdk/toolchain/patches/*.diff utils/dc-chain/patches
39+
cd /usr/local/dc/kos/kos/ds
40+
git submodule update --init --recursive
3941
```
4042
##### Toolchain
4143
```console
@@ -92,6 +94,10 @@ make toolchain
9294
```console
9395
make
9496
```
97+
##### Libraries only
98+
```console
99+
cd ${KOS_BASE}/ds/lib && make
100+
```
95101
##### Modules, applications and commands only
96102
```console
97103
cd ${KOS_BASE}/ds/modules && make

exports.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ include dc/sound/sound.h
2424

2525
include ds.h
2626
include fs.h
27+
include fatfs.h
2728
include img/SegaPVRImage.h
2829
include img/decode.h
2930
include img/load.h
@@ -2089,12 +2090,6 @@ sdc_print_ident
20892090
sdc_blockdev_for_partition
20902091
sdc_blockdev_for_device
20912092
#
2092-
# Ext2 Filesystem
2093-
fs_ext2_init
2094-
fs_ext2_shutdown
2095-
fs_ext2_mount
2096-
fs_ext2_unmount
2097-
#
20982093
# FAT Filesystem
20992094
fs_fat_init
21002095
fs_fat_shutdown

firmware/bootloader/Makefile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#
22
# DreamShell boot loader
3-
# (c)2011-2024 SWAT
3+
# (c)2011-2025 SWAT
44
#
55

66
TARGET = bootloader
7-
VERSION = 2.7
7+
VERSION = 2.8
88
TARGET_NAME = DreamShell_$(TARGET)_v$(VERSION)
99
TARGET_CD = cd/1DS_BOOT.BIN
1010
KOS_ROMDISK_DIR = romdisk
@@ -22,22 +22,18 @@ rm-elf:
2222

2323
include ../../sdk/Makefile.cfg
2424

25-
FATFS = $(DS_BASE)/src/fs/fat
26-
DRIVERS = $(DS_BASE)/src/drivers
2725
UTILS = $(DS_BASE)/src/utils
2826

2927
OBJS = src/main.o src/spiral.o src/menu.o src/descramble.o \
30-
$(DRIVERS)/spi.o $(DRIVERS)/sd.o \
31-
$(FATFS)/option/ccsbcs.o $(FATFS)/option/syscall.o \
32-
$(FATFS)/ff.o $(FATFS)/dc.o $(FATFS)/../fs.o \
28+
$(DS_BASE)/src/fs/fs.o \
3329
$(UTILS)/memcpy.op $(UTILS)/memset.op romdisk.o
3430

35-
KOS_CFLAGS += -I$(DS_BASE)/include -I$(DS_BASE)/include/fatfs -I./include -DVERSION="$(VERSION)"
31+
KOS_CFLAGS += -I$(DS_BASE)/include -I$(DS_BASE)/lib/fatfs/include -I./include -DVERSION="$(VERSION)"
3632

3733
$(TARGET).bin: $(TARGET).elf
3834
$(TARGET).elf: $(OBJS)
3935
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET).elf \
40-
$(OBJS) $(OBJEXTRA) -lkosext2fs -lz -lkmg $(KOS_LIBS)
36+
$(OBJS) $(OBJEXTRA) -lz -lkmg -lfatfs $(KOS_LIBS)
4137
$(KOS_STRIP) $(TARGET).elf
4238
$(KOS_OBJCOPY) -R .stack -O binary $(TARGET).elf $(TARGET).bin
4339

include/fs.h

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* \file fs.h
33
* \brief DreamShell filesystem
4-
* \date 2007-2024
4+
* \date 2007-2025
55
* \author SWAT www.dc-swat.ru
66
*/
77

@@ -10,18 +10,16 @@
1010
#define _DS_FS_H
1111

1212
#include <arch/types.h>
13-
#include <kos/blockdev.h>
14-
#include <ext2/fs_ext2.h>
1513

1614
/**
1715
* Initialize SD Card
18-
* and mount all partitions with FAT or EXT2 filesystems
16+
* and mount all partitions with FAT filesystems
1917
*/
2018
int InitSDCard();
2119

2220
/**
2321
* Initialize G1-ATA device
24-
* and mount all partitions with FAT or EXT2 filesystems
22+
* and mount all partitions with FAT filesystems
2523
*/
2624
int InitIDE();
2725

@@ -41,59 +39,5 @@ int SearchRoot();
4139
*/
4240
int RootDeviceIsSupported(const char *name);
4341

44-
/**
45-
* FAT filesystem API
46-
*/
47-
48-
typedef enum fatfs_ioctl {
49-
50-
FATFS_IOCTL_CTRL_SYNC = 0, /* Flush disk cache (for write functions) */
51-
FATFS_IOCTL_GET_SECTOR_COUNT, /* Get media size (for only f_mkfs()), 4 byte unsigned */
52-
FATFS_IOCTL_GET_SECTOR_SIZE, /* Get sector size (for multiple sector size (_MAX_SS >= 1024)), 2 byte unsigned */
53-
FATFS_IOCTL_GET_BLOCK_SIZE, /* Get erase block size (for only f_mkfs()), 2 byte unsigned */
54-
FATFS_IOCTL_CTRL_ERASE_SECTOR, /* Force erased a block of sectors (for only _USE_ERASE) */
55-
FATFS_IOCTL_GET_BOOT_SECTOR_DATA, /* Get first sector data, ffconf.h _MAX_SS bytes */
56-
FATFS_IOCTL_GET_FD_LBA, /* Get file LBA, 4 byte unsigned */
57-
FATFS_IOCTL_GET_FD_LINK_MAP /* Get file clusters linkmap, 128+ bytes */
58-
59-
} fatfs_ioctl_t;
60-
61-
/**
62-
* Initialize and shutdown FAT filesystem
63-
* return 0 on success, or < 0 if error
64-
*/
65-
int fs_fat_init(void);
66-
int fs_fat_shutdown(void);
67-
68-
/**
69-
* Mount FAT filesystem on specified partition
70-
* For block device need reset to 0 start_block number
71-
* return 0 on success, or < 0 if error
72-
*/
73-
int fs_fat_mount(const char *mp, kos_blockdev_t *dev_pio, kos_blockdev_t *dev_dma, int partition);
74-
75-
/**
76-
* Unmount FAT filesystem
77-
* return 0 on success, or < 0 if error
78-
*/
79-
int fs_fat_unmount(const char *mp);
80-
81-
/**
82-
* Check mount point for FAT filesystem
83-
* return 0 is not FAT
84-
*/
85-
int fs_fat_is_mounted(const char *mp);
86-
87-
/**
88-
* Check partition type for FAT
89-
* return 0 if not FAT or 16/32 if FAT partition
90-
*/
91-
int is_fat_partition(uint8 partition_type);
92-
93-
/**
94-
* Check partition type for EXT2
95-
*/
96-
#define is_ext2_partition(partition_type) (partition_type == 0x83)
97-
9842

9943
#endif /* _DS_FS_H */

lib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
_SUBDIRS = libcfg/src libparallax SDL_rtf \
88
lua SDL SDL_gfx SDL_image SDL_ttf \
9-
libtsunami
9+
libtsunami fatfs/fatfs
1010

11-
_SUBDIRS_CLEAN = $(_SUBDIRS) freetype mxml
11+
_SUBDIRS_CLEAN = $(_SUBDIRS) freetype mxml fatfs/fatfs
1212

1313
all: build_freetype build_mxml $(patsubst %, _dir_%, $(_SUBDIRS))
1414

0 commit comments

Comments
 (0)