mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
V1.40
[FEATURE UPDATE] I changed out the memory based fat32 filesystem for one that runs on a 512mb disk img made during the make command (only get's made if the disk.img file is nonexistent) allowing files to be permanent. Also all these files combined are 67 files.. just fyi.
This commit is contained in:
parent
d2e7808cfa
commit
cc0db5de9d
67 changed files with 1057 additions and 354 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -18,3 +18,4 @@ limine 2/Makefile
|
||||||
limine 2/limine
|
limine 2/limine
|
||||||
limine 2/limine.dSYM/Contents/Resources/DWARF/limine
|
limine 2/limine.dSYM/Contents/Resources/DWARF/limine
|
||||||
limine 2/limine.exe
|
limine 2/limine.exe
|
||||||
|
disk.img
|
||||||
20
Makefile
20
Makefile
|
|
@ -13,6 +13,7 @@ ISO_DIR = iso_root
|
||||||
|
|
||||||
KERNEL_ELF = $(BUILD_DIR)/brewos.elf
|
KERNEL_ELF = $(BUILD_DIR)/brewos.elf
|
||||||
ISO_IMAGE = brewos.iso
|
ISO_IMAGE = brewos.iso
|
||||||
|
DISK_IMG = disk.img
|
||||||
|
|
||||||
C_SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
C_SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
||||||
CLI_APP_SOURCES = $(wildcard $(SRC_DIR)/cli_apps/*.c)
|
CLI_APP_SOURCES = $(wildcard $(SRC_DIR)/cli_apps/*.c)
|
||||||
|
|
@ -37,7 +38,7 @@ LIMINE_URL_BASE = https://github.com/limine-bootloader/limine/raw/v$(LIMINE_VERS
|
||||||
|
|
||||||
.PHONY: all clean run limine-setup
|
.PHONY: all clean run limine-setup
|
||||||
|
|
||||||
all: $(ISO_IMAGE)
|
all: $(ISO_IMAGE) $(DISK_IMG)
|
||||||
|
|
||||||
# Ensure build directories exist
|
# Ensure build directories exist
|
||||||
$(BUILD_DIR):
|
$(BUILD_DIR):
|
||||||
|
|
@ -112,10 +113,19 @@ $(ISO_IMAGE): $(KERNEL_ELF) limine.cfg limine-setup
|
||||||
# Install Limine to ISO (for BIOS boot)
|
# Install Limine to ISO (for BIOS boot)
|
||||||
./limine/limine bios-install $(ISO_IMAGE)
|
./limine/limine bios-install $(ISO_IMAGE)
|
||||||
|
|
||||||
clean:
|
# Create 512MB FAT32 Disk Image
|
||||||
rm -rf $(BUILD_DIR) $(ISO_DIR) $(ISO_IMAGE)
|
$(DISK_IMG):
|
||||||
|
@if [ ! -f $(DISK_IMG) ]; then \
|
||||||
|
echo "Creating 512MB FAT32 disk image..."; \
|
||||||
|
hdiutil create -size 512m -fs "MS-DOS FAT32" -layout NONE -type UDTO -o disk_temp; \
|
||||||
|
mv disk_temp.cdr $(DISK_IMG); \
|
||||||
|
fi
|
||||||
|
|
||||||
run: $(ISO_IMAGE)
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR) $(ISO_DIR) $(ISO_IMAGE) $(DISK_IMG)
|
||||||
|
|
||||||
|
run: $(ISO_IMAGE) $(DISK_IMG)
|
||||||
qemu-system-x86_64 -m 2G -serial stdio -cdrom $(ISO_IMAGE) -boot d \
|
qemu-system-x86_64 -m 2G -serial stdio -cdrom $(ISO_IMAGE) -boot d \
|
||||||
-audiodev coreaudio,id=audio0 -machine pcspk-audiodev=audio0 \
|
-audiodev coreaudio,id=audio0 -machine pcspk-audiodev=audio0 \
|
||||||
-netdev user,id=net0,hostfwd=udp::12345-:12345 -device e1000,netdev=net0
|
-netdev user,id=net0,hostfwd=udp::12345-:12345 -device e1000,netdev=net0 \
|
||||||
|
-drive file=$(DISK_IMG),format=raw,media=disk,index=1
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Brew OS 1.20 Alpha
|
# Brew OS 1.40 Alpha
|
||||||
|
|
||||||
## Brewkernel is now BrewOS!
|
## Brewkernel is now BrewOS!
|
||||||
Brewkernel will from now on be deprecated as it's core became too messy. I have built a less bloated kernel and wrote a DE above it, which is why it is now an OS instead of a kernel (in my opinion).
|
Brewkernel will from now on be deprecated as it's core became too messy. I have built a less bloated kernel and wrote a DE above it, which is why it is now an OS instead of a kernel (in my opinion).
|
||||||
|
|
@ -9,7 +9,8 @@ Brew Kernel is a simple x86_64 hobbyist operating system.
|
||||||
It features a DE (and WM), a FAT32 filesystem, customizable UI and much much more!
|
It features a DE (and WM), a FAT32 filesystem, customizable UI and much much more!
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Basic Networking Stack
|
-Disk saving
|
||||||
|
- Basic Networking Stack (UDP, TCP)
|
||||||
- Brew WM
|
- Brew WM
|
||||||
- Fat 32 FS
|
- Fat 32 FS
|
||||||
- 64-bit long mode support
|
- 64-bit long mode support
|
||||||
|
|
|
||||||
BIN
brewos.iso
BIN
brewos.iso
Binary file not shown.
BIN
build/about.o
BIN
build/about.o
Binary file not shown.
BIN
build/ata.o
Normal file
BIN
build/ata.o
Normal file
Binary file not shown.
BIN
build/brewos.elf
BIN
build/brewos.elf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/cmd.o
BIN
build/cmd.o
Binary file not shown.
Binary file not shown.
BIN
build/dns.o
BIN
build/dns.o
Binary file not shown.
BIN
build/e1000.o
BIN
build/e1000.o
Binary file not shown.
BIN
build/editor.o
BIN
build/editor.o
Binary file not shown.
BIN
build/explorer.o
BIN
build/explorer.o
Binary file not shown.
BIN
build/fat32.o
BIN
build/fat32.o
Binary file not shown.
BIN
build/graphics.o
BIN
build/graphics.o
Binary file not shown.
BIN
build/http.o
BIN
build/http.o
Binary file not shown.
BIN
build/icmp.o
BIN
build/icmp.o
Binary file not shown.
BIN
build/idt.o
BIN
build/idt.o
Binary file not shown.
Binary file not shown.
BIN
build/main.o
BIN
build/main.o
Binary file not shown.
BIN
build/markdown.o
BIN
build/markdown.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/network.o
BIN
build/network.o
Binary file not shown.
BIN
build/notepad.o
BIN
build/notepad.o
Binary file not shown.
BIN
build/pci.o
BIN
build/pci.o
Binary file not shown.
BIN
build/platform.o
BIN
build/platform.o
Binary file not shown.
BIN
build/ps2.o
BIN
build/ps2.o
Binary file not shown.
BIN
build/rtc.o
BIN
build/rtc.o
Binary file not shown.
BIN
build/tcp.o
BIN
build/tcp.o
Binary file not shown.
BIN
build/vm.o
BIN
build/vm.o
Binary file not shown.
BIN
build/wm.o
BIN
build/wm.o
Binary file not shown.
Binary file not shown.
|
|
@ -35,8 +35,8 @@ static void about_paint(Window *win) {
|
||||||
|
|
||||||
// Version info
|
// Version info
|
||||||
draw_string(offset_x, offset_y + 105, "BrewOS", COLOR_BLACK);
|
draw_string(offset_x, offset_y + 105, "BrewOS", COLOR_BLACK);
|
||||||
draw_string(offset_x, offset_y + 120, "BrewOS Version 1.30", COLOR_BLACK);
|
draw_string(offset_x, offset_y + 120, "BrewOS Version 1.40", COLOR_BLACK);
|
||||||
draw_string(offset_x, offset_y + 135, "Kernel Version 2.3.0", COLOR_BLACK);
|
draw_string(offset_x, offset_y + 135, "Kernel Version 2.4.0", COLOR_BLACK);
|
||||||
|
|
||||||
// Copyright
|
// Copyright
|
||||||
draw_string(offset_x, offset_y + 150, "(C) 2026 boreddevnl.", COLOR_BLACK);
|
draw_string(offset_x, offset_y + 150, "(C) 2026 boreddevnl.", COLOR_BLACK);
|
||||||
|
|
|
||||||
124
src/kernel/ata.c
Normal file
124
src/kernel/ata.c
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
#include "ata.h"
|
||||||
|
|
||||||
|
#define ATA_DATA 0x1F0
|
||||||
|
#define ATA_ERROR 0x1F1
|
||||||
|
#define ATA_SEC_CNT 0x1F2
|
||||||
|
#define ATA_LBA_LO 0x1F3
|
||||||
|
#define ATA_LBA_MID 0x1F4
|
||||||
|
#define ATA_LBA_HI 0x1F5
|
||||||
|
#define ATA_DRIVE_HEAD 0x1F6
|
||||||
|
#define ATA_STATUS 0x1F7
|
||||||
|
#define ATA_CMD 0x1F7
|
||||||
|
|
||||||
|
#define CMD_READ_PIO 0x20
|
||||||
|
#define CMD_WRITE_PIO 0x30
|
||||||
|
#define CMD_IDENTIFY 0xEC
|
||||||
|
|
||||||
|
// IO Port Helpers
|
||||||
|
static inline void outb(uint16_t port, uint8_t val) {
|
||||||
|
__asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint8_t inb(uint16_t port) {
|
||||||
|
uint8_t ret;
|
||||||
|
__asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void insw(uint16_t port, void *addr, uint32_t cnt) {
|
||||||
|
__asm__ volatile ("rep insw" : "+D"(addr), "+c"(cnt) : "d"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void outsw(uint16_t port, const void *addr, uint32_t cnt) {
|
||||||
|
__asm__ volatile ("rep outsw" : "+S"(addr), "+c"(cnt) : "d"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ata_wait_bsy(void) {
|
||||||
|
while (inb(ATA_STATUS) & 0x80);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ata_wait_drq(void) {
|
||||||
|
while (!(inb(ATA_STATUS) & 0x08));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select drive (0 = Master, 1 = Slave)
|
||||||
|
static void ata_select_drive(int drive) {
|
||||||
|
outb(ATA_DRIVE_HEAD, 0xE0 | (drive << 4));
|
||||||
|
// Small delay
|
||||||
|
inb(ATA_STATUS);
|
||||||
|
inb(ATA_STATUS);
|
||||||
|
inb(ATA_STATUS);
|
||||||
|
inb(ATA_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ata_init(void) {
|
||||||
|
// Simple probe: Try to identify Primary Slave (where we put disk.img in QEMU index=1)
|
||||||
|
// Note: QEMU index=0 is usually the CDROM if -boot d is used, or Primary Master.
|
||||||
|
// We will try to read from the drive to verify it exists.
|
||||||
|
ata_select_drive(1); // Select Slave
|
||||||
|
outb(ATA_SEC_CNT, 0);
|
||||||
|
outb(ATA_LBA_LO, 0);
|
||||||
|
outb(ATA_LBA_MID, 0);
|
||||||
|
outb(ATA_LBA_HI, 0);
|
||||||
|
outb(ATA_CMD, CMD_IDENTIFY);
|
||||||
|
|
||||||
|
uint8_t status = inb(ATA_STATUS);
|
||||||
|
if (status == 0) return false; // No drive
|
||||||
|
|
||||||
|
// Poll until BSY clears
|
||||||
|
while(inb(ATA_STATUS) & 0x80);
|
||||||
|
|
||||||
|
// Check for ATAPI signature (we don't want the CDROM)
|
||||||
|
if (inb(ATA_LBA_MID) != 0 || inb(ATA_LBA_HI) != 0) {
|
||||||
|
return false; // Not ATA
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read 256 words of identify data to clear buffer
|
||||||
|
uint16_t buffer[256];
|
||||||
|
ata_wait_drq();
|
||||||
|
insw(ATA_DATA, buffer, 256);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ata_read_sectors(uint32_t lba, uint8_t count, void* buffer) {
|
||||||
|
ata_wait_bsy();
|
||||||
|
ata_select_drive(1); // Always using Slave for storage
|
||||||
|
|
||||||
|
outb(ATA_SEC_CNT, count);
|
||||||
|
outb(ATA_LBA_LO, (uint8_t)lba);
|
||||||
|
outb(ATA_LBA_MID, (uint8_t)(lba >> 8));
|
||||||
|
outb(ATA_LBA_HI, (uint8_t)(lba >> 16));
|
||||||
|
outb(ATA_DRIVE_HEAD, 0xE0 | (1 << 4) | ((lba >> 24) & 0x0F));
|
||||||
|
outb(ATA_CMD, CMD_READ_PIO);
|
||||||
|
|
||||||
|
uint16_t *buf = (uint16_t*)buffer;
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
ata_wait_bsy();
|
||||||
|
ata_wait_drq();
|
||||||
|
insw(ATA_DATA, buf, 256);
|
||||||
|
buf += 256;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ata_write_sectors(uint32_t lba, uint8_t count, const void* buffer) {
|
||||||
|
ata_wait_bsy();
|
||||||
|
ata_select_drive(1);
|
||||||
|
|
||||||
|
outb(ATA_SEC_CNT, count);
|
||||||
|
outb(ATA_LBA_LO, (uint8_t)lba);
|
||||||
|
outb(ATA_LBA_MID, (uint8_t)(lba >> 8));
|
||||||
|
outb(ATA_LBA_HI, (uint8_t)(lba >> 16));
|
||||||
|
outb(ATA_DRIVE_HEAD, 0xE0 | (1 << 4) | ((lba >> 24) & 0x0F));
|
||||||
|
outb(ATA_CMD, CMD_WRITE_PIO);
|
||||||
|
|
||||||
|
const uint16_t *buf = (const uint16_t*)buffer;
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
ata_wait_bsy();
|
||||||
|
ata_wait_drq();
|
||||||
|
outsw(ATA_DATA, buf, 256);
|
||||||
|
buf += 256;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
11
src/kernel/ata.h
Normal file
11
src/kernel/ata.h
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
// Initialize ATA driver and find the FAT32 disk
|
||||||
|
bool ata_init(void);
|
||||||
|
|
||||||
|
// Read/Write sectors (LBA28)
|
||||||
|
// Returns 0 on success, non-zero on error
|
||||||
|
int ata_read_sectors(uint32_t lba, uint8_t count, void* buffer);
|
||||||
|
int ata_write_sectors(uint32_t lba, uint8_t count, const void* buffer);
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
void cli_cmd_brewver(char *args) {
|
void cli_cmd_brewver(char *args) {
|
||||||
(void)args;
|
(void)args;
|
||||||
cli_write("BrewOS v1.30 Alpha\n");
|
cli_write("BrewOS v1.40 Alpha\n");
|
||||||
cli_write("BrewOS Kernel V2.3.0 Pre-Alpha\n");
|
cli_write("BrewOS Kernel V2.4.0 Pre-Alpha\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -618,11 +618,21 @@ static void program() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cli_cmd_cc(char *args) {
|
void cli_cmd_cc(char *args) {
|
||||||
|
// Skip leading whitespace
|
||||||
|
while (args && *args == ' ') args++;
|
||||||
|
|
||||||
if (!args || !*args) {
|
if (!args || !*args) {
|
||||||
cmd_write("Usage: cc <filename.c>\n");
|
cmd_write("Usage: cc <filename.c>\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trim trailing whitespace
|
||||||
|
int len = cli_strlen(args);
|
||||||
|
while (len > 0 && (args[len-1] == ' ' || args[len-1] == '\t' || args[len-1] == '\n')) {
|
||||||
|
args[len-1] = 0;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
FAT32_FileHandle *fh = fat32_open(args, "r");
|
FAT32_FileHandle *fh = fat32_open(args, "r");
|
||||||
if (!fh) {
|
if (!fh) {
|
||||||
cmd_write("Error: Cannot open source file.\n");
|
cmd_write("Error: Cannot open source file.\n");
|
||||||
|
|
@ -636,8 +646,8 @@ void cli_cmd_cc(char *args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = fat32_read(fh, source, MAX_SOURCE - 1);
|
int read_len = fat32_read(fh, source, MAX_SOURCE - 1);
|
||||||
source[len] = 0;
|
source[read_len] = 0;
|
||||||
fat32_close(fh);
|
fat32_close(fh);
|
||||||
|
|
||||||
lexer(source);
|
lexer(source);
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,9 @@ void cli_cmd_echo(char *args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cli_cmd_cat(char *args) {
|
void cli_cmd_cat(char *args) {
|
||||||
|
// Skip leading whitespace
|
||||||
|
while (args && *args == ' ') args++;
|
||||||
|
|
||||||
if (!args || args[0] == 0) {
|
if (!args || args[0] == 0) {
|
||||||
cli_write("Usage: cat <filename>\n");
|
cli_write("Usage: cat <filename>\n");
|
||||||
return;
|
return;
|
||||||
|
|
@ -253,7 +256,7 @@ void cli_cmd_touch(char *args) {
|
||||||
|
|
||||||
char filename[256];
|
char filename[256];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (args[i] && args[i] != ' ' && args[i] != '\t') {
|
while (args[i] && args[i] != ' ' && args[i] != '\t' && args[i] != '\n') {
|
||||||
filename[i] = args[i];
|
filename[i] = args[i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
175
src/kernel/cmd.c
175
src/kernel/cmd.c
|
|
@ -328,6 +328,45 @@ void pager_set_mode(void) {
|
||||||
current_mode = MODE_PAGER;
|
current_mode = MODE_PAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Internal LS command to avoid stack overflow in external module
|
||||||
|
static void internal_cmd_ls(char *args) {
|
||||||
|
char path[256];
|
||||||
|
if (args && *args) {
|
||||||
|
int i=0;
|
||||||
|
while(args[i] && i < 255) { path[i] = args[i]; i++; }
|
||||||
|
path[i] = 0;
|
||||||
|
} else {
|
||||||
|
path[0] = '.'; path[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int max_files = 64;
|
||||||
|
FAT32_FileInfo *files = (FAT32_FileInfo*)kmalloc(max_files * sizeof(FAT32_FileInfo));
|
||||||
|
if (!files) {
|
||||||
|
cmd_write("Error: Out of memory\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = fat32_list_directory(path, files, max_files);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
if (files[i].is_directory) {
|
||||||
|
cmd_write("[DIR] ");
|
||||||
|
} else {
|
||||||
|
cmd_write("[FILE] ");
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_write(files[i].name);
|
||||||
|
if (!files[i].is_directory) {
|
||||||
|
cmd_write(" ");
|
||||||
|
cmd_write_int(files[i].size);
|
||||||
|
cmd_write("b");
|
||||||
|
}
|
||||||
|
cmd_write("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
kfree(files);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Commands (now delegated to cli_apps/) ---
|
// --- Commands (now delegated to cli_apps/) ---
|
||||||
|
|
||||||
// Command dispatch table
|
// Command dispatch table
|
||||||
|
|
@ -374,8 +413,8 @@ static const CommandEntry commands[] = {
|
||||||
{"cd", cli_cmd_cd},
|
{"cd", cli_cmd_cd},
|
||||||
{"PWD", cli_cmd_pwd},
|
{"PWD", cli_cmd_pwd},
|
||||||
{"pwd", cli_cmd_pwd},
|
{"pwd", cli_cmd_pwd},
|
||||||
{"LS", cli_cmd_ls},
|
{"LS", internal_cmd_ls},
|
||||||
{"ls", cli_cmd_ls},
|
{"ls", internal_cmd_ls},
|
||||||
{"MKDIR", cli_cmd_mkdir},
|
{"MKDIR", cli_cmd_mkdir},
|
||||||
{"mkdir", cli_cmd_mkdir},
|
{"mkdir", cli_cmd_mkdir},
|
||||||
{"RM", cli_cmd_rm},
|
{"RM", cli_cmd_rm},
|
||||||
|
|
@ -895,12 +934,14 @@ void cmd_reset(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_test_files(void) {
|
static void create_test_files(void) {
|
||||||
fat32_mkdir("Documents");
|
if (!fat32_exists("Documents")) fat32_mkdir("Documents");
|
||||||
fat32_mkdir("Projects");
|
if (!fat32_exists("Projects")) fat32_mkdir("Projects");
|
||||||
fat32_mkdir("Documents/Important");
|
if (!fat32_exists("Documents/Important")) fat32_mkdir("Documents/Important");
|
||||||
fat32_mkdir("Apps");
|
if (!fat32_exists("Apps")) fat32_mkdir("Apps");
|
||||||
|
|
||||||
FAT32_FileHandle *fh = fat32_open("README.md", "w");
|
FAT32_FileHandle *fh;
|
||||||
|
// Always try to write README to ensure content exists (fixes empty file issue)
|
||||||
|
fh = fat32_open("README.md", "w");
|
||||||
if (fh) {
|
if (fh) {
|
||||||
const char *content =
|
const char *content =
|
||||||
"# Brew OS 1.01 Alpha\n\n"
|
"# Brew OS 1.01 Alpha\n\n"
|
||||||
|
|
@ -992,8 +1033,8 @@ static void create_test_files(void) {
|
||||||
"The above attribution requirements are informational and intended to\n"
|
"The above attribution requirements are informational and intended to\n"
|
||||||
"ensure proper credit is given. They do not alter or supersede the\n"
|
"ensure proper credit is given. They do not alter or supersede the\n"
|
||||||
"terms of the GNU General Public License (GPL), which governs this work.\n";
|
"terms of the GNU General Public License (GPL), which governs this work.\n";
|
||||||
fat32_write(fh, (void *)content, cmd_strlen(content));
|
fat32_write(fh, (void *)content, cmd_strlen(content));
|
||||||
fat32_close(fh);
|
fat32_close(fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
fh = fat32_open("Apps/README.md", "w");
|
fh = fat32_open("Apps/README.md", "w");
|
||||||
|
|
@ -1001,7 +1042,7 @@ static void create_test_files(void) {
|
||||||
const char *content =
|
const char *content =
|
||||||
"# All compiled C files in this directory are openable from any other directory by typing in the name of the compiled file by typing in the name of the compiled file.\n\n"
|
"# All compiled C files in this directory are openable from any other directory by typing in the name of the compiled file by typing in the name of the compiled file.\n\n"
|
||||||
"The c file 'wordofgod.c' contains a C program similar to one in TempleOS, which Terry A. Davis (RIP) saw as 'words from god' telling him what to do with his kernel.\n"
|
"The c file 'wordofgod.c' contains a C program similar to one in TempleOS, which Terry A. Davis (RIP) saw as 'words from god' telling him what to do with his kernel.\n"
|
||||||
"I made this file as a tribute to him, as he also inspired me to create this project in '24. If you want to run it you simply do cc (or compc) wordofgod.c and then run ./wordofgod \n";
|
"I made this file as a tribute to him, as he also inspired me to create this project in '24. If you want to run it you simply do cc (or compc) wordgod.c and then run ./wordgod \n";
|
||||||
fat32_write(fh, (void *)content, cmd_strlen(content));
|
fat32_write(fh, (void *)content, cmd_strlen(content));
|
||||||
fat32_close(fh);
|
fat32_close(fh);
|
||||||
}
|
}
|
||||||
|
|
@ -1024,74 +1065,60 @@ static void create_test_files(void) {
|
||||||
|
|
||||||
fh = fat32_open("Apps/wordofgod.c", "w");
|
fh = fat32_open("Apps/wordofgod.c", "w");
|
||||||
if (fh) {
|
if (fh) {
|
||||||
char *h = "int main(){int l;l=malloc(1200);";
|
// Buffer the entire file content to write in one go
|
||||||
fat32_write(fh, h, cmd_strlen(h));
|
// This prevents issues with multiple small writes causing truncation
|
||||||
char *w1 = "poke(l+0,\"In \");poke(l+4,\"the \");poke(l+8,\"beginning \");poke(l+12,\"God \");poke(l+16,\"created \");poke(l+20,\"heaven \");poke(l+24,\"and \");poke(l+28,\"earth \");poke(l+32,\"light \");poke(l+36,\"darkness \");";
|
char *buf = (char*)kmalloc(8192);
|
||||||
fat32_write(fh, w1, cmd_strlen(w1));
|
if (buf) {
|
||||||
char *w2 = "poke(l+40,\"day \");poke(l+44,\"night \");poke(l+48,\"waters \");poke(l+52,\"firmament \");poke(l+56,\"evening \");poke(l+60,\"morning \");poke(l+64,\"land \");poke(l+68,\"seas \");poke(l+72,\"grass \");poke(l+76,\"herb \");";
|
int p = 0;
|
||||||
fat32_write(fh, w2, cmd_strlen(w2));
|
const char *strs[] = {
|
||||||
char *w3 = "poke(l+80,\"seed \");poke(l+84,\"fruit \");poke(l+88,\"tree \");poke(l+92,\"sun \");poke(l+96,\"moon \");poke(l+100,\"stars \");poke(l+104,\"signs \");poke(l+108,\"seasons \");poke(l+112,\"days \");poke(l+116,\"years \");";
|
"int main(){int l;l=malloc(1200);",
|
||||||
fat32_write(fh, w3, cmd_strlen(w3));
|
"poke(l+0,\"In \");poke(l+4,\"the \");poke(l+8,\"beginning \");poke(l+12,\"God \");poke(l+16,\"created \");poke(l+20,\"heaven \");poke(l+24,\"and \");poke(l+28,\"earth \");poke(l+32,\"light \");poke(l+36,\"darkness \");",
|
||||||
char *w4 = "poke(l+120,\"creature \");poke(l+124,\"life \");poke(l+128,\"fowl \");poke(l+132,\"whales \");poke(l+136,\"cattle \");poke(l+140,\"creeping \");poke(l+144,\"beast \");poke(l+148,\"man \");poke(l+152,\"image \");poke(l+156,\"likeness \");";
|
"poke(l+40,\"day \");poke(l+44,\"night \");poke(l+48,\"waters \");poke(l+52,\"firmament \");poke(l+56,\"evening \");poke(l+60,\"morning \");poke(l+64,\"land \");poke(l+68,\"seas \");poke(l+72,\"grass \");poke(l+76,\"herb \");",
|
||||||
fat32_write(fh, w4, cmd_strlen(w4));
|
"poke(l+80,\"seed \");poke(l+84,\"fruit \");poke(l+88,\"tree \");poke(l+92,\"sun \");poke(l+96,\"moon \");poke(l+100,\"stars \");poke(l+104,\"signs \");poke(l+108,\"seasons \");poke(l+112,\"days \");poke(l+116,\"years \");",
|
||||||
char *w5 = "poke(l+160,\"dominion \");poke(l+164,\"fish \");poke(l+168,\"air \");poke(l+172,\"every \");poke(l+176,\"CIA \");poke(l+180,\"meat \");poke(l+184,\"holy \");poke(l+188,\"rest \");poke(l+192,\"dust \");poke(l+196,\"breath \");";
|
"poke(l+120,\"creature \");poke(l+124,\"life \");poke(l+128,\"fowl \");poke(l+132,\"whales \");poke(l+136,\"cattle \");poke(l+140,\"creeping \");poke(l+144,\"beast \");poke(l+148,\"man \");poke(l+152,\"image \");poke(l+156,\"likeness \");",
|
||||||
fat32_write(fh, w5, cmd_strlen(w5));
|
"poke(l+160,\"dominion \");poke(l+164,\"fish \");poke(l+168,\"air \");poke(l+172,\"every \");poke(l+176,\"CIA \");poke(l+180,\"meat \");poke(l+184,\"holy \");poke(l+188,\"rest \");poke(l+192,\"dust \");poke(l+196,\"breath \");",
|
||||||
char *w6 = "poke(l+200,\"soul \");poke(l+204,\"garden \");poke(l+208,\"east \");poke(l+212,\"Eden \");poke(l+216,\"ground \");poke(l+220,\"sight \");poke(l+224,\"good \");poke(l+228,\"evil \");poke(l+232,\"river \");poke(l+236,\"gold \");";
|
"poke(l+200,\"soul \");poke(l+204,\"garden \");poke(l+208,\"east \");poke(l+212,\"Eden \");poke(l+216,\"ground \");poke(l+220,\"sight \");poke(l+224,\"good \");poke(l+228,\"evil \");poke(l+232,\"river \");poke(l+236,\"gold \");",
|
||||||
fat32_write(fh, w6, cmd_strlen(w6));
|
"poke(l+240,\"stone \");poke(l+244,\"woman \");poke(l+248,\"wife \");poke(l+252,\"flesh \");poke(l+256,\"bone \");poke(l+260,\"naked \");poke(l+264,\"serpent \");poke(l+268,\"subtle \");poke(l+272,\"eat \");poke(l+276,\"eyes \");",
|
||||||
char *w7 = "poke(l+240,\"stone \");poke(l+244,\"woman \");poke(l+248,\"wife \");poke(l+252,\"flesh \");poke(l+256,\"bone \");poke(l+260,\"naked \");poke(l+264,\"serpent \");poke(l+268,\"subtle \");poke(l+272,\"eat \");poke(l+276,\"eyes \");";
|
"poke(l+280,\"wise \");poke(l+284,\"cool \");poke(l+288,\"voice \");poke(l+292,\"fear \");poke(l+296,\"hid \");poke(l+300,\"cursed \");poke(l+304,\"belly \");poke(l+308,\"enmity \");poke(l+312,\"sorrow \");poke(l+316,\"conception \");",
|
||||||
fat32_write(fh, w7, cmd_strlen(w7));
|
"poke(l+320,\"children \");poke(l+324,\"desire \");poke(l+328,\"husband \");poke(l+332,\"thorns \");poke(l+336,\"thistles \");poke(l+340,\"sweat \");poke(l+344,\"bread \");poke(l+348,\"mother \");poke(l+352,\"skin \");poke(l+356,\"coats \");",
|
||||||
char *w8 = "poke(l+280,\"wise \");poke(l+284,\"cool \");poke(l+288,\"voice \");poke(l+292,\"fear \");poke(l+296,\"hid \");poke(l+300,\"cursed \");poke(l+304,\"belly \");poke(l+308,\"enmity \");poke(l+312,\"sorrow \");poke(l+316,\"conception \");";
|
"poke(l+360,\"cherubims \");poke(l+364,\"sword \");poke(l+368,\"gate \");poke(l+372,\"offering \");poke(l+376,\"respect \");poke(l+380,\"sin \");poke(l+384,\"door \");poke(l+388,\"blood \");poke(l+392,\"brother \");poke(l+396,\"keeper \");",
|
||||||
fat32_write(fh, w8, cmd_strlen(w8));
|
"poke(l+400,\"voice \");poke(l+404,\"heard \");poke(l+408,\"walking \");poke(l+412,\"cool \");poke(l+416,\"day \");poke(l+420,\"where \");poke(l+424,\"art \");poke(l+428,\"thou \");poke(l+432,\"told \");poke(l+436,\"thee \");",
|
||||||
char *w9 = "poke(l+320,\"children \");poke(l+324,\"desire \");poke(l+328,\"husband \");poke(l+332,\"thorns \");poke(l+336,\"thistles \");poke(l+340,\"sweat \");poke(l+344,\"bread \");poke(l+348,\"mother \");poke(l+352,\"skin \");poke(l+356,\"coats \");";
|
"poke(l+440,\"hast \");poke(l+444,\"eaten \");poke(l+448,\"tree \");poke(l+452,\"whereof \");poke(l+456,\"commanded \");poke(l+460,\"shouldest \");poke(l+464,\"not \");poke(l+468,\"eat \");poke(l+472,\"gave \");poke(l+476,\"me \");",
|
||||||
fat32_write(fh, w9, cmd_strlen(w9));
|
"poke(l+480,\"beguiled \");poke(l+484,\"belly \");poke(l+488,\"go \");poke(l+492,\"dust \");poke(l+496,\"shalt \");poke(l+500,\"eat \");poke(l+504,\"days \");poke(l+508,\"life \");poke(l+512,\"put \");poke(l+516,\"enmity \");",
|
||||||
char *w10 = "poke(l+360,\"cherubims \");poke(l+364,\"sword \");poke(l+368,\"gate \");poke(l+372,\"offering \");poke(l+376,\"respect \");poke(l+380,\"sin \");poke(l+384,\"door \");poke(l+388,\"blood \");poke(l+392,\"brother \");poke(l+396,\"keeper \");";
|
"poke(l+520,\"between \");poke(l+524,\"seed \");poke(l+528,\"bruise \");poke(l+532,\"head \");poke(l+536,\"heel \");poke(l+540,\"multiply \");poke(l+544,\"sorrow \");poke(l+548,\"conception \");poke(l+552,\"forth \");poke(l+556,\"children \");",
|
||||||
fat32_write(fh, w10, cmd_strlen(w10));
|
"poke(l+560,\"desire \");poke(l+564,\"rule \");poke(l+568,\"over \");poke(l+572,\"sake \");poke(l+576,\"sweat \");poke(l+580,\"face \");poke(l+584,\"till \");poke(l+588,\"return \");poke(l+592,\"ground \");poke(l+596,\"taken \");",
|
||||||
char *w11 = "poke(l+400,\"voice \");poke(l+404,\"heard \");poke(l+408,\"walking \");poke(l+412,\"cool \");poke(l+416,\"day \");poke(l+420,\"where \");poke(l+424,\"art \");poke(l+428,\"thou \");poke(l+432,\"told \");poke(l+436,\"thee \");";
|
"poke(l+600,\"mother \");poke(l+604,\"living \");poke(l+608,\"coats \");poke(l+612,\"skins \");poke(l+616,\"clothed \");poke(l+620,\"become \");poke(l+624,\"one \");poke(l+628,\"us \");poke(l+632,\"know \");poke(l+636,\"good \");",
|
||||||
fat32_write(fh, w11, cmd_strlen(w11));
|
"poke(l+640,\"evil \");poke(l+644,\"lest \");poke(l+648,\"put \");poke(l+652,\"hand \");poke(l+656,\"take \");poke(l+660,\"live \");poke(l+664,\"ever \");poke(l+668,\"sent \");poke(l+672,\"garden \");poke(l+676,\"eden \");",
|
||||||
char *w12 = "poke(l+440,\"hast \");poke(l+444,\"eaten \");poke(l+448,\"tree \");poke(l+452,\"whereof \");poke(l+456,\"commanded \");poke(l+460,\"shouldest \");poke(l+464,\"not \");poke(l+468,\"eat \");poke(l+472,\"gave \");poke(l+476,\"me \");";
|
"poke(l+680,\"flaming \");poke(l+684,\"sword \");poke(l+688,\"turned \");poke(l+692,\"way \");poke(l+696,\"knew \");poke(l+700,\"conceived \");poke(l+704,\"bare \");poke(l+708,\"cain \");poke(l+712,\"said \");poke(l+716,\"gotten \");",
|
||||||
fat32_write(fh, w12, cmd_strlen(w12));
|
"poke(l+720,\"lord \");poke(l+724,\"again \");poke(l+728,\"abel \");poke(l+732,\"sheep \");poke(l+736,\"tiller \");poke(l+740,\"process \");poke(l+744,\"time \");poke(l+748,\"pass \");poke(l+752,\"brought \");poke(l+756,\"fruit \");",
|
||||||
char *w13 = "poke(l+480,\"beguiled \");poke(l+484,\"belly \");poke(l+488,\"go \");poke(l+492,\"dust \");poke(l+496,\"shalt \");poke(l+500,\"eat \");poke(l+504,\"days \");poke(l+508,\"life \");poke(l+512,\"put \");poke(l+516,\"enmity \");";
|
"poke(l+760,\"offering \");poke(l+764,\"firstlings \");poke(l+768,\"flock \");poke(l+772,\"fat \");poke(l+776,\"thereof \");poke(l+780,\"respect \");poke(l+784,\"wroth \");poke(l+788,\"countenance \");poke(l+792,\"fallen \");poke(l+796,\"well \");",
|
||||||
fat32_write(fh, w13, cmd_strlen(w13));
|
"poke(l+800,\"accepted \");poke(l+804,\"not \");poke(l+808,\"sin \");poke(l+812,\"lieth \");poke(l+816,\"door \");poke(l+820,\"unto \");poke(l+824,\"rule \");poke(l+828,\"talked \");poke(l+832,\"field \");poke(l+836,\"rose \");",
|
||||||
char *w14 = "poke(l+520,\"between \");poke(l+524,\"seed \");poke(l+528,\"bruise \");poke(l+532,\"head \");poke(l+536,\"heel \");poke(l+540,\"multiply \");poke(l+544,\"sorrow \");poke(l+548,\"conception \");poke(l+552,\"forth \");poke(l+556,\"children \");";
|
"poke(l+840,\"slew \");poke(l+844,\"done \");poke(l+848,\"crieth \");poke(l+852,\"mouth \");poke(l+856,\"receive \");poke(l+860,\"strength \");poke(l+864,\"fugitive \");poke(l+868,\"vagabond \");poke(l+872,\"punishment \");poke(l+876,\"greater \");",
|
||||||
fat32_write(fh, w14, cmd_strlen(w14));
|
"poke(l+880,\"bear \");poke(l+884,\"driven \");poke(l+888,\"hid \");poke(l+892,\"findeth \");poke(l+896,\"slay \");poke(l+900,\"vengeance \");poke(l+904,\"sevenfold \");poke(l+908,\"mark \");poke(l+912,\"finding \");poke(l+916,\"kill \");",
|
||||||
char *w15 = "poke(l+560,\"desire \");poke(l+564,\"rule \");poke(l+568,\"over \");poke(l+572,\"sake \");poke(l+576,\"sweat \");poke(l+580,\"face \");poke(l+584,\"till \");poke(l+588,\"return \");poke(l+592,\"ground \");poke(l+596,\"taken \");";
|
"poke(l+920,\"presence \");poke(l+924,\"dwelt \");poke(l+928,\"nod \");poke(l+932,\"enoch \");poke(l+936,\"city \");poke(l+940,\"irad \");poke(l+944,\"mehujael \");poke(l+948,\"methusael \");poke(l+952,\"lamech \");poke(l+956,\"adah \");",
|
||||||
fat32_write(fh, w15, cmd_strlen(w15));
|
"poke(l+960,\"zillah \");poke(l+964,\"jabal \");poke(l+968,\"tent \");poke(l+972,\"cattle \");poke(l+976,\"jubal \");poke(l+980,\"harp \");poke(l+984,\"organ \");poke(l+988,\"tubalcain \");poke(l+992,\"brass \");poke(l+996,\"iron \");",
|
||||||
char *w16 = "poke(l+600,\"mother \");poke(l+604,\"living \");poke(l+608,\"coats \");poke(l+612,\"skins \");poke(l+616,\"clothed \");poke(l+620,\"become \");poke(l+624,\"one \");poke(l+628,\"us \");poke(l+632,\"know \");poke(l+636,\"good \");";
|
"poke(l+1000,\"naamah \");poke(l+1004,\"wives \");poke(l+1008,\"hear \");poke(l+1012,\"speech \");poke(l+1016,\"hearken \");poke(l+1020,\"young \");poke(l+1024,\"hurt \");poke(l+1028,\"wounding \");poke(l+1032,\"avenged \");poke(l+1036,\"seventy \");",
|
||||||
fat32_write(fh, w16, cmd_strlen(w16));
|
"poke(l+1040,\"seth \");poke(l+1044,\"appointed \");poke(l+1048,\"enos \");poke(l+1052,\"began \");poke(l+1056,\"call \");poke(l+1060,\"name \");poke(l+1064,\"generations \");poke(l+1068,\"adam \");poke(l+1072,\"likeness \");poke(l+1076,\"blessed \");",
|
||||||
char *w17 = "poke(l+640,\"evil \");poke(l+644,\"lest \");poke(l+648,\"put \");poke(l+652,\"hand \");poke(l+656,\"take \");poke(l+660,\"live \");poke(l+664,\"ever \");poke(l+668,\"sent \");poke(l+672,\"garden \");poke(l+676,\"eden \");";
|
"poke(l+1080,\"begat \");poke(l+1084,\"sons \");poke(l+1088,\"daughters \");poke(l+1092,\"lived \");poke(l+1096,\"died \");poke(l+1100,\"cainan \");poke(l+1104,\"mahalaleel \");poke(l+1108,\"jared \");poke(l+1112,\"walked \");poke(l+1116,\"three \");",
|
||||||
fat32_write(fh, w17, cmd_strlen(w17));
|
"poke(l+1120,\"hundred \");poke(l+1124,\"sixty \");poke(l+1128,\"five \");poke(l+1132,\"methuselah \");poke(l+1136,\"lamech \");poke(l+1140,\"noah \");poke(l+1144,\"comfort \");poke(l+1148,\"work \");poke(l+1152,\"toil \");poke(l+1156,\"hands \");",
|
||||||
char *w18 = "poke(l+680,\"flaming \");poke(l+684,\"sword \");poke(l+688,\"turned \");poke(l+692,\"way \");poke(l+696,\"knew \");poke(l+700,\"conceived \");poke(l+704,\"bare \");poke(l+708,\"cain \");poke(l+712,\"said \");poke(l+716,\"gotten \");";
|
"poke(l+1160,\"shem \");poke(l+1164,\"ham \");poke(l+1168,\"japheth \");poke(l+1172,\"men \");poke(l+1176,\"daughters \");poke(l+1180,\"born \");poke(l+1184,\"fair \");poke(l+1188,\"chose \");poke(l+1192,\"spirit \");poke(l+1196,\"strive \");",
|
||||||
fat32_write(fh, w18, cmd_strlen(w18));
|
"int c;int r;r=abs(rand());r=r-(r/5)*5;c=14+r;int i;i=0;while(i<c){int x;x=abs(rand());x=x-(x/300)*300;int w;w=peek(l+x*4);print_str(w);i=i+1;}nl();}",
|
||||||
char *w19 = "poke(l+720,\"lord \");poke(l+724,\"again \");poke(l+728,\"abel \");poke(l+732,\"sheep \");poke(l+736,\"tiller \");poke(l+740,\"process \");poke(l+744,\"time \");poke(l+748,\"pass \");poke(l+752,\"brought \");poke(l+756,\"fruit \");";
|
NULL
|
||||||
fat32_write(fh, w19, cmd_strlen(w19));
|
};
|
||||||
char *w20 = "poke(l+760,\"offering \");poke(l+764,\"firstlings \");poke(l+768,\"flock \");poke(l+772,\"fat \");poke(l+776,\"thereof \");poke(l+780,\"respect \");poke(l+784,\"wroth \");poke(l+788,\"countenance \");poke(l+792,\"fallen \");poke(l+796,\"well \");";
|
|
||||||
fat32_write(fh, w20, cmd_strlen(w20));
|
for (int i = 0; strs[i]; i++) {
|
||||||
char *w21 = "poke(l+800,\"accepted \");poke(l+804,\"not \");poke(l+808,\"sin \");poke(l+812,\"lieth \");poke(l+816,\"door \");poke(l+820,\"unto \");poke(l+824,\"rule \");poke(l+828,\"talked \");poke(l+832,\"field \");poke(l+836,\"rose \");";
|
const char *s = strs[i];
|
||||||
fat32_write(fh, w21, cmd_strlen(w21));
|
while (*s && p < 8191) buf[p++] = *s++;
|
||||||
char *w22 = "poke(l+840,\"slew \");poke(l+844,\"done \");poke(l+848,\"crieth \");poke(l+852,\"mouth \");poke(l+856,\"receive \");poke(l+860,\"strength \");poke(l+864,\"fugitive \");poke(l+868,\"vagabond \");poke(l+872,\"punishment \");poke(l+876,\"greater \");";
|
}
|
||||||
fat32_write(fh, w22, cmd_strlen(w22));
|
|
||||||
char *w23 = "poke(l+880,\"bear \");poke(l+884,\"driven \");poke(l+888,\"hid \");poke(l+892,\"findeth \");poke(l+896,\"slay \");poke(l+900,\"vengeance \");poke(l+904,\"sevenfold \");poke(l+908,\"mark \");poke(l+912,\"finding \");poke(l+916,\"kill \");";
|
fat32_write(fh, buf, p);
|
||||||
fat32_write(fh, w23, cmd_strlen(w23));
|
kfree(buf);
|
||||||
char *w24 = "poke(l+920,\"presence \");poke(l+924,\"dwelt \");poke(l+928,\"nod \");poke(l+932,\"enoch \");poke(l+936,\"city \");poke(l+940,\"irad \");poke(l+944,\"mehujael \");poke(l+948,\"methusael \");poke(l+952,\"lamech \");poke(l+956,\"adah \");";
|
}
|
||||||
fat32_write(fh, w24, cmd_strlen(w24));
|
|
||||||
char *w25 = "poke(l+960,\"zillah \");poke(l+964,\"jabal \");poke(l+968,\"tent \");poke(l+972,\"cattle \");poke(l+976,\"jubal \");poke(l+980,\"harp \");poke(l+984,\"organ \");poke(l+988,\"tubalcain \");poke(l+992,\"brass \");poke(l+996,\"iron \");";
|
|
||||||
fat32_write(fh, w25, cmd_strlen(w25));
|
|
||||||
char *w26 = "poke(l+1000,\"naamah \");poke(l+1004,\"wives \");poke(l+1008,\"hear \");poke(l+1012,\"speech \");poke(l+1016,\"hearken \");poke(l+1020,\"young \");poke(l+1024,\"hurt \");poke(l+1028,\"wounding \");poke(l+1032,\"avenged \");poke(l+1036,\"seventy \");";
|
|
||||||
fat32_write(fh, w26, cmd_strlen(w26));
|
|
||||||
char *w27 = "poke(l+1040,\"seth \");poke(l+1044,\"appointed \");poke(l+1048,\"enos \");poke(l+1052,\"began \");poke(l+1056,\"call \");poke(l+1060,\"name \");poke(l+1064,\"generations \");poke(l+1068,\"adam \");poke(l+1072,\"likeness \");poke(l+1076,\"blessed \");";
|
|
||||||
fat32_write(fh, w27, cmd_strlen(w27));
|
|
||||||
char *w28 = "poke(l+1080,\"begat \");poke(l+1084,\"sons \");poke(l+1088,\"daughters \");poke(l+1092,\"lived \");poke(l+1096,\"died \");poke(l+1100,\"cainan \");poke(l+1104,\"mahalaleel \");poke(l+1108,\"jared \");poke(l+1112,\"walked \");poke(l+1116,\"three \");";
|
|
||||||
fat32_write(fh, w28, cmd_strlen(w28));
|
|
||||||
char *w29 = "poke(l+1120,\"hundred \");poke(l+1124,\"sixty \");poke(l+1128,\"five \");poke(l+1132,\"methuselah \");poke(l+1136,\"lamech \");poke(l+1140,\"noah \");poke(l+1144,\"comfort \");poke(l+1148,\"work \");poke(l+1152,\"toil \");poke(l+1156,\"hands \");";
|
|
||||||
fat32_write(fh, w29, cmd_strlen(w29));
|
|
||||||
char *w30 = "poke(l+1160,\"shem \");poke(l+1164,\"ham \");poke(l+1168,\"japheth \");poke(l+1172,\"men \");poke(l+1176,\"daughters \");poke(l+1180,\"born \");poke(l+1184,\"fair \");poke(l+1188,\"chose \");poke(l+1192,\"spirit \");poke(l+1196,\"strive \");";
|
|
||||||
fat32_write(fh, w30, cmd_strlen(w30));
|
|
||||||
char *e = "int c;int r;r=abs(rand());r=r-(r/5)*5;c=14+r;int i;i=0;while(i<c){int x;x=abs(rand());x=x-(x/300)*300;int w;w=peek(l+x*4);print_str(w);i=i+1;}nl();}";
|
|
||||||
fat32_write(fh, e, cmd_strlen(e));
|
|
||||||
fat32_close(fh);
|
fat32_close(fh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmd_init(void) {
|
void cmd_init(void) {
|
||||||
fat32_init(); // Init FAT32 filesystem
|
fat32_init(); // Init FAT32 filesystem
|
||||||
create_test_files();
|
create_test_files();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "fat32.h"
|
#include "fat32.h"
|
||||||
#include "wm.h"
|
#include "wm.h"
|
||||||
|
#include "memory_manager.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "markdown.h"
|
#include "markdown.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
@ -278,7 +279,9 @@ static void explorer_set_folder_color(const char *folder_path, uint32_t color) {
|
||||||
static void explorer_load_directory(const char *path) {
|
static void explorer_load_directory(const char *path) {
|
||||||
explorer_strcpy(current_path, path);
|
explorer_strcpy(current_path, path);
|
||||||
|
|
||||||
FAT32_FileInfo entries[EXPLORER_MAX_FILES];
|
FAT32_FileInfo *entries = (FAT32_FileInfo*)kmalloc(EXPLORER_MAX_FILES * sizeof(FAT32_FileInfo));
|
||||||
|
if (!entries) return;
|
||||||
|
|
||||||
int count = fat32_list_directory(path, entries, EXPLORER_MAX_FILES);
|
int count = fat32_list_directory(path, entries, EXPLORER_MAX_FILES);
|
||||||
|
|
||||||
item_count = 0;
|
item_count = 0;
|
||||||
|
|
@ -306,6 +309,7 @@ static void explorer_load_directory(const char *path) {
|
||||||
item_count++;
|
item_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kfree(entries);
|
||||||
selected_item = -1;
|
selected_item = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1040
src/kernel/fat32.c
1040
src/kernel/fat32.c
File diff suppressed because it is too large
Load diff
|
|
@ -83,6 +83,8 @@ typedef struct {
|
||||||
uint32_t size; // File size
|
uint32_t size; // File size
|
||||||
uint32_t mode; // 0=read, 1=write, 2=append
|
uint32_t mode; // 0=read, 1=write, 2=append
|
||||||
bool valid; // Is this handle valid?
|
bool valid; // Is this handle valid?
|
||||||
|
uint32_t dir_sector; // Sector containing the directory entry
|
||||||
|
uint32_t dir_offset; // Offset within that sector
|
||||||
} FAT32_FileHandle;
|
} FAT32_FileHandle;
|
||||||
|
|
||||||
// Directory Entry Info (for listing)
|
// Directory Entry Info (for listing)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue