
New features: - support of kernel tasks in 64bit mode - support of LwIP in 64bit mode Missing features in 64bit mode - user-level support - APIC support => SMP support To create a 64bit version of the MetalSVM kernel, the compiler flags “-m64 -mno-red-zone” and the assembler flags “-felf64” has to be used. Please use qemu-system-x86_64 as test platform. Notice, metalsvm.elf is a 32bit ELF file. However, it contains (beside the startup code) only 64bit code. This is required because GRUB doesn’t boot 64bit ELF kernels. Therefore, for disassembling via objdump the flag “-M x86-64” has to be used.
79 lines
1.8 KiB
NASM
79 lines
1.8 KiB
NASM
;
|
|
; Written by the Chair for Operating Systems, RWTH Aachen University
|
|
;
|
|
; NO Copyright (C) 2010-2012, Stefan Lankes
|
|
; consider these trivial functions to be public domain.
|
|
;
|
|
; These functions are distributed on an "AS IS" BASIS,
|
|
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
;
|
|
|
|
[BITS 64]
|
|
SECTION .text
|
|
global strcpy
|
|
strcpy:
|
|
push rdi
|
|
|
|
L1:
|
|
lodsb
|
|
stosb
|
|
test al, al
|
|
jne L1
|
|
|
|
pop rax
|
|
ret
|
|
|
|
global strncpy
|
|
strncpy:
|
|
push rdi
|
|
mov rcx, rdx
|
|
|
|
L2:
|
|
dec rcx
|
|
js L3
|
|
lodsb
|
|
stosb
|
|
test al, al
|
|
jne L1
|
|
rep
|
|
stosb
|
|
|
|
L3:
|
|
pop rax
|
|
ret
|
|
|
|
%if 0
|
|
; The following function is derived from JamesM's kernel development tutorials
|
|
; (http://www.jamesmolloy.co.uk/tutorial_html/)
|
|
global copy_page_physical
|
|
copy_page_physical:
|
|
push esi ; According to __cdecl, we must preserve the contents of ESI
|
|
push edi ; and EDI.
|
|
pushf ; push EFLAGS, so we can pop it and reenable interrupts
|
|
; later, if they were enabled anyway.
|
|
cli ; Disable interrupts, so we aren't interrupted.
|
|
; Load these in BEFORE we disable paging!
|
|
|
|
mov edi, [esp+12+4] ; Destination address
|
|
mov esi, [esp+12+8] ; Source address
|
|
|
|
mov edx, cr0 ; Get the control register...
|
|
and edx, 0x7fffffff ; and...
|
|
mov cr0, edx ; Disable paging.
|
|
|
|
cld
|
|
mov ecx, 0x400 ; 1024*4bytes = 4096 bytes = page size
|
|
rep movsd ; copy page
|
|
|
|
mov edx, cr0 ; Get the control register again
|
|
or edx, 0x80000000 ; and...
|
|
mov cr0, edx ; Enable paging.
|
|
|
|
popf ; Pop EFLAGS back.
|
|
pop edi ; Get the original value of EDI
|
|
pop esi ; and ESI back.
|
|
ret
|
|
|
|
%endif
|
|
|
|
SECTION .note.GNU-stack noalloc noexec nowrite progbits
|