Skip to content

Commit 44c782e

Browse files
authored
Add files via upload
1 parent 4d48588 commit 44c782e

21 files changed

+4954
-0
lines changed

headers/command_processor.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef APOLLO_COMMAND_PROCESSOR_H
2+
#define APOLLO_COMMAND_PROCESSOR_H
3+
4+
#include <stdint.h>
5+
#include <stdbool.h>
6+
7+
void command_processor_initialize(void);
8+
9+
void command_processor_handle_input(uint8_t scan_code);
10+
11+
bool command_processor_is_initialized(void);
12+
uint32_t command_processor_get_commands_executed(void);
13+
const char* command_processor_get_current_user(void);
14+
15+
// Available commands:
16+
// File System: ls, dir, cd, pwd, mkdir, rmdir, rm, cp, mv, cat, touch, find, tree, grep
17+
// System Info: sysinfo, meminfo, df, ps, whoami, date, uptime
18+
// Utilities: calc, echo, history, clear, edit, palette
19+
// Control: reboot, shutdown, help
20+
21+
#endif

headers/config.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#ifndef APOLLO_CONFIG_H
2+
#define APOLLO_CONFIG_H
3+
4+
#define APOLLO_VERSION_MAJOR 1
5+
#define APOLLO_VERSION_MINOR 0
6+
#define APOLLO_VERSION_PATCH 0
7+
#define APOLLO_VERSION_STRING "1.0.0"
8+
9+
#define APOLLO_ARCH_X86_64 1
10+
#define APOLLO_ARCH_STRING "x86_64"
11+
12+
#define APOLLO_PAGE_SIZE 4096
13+
#define APOLLO_KERNEL_HEAP_SIZE (16 * 1024 * 1024) // 16MB
14+
#define APOLLO_KERNEL_STACK_SIZE (64 * 1024) // 64KB
15+
#define APOLLO_MEMORY_ALIGNMENT 8
16+
17+
#define APOLLO_VGA_WIDTH 80
18+
#define APOLLO_VGA_HEIGHT 25
19+
#define APOLLO_VGA_COLORS 16
20+
21+
#define APOLLO_KEYBOARD_BUFFER_SIZE 256
22+
#define APOLLO_COMMAND_MAX_LENGTH 256
23+
#define APOLLO_COMMAND_HISTORY_SIZE 32
24+
#define APOLLO_MAX_COMMAND_ARGS 16
25+
26+
#define APOLLO_MULTIBOOT2_MAGIC 0xe85250d6
27+
#define APOLLO_KERNEL_LOAD_ADDRESS 0x100000 // 1MB
28+
29+
#ifdef DEBUG
30+
#define APOLLO_DEBUG_ENABLED 1
31+
#define APOLLO_SERIAL_DEBUG 1
32+
#else
33+
#define APOLLO_DEBUG_ENABLED 0
34+
#define APOLLO_SERIAL_DEBUG 0
35+
#endif
36+
37+
#define APOLLO_FEATURE_MEMORY_MANAGER 1
38+
#define APOLLO_FEATURE_COMMAND_SHELL 1
39+
#define APOLLO_FEATURE_VGA_GRAPHICS 1
40+
#define APOLLO_FEATURE_PS2_KEYBOARD 1
41+
#define APOLLO_FEATURE_RTC_CLOCK 1
42+
43+
#define APOLLO_COMPILER_NAME "GCC"
44+
#define APOLLO_BUILD_DATE __DATE__
45+
#define APOLLO_BUILD_TIME __TIME__
46+
47+
#define APOLLO_MAX_FILENAME_LENGTH 255
48+
#define APOLLO_MAX_PATH_LENGTH 1024
49+
#define APOLLO_MAX_PROCESSES 32
50+
#define APOLLO_MAX_THREADS 128
51+
52+
#define APOLLO_ASSERT_ENABLED 1
53+
#define APOLLO_ERROR_CHECKING 1
54+
55+
#define APOLLO_CPU_VENDOR_INTEL 0x756e6547 // "Genu"
56+
#define APOLLO_CPU_VENDOR_AMD 0x68747541 // "Auth"
57+
58+
#define APOLLO_TIMER_FREQUENCY 1000 // 1000 Hz
59+
#define APOLLO_SCHEDULER_QUANTUM 10 // 10ms
60+
61+
#define APOLLO_VGA_CTRL_PORT 0x3D4
62+
#define APOLLO_VGA_DATA_PORT 0x3D5
63+
#define APOLLO_KB_DATA_PORT 0x60
64+
#define APOLLO_KB_STATUS_PORT 0x64
65+
#define APOLLO_CMOS_ADDRESS_PORT 0x70
66+
#define APOLLO_CMOS_DATA_PORT 0x71
67+
68+
#define APOLLO_HEAP_MAGIC 0xDEADBEEF
69+
#define APOLLO_STACK_MAGIC 0xCAFEBABE
70+
#define APOLLO_KERNEL_MAGIC 0x41504F4C // "APOL"
71+
72+
#define APOLLO_DEFAULT_FG_COLOR 7 // Light gray
73+
#define APOLLO_DEFAULT_BG_COLOR 0 // Black
74+
#define APOLLO_LOGO_COLOR 14 // Yellow
75+
#define APOLLO_ACCENT_COLOR 3 // Orange
76+
77+
#define APOLLO_KB(x) ((x) * 1024)
78+
#define APOLLO_MB(x) ((x) * 1024 * 1024)
79+
#define APOLLO_GB(x) ((x) * 1024ULL * 1024 * 1024)
80+
81+
#define APOLLO_STRINGIFY(x) #x
82+
#define APOLLO_TOSTRING(x) APOLLO_STRINGIFY(x)
83+
84+
#if APOLLO_DEBUG_ENABLED
85+
#define APOLLO_DEBUG_PRINT(fmt, ...) debug_printf(fmt, ##__VA_ARGS__)
86+
#else
87+
#define APOLLO_DEBUG_PRINT(fmt, ...) do {} while(0)
88+
#endif
89+
90+
#define APOLLO_STATIC_ASSERT(cond, msg) \
91+
typedef char apollo_static_assert_##msg[(cond) ? 1 : -1]
92+
93+
APOLLO_STATIC_ASSERT(APOLLO_PAGE_SIZE == 4096, page_size_must_be_4k);
94+
APOLLO_STATIC_ASSERT(APOLLO_MEMORY_ALIGNMENT >= 8, alignment_must_be_at_least_8);
95+
APOLLO_STATIC_ASSERT(APOLLO_KEYBOARD_BUFFER_SIZE > 0, keyboard_buffer_must_be_positive);
96+
97+
#endif

