Skip to content

Commit 952cded

Browse files
A number of optimizations have been made for OpenKernel.
1 parent c2fde47 commit 952cded

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

Drivers/Cpu/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ void get_sys_cpuinfo(const char *mode) {
2626

2727
void cpu_status(const char *mode) {
2828
if (mode[0] == 'S') {
29-
__asm__ __volatile__ ("hlt");
29+
hlt();
3030
}
3131
if (mode[0] == 'A') {
32-
__asm__ __volatile__ ("sti");
32+
sti();
3333
}
3434
}
3535

Kernel/KernelServices/SystemManagement/sysmng.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void sys_next_status(const char *mode, uint32_t seconds) {
1212
outb(0x605, 0x20);
1313
}
1414
else if(mode[0] == 'R') {
15-
__asm__ volatile ("cli");
15+
cli();
1616
while (inb(0x64) & 0x02);
1717
outb(0x64, 0xFE);
1818
}
@@ -30,6 +30,6 @@ void exit_program(const char *mode, const char *message) {
3030
}
3131

3232
while (true) {
33-
__asm__ __volatile__ ("hlt");
33+
hlt();
3434
}
3535
}

Kernel/KernelServices/SystemManagement/sysmng.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <OpenKernel/SystemLib/SystemIO/io.h>
66
#include <OpenKernel/SystemLib/TimeMng/time.h>
77
#include <OpenKernel/Drivers/Vga/vga.h>
8+
#include <OpenKernel/Drivers/Cpu/cpu.h>
89

910
void sys_next_status(const char *mode, uint32_t seconds);
1011
void exit_program(const char *mode, const char *message);

SystemLib/TimeMng/time.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "time.h"
22
#include <OpenKernel/Drivers/Vga/vga.h>
33
#include <OpenKernel/SystemLib/SystemIO/io.h>
4+
#include <OpenKernel/Drivers/Cpu/cpu.h>
5+
#include <OpenKernel/SystemLib/TypeConversion/type_conv.h>
46

57
systime sys_time = {0, 0, 0, 0, 0, 0};
68

@@ -12,10 +14,6 @@ static uint8_t rtc_read(uint8_t reg) {
1214
return inb(RTC_DATA);
1315
}
1416

15-
static uint8_t bcd_to_bin(uint8_t val) {
16-
return ((val / 16) * 10) + (val & 0x0F);
17-
}
18-
1917
void uptime() {
2018
uint8_t sec, min, hour, day, month, year;
2119
sec = rtc_read(0x00);
@@ -74,6 +72,6 @@ void print_time() {
7472

7573
void sleep(uint32_t seconds) {
7674
for (uint64_t i = 0; i < (uint64_t)seconds * 50000000ULL; i++) {
77-
__asm__ __volatile__ ("nop");
75+
nop();
7876
}
7977
}

0 commit comments

Comments
 (0)