aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers
diff options
context:
space:
mode:
authorMarvin Borner2020-11-05 17:30:39 +0100
committerMarvin Borner2020-11-05 17:32:53 +0100
commit63e86f792167e6cc2e9600d00b184a3c83fe7498 (patch)
tree31e2d583be3ebf34782f6ec37f6c524657c40686 /kernel/drivers
parent916fca2161e76de67a5106b90baf00a57f2a0512 (diff)
Added warning flags and fixed them :)
Diffstat (limited to 'kernel/drivers')
-rw-r--r--kernel/drivers/acpi.c16
-rw-r--r--kernel/drivers/fpu.c4
-rw-r--r--kernel/drivers/ide.c8
-rw-r--r--kernel/drivers/interrupts.c6
-rw-r--r--kernel/drivers/keyboard.c10
-rw-r--r--kernel/drivers/mouse.c10
-rw-r--r--kernel/drivers/pci.c4
-rw-r--r--kernel/drivers/rtl8139.c47
-rw-r--r--kernel/drivers/timer.c8
9 files changed, 57 insertions, 56 deletions
diff --git a/kernel/drivers/acpi.c b/kernel/drivers/acpi.c
index 0db4522..5ab0ac6 100644
--- a/kernel/drivers/acpi.c
+++ b/kernel/drivers/acpi.c
@@ -12,7 +12,7 @@ int check_sdt(struct sdt_header *header)
u8 sum = 0;
for (u32 i = 0; i < header->length; i++)
- sum += ((char *)header)[i];
+ sum += (u8)(((u8 *)header)[i]);
return sum == 0;
}
@@ -22,12 +22,12 @@ int check_sdp(struct sdp_header *header)
u8 sum = 0;
for (u32 i = 0; i < sizeof(struct rsdp); i++)
- sum += ((char *)header)[i];
+ sum += (u8)(((u8 *)header)[i]);
return sum == 0;
}
-struct rsdp *find_rsdp()
+struct rsdp *find_rsdp(void)
{
// Main BIOS area
for (int i = 0xe0000; i < 0xfffff; i++) {
@@ -47,9 +47,9 @@ struct rsdp *find_rsdp()
void *find_sdt(struct rsdt *rsdt, const char *signature)
{
- int entries = (rsdt->header.length - sizeof(rsdt->header)) / 4;
+ u32 entries = (rsdt->header.length - sizeof(rsdt->header)) / 4;
- for (int i = 0; i < entries; i++) {
+ for (u32 i = 0; i < entries; i++) {
struct sdt_header *header = (struct sdt_header *)rsdt->sdt_pointer[i];
if (memcmp(header->signature, signature, 4) == 0) {
if (check_sdt(header))
@@ -62,7 +62,7 @@ void *find_sdt(struct rsdt *rsdt, const char *signature)
return NULL;
}
-void acpi_install()
+void acpi_install(void)
{
struct rsdp *rsdp = find_rsdp();
assert(rsdp && rsdp->header.revision == 0 && check_sdp(&rsdp->header));
@@ -77,7 +77,7 @@ void acpi_install()
madt_install();
}
-void hpet_install(int period)
+void hpet_install(u32 period)
{
if (hpet && hpet->legacy_replacement && hpet->comparator_count > 0) {
struct hpet_registers *r = (struct hpet_registers *)hpet->address.phys;
@@ -97,7 +97,7 @@ void hpet_install(int period)
}
}
-void madt_install()
+void madt_install(void)
{
if (!madt)
return;
diff --git a/kernel/drivers/fpu.c b/kernel/drivers/fpu.c
index f7eeceb..e61e267 100644
--- a/kernel/drivers/fpu.c
+++ b/kernel/drivers/fpu.c
@@ -7,12 +7,12 @@ void set_fpu_cw(const u16 cw)
__asm__ volatile("fldcw %0" ::"m"(cw));
}
-void fpu_install()
+void fpu_install(void)
{
__asm__ volatile("clts");
u32 t = 0;
__asm__ volatile("mov %%cr0, %0" : "=r"(t));
- t &= ~(1 << 2);
+ t &= (u32) ~(1 << 2);
t |= (1 << 1);
__asm__ volatile("mov %0, %%cr0" ::"r"(t));
diff --git a/kernel/drivers/ide.c b/kernel/drivers/ide.c
index 1a94ae3..227dfe5 100644
--- a/kernel/drivers/ide.c
+++ b/kernel/drivers/ide.c
@@ -16,7 +16,7 @@ int ide_stat()
void ide_wait()
{
- u8 stat = 0;
+ int stat = 0;
do
stat = ide_stat();
while ((stat & IDE_BUSY) != 0);
@@ -25,10 +25,10 @@ void ide_wait()
// TODO: Fix strange ide_read bugs
void *ide_read(void *b, u32 block)
{
- int sector_count = BLOCK_SIZE / SECTOR_SIZE; // 2
- int sector = block * sector_count;
+ u8 sector_count = BLOCK_SIZE / SECTOR_SIZE; // 2
+ u32 sector = block * sector_count;
- outb(IDE_IO + IDE_SECTOR_COUNT, sector_count); // Number of sectors
+ outb(IDE_IO + IDE_SECTOR_COUNT, (u8)sector_count); // Number of sectors
outb(IDE_IO + IDE_LOW, LBA_LOW(sector));
outb(IDE_IO + IDE_MID, LBA_MID(sector));
diff --git a/kernel/drivers/interrupts.c b/kernel/drivers/interrupts.c
index 57b0ab5..b0751d6 100644
--- a/kernel/drivers/interrupts.c
+++ b/kernel/drivers/interrupts.c
@@ -90,7 +90,7 @@ void irq_handler(struct regs *r)
}
// Map ISRs to the correct entries in the IDT
-void irq_install()
+void irq_install(void)
{
irq_remap();
@@ -182,7 +182,7 @@ void isr_handler(struct regs *r)
}
}
-void isr_install()
+void isr_install(void)
{
idt_set_gate(0, (u32)isr0, 0x08, 0x8E);
idt_set_gate(1, (u32)isr1, 0x08, 0x8E);
@@ -224,7 +224,7 @@ void isr_install()
/**
* Combined
*/
-void interrupts_install()
+void interrupts_install(void)
{
idt_install();
isr_install();
diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c
index 2bd67ba..67e0a72 100644
--- a/kernel/drivers/keyboard.c
+++ b/kernel/drivers/keyboard.c
@@ -15,7 +15,7 @@ int state = 0;
int merged = 0;
void keyboard_handler()
{
- u32 scancode = (u32)inb(0x60);
+ int scancode = inb(0x60);
// TODO: Support more than two-byte scancodes
if (scancode == 0xe0) {
@@ -40,20 +40,20 @@ void keyboard_handler()
merged = 0;
}
-void keyboard_acknowledge()
+void keyboard_acknowledge(void)
{
while (inb(0x60) != 0xfa)
;
}
-void keyboard_rate()
+void keyboard_rate(void)
{
outb(0x60, 0xF3);
keyboard_acknowledge();
outb(0x60, 0x0); // Rate{00000} Delay{00} 0
}
-void keyboard_install()
+void keyboard_install(void)
{
//keyboard_rate(); TODO: Fix keyboard rate?
irq_install_handler(1, keyboard_handler);
@@ -67,7 +67,7 @@ char keymap[128] = {
0, // Alt key
' ', // Space bar
15, // Caps lock
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F keys
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F keys
0, // Num lock
0, // Scroll lock
0, // Home key
diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c
index a5f5d0c..9b34b0a 100644
--- a/kernel/drivers/mouse.c
+++ b/kernel/drivers/mouse.c
@@ -17,18 +17,18 @@ void mouse_handler()
{
switch (mouse_cycle) {
case 0:
- mouse_byte[0] = inb(0x60);
+ mouse_byte[0] = (char)inb(0x60);
if (((mouse_byte[0] >> 3) & 1) == 1)
mouse_cycle++;
else
mouse_cycle = 0;
break;
case 1:
- mouse_byte[1] = inb(0x60);
+ mouse_byte[1] = (char)inb(0x60);
mouse_cycle++;
break;
case 2:
- mouse_byte[2] = inb(0x60);
+ mouse_byte[2] = (char)inb(0x60);
free(event);
event = malloc(sizeof(*event));
@@ -71,13 +71,13 @@ void mouse_write(u8 a_write)
outb(0x60, a_write);
}
-char mouse_read()
+u8 mouse_read(void)
{
mouse_wait(0);
return inb(0x60);
}
-void mouse_install()
+void mouse_install(void)
{
u8 status;
diff --git a/kernel/drivers/pci.c b/kernel/drivers/pci.c
index 6130cd0..72b9aa8 100644
--- a/kernel/drivers/pci.c
+++ b/kernel/drivers/pci.c
@@ -100,7 +100,7 @@ static u32 pci_isa = 0;
static u8 pci_remaps[4] = { 0 };
// Remap
-void pci_install()
+void pci_install(void)
{
pci_scan(&find_isa_bridge, -1, &pci_isa);
if (pci_isa) {
@@ -122,7 +122,7 @@ int pci_get_interrupt(u32 device)
u32 irq_pin = pci_read_field(device, 0x3D, 1);
if (irq_pin == 0)
return (int)pci_read_field(device, PCI_INTERRUPT_LINE, 1);
- int pirq = (int)(irq_pin + pci_extract_slot(device) - 2) % 4;
+ int pirq = ((int)irq_pin + pci_extract_slot(device) - 2) % 4;
int int_line = (int)pci_read_field(device, PCI_INTERRUPT_LINE, 1);
if (pci_remaps[pirq] >= 0x80) {
diff --git a/kernel/drivers/rtl8139.c b/kernel/drivers/rtl8139.c
index 14770c8..ec45bd7 100644
--- a/kernel/drivers/rtl8139.c
+++ b/kernel/drivers/rtl8139.c
@@ -13,12 +13,11 @@
static u8 mac[6];
static u8 *rx_buffer;
-static u32 current_packet_ptr;
static u32 rtl_device_pci = 0;
static u32 rtl_iobase = 0;
-u8 *rtl8139_get_mac()
+u8 *rtl8139_get_mac(void)
{
if (!rtl_device_pci)
return NULL;
@@ -26,8 +25,10 @@ u8 *rtl8139_get_mac()
return mac;
}
-void rtl8139_receive_packet()
+void rtl8139_receive_packet(void)
{
+ static u32 current_packet_ptr;
+
if (!rtl_device_pci)
return;
@@ -39,12 +40,12 @@ void rtl8139_receive_packet()
memcpy(packet, t, length);
ethernet_handle_packet(packet, length);
- current_packet_ptr = (current_packet_ptr + length + 4 + 3) & (~3);
+ current_packet_ptr = (current_packet_ptr + length + 4 + 3) & (u32)(~3);
if (current_packet_ptr >= RX_BUF_SIZE)
current_packet_ptr -= RX_BUF_SIZE;
- outw(rtl_iobase + RTL_PORT_RXPTR, current_packet_ptr - 0x10);
+ outw((u16)(rtl_iobase + RTL_PORT_RXPTR), (u16)(current_packet_ptr - 0x10));
}
static u8 tsad_array[4] = { 0x20, 0x24, 0x28, 0x2C };
@@ -56,8 +57,8 @@ void rtl8139_send_packet(void *data, u32 len)
return;
/* printf("Sending packet %d\n\n", len); */
- outl(rtl_iobase + tsad_array[tx_current], (u32)data);
- outl(rtl_iobase + tsd_array[tx_current++], len);
+ outl((u16)(rtl_iobase + tsad_array[tx_current]), (u32)data);
+ outl((u16)(rtl_iobase + tsd_array[tx_current++]), len);
if (tx_current > 3)
tx_current = 0;
}
@@ -69,16 +70,15 @@ void rtl8139_find(u32 device, u16 vendor_id, u16 device_id, void *extra)
}
}
-// TODO: Fix late packet arrival
void rtl8139_irq_handler()
{
if (!rtl_device_pci)
return;
/* print("\nRTL INT!\n"); */
- u16 status = inw(rtl_iobase + RTL_PORT_ISR);
+ u16 status = inw((u16)(rtl_iobase + RTL_PORT_ISR));
- outw(rtl_iobase + RTL_PORT_ISR, 0x5);
+ outw((u16)(rtl_iobase + RTL_PORT_ISR), 0x5);
if (status & RTL_TOK) {
print("Got response!\n");
@@ -88,7 +88,7 @@ void rtl8139_irq_handler()
}
}
-void rtl8139_init()
+void rtl8139_init(void)
{
if (!rtl_device_pci)
return;
@@ -104,41 +104,41 @@ void rtl8139_init()
rtl_iobase = 0;
if (rtl_bar0 & 0x00000001)
- rtl_iobase = rtl_bar0 & (~0x3);
+ rtl_iobase = rtl_bar0 & ((u32)~0x3);
// Get mac address
- for (int i = 0; i < 6; ++i)
- mac[i] = inb(rtl_iobase + RTL_PORT_MAC + i);
+ for (u32 i = 0; i < 6; ++i)
+ mac[i] = inb((u16)(rtl_iobase + RTL_PORT_MAC + i));
printf("Mac address: %x:%x:%x:%x:%x:%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
// Activate
- outb(rtl_iobase + RTL_PORT_CONFIG, 0x0);
+ outb((u16)(rtl_iobase + RTL_PORT_CONFIG), 0x0);
// Reset
outb((u16)(rtl_iobase + RTL_PORT_CMD), 0x10);
- while ((inb(rtl_iobase + RTL_PORT_CMD) & 0x10) != 0)
+ while ((inb((u16)(rtl_iobase + RTL_PORT_CMD)) & 0x10) != 0)
;
// Set receive buffer
rx_buffer = (u8 *)malloc(RX_BUF_SIZE + 1516);
memset(rx_buffer, 0, RX_BUF_SIZE + 1516);
- outl(rtl_iobase + RTL_PORT_RBSTART, (u32)rx_buffer);
+ outl((u16)(rtl_iobase + RTL_PORT_RBSTART), (u32)rx_buffer);
// Set TOK and ROK
- outw(rtl_iobase + RTL_PORT_IMR, 0x0005);
+ outw((u16)(rtl_iobase + RTL_PORT_IMR), 0x0005);
// AB+AM+APM+AAP except WRAP
- outl(rtl_iobase + RTL_PORT_RCR, 0xf | (1 << 7));
+ outl((u16)(rtl_iobase + RTL_PORT_RCR), 0xf | (1 << 7));
// Enable receive and transmit
- outb(rtl_iobase + RTL_PORT_CMD, 0x08 | 0x04);
+ outb((u16)(rtl_iobase + RTL_PORT_CMD), 0x08 | 0x04);
// Install interrupt handler
- u32 rtl_irq = pci_get_interrupt(rtl_device_pci);
+ int rtl_irq = pci_get_interrupt(rtl_device_pci);
irq_install_handler(rtl_irq, rtl8139_irq_handler);
}
-int rtl8139_install()
+int rtl8139_install(void)
{
pci_scan(&rtl8139_find, -1, &rtl_device_pci);
@@ -146,5 +146,6 @@ int rtl8139_install()
print("Found rtl8139 card\n");
rtl8139_init();
}
- return rtl_device_pci;
+
+ return (int)rtl_device_pci;
}
diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c
index 3bc1811..e9e90a0 100644
--- a/kernel/drivers/timer.c
+++ b/kernel/drivers/timer.c
@@ -11,11 +11,11 @@ void timer_phase(int hz)
{
int divisor = 3579545 / 3 / hz;
outb(0x43, 0x36); // 01 10 11 0b // CTR, RW, MODE, BCD
- outb(0x40, divisor & 0xFF);
- outb(0x40, divisor >> 8);
+ outb(0x40, (u8)(divisor & 0xFF));
+ outb(0x40, (u8)(divisor >> 8));
}
-u32 timer_get()
+u32 timer_get(void)
{
return timer_ticks;
}
@@ -38,7 +38,7 @@ void timer_wait(u32 ticks)
}
// Install timer handler into IRQ0
-void timer_install()
+void timer_install(void)
{
/* hpet_install(10000); // TODO: Find optimal femtosecond period */
/* if (!hpet) */