Make it compileable by clang
This commit is contained in:
19
trace_lbr.c
19
trace_lbr.c
@@ -57,24 +57,7 @@ void handle_sigtrap() {
|
|||||||
wrmsr(MSR_IA32_DEBUGCTLMSR, 3);
|
wrmsr(MSR_IA32_DEBUGCTLMSR, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t set_eflags_tf(uint32_t tf) {
|
uint32_t set_eflags_tf(uint32_t tf);
|
||||||
uint32_t prev;
|
|
||||||
__asm__ __inline__ __volatile__ (
|
|
||||||
"pushfd;"
|
|
||||||
"pop eax;"
|
|
||||||
"ror eax, 8;"
|
|
||||||
"mov edx, eax;"
|
|
||||||
"and edx, 1;"
|
|
||||||
"and eax, ~1;"
|
|
||||||
"or eax, ecx;"
|
|
||||||
"rol eax, 8;"
|
|
||||||
"push eax;"
|
|
||||||
"popfd"
|
|
||||||
: "=d"(prev)
|
|
||||||
: "c"(tf)
|
|
||||||
: "eax", "memory");
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
void trace_lbr_begin() {
|
void trace_lbr_begin() {
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
|
59
umka.asm
59
umka.asm
@@ -71,7 +71,7 @@ public new_sys_threads as 'kos_new_sys_threads'
|
|||||||
public osloop as 'kos_osloop'
|
public osloop as 'kos_osloop'
|
||||||
public set_mouse_data as 'kos_set_mouse_data'
|
public set_mouse_data as 'kos_set_mouse_data'
|
||||||
public scheduler_current as 'kos_scheduler_current'
|
public scheduler_current as 'kos_scheduler_current'
|
||||||
public eth_input as 'kos_eth_input'
|
public kos_eth_input
|
||||||
public net_buff_alloc as 'kos_net_buff_alloc'
|
public net_buff_alloc as 'kos_net_buff_alloc'
|
||||||
|
|
||||||
public mem_block_list
|
public mem_block_list
|
||||||
@@ -328,6 +328,63 @@ proc umka._.check_alignment
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
public i40_asm
|
||||||
|
|
||||||
|
;void i40_asm(uint32_t _eax,
|
||||||
|
; uint32_t _ebx,
|
||||||
|
; uint32_t _ecx,
|
||||||
|
; uint32_t _edx,
|
||||||
|
; uint32_t _esi,
|
||||||
|
; uint32_t _edi,
|
||||||
|
; uint32_t _ebp,
|
||||||
|
; uint32_t *_eax_out,
|
||||||
|
; uint32_t _ebx_out)
|
||||||
|
i40_asm:
|
||||||
|
; Return address: esp
|
||||||
|
; First argument: esp + 4
|
||||||
|
push eax ebx ecx edx esi edi ebp
|
||||||
|
; First argument: esp + 4 + 7 * sizeof(dword) = esp + 8 + 7 * 4 = esp + 4 + 28 = esp + 32
|
||||||
|
mov eax, [esp + 32]
|
||||||
|
mov ebx, [esp + 36]
|
||||||
|
mov ecx, [esp + 40]
|
||||||
|
mov edx, [esp + 44]
|
||||||
|
mov esi, [esp + 48]
|
||||||
|
mov edi, [esp + 52]
|
||||||
|
mov ebp, [esp + 56]
|
||||||
|
call i40
|
||||||
|
mov edi, [esp + 60]
|
||||||
|
mov [edi], eax
|
||||||
|
mov edi, [esp + 64]
|
||||||
|
mov [edi], ebx
|
||||||
|
pop ebp edi esi edx ecx ebx eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
public set_eflags_tf
|
||||||
|
|
||||||
|
proc set_eflags_tf c uses ebx esi edi ebp, tf
|
||||||
|
mov ecx, [tf]
|
||||||
|
pushfd
|
||||||
|
pop eax
|
||||||
|
ror eax, 8
|
||||||
|
mov edx, eax
|
||||||
|
and edx, 1
|
||||||
|
and eax, 0xfffffffe
|
||||||
|
or eax, ecx
|
||||||
|
rol eax, 8
|
||||||
|
push eax
|
||||||
|
popfd
|
||||||
|
mov eax, edx
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
|
proc kos_eth_input c uses ebx esi edi ebp, buffer_ptr
|
||||||
|
push .retaddr
|
||||||
|
push [buffer_ptr]
|
||||||
|
jmp eth_input
|
||||||
|
.retaddr:
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
proc umka_init c uses ebx esi edi ebp
|
proc umka_init c uses ebx esi edi ebp
|
||||||
mov [umka_initialized], 1
|
mov [umka_initialized], 1
|
||||||
call umka._.check_alignment
|
call umka._.check_alignment
|
||||||
|
87
umka.h
87
umka.h
@@ -449,13 +449,13 @@ static inline size_t
|
|||||||
umka_new_sys_threads(uint32_t flags, void (*entry)(), void *stack) {
|
umka_new_sys_threads(uint32_t flags, void (*entry)(), void *stack) {
|
||||||
size_t tid;
|
size_t tid;
|
||||||
__asm__ __inline__ __volatile__ (
|
__asm__ __inline__ __volatile__ (
|
||||||
"push ebx;"
|
"push %%ebx;"
|
||||||
"push esi;"
|
"push %%esi;"
|
||||||
"push edi;"
|
"push %%edi;"
|
||||||
"call kos_new_sys_threads;"
|
"call kos_new_sys_threads;"
|
||||||
"pop edi;"
|
"pop %%edi;"
|
||||||
"pop esi;"
|
"pop %%esi;"
|
||||||
"pop ebx"
|
"pop %%ebx"
|
||||||
: "=a"(tid)
|
: "=a"(tid)
|
||||||
: "b"(flags),
|
: "b"(flags),
|
||||||
"c"(entry),
|
"c"(entry),
|
||||||
@@ -467,9 +467,9 @@ umka_new_sys_threads(uint32_t flags, void (*entry)(), void *stack) {
|
|||||||
static inline void
|
static inline void
|
||||||
kos_enable_acpi() {
|
kos_enable_acpi() {
|
||||||
__asm__ __inline__ __volatile__ (
|
__asm__ __inline__ __volatile__ (
|
||||||
"pushad;"
|
"pusha;"
|
||||||
"call enable_acpi;"
|
"call enable_acpi;"
|
||||||
"popad"
|
"popa"
|
||||||
:
|
:
|
||||||
:
|
:
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
@@ -478,11 +478,11 @@ kos_enable_acpi() {
|
|||||||
static inline void
|
static inline void
|
||||||
kos_acpi_call_name(void *ctx, const char *name) {
|
kos_acpi_call_name(void *ctx, const char *name) {
|
||||||
__asm__ __inline__ __volatile__ (
|
__asm__ __inline__ __volatile__ (
|
||||||
"pushad;"
|
"pusha;"
|
||||||
"push %[name];"
|
"push %[name];"
|
||||||
"push %[ctx];"
|
"push %[ctx];"
|
||||||
"call acpi.call_name;"
|
"call acpi.call_name;"
|
||||||
"popad"
|
"popa"
|
||||||
:
|
:
|
||||||
: [ctx] "r"(ctx), [name] "r"(name)
|
: [ctx] "r"(ctx), [name] "r"(name)
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
@@ -555,6 +555,8 @@ extern void *kos_acpi_dev_data;
|
|||||||
extern size_t kos_acpi_dev_size;
|
extern size_t kos_acpi_dev_size;
|
||||||
extern void *kos_acpi_dev_next;
|
extern void *kos_acpi_dev_next;
|
||||||
|
|
||||||
|
void kos_eth_input(void *buf);
|
||||||
|
|
||||||
STDCALL void*
|
STDCALL void*
|
||||||
kos_kernel_alloc(size_t len);
|
kos_kernel_alloc(size_t len);
|
||||||
|
|
||||||
@@ -577,9 +579,9 @@ typedef struct {
|
|||||||
static inline void
|
static inline void
|
||||||
umka_stack_init() {
|
umka_stack_init() {
|
||||||
__asm__ __inline__ __volatile__ (
|
__asm__ __inline__ __volatile__ (
|
||||||
"pushad;"
|
"pusha;"
|
||||||
"call kos_stack_init;"
|
"call kos_stack_init;"
|
||||||
"popad"
|
"popa"
|
||||||
:
|
:
|
||||||
:
|
:
|
||||||
: "memory", "cc");
|
: "memory", "cc");
|
||||||
@@ -888,8 +890,8 @@ umka_find_next_task(int32_t priority) {
|
|||||||
find_next_task_t fnt;
|
find_next_task_t fnt;
|
||||||
__asm__ __inline__ __volatile__ (
|
__asm__ __inline__ __volatile__ (
|
||||||
"call find_next_task;"
|
"call find_next_task;"
|
||||||
"setz al;"
|
"setz %%al;"
|
||||||
"movzx eax, al"
|
"movzx %%eax, %%al"
|
||||||
: "=b"(fnt.appdata),
|
: "=b"(fnt.appdata),
|
||||||
"=D"(fnt.taskdata),
|
"=D"(fnt.taskdata),
|
||||||
"=a"(fnt.same)
|
"=a"(fnt.same)
|
||||||
@@ -898,23 +900,27 @@ umka_find_next_task(int32_t priority) {
|
|||||||
return fnt;
|
return fnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void i40_asm(uint32_t eax,
|
||||||
|
uint32_t ebx,
|
||||||
|
uint32_t ecx,
|
||||||
|
uint32_t edx,
|
||||||
|
uint32_t esi,
|
||||||
|
uint32_t edi,
|
||||||
|
uint32_t ebp,
|
||||||
|
uint32_t *eax_out,
|
||||||
|
uint32_t *ebx_out);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
umka_i40(pushad_t *regs) {
|
umka_i40(pushad_t *regs) {
|
||||||
__asm__ __inline__ __volatile__ (
|
i40_asm(regs->eax,
|
||||||
"push ebp;"
|
regs->ebx,
|
||||||
"mov ebp, %[ebp];"
|
regs->ecx,
|
||||||
"call i40;"
|
regs->edx,
|
||||||
"pop ebp"
|
regs->esi,
|
||||||
: "=a"(regs->eax),
|
regs->edi,
|
||||||
"=b"(regs->ebx)
|
regs->ebp,
|
||||||
: "a"(regs->eax),
|
®s->eax,
|
||||||
"b"(regs->ebx),
|
®s->ebx);
|
||||||
"c"(regs->ecx),
|
|
||||||
"d"(regs->edx),
|
|
||||||
"S"(regs->esi),
|
|
||||||
"D"(regs->edi),
|
|
||||||
[ebp] "Rm"(regs->ebp)
|
|
||||||
: "memory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -1338,20 +1344,15 @@ static inline void
|
|||||||
umka_sys_put_image_palette(void *image, size_t xsize, size_t ysize,
|
umka_sys_put_image_palette(void *image, size_t xsize, size_t ysize,
|
||||||
size_t x, size_t y, size_t bpp, void *palette,
|
size_t x, size_t y, size_t bpp, void *palette,
|
||||||
size_t row_offset) {
|
size_t row_offset) {
|
||||||
__asm__ __inline__ __volatile__ (
|
pushad_t regs = { 0 };
|
||||||
"push ebp;"
|
regs.eax = 65;
|
||||||
"mov ebp, %[row_offset];"
|
regs.ebx = (uintptr_t)image;
|
||||||
"call i40;"
|
regs.ecx = (xsize << 16) + ysize;
|
||||||
"pop ebp"
|
regs.edx = (x << 16) + y;
|
||||||
:
|
regs.esi = bpp;
|
||||||
: "a"(65),
|
regs.edi = (uintptr_t)palette;
|
||||||
"b"(image),
|
regs.ebp = row_offset;
|
||||||
"c"((xsize << 16) + ysize),
|
umka_i40(®s);
|
||||||
"d"((x << 16) + y),
|
|
||||||
"S"(bpp),
|
|
||||||
"D"(palette),
|
|
||||||
[row_offset] "Rm"(row_offset)
|
|
||||||
: "memory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
12
vnet.c
12
vnet.c
@@ -93,15 +93,5 @@ void vnet_receive_frame(net_device_t *dev, void *data, size_t size) {
|
|||||||
buf->device = dev;
|
buf->device = dev;
|
||||||
buf->offset = offsetof(net_buff_t, data);
|
buf->offset = offsetof(net_buff_t, data);
|
||||||
memcpy(buf->data, data, size);
|
memcpy(buf->data, data, size);
|
||||||
__asm__ __inline__ __volatile__ (
|
kos_eth_input(buf);
|
||||||
"pushad;"
|
|
||||||
"lea ecx, 1f;"
|
|
||||||
"push ecx;"
|
|
||||||
"push eax;"
|
|
||||||
"jmp kos_eth_input;"
|
|
||||||
"1:"
|
|
||||||
"popad"
|
|
||||||
:
|
|
||||||
: "a"(buf)
|
|
||||||
: "memory", "ecx");
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user