1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Rename "i386" to "x86"

This commit is contained in:
Alex Kotov 2020-11-30 16:31:20 +05:00
parent a2ba49cdc9
commit 16b595b68e
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 47 additions and 47 deletions

View file

@ -1,6 +1,6 @@
#include "console.h"
#include <kernaux/arch/i386.h>
#include <kernaux/arch/x86.h>
#include <kernaux/stdlib.h>
void console_print(const char *const s)
@ -9,7 +9,7 @@ void console_print(const char *const s)
}
void console_putc(const char c) {
kernaux_arch_i386_outportb(0x3F8, c);
kernaux_arch_x86_outportb(0x3F8, c);
}
void console_puts(const char *const s)

View file

@ -3,7 +3,7 @@
#include "page_dir.h"
#include "panic.h"
#include <kernaux/arch/i386.h>
#include <kernaux/arch/x86.h>
#include <kernaux/stdlib.h>
// CR0 bits
@ -29,32 +29,32 @@ static PageDir page_dir;
void paging_enable()
{
unsigned long cr0 = kernaux_arch_i386_read_cr0();
unsigned long cr4 = kernaux_arch_i386_read_cr4();
unsigned long cr0 = kernaux_arch_x86_read_cr0();
unsigned long cr4 = kernaux_arch_x86_read_cr4();
assert(cr0 & I386_CR0_PE, "The boot loader should have put us in protected mode.");
// First clear PG and PGE flag, as PGE must be enabled after PG.
kernaux_arch_i386_write_cr0(cr0 & ~I386_CR0_PG);
kernaux_arch_i386_write_cr4(cr4 & ~(I386_CR4_PGE | I386_CR4_PSE));
kernaux_arch_x86_write_cr0(cr0 & ~I386_CR0_PG);
kernaux_arch_x86_write_cr4(cr4 & ~(I386_CR4_PGE | I386_CR4_PSE));
cr0 = kernaux_arch_i386_read_cr0();
cr4 = kernaux_arch_i386_read_cr4();
cr0 = kernaux_arch_x86_read_cr0();
cr4 = kernaux_arch_x86_read_cr4();
// Our page table contains 4MB entries.
cr4 |= I386_CR4_PSE;
kernaux_arch_i386_write_cr4(cr4);
kernaux_arch_x86_write_cr4(cr4);
// First enable paging, then enable global page flag.
cr0 |= I386_CR0_PG;
kernaux_arch_i386_write_cr0(cr0);
kernaux_arch_x86_write_cr0(cr0);
cr0 |= I386_CR0_WP;
kernaux_arch_i386_write_cr0(cr0);
kernaux_arch_i386_write_cr4(cr4);
kernaux_arch_x86_write_cr0(cr0);
kernaux_arch_x86_write_cr4(cr4);
}
void paging_clear()
@ -116,6 +116,6 @@ int paging_mapkernel(const struct KernelMQ_Info *const kinfo)
unsigned long paging_load()
{
unsigned long page_dir_phys = (unsigned long)page_dir;
kernaux_arch_i386_write_cr3(page_dir_phys);
kernaux_arch_x86_write_cr3(page_dir_phys);
return page_dir_phys;
}

View file

@ -2,12 +2,12 @@
#include "logger.h"
#include <kernaux/arch/i386.h>
#include <kernaux/arch/x86.h>
void panic(const char *const s)
{
logger_fail_from("panic", s);
kernaux_arch_i386_hang();
kernaux_arch_x86_hang();
}
void halt()

View file

@ -2,7 +2,7 @@
#include "logger.h"
#include <kernaux/arch/i386.h>
#include <kernaux/arch/x86.h>
#define MASTER_COMMAND 0x20
#define MASTER_DATA 0x21
@ -20,16 +20,16 @@ void pic_enable_all()
{
logger_info_from("pic", "Enable all IRQs.");
kernaux_arch_i386_outportb(MASTER_DATA, 0);
kernaux_arch_i386_outportb(SLAVE_DATA, 0);
kernaux_arch_x86_outportb(MASTER_DATA, 0);
kernaux_arch_x86_outportb(SLAVE_DATA, 0);
}
void pic_disable_all()
{
logger_info_from("pic", "Disable all IRQs.");
kernaux_arch_i386_outportb(MASTER_DATA, 0xFF);
kernaux_arch_i386_outportb(SLAVE_DATA, 0xFF);
kernaux_arch_x86_outportb(MASTER_DATA, 0xFF);
kernaux_arch_x86_outportb(SLAVE_DATA, 0xFF);
}
void pic_enable(const unsigned char line)
@ -42,12 +42,12 @@ void pic_enable(const unsigned char line)
logger_info_from("pic", "Enable line %u.", line);
if (line < IRQS_COUNT) {
const unsigned char mask = kernaux_arch_i386_inportb(MASTER_DATA);
kernaux_arch_i386_outportb(MASTER_DATA, mask & ~(1 << line));
const unsigned char mask = kernaux_arch_x86_inportb(MASTER_DATA);
kernaux_arch_x86_outportb(MASTER_DATA, mask & ~(1 << line));
}
else {
const unsigned char mask = kernaux_arch_i386_inportb(SLAVE_DATA);
kernaux_arch_i386_outportb(SLAVE_DATA, mask & ~(1 << (line - IRQS_COUNT)));
const unsigned char mask = kernaux_arch_x86_inportb(SLAVE_DATA);
kernaux_arch_x86_outportb(SLAVE_DATA, mask & ~(1 << (line - IRQS_COUNT)));
}
}
@ -61,12 +61,12 @@ void pic_disable(const unsigned char line)
logger_info_from("pic", "Disable line %u.", line);
if (line < IRQS_COUNT) {
const unsigned char mask = kernaux_arch_i386_inportb(MASTER_DATA);
kernaux_arch_i386_outportb(MASTER_DATA, mask | (1 << line));
const unsigned char mask = kernaux_arch_x86_inportb(MASTER_DATA);
kernaux_arch_x86_outportb(MASTER_DATA, mask | (1 << line));
}
else {
const unsigned char mask = kernaux_arch_i386_inportb(SLAVE_DATA);
kernaux_arch_i386_outportb(SLAVE_DATA, mask | (1 << (line - IRQS_COUNT)));
const unsigned char mask = kernaux_arch_x86_inportb(SLAVE_DATA);
kernaux_arch_x86_outportb(SLAVE_DATA, mask | (1 << (line - IRQS_COUNT)));
}
}
@ -80,28 +80,28 @@ void pic_remap(const unsigned char new_master_irq_start, const unsigned char new
slave_irq_start = new_slave_irq_start;
// Save masks
unsigned char master_mask = kernaux_arch_i386_inportb(MASTER_DATA);
unsigned char slave_mask = kernaux_arch_i386_inportb(SLAVE_DATA);
unsigned char master_mask = kernaux_arch_x86_inportb(MASTER_DATA);
unsigned char slave_mask = kernaux_arch_x86_inportb(SLAVE_DATA);
// Start the initialization sequence
kernaux_arch_i386_outportb(MASTER_COMMAND, 0x11);
kernaux_arch_i386_outportb(SLAVE_COMMAND, 0x11);
kernaux_arch_x86_outportb(MASTER_COMMAND, 0x11);
kernaux_arch_x86_outportb(SLAVE_COMMAND, 0x11);
// Set IRQ vectors
kernaux_arch_i386_outportb(MASTER_DATA, new_master_irq_start);
kernaux_arch_i386_outportb(SLAVE_DATA, new_slave_irq_start);
kernaux_arch_x86_outportb(MASTER_DATA, new_master_irq_start);
kernaux_arch_x86_outportb(SLAVE_DATA, new_slave_irq_start);
// Connect master and slave with each other
kernaux_arch_i386_outportb(MASTER_DATA, 0x04);
kernaux_arch_i386_outportb(SLAVE_DATA, 0x02);
kernaux_arch_x86_outportb(MASTER_DATA, 0x04);
kernaux_arch_x86_outportb(SLAVE_DATA, 0x02);
// 8086/88 (MCS-80/85) mode
kernaux_arch_i386_outportb(MASTER_DATA, 0x01);
kernaux_arch_i386_outportb(SLAVE_DATA, 0x01);
kernaux_arch_x86_outportb(MASTER_DATA, 0x01);
kernaux_arch_x86_outportb(SLAVE_DATA, 0x01);
// Restore masks
kernaux_arch_i386_outportb(MASTER_DATA, master_mask);
kernaux_arch_i386_outportb(SLAVE_DATA, slave_mask);
kernaux_arch_x86_outportb(MASTER_DATA, master_mask);
kernaux_arch_x86_outportb(SLAVE_DATA, slave_mask);
}
unsigned char pic_end_of_interrupt(const unsigned char irq)
@ -114,10 +114,10 @@ unsigned char pic_end_of_interrupt(const unsigned char irq)
}
if (to_slave) {
kernaux_arch_i386_outportb(SLAVE_COMMAND, 0x20);
kernaux_arch_x86_outportb(SLAVE_COMMAND, 0x20);
}
kernaux_arch_i386_outportb(MASTER_COMMAND, 0x20);
kernaux_arch_x86_outportb(MASTER_COMMAND, 0x20);
return 1;
}

View file

@ -2,7 +2,7 @@
#include "logger.h"
#include <kernaux/arch/i386.h>
#include <kernaux/arch/x86.h>
void timer_initialize(unsigned int frequency)
{
@ -13,9 +13,9 @@ void timer_initialize(unsigned int frequency)
const unsigned char l = divisor & 0xFF;
const unsigned char h = (divisor >> 8) & 0xFF;
kernaux_arch_i386_outportb(0x43, 0x36);
kernaux_arch_i386_outportb(0x40, l);
kernaux_arch_i386_outportb(0x40, h);
kernaux_arch_x86_outportb(0x43, 0x36);
kernaux_arch_x86_outportb(0x40, l);
kernaux_arch_x86_outportb(0x40, h);
}
void timer_register_handler(timer_handler_t handler)