headers/filesystem.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#ifndef APOLLO_FILESYSTEM_H
2+
#define APOLLO_FILESYSTEM_H
3+
4+
#include <stdint.h>
5+
#include <stdbool.h>
6+
7+
#define FS_MAX_FILENAME_LENGTH 64
8+
#define FS_MAX_PATH_LENGTH 256
9+
#define FS_MAX_FILE_SIZE (64 * 1024) // 64KB max file size
10+
#define FS_MAX_FILES 256
11+
#define FS_MAX_DIRECTORIES 64
12+
#define FS_BLOCK_SIZE 512
13+
#define FS_MAX_BLOCKS 1024
14+
15+
typedef enum {
16+
FS_TYPE_FILE = 1,
17+
FS_TYPE_DIRECTORY = 2
18+
} fs_file_type_t;
19+
20+
typedef enum {
21+
FS_PERM_READ = 0x01,
22+
FS_PERM_WRITE = 0x02,
23+
FS_PERM_EXECUTE = 0x04
24+
} fs_permissions_t;
25+
26+
typedef struct {
27+
char name[FS_MAX_FILENAME_LENGTH];
28+
fs_file_type_t type;
29+
uint32_t size;
30+
uint32_t created_time;
31+
uint32_t modified_time;
32+
uint8_t permissions;
33+
uint32_t parent_id;
34+
uint32_t data_block;
35+
bool is_valid;
36+
} fs_file_info_t;
37+
38+
typedef struct {
39+
char name[FS_MAX_FILENAME_LENGTH];
40+
fs_file_type_t type;
41+
uint32_t size;
42+
uint8_t permissions;
43+
} fs_dir_entry_t;
44+
45+
typedef struct {
46+
uint32_t file_id;
47+
uint32_t position;
48+
bool is_open;
49+
bool write_mode;
50+
} fs_file_handle_t;
51+
52+
void filesystem_initialize(void);
53+
54+
bool filesystem_create_directory(const char* path);
55+
bool filesystem_remove_directory(const char* path);
56+
bool filesystem_change_directory(const char* path);
57+
bool filesystem_get_current_directory(char* buffer, uint32_t buffer_size);
58+
uint32_t filesystem_list_directory(const char* path, fs_dir_entry_t* entries, uint32_t max_entries);
59+
60+
bool filesystem_create_file(const char* path);
61+
bool filesystem_delete_file(const char* path);
62+
bool filesystem_copy_file(const char* source, const char* destination);
63+
bool filesystem_move_file(const char* source, const char* destination);
64+
bool filesystem_file_exists(const char* path);
65+
bool filesystem_get_file_info(const char* path, fs_file_info_t* info);
66+
67+
fs_file_handle_t* filesystem_open_file(const char* path, bool write_mode);
68+
void filesystem_close_file(fs_file_handle_t* handle);
69+
uint32_t filesystem_read_file(fs_file_handle_t* handle, void* buffer, uint32_t size);
70+
uint32_t filesystem_write_file(fs_file_handle_t* handle, const void* buffer, uint32_t size);
71+
bool filesystem_seek_file(fs_file_handle_t* handle, uint32_t position);
72+
73+
bool filesystem_resolve_path(const char* path, char* resolved_path, uint32_t buffer_size);
74+
uint32_t filesystem_get_free_space(void);
75+
uint32_t filesystem_get_used_space(void);
76+
void filesystem_format(void);
77+
78+
typedef struct {
79+
uint32_t total_files;
80+
uint32_t total_directories;
81+
uint32_t free_blocks;
82+
uint32_t used_blocks;
83+
uint32_t total_space;
84+
uint32_t free_space;
85+
} fs_stats_t;
86+
87+
bool filesystem_get_stats(fs_stats_t* stats);
88+
89+
#endif

headers/heap_allocator.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef APOLLO_HEAP_ALLOCATOR_H
2+
#define APOLLO_HEAP_ALLOCATOR_H
3+
4+
#include <stddef.h>
5+
#include <stdint.h>
6+
7+
void heap_allocator_initialize(void);
8+
9+
void* apollo_allocate_memory(size_t size);
10+
void apollo_free_memory(void* ptr);
11+
void* apollo_allocate_zeroed_memory(size_t count, size_t element_size);
12+
void* apollo_reallocate_memory(void* ptr, size_t new_size);
13+
14+
size_t heap_allocator_get_used_memory(void);
15+
size_t heap_allocator_get_free_memory(void);
16+
size_t heap_allocator_get_total_memory(void);
17+
18+
void heap_allocator_dump_info(void);
19+
20+
#endif

headers/input_manager.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#ifndef APOLLO_INPUT_MANAGER_H
2+
#define APOLLO_INPUT_MANAGER_H
3+
4+
#include <stdint.h>
5+
#include <stdbool.h>
6+
7+
#define SCANCODE_UP_ARROW 0x48
8+
#define SCANCODE_DOWN_ARROW 0x50
9+
#define SCANCODE_LEFT_ARROW 0x4B
10+
#define SCANCODE_RIGHT_ARROW 0x4D
11+
#define SCANCODE_ESCAPE 0x01
12+
#define SCANCODE_ENTER 0x1C
13+
#define SCANCODE_BACKSPACE 0x0E
14+
#define SCANCODE_TAB 0x0F
15+
#define SCANCODE_SPACE 0x39
16+
#define SCANCODE_DELETE 0x53
17+
#define SCANCODE_INSERT 0x52
18+
#define SCANCODE_HOME 0x47
19+
#define SCANCODE_END 0x4F
20+
#define SCANCODE_PAGE_UP 0x49
21+
#define SCANCODE_PAGE_DOWN 0x51
22+
23+
#define SCANCODE_F1 0xF1
24+
#define SCANCODE_F2 0xF2
25+
#define SCANCODE_F3 0xF3
26+
#define SCANCODE_F4 0xF4
27+
#define SCANCODE_F5 0xF5
28+
#define SCANCODE_F6 0xF6
29+
#define SCANCODE_F7 0xF7
30+
#define SCANCODE_F8 0xF8
31+
#define SCANCODE_F9 0xF9
32+
#define SCANCODE_F10 0xFA
33+
#define SCANCODE_F11 0xFB
34+
#define SCANCODE_F12 0xFC
35+
36+
void input_manager_initialize(void);
37+
38+
bool input_manager_has_input(void);
39+
uint8_t input_manager_read_scancode(void);
40+
41+
char input_manager_scancode_to_ascii(uint8_t scan_code);
42+
43+
bool input_manager_is_shift_pressed(void);
44+
bool input_manager_is_ctrl_pressed(void);
45+
bool input_manager_is_alt_pressed(void);
46+
47+
bool input_manager_is_caps_lock_on(void);
48+
bool input_manager_is_num_lock_on(void);
49+
bool input_manager_is_scroll_lock_on(void);
50+
51+
uint8_t input_manager_get_last_scancode(void);
52+
53+
#endif

