feat: Massive OS expansion with IPC, Sound & TTS, Block layer, FAT32/ext2/sysfs, Signals, Syscalls, Modules, Drivers & 50+ LazyBox applets

This commit is contained in:
subhobhai943 committed 2026-08-16 23:06:53 +05:30
1 parent 5662be29f5
commit d680335f05
64 files changed
+2370 -166

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
#include <block/block.h>
#include <block/elevator.h>
#include <lib/string.h>
#include <kernel/printk.h>
static block_device_t* registered_devices[MAX_BLOCK_DEVS];
static size_t device_count = 0;
void block_init(void) {
memset(registered_devices, 0, sizeof(registered_devices));
device_count = 0;
elevator_init();
printk(KERN_INFO "BLOCK: Generic Block Device Layer initialized\n");
}
int block_register_device(block_device_t* dev) {
if (!dev || device_count >= MAX_BLOCK_DEVS) return -1;
registered_devices[device_count++] = dev;
printk(KERN_INFO "BLOCK: Registered device '%s' (%llu sectors, %u B/sec)\n",
dev->name, dev->total_sectors, dev->sector_size);
return 0;
}
block_device_t* block_get_device(const char* name) {
if (!name) return NULL;
for (size_t i = 0; i < device_count; i++) {
if (registered_devices[i] && strcmp(registered_devices[i]->name, name) == 0) {
return registered_devices[i];
}
}
return NULL;
}
int block_submit_bio(const char* dev_name, block_req_type_t type, uint64_t sector, uint32_t count, void* buffer) {
block_device_t* dev = block_get_device(dev_name);
if (!dev) return -1;
switch (type) {
case REQ_READ:
if (!dev->read_sectors) return -1;
return dev->read_sectors(dev, sector, count, buffer);
case REQ_WRITE:
if (dev->read_only || !dev->write_sectors) return -1;
return dev->write_sectors(dev, sector, count, (const void*)buffer);
case REQ_FLUSH:
if (dev->flush) return dev->flush(dev);
return 0;
}
return -1;
}
size_t block_get_device_count(void) {
return device_count;
}
block_device_t* block_get_device_by_index(size_t index) {
if (index >= device_count) return NULL;
return registered_devices[index];
}
+47
View File
@@ -0,0 +1,47 @@
#include <block/elevator.h>
#include <kernel/printk.h>
static void noop_queue_request(block_device_t* dev, block_request_t* req) {
if (!dev || !req) return;
req->next = NULL;
if (!dev->queue_tail) {
dev->queue_head = req;
dev->queue_tail = req;
} else {
dev->queue_tail->next = req;
dev->queue_tail = req;
}
}
static block_request_t* noop_dispatch_request(block_device_t* dev) {
if (!dev || !dev->queue_head) return NULL;
block_request_t* req = dev->queue_head;
dev->queue_head = req->next;
if (!dev->queue_head) {
dev->queue_tail = NULL;
}
return req;
}
static elevator_t noop_elevator = {
.type = ELEVATOR_NOOP,
.name = "noop",
.queue_request = noop_queue_request,
.dispatch_request = noop_dispatch_request
};
static elevator_t* current_elevator = &noop_elevator;
void elevator_init(void) {
current_elevator = &noop_elevator;
printk(KERN_INFO "ELEVATOR: Initialized default '%s' I/O scheduler\n", current_elevator->name);
}
elevator_t* elevator_get_active(void) {
return current_elevator;
}
void elevator_set_scheduler(elevator_type_t type) {
(void)type;
current_elevator = &noop_elevator;
}