Espresso 0.0.1a

This commit is contained in:
2025-06-17 15:50:07 -05:00
parent eeea3b2d86
commit fca025a9bf
24 changed files with 1080 additions and 600 deletions

View File

@ -1,32 +1,43 @@
/*#include <stdint.h>
#include <types.h>
#include <port_io.h>
#include <drivers/irq.h>
#include <stdio.h>
#define PIT_CHANNEL0 0x40
#define PIT_COMMAND 0x43
#define PIT_FREQUENCY 1193182
#include <drivers/pit.h>
static uint32_t tick = 0;
void pit_callback(struct regs* r)
#define PIT_CHANNEL0 0x40
#define PIT_COMMAND 0x43
#define PIT_IRQ_LINE 0
#define PIT_FREQUENCY_BASE 1193182
volatile uint64_t pit_ticks = 0;
bool pit_initialized = false;
void pit_init(void)
{
(void)r;
tick++;
uint16_t divisor = (uint16_t)1193;
/* Send command byte */
outb(PIT_COMMAND, 0x36); /* Channel 0, low/high byte, mode 3 (square wave), binary */
/* Send divisor low and high byte */
outb(PIT_CHANNEL0, (uint8_t)(divisor & 0xFF)); /* Low byte */
outb(PIT_CHANNEL0, (uint8_t)((divisor >> 8) & 0xFF)); /* High byte */
pit_initialized = true;
}
void pit_init(uint32_t frequency)
void pit_handler(void)
{
uint32_t divisor = PIT_FREQUENCY / frequency;
outb(PIT_COMMAND, 0x36);
outb(PIT_CHANNEL0, (uint8_t)(divisor & 0xFF));
outb(PIT_CHANNEL0, (uint8_t)((divisor >> 8) & 0xFF));
register_interrupt_handler(32, pit_callback);
pit_ticks++;
}
void sleep(uint32_t milliseconds)
void pit_sleep(uint64_t ms)
{
uint32_t target = tick + milliseconds;
while (tick < target);
}*/
uint64_t target = pit_ticks + ms;
while (pit_ticks < target)
{
asm volatile ("hlt");
}
}