From: Amelia Coutard Date: Fri, 22 Dec 2023 11:12:05 +0000 (+0100) Subject: Changement de styles de commentaires pour les fichiers en assembleur X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=310aa826f8051221e03749f62b8d6430f4437e50;p=voyage-au-centre-des-fichiers.git Changement de styles de commentaires pour les fichiers en assembleur --- diff --git a/kernel/src/boot.S b/kernel/src/boot.S index 8d6c3c2..3dfa906 100644 --- a/kernel/src/boot.S +++ b/kernel/src/boot.S @@ -1,15 +1,15 @@ -# Copyright 2023 Amélia COUTARD. -# -# This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with this program. If -# not, see . +// Copyright 2023 Amélia COUTARD. +// +// This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . #include "lib/multiboot2.hpp" @@ -47,43 +47,43 @@ GDT: .set GDT.NULL, . - GDT .quad 0 .set GDT.KERNEL_DATA, . - GDT - .short 0xFFFF # Limit[0:16] - .short 0x0000 # Base[0:16] - .byte 0x00 # Base[16:24] - .byte 0b10010010 # Access: present | writeable | ring0 - .byte 0b11001111 # Flags: page_gran | d_b, Limit[16:20] - .byte 0x00 # Base[24:32] + .short 0xFFFF // Limit[0:16] + .short 0x0000 // Base[0:16] + .byte 0x00 // Base[16:24] + .byte 0b10010010 // Access: present | writeable | ring0 + .byte 0b11001111 // Flags: page_gran | d_b, Limit[16:20] + .byte 0x00 // Base[24:32] .set GDT.KERNEL_CODE, . - GDT - .short 0xFFFF # Limit[0:16] - .short 0x0000 # Base[0:16] - .byte 0x00 # Base[16:24] - .byte 0b10011010 # Access: present | readable | ring0 - .byte 0b10101111 # Flags: page_gran | long_mode, Limit[16:20] - .byte 0x00 # Base[24:32] + .short 0xFFFF // Limit[0:16] + .short 0x0000 // Base[0:16] + .byte 0x00 // Base[16:24] + .byte 0b10011010 // Access: present | readable | ring0 + .byte 0b10101111 // Flags: page_gran | long_mode, Limit[16:20] + .byte 0x00 // Base[24:32] .set GDT.USER_DATA, . - GDT - .short 0xFFFF # Limit[0:16] - .short 0x0000 # Base[0:16] - .byte 0x00 # Base[16:24] - .byte 0b11110010 # Access: present | writeable | ring3 - .byte 0b11001111 # Flags: page_gran | d_b, Limit[16:20] - .byte 0x00 # Base[24:32] + .short 0xFFFF // Limit[0:16] + .short 0x0000 // Base[0:16] + .byte 0x00 // Base[16:24] + .byte 0b11110010 // Access: present | writeable | ring3 + .byte 0b11001111 // Flags: page_gran | d_b, Limit[16:20] + .byte 0x00 // Base[24:32] .set GDT.USER_CODE, . - GDT - .short 0xFFFF # Limit[0:16] - .short 0x0000 # Base[0:16] - .byte 0x00 # Base[16:24] - .byte 0b11111010 # Access: present | readable | ring3 - .byte 0b10101111 # Flags: page_gran | long_mode, Limit[16:20] - .byte 0x00 # Base[24:32] + .short 0xFFFF // Limit[0:16] + .short 0x0000 // Base[0:16] + .byte 0x00 // Base[16:24] + .byte 0b11111010 // Access: present | readable | ring3 + .byte 0b10101111 // Flags: page_gran | long_mode, Limit[16:20] + .byte 0x00 // Base[24:32] .globl GDT.TSS .set GDT.TSS, . - GDT - .short (TSS_SIZE - 1) & 0xFFFF # Limit[0:16] - .short 0x0000 # Base[0:16] # TSS & 0xFFFF - .byte 0x00 # Base[16:24] # (TSS >> 16) & 0xFF - .byte 0b10001001 # Access - .byte (0b0000 << 4) | (((TSS_SIZE - 1) >> 16) & 0xF) # Flags, Limit[16:20] - .byte 0x00 # Base[24:32] # (TSS >> 24) & 0xFF - .int 0 # Base[32:63] # (TSS >> 32) & 0xFFFFFFFF - .int 0 # reserved + .short (TSS_SIZE - 1) & 0xFFFF // Limit[0:16] + .short 0x0000 // Base[0:16] // TSS & 0xFFFF + .byte 0x00 // Base[16:24] // (TSS >> 16) & 0xFF + .byte 0b10001001 // Access + .byte (0b0000 << 4) | (((TSS_SIZE - 1) >> 16) & 0xF) // Flags, Limit[16:20] + .byte 0x00 // Base[24:32] // (TSS >> 24) & 0xFF + .int 0 // Base[32:63] // (TSS >> 32) & 0xFFFFFFFF + .int 0 // reserved GDT.PTR: .short . - GDT - 1 .quad GDT - KERNEL_VMA @@ -116,10 +116,10 @@ old_PML4T: PML4T: .quad PDPT_low - KERNEL_VMA + 3 .skip 0x1000 - 16 .quad PDPT_high - KERNEL_VMA + 3 -PDPT_low: .quad 0x83 # 1GiB page | R/W | P +PDPT_low: .quad 0x83 // 1GiB page | R/W | P .skip 0x1000 - 8 PDPT_high: .skip 0x1000 - 16 - .quad 0x183 # G | 1GiB page | R/W | P + .quad 0x183 // G | 1GiB page | R/W | P .quad 0x183 + 1024 * 1024 * 1024 .section .bss @@ -127,11 +127,11 @@ PDPT_high: .skip 0x1000 - 16 phys_mem_map: .skip 0x1000 * 128 - 8 .align 16 stack_bottom: -.skip 4096 * 4 # 16KiB +.skip 4096 * 4 // 16KiB .globl stack_top stack_top: interrupt_stack_bottom: -.skip 4096 * 4 # 16KiB +.skip 4096 * 4 // 16KiB .globl interrupt_stack_top interrupt_stack_top: @@ -153,22 +153,22 @@ check_cpuid_support: push %ecx popfl xor %ecx, %eax - jz halt # No cpuid. + jz halt // No cpuid. ret check_long_mode_support: mov $0x80000000, %eax cpuid cmp $0x80000001, %eax - jb halt # No ability to check for long mode. + jb halt // No ability to check for long mode. mov $0x80000001, %eax cpuid - # Long mode: + // Long mode: test $1 << 29, %edx - jz halt # No long mode. - # 1GiB pages: + jz halt // No long mode. + // 1GiB pages: test $1 << 26, %edx - jz halt # No 1GiB pages. + jz halt // No 1GiB pages. ret .globl _start @@ -176,43 +176,43 @@ _start: cli mov $stack_top - KERNEL_VMA, %esp - # Save multiboot info: - push $0 # / - push %eax # \ magic - push $0 # / - push %ebx # \ info structure + // Save multiboot info: + push $0 // / + push %eax // \ magic + push $0 // / + push %ebx // \ info structure call check_cpuid_support call check_long_mode_support - # Disable 32-bit paging: + // Disable 32-bit paging: mov %cr0, %eax and $~(1 << 31), %eax mov %eax, %cr0 - # Setup 64-bit paging: + // Setup 64-bit paging: mov $PML4T - KERNEL_VMA, %eax - or $0x10, %eax # NO CACHE + or $0x10, %eax // NO CACHE mov %eax, %cr3 - # Enable PAE paging, and global pages: + // Enable PAE paging, and global pages: mov %cr4, %eax - or $1 << 5, %eax # PAE - or $1 << 7, %eax # PGE + or $1 << 5, %eax // PAE + or $1 << 7, %eax // PGE mov %eax, %cr4 - # Set long mode bit (and NXE): + // Set long mode bit (and NXE): mov $0xC0000080, %ecx rdmsr or $1 << 8, %eax or $1 << 11, %eax wrmsr - # Enable paging: + // Enable paging: mov %cr0, %eax or $1 << 31, %eax mov %eax, %cr0 - # Jump to 64 bits: + // Jump to 64 bits: lgdt GDT.PTR - KERNEL_VMA jmp $GDT.KERNEL_CODE, $.trampoline @@ -221,19 +221,19 @@ _start: mov %esp, %esp movq $GDT, GDT.PTR + 2 - lgdt GDT.PTR # Reload GDT in higher half. + lgdt GDT.PTR // Reload GDT in higher half. pushq $GDT.KERNEL_CODE movabsq $.trampoline2, %rax pushq %rax - lretq # Jump to new GDT. + lretq // Jump to new GDT. .trampoline2: - mov $GDT.KERNEL_DATA, %ax # Set the A-register to the data descriptor. - mov %ax, %ds # Set the data segment to the A-register. - mov %ax, %es # Set the extra segment to the A-register. - mov %ax, %fs # Set the F-segment to the A-register. - mov %ax, %gs # Set the G-segment to the A-register. - mov %ax, %ss # Set the stack segment to the A-register. + mov $GDT.KERNEL_DATA, %ax // Set the A-register to the data descriptor. + mov %ax, %ds // Set the data segment to the A-register. + mov %ax, %es // Set the extra segment to the A-register. + mov %ax, %fs // Set the F-segment to the A-register. + mov %ax, %gs // Set the G-segment to the A-register. + mov %ax, %ss // Set the stack segment to the A-register. mov $.higher_half, %rax jmp *%rax @@ -241,11 +241,11 @@ _start: .section .text .higher_half: mov %esp, %esp - pop %r14 # Multiboot info address. - pop %r15 # Multiboot magic. + pop %r14 // Multiboot info address. + pop %r15 // Multiboot magic. mov $stack_top, %rsp - # map physical memory in kernel: + // map physical memory in kernel: mov $phys_mem_map - KERNEL_VMA + 3, %rbx mov $PML4T + 256 * 8, %rdi mov $128, %rcx @@ -254,7 +254,7 @@ _start: add $8, %rdi loop 1b - mov $0x183, %rbx # G | R/W | P + mov $0x183, %rbx // G | R/W | P mov $phys_mem_map, %rdi mov $128 * 512, %rcx 1: mov %rbx, (%rdi) @@ -262,12 +262,12 @@ _start: add $8, %rdi loop 1b - # Setup new page tables: + // Setup new page tables: mov $PML4T - KERNEL_VMA, %rax - or $0x10, %eax # NO CACHE + or $0x10, %eax // NO CACHE mov %rax, %cr3 - # Setup TSS address in GDT + // Setup TSS address in GDT movabs $TSS, %rax shr $0, %rax and $0xFFFF, %rax @@ -288,9 +288,9 @@ _start: mov %r14, %rsi mov %r15, %rdi - call kmain # With the two arguments popped earlier. + call kmain // With the two arguments popped earlier. - # kmain should never terminate, but, oh well. + // kmain should never terminate, but, oh well. call _fini cli diff --git a/kernel/src/interrupts.S b/kernel/src/interrupts.S index 085ca7e..c416176 100644 --- a/kernel/src/interrupts.S +++ b/kernel/src/interrupts.S @@ -1,15 +1,15 @@ -# Copyright 2023 Amélia COUTARD. -# -# This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with this program. If -# not, see . +// Copyright 2023 Amélia COUTARD. +// +// This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . #define PUSH_REGS \ pushq %rax; \ diff --git a/kernel/src/lib/crti.S b/kernel/src/lib/crti.S index b467d0c..4353c68 100644 --- a/kernel/src/lib/crti.S +++ b/kernel/src/lib/crti.S @@ -1,15 +1,15 @@ -# Copyright 2023 Amélia COUTARD. -# -# This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with this program. If -# not, see . +// Copyright 2023 Amélia COUTARD. +// +// This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . .section .init .global _init diff --git a/kernel/src/lib/crtn.S b/kernel/src/lib/crtn.S index e93bbe4..c202ca1 100644 --- a/kernel/src/lib/crtn.S +++ b/kernel/src/lib/crtn.S @@ -1,15 +1,15 @@ -# Copyright 2023 Amélia COUTARD. -# -# This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with this program. If -# not, see . +// Copyright 2023 Amélia COUTARD. +// +// This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . .section .init /* gcc will nicely put the contents of crtend.o's .init section here. */ diff --git a/kernel/src/ring3.S b/kernel/src/ring3.S index c73e9c4..6b5a690 100644 --- a/kernel/src/ring3.S +++ b/kernel/src/ring3.S @@ -1,15 +1,15 @@ -# Copyright 2023 Amélia COUTARD. -# -# This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with this program. If -# not, see . +// Copyright 2023 Amélia COUTARD. +// +// This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . .section .text @@ -20,7 +20,7 @@ ftl_to_userspace: mov %ax, %es mov %ax, %fs mov %ax, %gs - # iretq handles cs and ss + // iretq handles cs and ss pushq $(8 * 3) | 3 pushq %rsi @@ -37,27 +37,27 @@ load_tss: .globl syscall_64bit_handler syscall_64bit_handler: - # Save all registers: + // Save all registers: .irp reg,rax,rbx,rcx,rdx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15 mov %\reg, save_reg_tmp_\reg .endr - # Setup stack: + // Setup stack: mov $stack_top, %rsp - # Get process data location: + // Get process data location: mov current_pid, %rdi call get_process - # Really save all regs: + // Really save all regs: .irp reg,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 - mov save_regs_tmp + \reg * 8, %rbx # Get %r\reg - mov %rbx, 8 + \reg * 8(%rax) # And store it. + mov save_regs_tmp + \reg * 8, %rbx // Get %r\reg + mov %rbx, 8 + \reg * 8(%rax) // And store it. .endr - mov save_reg_tmp_rcx, %rbx # Save the rip also. + mov save_reg_tmp_rcx, %rbx // Save the rip also. mov %rbx, 0x88(%rax) - # Get ready for syscall: + // Get ready for syscall: mov save_reg_tmp_rdi, %rdi mov save_reg_tmp_rsi, %rsi mov save_reg_tmp_rdx, %rdx - mov save_reg_tmp_r10, %rcx # Syscall ABI -> C ABI + mov save_reg_tmp_r10, %rcx // Syscall ABI -> C ABI mov save_reg_tmp_r8, %r8 mov save_reg_tmp_r9, %r9 mov save_reg_tmp_rax, %rax @@ -65,23 +65,23 @@ syscall_64bit_handler: jae incorrect_syscall callq *syscalls_call_table(, %rax, 8) syscall_end: - mov %rax, %rbp # Save the return - # Get process data location: + mov %rax, %rbp // Save the return + // Get process data location: mov current_pid, %rdi call get_process - # Restore all regs: + // Restore all regs: .irp reg,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 - mov 8 + \reg * 8(%rax), %rbx # Get %r\reg - mov %rbx, save_regs_tmp + \reg * 8 # And restore it. + mov 8 + \reg * 8(%rax), %rbx // Get %r\reg + mov %rbx, save_regs_tmp + \reg * 8 // And restore it. .endr - mov %rbp, save_reg_tmp_rax # Restore the return register as well. - mov 0x88(%rax), %rbx # Save the rip in place of rcx, because this is sysret. + mov %rbp, save_reg_tmp_rax // Restore the return register as well. + mov 0x88(%rax), %rbx // Save the rip in place of rcx, because this is sysret. mov %rbx, save_reg_tmp_rcx - # Really restore all regs: + // Really restore all regs: .irp reg,rax,rbx,rcx,rdx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15 mov save_reg_tmp_\reg, %\reg .endr - # Current process registers have now all been restored. + // Current process registers have now all been restored. sysretq incorrect_syscall: call syscall_rax_error_handler @@ -95,7 +95,7 @@ syscalls_call_table: .quad syscall_write .quad syscall_close syscalls_call_table_end: -.set syscall_n, (syscalls_call_table_end - syscalls_call_table) >> 3 # Because / 8 *doesn't work* ! +.set syscall_n, (syscalls_call_table_end - syscalls_call_table) >> 3 // Because / 8 *doesn't work* ! .globl syscall_n .section .data diff --git a/test_module/src/test.S b/test_module/src/test.S index 863f1b7..c5919fa 100644 --- a/test_module/src/test.S +++ b/test_module/src/test.S @@ -1,15 +1,15 @@ -# Copyright 2023 Amélia COUTARD. -# -# This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with this program. If -# not, see . +// Copyright 2023 Amélia COUTARD. +// +// This file from the program "voyage au centre des fichiers" is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with this program. If +// not, see . .section .text