Some attempts to get keyboard working on HW
This commit is contained in:
parent
6ed6094b82
commit
2e8c32a3b0
5 changed files with 29 additions and 5 deletions
|
|
@ -115,6 +115,8 @@ fb_refresh()
|
|||
}
|
||||
}
|
||||
|
||||
__asm__ volatile ("wbinvd" : : : "memory");
|
||||
|
||||
fb_damages_count = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ void _start() {
|
|||
cpu_set_timer();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
rtc_init();
|
||||
#endif
|
||||
|
||||
|
|
@ -80,6 +80,8 @@ void _start() {
|
|||
// uint8_t data = ps2_read_data();
|
||||
// putu8x(data);
|
||||
// putln();
|
||||
printf("hlt\n");
|
||||
__asm__("hlt");
|
||||
}
|
||||
|
||||
pt_create_minimal();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@
|
|||
|
||||
#define SPURIOUS_VECTOR_APIC_ENABLE 0x100
|
||||
|
||||
static inline void
|
||||
wbinvd(void)
|
||||
{
|
||||
__asm__ volatile ("wbinvd" : : : "memory");
|
||||
}
|
||||
|
||||
struct lapic_register {
|
||||
uint32_t value;
|
||||
uint32_t padding[3];
|
||||
|
|
@ -56,6 +62,7 @@ void lapic_init(void)
|
|||
ASSERT((LAPIC_ADDR->lapic_version.value & 0xff) <= 0x15);
|
||||
|
||||
LAPIC_ADDR->spurious_vector.value = SPURIOUS_VECTOR_APIC_ENABLE | 0xff;
|
||||
wbinvd();
|
||||
}
|
||||
|
||||
unsigned lapic_get_id(void)
|
||||
|
|
@ -70,6 +77,7 @@ unsigned int cpu_get_core_id(void) {
|
|||
void lapic_eoi(void)
|
||||
{
|
||||
LAPIC_ADDR->eoi.value = 0;
|
||||
wbinvd();
|
||||
}
|
||||
|
||||
void lapic_set_timer(void)
|
||||
|
|
@ -77,6 +85,7 @@ void lapic_set_timer(void)
|
|||
LAPIC_ADDR->timer_divisor.value = 0b1010;
|
||||
LAPIC_ADDR->lvt_timer.value = 0xFE | (1 << 17);
|
||||
LAPIC_ADDR->timer_initial.value = 0x1000000;
|
||||
wbinvd();
|
||||
}
|
||||
|
||||
#define IOAPICID 0x00
|
||||
|
|
@ -128,13 +137,16 @@ struct EntryIntOverride {
|
|||
static uint32_t ioapic_read(volatile uint32_t *ioapic, unsigned offset)
|
||||
{
|
||||
ioapic[IOREGSEL] = offset;
|
||||
wbinvd();
|
||||
return ioapic[IOWIN];
|
||||
}
|
||||
|
||||
static void ioapic_write(volatile uint32_t *ioapic, unsigned offset, uint32_t value)
|
||||
{
|
||||
ioapic[IOREGSEL] = offset;
|
||||
wbinvd();
|
||||
ioapic[IOWIN] = value;
|
||||
wbinvd();
|
||||
}
|
||||
|
||||
static unsigned irq_to_gsi_number(unsigned irq, uint16_t *flags)
|
||||
|
|
|
|||
|
|
@ -163,7 +163,10 @@ rtc_eoi(void)
|
|||
|
||||
void clock_handler(void) {
|
||||
static unsigned int i = 0;
|
||||
printf("RTC Interrupt %d\n", i++);
|
||||
if (i % 16 == 0) {
|
||||
printf("RTC Interrupt %d\n", i);
|
||||
}
|
||||
i++;
|
||||
rtc_eoi();
|
||||
}
|
||||
|
||||
|
|
@ -178,5 +181,6 @@ rtc_init(void) {
|
|||
interrupt_handler_register(0x40, clock_handler);
|
||||
rtc_set_rate(15);
|
||||
rtc_set_periodic(true);
|
||||
ioapic_configure_irq(RTC_IRQ_NUMBER, 0x40 | IORED_DELIVERY_NORMAL | ((uint64_t)lapic_get_id() << IORED_DESTINATION_SHIFT));
|
||||
bool success = ioapic_configure_irq(RTC_IRQ_NUMBER, 0x40 | IORED_DELIVERY_NORMAL | ((uint64_t)lapic_get_id() << IORED_DESTINATION_SHIFT));
|
||||
ASSERT(success);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,8 +290,12 @@ void ps2_init() {
|
|||
/* register interrupt handlers */
|
||||
interrupt_handler_register(101, port1_handler);
|
||||
interrupt_handler_register(102, port2_handler);
|
||||
ioapic_configure_irq(1, 101 | IORED_DELIVERY_NORMAL | ((uint64_t)lapic_get_id() << IORED_DESTINATION_SHIFT));
|
||||
ioapic_configure_irq(12, 102 | IORED_DELIVERY_NORMAL | ((uint64_t)lapic_get_id() << IORED_DESTINATION_SHIFT));
|
||||
|
||||
bool success;
|
||||
success = ioapic_configure_irq(1, 101 | IORED_DELIVERY_NORMAL | ((uint64_t)lapic_get_id() << IORED_DESTINATION_SHIFT));
|
||||
ASSERT(success);
|
||||
success = ioapic_configure_irq(12, 102 | IORED_DELIVERY_NORMAL | ((uint64_t)lapic_get_id() << IORED_DESTINATION_SHIFT));
|
||||
ASSERT(success);
|
||||
|
||||
/* Flush Outputbuffer again because it doesn't work otherwise */
|
||||
ps2_empty_output_buffer();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue