mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-24 14:56:49 +03:00
Revert to -masm=intel for inline assembly
This commit is contained in:
parent
e7838e854f
commit
1bb1bd2201
@ -10,6 +10,7 @@ INTERNAL_CFLAGS = \
|
|||||||
-fno-stack-protector \
|
-fno-stack-protector \
|
||||||
-fno-pic \
|
-fno-pic \
|
||||||
-fomit-frame-pointer \
|
-fomit-frame-pointer \
|
||||||
|
-masm=intel \
|
||||||
-mno-80387 \
|
-mno-80387 \
|
||||||
-mno-mmx \
|
-mno-mmx \
|
||||||
-mno-3dnow \
|
-mno-3dnow \
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
#ifndef __LIB__ASM_H__
|
|
||||||
#define __LIB__ASM_H__
|
|
||||||
|
|
||||||
#define ASM(body, ...) asm volatile (".intel_syntax noprefix\n\t" body ".att_syntax prefix" : __VA_ARGS__)
|
|
||||||
#define ASM_BASIC(body) asm (".intel_syntax noprefix\n\t" body ".att_syntax prefix")
|
|
||||||
|
|
||||||
#define FARJMP16(seg, off) \
|
|
||||||
".byte 0xea\n\t" \
|
|
||||||
".2byte " off "\n\t" \
|
|
||||||
".2byte " seg "\n\t" \
|
|
||||||
|
|
||||||
#define FARJMP32(seg, off) \
|
|
||||||
".byte 0xea\n\t" \
|
|
||||||
".4byte " off "\n\t" \
|
|
||||||
".2byte " seg "\n\t" \
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,6 +1,4 @@
|
|||||||
#include <lib/asm.h>
|
asm (
|
||||||
|
|
||||||
ASM_BASIC(
|
|
||||||
".section .entry\n\t"
|
".section .entry\n\t"
|
||||||
|
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
|
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
@ -10,6 +10,7 @@ INTERNAL_CFLAGS = \
|
|||||||
-fno-stack-protector \
|
-fno-stack-protector \
|
||||||
-fno-pic \
|
-fno-pic \
|
||||||
-fomit-frame-pointer \
|
-fomit-frame-pointer \
|
||||||
|
-masm=intel \
|
||||||
-mno-80387 \
|
-mno-80387 \
|
||||||
-mno-mmx \
|
-mno-mmx \
|
||||||
-mno-3dnow \
|
-mno-3dnow \
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
#ifndef __LIB__ASM_H__
|
|
||||||
#define __LIB__ASM_H__
|
|
||||||
|
|
||||||
#define ASM(body, ...) asm volatile (".intel_syntax noprefix\n\t" body ".att_syntax prefix" : __VA_ARGS__)
|
|
||||||
#define ASM_BASIC(body) asm (".intel_syntax noprefix\n\t" body ".att_syntax prefix")
|
|
||||||
|
|
||||||
#define FARJMP16(seg, off) \
|
|
||||||
".byte 0xea\n\t" \
|
|
||||||
".2byte " off "\n\t" \
|
|
||||||
".2byte " seg "\n\t" \
|
|
||||||
|
|
||||||
#define FARJMP32(seg, off) \
|
|
||||||
".byte 0xea\n\t" \
|
|
||||||
".4byte " off "\n\t" \
|
|
||||||
".2byte " seg "\n\t" \
|
|
||||||
|
|
||||||
#endif
|
|
@ -9,7 +9,6 @@
|
|||||||
#include <lib/cio.h>
|
#include <lib/cio.h>
|
||||||
#include <lib/e820.h>
|
#include <lib/e820.h>
|
||||||
#include <lib/print.h>
|
#include <lib/print.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
|
|
||||||
uint8_t bcd_to_int(uint8_t val) {
|
uint8_t bcd_to_int(uint8_t val) {
|
||||||
return (val & 0x0f) + ((val & 0xf0) >> 4) * 10;
|
return (val & 0x0f) + ((val & 0xf0) >> 4) * 10;
|
||||||
@ -18,18 +17,20 @@ uint8_t bcd_to_int(uint8_t val) {
|
|||||||
int cpuid(uint32_t leaf, uint32_t subleaf,
|
int cpuid(uint32_t leaf, uint32_t subleaf,
|
||||||
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
|
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
|
||||||
uint32_t cpuid_max;
|
uint32_t cpuid_max;
|
||||||
ASM("cpuid\n\t", "=a" (cpuid_max)
|
asm volatile ("cpuid"
|
||||||
: "a" (leaf & 0x80000000)
|
: "=a" (cpuid_max)
|
||||||
: "ebx", "ecx", "edx");
|
: "a" (leaf & 0x80000000)
|
||||||
|
: "ebx", "ecx", "edx");
|
||||||
if (leaf > cpuid_max)
|
if (leaf > cpuid_max)
|
||||||
return 1;
|
return 1;
|
||||||
ASM("cpuid\n\t", "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
|
asm volatile ("cpuid"
|
||||||
: "a" (leaf), "c" (subleaf));
|
: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
|
||||||
|
: "a" (leaf), "c" (subleaf));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) void panic(const char *fmt, ...) {
|
__attribute__((noreturn)) void panic(const char *fmt, ...) {
|
||||||
ASM("cli\n\t", :: "memory");
|
asm volatile ("cli" ::: "memory");
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ASM("hlt\n\t", :: "memory");
|
asm volatile ("hlt" ::: "memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,35 +2,34 @@
|
|||||||
#define __CIO_H__
|
#define __CIO_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
|
|
||||||
static inline void port_out_b(uint16_t port, uint8_t value) {
|
static inline void port_out_b(uint16_t port, uint8_t value) {
|
||||||
ASM("out dx, al\n\t", : "a" (value), "d" (port) : "memory");
|
asm volatile ("out dx, al" : : "a" (value), "d" (port) : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void port_out_w(uint16_t port, uint16_t value) {
|
static inline void port_out_w(uint16_t port, uint16_t value) {
|
||||||
ASM("out dx, ax\n\t", : "a" (value), "d" (port) : "memory");
|
asm volatile ("out dx, ax" : : "a" (value), "d" (port) : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void port_out_d(uint16_t port, uint32_t value) {
|
static inline void port_out_d(uint16_t port, uint32_t value) {
|
||||||
ASM("out dx, eax\n\t", : "a" (value), "d" (port) : "memory");
|
asm volatile ("out dx, eax" : : "a" (value), "d" (port) : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t port_in_b(uint16_t port) {
|
static inline uint8_t port_in_b(uint16_t port) {
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
ASM("in al, dx\n\t", "=a" (value) : "d" (port) : "memory");
|
asm volatile ("in al, dx" : "=a" (value) : "d" (port) : "memory");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t port_in_w(uint16_t port) {
|
static inline uint16_t port_in_w(uint16_t port) {
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
ASM("in ax, dx\n\t", "=a" (value) : "d" (port) : "memory");
|
asm volatile ("in ax, dx" : "=a" (value) : "d" (port) : "memory");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t port_in_d(uint16_t port) {
|
static inline uint32_t port_in_d(uint16_t port) {
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
ASM("in eax, dx\n\t", "=a" (value) : "d" (port) : "memory");
|
asm volatile ("in eax, dx" : "=a" (value) : "d" (port) : "memory");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <lib/libc.h>
|
#include <lib/libc.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
|
|
||||||
int toupper(int c) {
|
int toupper(int c) {
|
||||||
if (c >= 'a' && c <= 'z') {
|
if (c >= 'a' && c <= 'z') {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#include <lib/asm.h>
|
asm (
|
||||||
|
|
||||||
ASM_BASIC(
|
|
||||||
".section .entry\n\t"
|
".section .entry\n\t"
|
||||||
|
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <lib/blib.h>
|
#include <lib/blib.h>
|
||||||
#include <drivers/disk.h>
|
#include <drivers/disk.h>
|
||||||
#include <lib/term.h>
|
#include <lib/term.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
|
|
||||||
void chainload(void) {
|
void chainload(void) {
|
||||||
int part; {
|
int part; {
|
||||||
@ -36,9 +35,9 @@ void chainload(void) {
|
|||||||
read(drive, (void *)0x7c00, 0, 512);
|
read(drive, (void *)0x7c00, 0, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASM(
|
asm volatile (
|
||||||
// Jump to real mode
|
// Jump to real mode
|
||||||
FARJMP32("0x08", "1f")
|
"jmp 0x08:1f\n\t"
|
||||||
"1: .code16\n\t"
|
"1: .code16\n\t"
|
||||||
"mov ax, 0x10\n\t"
|
"mov ax, 0x10\n\t"
|
||||||
"mov ds, ax\n\t"
|
"mov ds, ax\n\t"
|
||||||
@ -49,7 +48,7 @@ void chainload(void) {
|
|||||||
"mov eax, cr0\n\t"
|
"mov eax, cr0\n\t"
|
||||||
"and al, 0xfe\n\t"
|
"and al, 0xfe\n\t"
|
||||||
"mov cr0, eax\n\t"
|
"mov cr0, eax\n\t"
|
||||||
FARJMP16("0", "1f")
|
"jmp 0x0000:1f\n\t"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"mov ax, 0\n\t"
|
"mov ax, 0\n\t"
|
||||||
"mov ds, ax\n\t"
|
"mov ds, ax\n\t"
|
||||||
@ -60,7 +59,8 @@ void chainload(void) {
|
|||||||
"push 0\n\t"
|
"push 0\n\t"
|
||||||
"push 0x7c00\n\t"
|
"push 0x7c00\n\t"
|
||||||
"retf\n\t"
|
"retf\n\t"
|
||||||
".code32\n\t",
|
".code32\n\t"
|
||||||
|
:
|
||||||
: "d" (drive)
|
: "d" (drive)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <lib/config.h>
|
#include <lib/config.h>
|
||||||
#include <lib/print.h>
|
#include <lib/print.h>
|
||||||
#include <lib/memmap.h>
|
#include <lib/memmap.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
|
|
||||||
#define KERNEL_LOAD_ADDR ((size_t)0x100000)
|
#define KERNEL_LOAD_ADDR ((size_t)0x100000)
|
||||||
#define INITRD_LOAD_ADDR ((size_t)0x1000000)
|
#define INITRD_LOAD_ADDR ((size_t)0x1000000)
|
||||||
@ -137,11 +136,11 @@ void linux_load(char *cmdline, int boot_drive) {
|
|||||||
|
|
||||||
term_deinit();
|
term_deinit();
|
||||||
|
|
||||||
ASM(
|
asm volatile (
|
||||||
"cli\n\t"
|
"cli\n\t"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
|
|
||||||
FARJMP32("0x08", "1f")
|
"jmp 0x08:1f\n\t"
|
||||||
"1: .code16\n\t"
|
"1: .code16\n\t"
|
||||||
"mov ax, 0x10\n\t"
|
"mov ax, 0x10\n\t"
|
||||||
"mov ds, ax\n\t"
|
"mov ds, ax\n\t"
|
||||||
@ -152,7 +151,7 @@ void linux_load(char *cmdline, int boot_drive) {
|
|||||||
"mov eax, cr0\n\t"
|
"mov eax, cr0\n\t"
|
||||||
"and al, 0xfe\n\t"
|
"and al, 0xfe\n\t"
|
||||||
"mov cr0, eax\n\t"
|
"mov cr0, eax\n\t"
|
||||||
FARJMP16("0", "1f")
|
"jmp 0x0000:1f\n\t"
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"mov ds, bx\n\t"
|
"mov ds, bx\n\t"
|
||||||
"mov es, bx\n\t"
|
"mov es, bx\n\t"
|
||||||
@ -164,7 +163,8 @@ void linux_load(char *cmdline, int boot_drive) {
|
|||||||
|
|
||||||
"push cx\n\t"
|
"push cx\n\t"
|
||||||
"push 0\n\t"
|
"push 0\n\t"
|
||||||
"retf\n\t",
|
"retf\n\t"
|
||||||
|
:
|
||||||
: "b" (real_mode_code_seg), "c" (kernel_entry_seg)
|
: "b" (real_mode_code_seg), "c" (kernel_entry_seg)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <lib/term.h>
|
#include <lib/term.h>
|
||||||
#include <drivers/pic.h>
|
#include <drivers/pic.h>
|
||||||
#include <fs/file.h>
|
#include <fs/file.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
#include <mm/vmm64.h>
|
#include <mm/vmm64.h>
|
||||||
|
|
||||||
struct stivale_header {
|
struct stivale_header {
|
||||||
@ -266,10 +265,10 @@ __attribute__((noreturn)) void stivale_spinup(int bits, bool level5pg,
|
|||||||
if (bits == 64) {
|
if (bits == 64) {
|
||||||
if (level5pg) {
|
if (level5pg) {
|
||||||
// Enable CR4.LA57
|
// Enable CR4.LA57
|
||||||
ASM(
|
asm volatile (
|
||||||
"mov eax, cr4\n\t"
|
"mov eax, cr4\n\t"
|
||||||
"bts eax, 12\n\t"
|
"bts eax, 12\n\t"
|
||||||
"mov cr4, eax\n\t", :: "eax", "memory"
|
"mov cr4, eax\n\t" ::: "eax", "memory"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +303,7 @@ __attribute__((noreturn)) void stivale_spinup(int bits, bool level5pg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASM(
|
asm volatile (
|
||||||
"cli\n\t"
|
"cli\n\t"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
"mov cr3, eax\n\t"
|
"mov cr3, eax\n\t"
|
||||||
@ -318,7 +317,7 @@ __attribute__((noreturn)) void stivale_spinup(int bits, bool level5pg,
|
|||||||
"mov eax, cr0\n\t"
|
"mov eax, cr0\n\t"
|
||||||
"or eax, 1 << 31\n\t"
|
"or eax, 1 << 31\n\t"
|
||||||
"mov cr0, eax\n\t"
|
"mov cr0, eax\n\t"
|
||||||
FARJMP32("0x28", "1f")
|
"jmp 0x28:1f\n\t"
|
||||||
"1: .code64\n\t"
|
"1: .code64\n\t"
|
||||||
"mov ax, 0x30\n\t"
|
"mov ax, 0x30\n\t"
|
||||||
"mov ds, ax\n\t"
|
"mov ds, ax\n\t"
|
||||||
@ -349,13 +348,14 @@ __attribute__((noreturn)) void stivale_spinup(int bits, bool level5pg,
|
|||||||
"xor r15, r15\n\t"
|
"xor r15, r15\n\t"
|
||||||
|
|
||||||
"iretq\n\t"
|
"iretq\n\t"
|
||||||
".code32\n\t",
|
".code32\n\t"
|
||||||
|
:
|
||||||
: "a" (pagemap.top_level), "b" (&entry_point),
|
: "a" (pagemap.top_level), "b" (&entry_point),
|
||||||
"D" (stivale_struct), "S" (&stack)
|
"D" (stivale_struct), "S" (&stack)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
} else if (bits == 32) {
|
} else if (bits == 32) {
|
||||||
ASM(
|
asm volatile (
|
||||||
"cli\n\t"
|
"cli\n\t"
|
||||||
"cld\n\t"
|
"cld\n\t"
|
||||||
|
|
||||||
@ -376,7 +376,8 @@ __attribute__((noreturn)) void stivale_spinup(int bits, bool level5pg,
|
|||||||
"xor edi, edi\n\t"
|
"xor edi, edi\n\t"
|
||||||
"xor ebp, ebp\n\t"
|
"xor ebp, ebp\n\t"
|
||||||
|
|
||||||
"iret\n\t",
|
"iret\n\t"
|
||||||
|
:
|
||||||
: "b" (&entry_point), "D" (stivale_struct), "S" (&stack)
|
: "b" (&entry_point), "D" (stivale_struct), "S" (&stack)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <lib/term.h>
|
#include <lib/term.h>
|
||||||
#include <drivers/pic.h>
|
#include <drivers/pic.h>
|
||||||
#include <fs/file.h>
|
#include <fs/file.h>
|
||||||
#include <lib/asm.h>
|
|
||||||
|
|
||||||
struct stivale2_tag {
|
struct stivale2_tag {
|
||||||
uint64_t identifier;
|
uint64_t identifier;
|
||||||
|
Loading…
Reference in New Issue
Block a user