Cleanup asm

This commit is contained in:
Baptiste Wicht 2016-07-02 16:44:36 +02:00
parent 40049a75cf
commit c06802ed30
2 changed files with 12 additions and 12 deletions

View File

@ -67,13 +67,13 @@ void idt_set_gate(size_t gate, void (*function)(void), uint16_t gdt_selector, id
uint64_t get_cr2(){ uint64_t get_cr2(){
uint64_t value; uint64_t value;
__asm__ __volatile__("mov rax, cr2; mov %0, rax;" : "=m" (value)); asm volatile("mov rax, cr2; mov %0, rax;" : "=m" (value));
return value; return value;
} }
uint64_t get_cr3(){ uint64_t get_cr3(){
uint64_t value; uint64_t value;
__asm__ __volatile__("mov rax, cr3; mov %0, rax;" : "=m" (value)); asm volatile("mov rax, cr3; mov %0, rax;" : "=m" (value));
return value; return value;
} }
@ -89,7 +89,7 @@ void install_idt(){
std::fill_n(irq_handlers, 16, nullptr); std::fill_n(irq_handlers, 16, nullptr);
//Give the IDTR address to the CPU //Give the IDTR address to the CPU
__asm__ __volatile__("lidt [%0]" : : "m" (idtr_64)); asm volatile("lidt [%0]" : : "m" (idtr_64));
} }
void install_isrs(){ void install_isrs(){
@ -181,7 +181,7 @@ void install_syscalls(){
} }
void enable_interrupts(){ void enable_interrupts(){
__asm__ __volatile__("sti" : : ); asm volatile("sti" : : );
} }
const char* exceptions_title[32] { const char* exceptions_title[32] {

View File

@ -50,21 +50,21 @@ void timer::sleep_ms(uint64_t delay){
_timer_countdown = delay; _timer_countdown = delay;
while(true){ while(true){
__asm__ __volatile__ ("cli"); asm volatile ("cli");
if(_timer_countdown != 0){ if(_timer_countdown != 0){
__asm__ __volatile__ ("sti"); asm volatile ("sti");
__asm__ __volatile__ ("nop"); asm volatile ("nop");
__asm__ __volatile__ ("nop"); asm volatile ("nop");
__asm__ __volatile__ ("nop"); asm volatile ("nop");
__asm__ __volatile__ ("nop"); asm volatile ("nop");
__asm__ __volatile__ ("nop"); asm volatile ("nop");
} else { } else {
break; break;
} }
} }
__asm__ __volatile__ ("sti"); asm volatile ("sti");
} }
uint64_t timer::ticks(){ uint64_t timer::ticks(){