diff options
author | aqua <aqua@iserlohn-fortress.net> | 2023-05-24 21:29:00 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2023-05-24 21:29:29 +0300 |
commit | 050aa3ab70dd69d1ca8ffe94fd146039a0885550 (patch) | |
tree | 4002a7a0bb86580cc6a2adc2eee45891ee068540 /i686/sys | |
parent | Place compiled objects and dependencies in build/ (diff) | |
download | kernel-050aa3ab70dd69d1ca8ffe94fd146039a0885550.tar.xz |
Make code ANSI C compatible
Diffstat (limited to 'i686/sys')
-rw-r--r-- | i686/sys/control.h | 15 | ||||
-rw-r--r-- | i686/sys/cpuid.h | 2 | ||||
-rw-r--r-- | i686/sys/io.h | 50 |
3 files changed, 33 insertions, 34 deletions
diff --git a/i686/sys/control.h b/i686/sys/control.h index 7dde3c8..89ab067 100644 --- a/i686/sys/control.h +++ b/i686/sys/control.h @@ -1,25 +1,24 @@ #pragma once -static inline void +static __inline__ void abort() { /* Symbol h is already defined? -asm volatile(R"(cli +__asm__(R"(cli h: hlt jmp h)"); */ - asm volatile(R"(cli -hlt)"); + __asm__("cli; hlt"); } -static inline void +static __inline__ void enable_interrupts() { - asm volatile("sti"); + __asm__("sti"); } -static inline void +static __inline__ void disable_interrupts() { - asm volatile("cli"); + __asm__("cli"); } diff --git a/i686/sys/cpuid.h b/i686/sys/cpuid.h index 65b43c6..6613967 100644 --- a/i686/sys/cpuid.h +++ b/i686/sys/cpuid.h @@ -12,7 +12,7 @@ struct CPUVersion { unsigned int family_ex : 8; unsigned int __unused_2 : 4; } __attribute__((packed, aligned(__alignof__(unsigned int)))); -// FIXME _Static_assert(sizeof(struct CPUVersion) == sizeof(unsigned int), "cpuid version struct size"); +/* FIXME _Static_assert(sizeof(struct CPUVersion) == sizeof(unsigned int), "cpuid version struct size"); */ unsigned int family(const struct CPUVersion v) diff --git a/i686/sys/io.h b/i686/sys/io.h index da586b9..403dc54 100644 --- a/i686/sys/io.h +++ b/i686/sys/io.h @@ -1,6 +1,6 @@ #pragma once -// port listings +/* port listings */ enum UART { COM1 = 0x3f8, COM2 = 0x2f8, @@ -12,81 +12,81 @@ enum UART { COM8 = 0x4e8, }; -static inline void +static __inline__ void outb(unsigned char val, unsigned short port) { - asm volatile("outb %0,%1" : : "a"(val), "dN"(port)); + __asm__("outb %0,%1" : : "a"(val), "dN"(port)); } -static inline void +static __inline__ void outw(unsigned short val, unsigned short port) { - asm volatile("outw %0,%1" : : "a"(val), "dN"(port)); + __asm__("outw %0,%1" : : "a"(val), "dN"(port)); } -static inline void +static __inline__ void outl(unsigned int val, unsigned short port) { - asm volatile("outl %0,%1" : : "a"(val), "dN"(port)); + __asm__("outl %0,%1" : : "a"(val), "dN"(port)); } -static inline unsigned char +static __inline__ unsigned char inb(unsigned short port) { unsigned char val; - asm volatile("inb %1,%0" : "=a"(val) : "dN"(port)); + __asm__("inb %1,%0" : "=a"(val) : "dN"(port)); return val; } -static inline unsigned short +static __inline__ unsigned short inw(unsigned short port) { unsigned short val; - asm volatile("inw %1,%0" : "=a"(val) : "dN"(port)); + __asm__("inw %1,%0" : "=a"(val) : "dN"(port)); return val; } -static inline unsigned int +static __inline__ unsigned int inl(unsigned short port) { unsigned int val; - asm volatile("inl %1,%0" : "=a"(val) : "dN"(port)); + __asm__("inl %1,%0" : "=a"(val) : "dN"(port)); return val; } -static inline void +static __inline__ void outsb(unsigned short port, const void *__buf, unsigned long __n) { - asm volatile("cld; rep; outsb" : "+S"(__buf), "+c"(__n) : "d"(port)); + __asm__("cld; rep; outsb" : "+S"(__buf), "+c"(__n) : "d"(port)); } -static inline void +static __inline__ void outsw(unsigned short port, const void *__buf, unsigned long __n) { - asm volatile("cld; rep; outsw" : "+S"(__buf), "+c"(__n) : "d"(port)); + __asm__("cld; rep; outsw" : "+S"(__buf), "+c"(__n) : "d"(port)); } -static inline void +static __inline__ void outsl(unsigned short port, const void *__buf, unsigned long __n) { - asm volatile("cld; rep; outsl" : "+S"(__buf), "+c"(__n) : "d"(port)); + __asm__("cld; rep; outsl" : "+S"(__buf), "+c"(__n) : "d"(port)); } -static inline void +static __inline__ void insb(unsigned short port, void *__buf, unsigned long __n) { - asm volatile("cld; rep; insb" : "+D"(__buf), "+c"(__n) : "d"(port)); + __asm__("cld; rep; insb" : "+D"(__buf), "+c"(__n) : "d"(port)); } -static inline void +static __inline__ void insw(unsigned short port, void *__buf, unsigned long __n) { - asm volatile("cld; rep; insw" : "+D"(__buf), "+c"(__n) : "d"(port)); + __asm__("cld; rep; insw" : "+D"(__buf), "+c"(__n) : "d"(port)); } -static inline void +static __inline__ void insl(unsigned short port, void *__buf, unsigned long __n) { - asm volatile("cld; rep; insl" : "+D"(__buf), "+c"(__n) : "d"(port)); + __asm__("cld; rep; insl" : "+D"(__buf), "+c"(__n) : "d"(port)); } |