Fix PMM for real HW + serial lock
This commit is contained in:
@@ -6,9 +6,13 @@
|
||||
|
||||
#include <kernel.h>
|
||||
#include <io/serial/serial.h>
|
||||
#include <sched/spinlock.h>
|
||||
|
||||
extern struct init_status init;
|
||||
|
||||
extern int panic_count;
|
||||
struct spinlock_t serial_lock = {0};
|
||||
|
||||
/*
|
||||
* outb - Writes a byte to a CPU port
|
||||
* @port: CPU port to write to
|
||||
@@ -85,9 +89,15 @@ static int is_transmit_empty()
|
||||
*/
|
||||
void skputc(char c)
|
||||
{
|
||||
// TODO: Spinlock here (serial access)
|
||||
while (!is_transmit_empty()); // wait for free spot
|
||||
outb(PORT, c);
|
||||
if (panic_count == 0) {
|
||||
spinlock_acquire(&serial_lock);
|
||||
while (!is_transmit_empty()); // wait for free spot
|
||||
outb(PORT, c);
|
||||
spinlock_release(&serial_lock);
|
||||
} else {
|
||||
while (!is_transmit_empty());
|
||||
outb(PORT, c);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user