Espresso 0.0.2a

This commit is contained in:
2026-02-12 20:33:46 -06:00
parent c0dc95e255
commit 021fdbbcef
26 changed files with 452 additions and 27315 deletions

View File

@ -32,6 +32,9 @@
#define ATA_SR_DRQ 0x08
#define ATA_SR_ERR 0x01
#define SECTOR_SIZE 512
void ide_initialize(void);
int32_t ide_identify(uint8_t drive, uint16_t* buffer);

View File

@ -2,6 +2,8 @@
#define _KERNEL_VARIABLES_H
#define KERNEL_VARIABLES_SIZE 4096 /* in bytes (note: it take up a whole page, yes.) */
void init_vars(void);
#endif

View File

@ -1,6 +1,21 @@
#ifndef _KERNEL_INCLUDES_H
#define _KERNEL_INCLUDES_H
#define KERNEL_VERSION "0.0.1e"
#define ESPRESSO_KERNEL_
#define KERNEL_VERSION "0.0.2a"
#define _STATE_NORMAL 0
#define _STATE_HANDLED 1
#define _STATE_INTERRUPT -1
#define _STATE_EXCEPTION -2
#define _STATE_CRASH -555
#define __always_inline inline __attribute__((always_inline))
#define __hot __attribute__((hot))
#define __cold __attribute__((cold))
#define __noreturn __attribute__((noreturn))
#define __section(x) __attribute__((section(x)))
#endif

View File

@ -10,12 +10,12 @@ static inline uint32_t inl(uint16_t port)
return rv;
}
static inline void outl(uint16_t port, uint32_t data)
static inline __attribute__((always_inline)) void outl(uint16_t port, uint32_t data)
{
asm volatile ("outl %%eax, %%dx" : : "dN" (port), "a" (data));
}
static inline void outb(uint16_t port, uint8_t val)
static inline __attribute__((always_inline)) void outb(uint16_t port, uint8_t val)
{
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
}
@ -30,17 +30,19 @@ static inline uint8_t inb(uint16_t port)
return ret;
}
static inline void io_wait()
static inline __attribute__((always_inline)) void io_wait()
{
outb(0x80, 0);
}
static inline void insw(uint16_t port, void* addr, uint32_t count) {
__asm__ volatile ("rep insw" : "+D"(addr), "+c"(count) : "d"(port) : "memory");
static inline __attribute__((always_inline)) void insw(uint16_t port, void* addr, uint32_t count)
{
asm volatile ("rep insw" : "+D"(addr), "+c"(count) : "d"(port) : "memory");
}
static inline void outsw(uint16_t port, const void* addr, uint32_t count) {
__asm__ volatile ("rep outsw" : "+S"(addr), "+c"(count) : "d"(port));
static inline __attribute__((always_inline)) void outsw(uint16_t port, const void* addr, uint32_t count)
{
asm volatile ("rep outsw" : "+S"(addr), "+c"(count) : "d"(port));
}
#endif

View File

@ -17,6 +17,9 @@ char* strdup(const char* s);
char* strtok(char* str, const char* delim);
char* strchr(const char* s, int c);
/* this function is NOT in the standard C library */
int num_strchr(const char* s, int c);
void lowers(char* str);
void uppers(char* str);

View File

@ -16,6 +16,9 @@ void terminal_write(const char* data, size_t size);
void terminal_writestring(const char* data);
void terminal_debug_writestring(const char* data);
void terminal_writeline(const char* data);
void terminal_writechar_r(const char ch);
void terminal_setcolor(uint8_t color);
uint8_t terminal_getcolor(void);
@ -26,6 +29,7 @@ void terminal_scroll(void);
unsigned char terminal_get_shifted(unsigned char uc);
void terminal_set_cursor(uint16_t row, uint16_t column);
void terminal_get_cursor(int* row, int* column);
void terminal_update_cursor(void);
#endif

View File

@ -21,7 +21,7 @@ void *sse2_memcpy(void *dst, const void *src, uint32_t n);
void double_vector_to_int_vector(const double *src, int32_t *dst);
void int_vector_to_double_vector(const int32_t *src, double *dst);
void *memclr_sse2(const void *const m_start, const size_t m_count);
void* memclr_sse2(void *m_start, size_t m_count);
#endif

View File

@ -5,22 +5,22 @@
/* Hardware text mode color constants. */
enum vga_color {
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15,
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15,
};
uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg);