Code: Select all
lib/entry.o: In function `seta20p2':
(.text+0x2c): relocation truncated to fit: R_386_16 against `.text'
lib/entry.o: In function `seta20p2':
(.text+0x39): relocation truncated to fit: R_386_16 against `.text'
collect2: error: ld returned 1 exit status
Code: Select all
#include "mmu.h"
.align 4
.text
.global multiboot_header
multiboot_header:
#define magic 0x1badb002
#define flags 0
.long magic
.long flags
.long -(magic+flags)
.global _start
_start:
# start in Real Mode
.code16
# Disable interrupts for obvious reasons
cli
# Zero out the data segment and stack segment in preparation
# for a new GDT that will redefine those segments for protected
# mode
xorw %ax, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
# Set address line 20 high so we can access 1MB and above
seta20p1:
inb $0x64,%al # Wait for not busy
testb $0x2,%al
jnz seta20p1
movb $0xd1,%al # 0xd1 -> port 0x64
outb %al,$0x64
seta20p2:
inb $0x64,%al # Wait for not busy
testb $0x2,%al
jnz seta20p2
movb $0xdf,%al # 0xdf -> port 0x60
outb %al,$0x60
# Switch from real to protected mode, using a GDT that
# does an identity mapping
lgdt gdtdesc
movl %cr0, %eax
orl $CR0_PE, %eax
movl %eax, %cr0
# Enter protected mode with a long jump,
# which will reset cs and eip
ljmp $KERNEL_CS, $start32
.code32
start32:
movw $KERNEL_DS, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
xorw %ax, %ax
# set up stack
movl $(stack + 4096), %esp
call main
#The above should never return, but in case it does
spin:
jmp spin
.align 4
# bootstrap gdt that overlaps code and data and identity maps
gdt:
SEGMENT_NULL # GDT must begin with null descriptor
SEGMENT(SEG_X|SEG_R, 0, 0xffffffff) # code segment
SEGMENT(SEG_W, 0, 0xffffffff) # data segment
# GDT descriptor that is loaded onto gdtr
gdtdesc:
.word (gdtdesc-gdt-1) #sideof(gdt) - 1
.long gdt # pointer to gdt
.comm stack, 4096