headers/process_manager.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#ifndef APOLLO_PROCESS_MANAGER_H
2+
#define APOLLO_PROCESS_MANAGER_H
3+
4+
#include <stdint.h>
5+
#include <stdbool.h>
6+
7+
typedef enum {
8+
PROCESS_STATE_RUNNING = 0,
9+
PROCESS_STATE_READY = 1,
10+
PROCESS_STATE_BLOCKED = 2,
11+
PROCESS_STATE_TERMINATED = 3
12+
} process_state_t;
13+
14+
typedef enum {
15+
PROCESS_TYPE_KERNEL = 0,
16+
PROCESS_TYPE_SYSTEM = 1,
17+
PROCESS_TYPE_USER = 2
18+
} process_type_t;
19+
20+
typedef struct {
21+
uint32_t pid;
22+
char name[64];
23+
process_state_t state;
24+
process_type_t type;
25+
uint32_t priority;
26+
uint32_t cpu_time;
27+
uint32_t memory_usage;
28+
uint32_t parent_pid;
29+
uint32_t start_time;
30+
void* entry_point;
31+
bool is_active;
32+
} process_t;
33+
34+
typedef struct {
35+
uint32_t total_processes;
36+
uint32_t running_processes;
37+
uint32_t blocked_processes;
38+
uint32_t total_cpu_time;
39+
uint32_t context_switches;
40+
} process_stats_t;
41+
42+
void process_manager_initialize(void);
43+
44+
uint32_t process_create(const char* name, process_type_t type, void* entry_point);
45+
bool process_terminate(uint32_t pid);
46+
bool process_suspend(uint32_t pid);
47+
bool process_resume(uint32_t pid);
48+
49+
bool process_get_info(uint32_t pid, process_t* info);
50+
uint32_t process_list(process_t* processes, uint32_t max_count);
51+
bool process_get_stats(process_stats_t* stats);
52+
53+
uint32_t process_get_current_pid(void);
54+
void process_yield(void);
55+
void process_scheduler_tick(void);
56+
57+
void process_update_memory_usage(uint32_t pid, uint32_t memory_bytes);
58+
void process_update_cpu_time(uint32_t pid, uint32_t time_slice);
59+
60+
#endif

headers/terminal.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#ifndef APOLLO_TERMINAL_H
2+
#define APOLLO_TERMINAL_H
3+
4+
#include <stdint.h>
5+
#include <stddef.h>
6+
7+
typedef enum {
8+
VGA_COLOR_BLACK = 0,
9+
VGA_COLOR_BLUE = 1,
10+
VGA_COLOR_GREEN = 2,
11+
VGA_COLOR_CYAN = 3,
12+
VGA_COLOR_RED = 4,
13+
VGA_COLOR_MAGENTA = 5,
14+
VGA_COLOR_BROWN = 6,
15+
VGA_COLOR_LIGHT_GREY = 7,
16+
VGA_COLOR_DARK_GREY = 8,
17+
VGA_COLOR_LIGHT_BLUE = 9,
18+
VGA_COLOR_LIGHT_GREEN = 10,
19+
VGA_COLOR_LIGHT_CYAN = 11,
20+
VGA_COLOR_LIGHT_RED = 12,
21+
VGA_COLOR_PINK = 13,
22+
VGA_COLOR_YELLOW = 14,
23+
VGA_COLOR_WHITE = 15,
24+
} vga_color_t;
25+
26+
void terminal_initialize(void);
27+
void terminal_clear(void);
28+
29+
void terminal_write_char(char c);
30+
void terminal_write_string(const char* str);
31+
32+
void terminal_set_color(uint8_t foreground, uint8_t background);
33+
void terminal_set_custom_color(uint8_t index, uint8_t red, uint8_t green, uint8_t blue);
34+
35+
void terminal_enable_cursor(void);
36+
void terminal_disable_cursor(void);
37+
void terminal_backspace(void);
38+
39+
void terminal_handle_scroll_input(uint8_t scan_code);
40+
void terminal_show_scroll_status(void);
41+
42+
void terminal_write_uint(uint32_t value);
43+
void terminal_write_int(int32_t value);
44+
void terminal_write_hex(uintptr_t value);
45+
46+
#endif

0 commit comments

Comments
 (0)