51 lines
1.6 KiB
ArmAsm
51 lines
1.6 KiB
ArmAsm
; Copyright 2022 Mattia Giambirtone & Contributors
|
|
;
|
|
; Licensed under the Apache License, Version 2.0 (the "License");
|
|
; you may not use this file except in compliance with the License.
|
|
; You may obtain a copy of the License at
|
|
;
|
|
; http://www.apache.org/licenses/LICENSE-2.0
|
|
;
|
|
; Unless required by applicable law or agreed to in writing, software
|
|
; distributed under the License is distributed on an "AS IS" BASIS,
|
|
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
; See the License for the specific language governing permissions and
|
|
; limitations under the License.
|
|
|
|
; Definition of our Global Descriptor Table
|
|
|
|
gdt_start: ; The labels are important to compute the size of the GDT: don't touch them!
|
|
; The GDT starts with 8 null bytes
|
|
dd 0x0 ; 4 byte
|
|
dd 0x0 ; 4 byte
|
|
|
|
; GDT for code segment. base = 0x00000000, length = 0xfffff
|
|
; for flags, refer to os-dev.pdf document, page 36
|
|
gdt_code:
|
|
dw 0xffff ; segment length, bits 0-15
|
|
dw 0x0 ; segment base, bits 0-15
|
|
db 0x0 ; segment base, bits 16-23
|
|
db 10011010b ; flags (8 bits)
|
|
db 11001111b ; flags (4 bits) + segment length, bits 16-19
|
|
db 0x0 ; segment base, bits 24-31
|
|
|
|
; GDT for data segment. base and length identical to code segment
|
|
; some flags changed, again, refer to os-dev.pdf
|
|
gdt_data:
|
|
dw 0xffff
|
|
dw 0x0
|
|
db 0x0
|
|
db 10010010b
|
|
db 11001111b
|
|
db 0x0
|
|
|
|
gdt_end:
|
|
|
|
; GDT descriptor
|
|
gdt_descriptor:
|
|
dw gdt_end - gdt_start - 1 ; size (16 bit), always one less of its true size
|
|
dd gdt_start ; address (32 bit)
|
|
|
|
; define some constants for later use
|
|
CODE_SEG equ gdt_code - gdt_start
|
|
DATA_SEG equ gdt_data - gdt_start |