clang-format shouldn't choke on assembly files.

This commit is contained in:
Morten Delenk 2017-04-29 11:35:43 +00:00
parent e63320f97c
commit d994c70468

View file

@ -1,89 +1,181 @@
#define ASM_FILE 1 #define ASM_FILE 1
#include <config.h> #include <config.h>
#include <multiboot.h> #include <multiboot.h>
.code32.section.text.boot.global _start _start : jmp _start2.align MULTIBOOT_HEADER_ALIGN .code32
.int MULTIBOOT_HEADER_MAGIC .section .text.boot
.global _start
_start:
jmp _start2
.align MULTIBOOT_HEADER_ALIGN
.int MULTIBOOT_HEADER_MAGIC
#ifndef ENABLE_FRAMEBUFFER #ifndef ENABLE_FRAMEBUFFER
.int 0x0.int - .int 0x0
(MULTIBOOT_HEADER_MAGIC) .int -(MULTIBOOT_HEADER_MAGIC)
#else #else
.int 0x7.int - .int 0x7
(MULTIBOOT_HEADER_MAGIC + 0x7).int 0, .int -(MULTIBOOT_HEADER_MAGIC+0x7)
0, 0, 0, 0.int 0.int 1024, 768, .int 0,0,0,0,0
24 .int 0
.int 1024, 768, 24
#endif #endif
.align MULTIBOOT_HEADER_ALIGN.extern start _start2 : mov $mb_ptr, .align MULTIBOOT_HEADER_ALIGN
% edi stosl mov % ebx, .extern start
% eax stosl // Store mb stuff _start2:
mov $mb_ptr, %edi
stosl
mov %ebx, %eax
stosl // Store mb stuff
#ifdef ENABLE_FPU #ifdef ENABLE_FPU
finit // Enable FPU finit //Enable FPU
#endif #endif
#ifdef ENABLE_SSE #ifdef ENABLE_SSE
// No check for SSE as SSE2+ is always present on x86_64 //No check for SSE as SSE2+ is always present on x86_64
mov mov %cr0, %eax
% cr0, and $0xFFFB, %ax
% eax and $0xFFFB, % ax or $0x2, % ax mov % eax, % cr0 mov % cr4, % eax or $3 << 9, % ax mov % eax, or $0x2, %ax
% cr4 mov %eax, %cr0
mov %cr4, %eax
or $3<<9, %ax
mov %eax, %cr4
#endif #endif
mov $kernel_stack, mov $kernel_stack, %esp
% esp mov $0x80000001, % eax cpuid and $0x20000000, mov $0x80000001, %eax
% edx // Check if long mode is supported cpuid
jz x86_64_err jmp x86_64_OK x86_64_err : cli hlt jmp x86_64_err x86_64_OK : and $0x20000000, %edx //Check if long mode is supported
// Assume PAE is supported jz x86_64_err
mov $pmfill, jmp x86_64_OK
% esi mov $pagemapL4, % edi movsl movsl mov $pagedirPT, % edi mov $0x87, % eax xor % ebx, % ebx mov $1023, x86_64_err:
% ecx.ptloop : stosl xchg % eax, % ebx stosl xchg % eax, % ebx add $0x40000000, cli
% eax jnc.ptloop_nc inc % ebx.ptloop_nc : loop.ptloop mov % cr4, % eax or $0x20, % eax mov % eax, hlt
% cr4 // Activate PAE jmp x86_64_err
mov $0xC0000080, x86_64_OK:
% ecx rdmsr or $0x00000100, //Assume PAE is supported
% eax wrmsr // Activate x86_64 mov $pmfill, %esi
mov $pagemapL4, mov $pagemapL4, %edi
% eax mov % eax, movsl
% cr3 // Load page table movsl
mov mov $pagedirPT, %edi
% cr0, mov $0x87, %eax
% eax bswap % eax or $0x80, % eax bswap % eax mov % eax, xor %ebx, %ebx
% cr0 // Activate paging mov $1023, %ecx
lgdt gdtr mov $0x30, .ptloop:
% ax ljmp $0x28, stosl
$_start3 // Jump into long mode xchg %eax, %ebx
.code64 _start3 : mov stosl
% ax, xchg %eax, %ebx
% ds mov % ax, % es mov % ax, % fs mov % ax, % gs mov % ax, add $0x40000000, %eax
% ss // Load 64-bit data jnc .ptloop_nc
mov $mb_ptr, inc %ebx
% rsi lodsl mov % rax, % rdi lodsl mov % rax, .ptloop_nc:
% loop .ptloop
rsi call start _stop : cli hlt jmp _stop mov %cr4, %eax
or $0x20, %eax
mov %eax, %cr4 //Activate PAE
mov $0xC0000080, %ecx
rdmsr
or $0x00000100, %eax
wrmsr //Activate x86_64
mov $pagemapL4, %eax
mov %eax, %cr3 //Load page table
mov %cr0, %eax
bswap %eax
or $0x80, %eax
bswap %eax
mov %eax, %cr0 //Activate paging
lgdt gdtr
mov $0x30, %ax
ljmp $0x28, $_start3 //Jump into long mode
.code64
_start3:
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
mov %ax, %ss //Load 64-bit data
mov $mb_ptr, %rsi
lodsl
mov %rax, %rdi
lodsl
mov %rax, %rsi
call start
_stop:
cli
hlt
jmp _stop
.section.data gdtr :.word 9 *
8.int gdt gdt : .section .data
.quad 0 // NULL gdtr:
// 32-bit kernel code .word 9 * 8
.word 0xFFFF.word 0x0000.byte 0x00.byte 0x9A.byte .int gdt
0xCF.byte 0x00 gdt:
// 32-bit kernel code .quad 0 //NULL
.word 0xFFFF.word 0x0000.byte 0x00.byte 0x92.byte //32-bit kernel code
0xCF.byte 00 .word 0xFFFF
// 32-bit user code .word 0x0000
.word 0xFFFF.word 0x0000.byte 0x00.byte 0xFA.byte .byte 0x00
0xCF.byte 0x00 .byte 0x9A
// 32-bit user data .byte 0xCF
.word 0xFFFF.word 0x0000.byte 0x00.byte 0xF2.byte .byte 0x00
0xCF.byte 00 //32-bit kernel code
// 64-bit kernel code .word 0xFFFF
.word 0xFFFF.word 0x0000.byte 0x00.byte 0x9B.byte .word 0x0000
0xAF.byte 0x00 .byte 0x00
// 64-bit kernel code .byte 0x92
.word 0xFFFF.word 0x0000.byte 0x00.byte 0x93.byte .byte 0xCF
0xCF.byte 00 .byte 00
// 64-bit user code //32-bit user code
.word 0xFFFF.word 0x0000.byte 0x00.byte 0xFB.byte .word 0xFFFF
0xAF.byte 0x00 .word 0x0000
// 64-bit user data .byte 0x00
.word 0xFFFF.word 0x0000.byte 0x00.byte 0xF3.byte 0xCF.byte 00 pmfill :.int pagedirPT .byte 0xFA
+ .byte 0xCF
0x7.int 0.section.bss mb_ptr :.space 16384 kernel_stack :.align 4096 pagemapL4 :.space 4096 pagedirPT : .byte 0x00
.space 4096 //32-bit user data
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0xF2
.byte 0xCF
.byte 00
//64-bit kernel code
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x9B
.byte 0xAF
.byte 0x00
//64-bit kernel code
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0x93
.byte 0xCF
.byte 00
//64-bit user code
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0xFB
.byte 0xAF
.byte 0x00
//64-bit user data
.word 0xFFFF
.word 0x0000
.byte 0x00
.byte 0xF3
.byte 0xCF
.byte 00
pmfill:
.int pagedirPT + 0x7
.int 0
.section .bss
mb_ptr:
.space 16384
kernel_stack:
.align 4096
pagemapL4:
.space 4096
pagedirPT:
.space 4096