OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 8:09 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Questions about Higher Half Kernel
PostPosted: Sat Nov 04, 2017 7:37 pm 
Offline
Member
Member

Joined: Wed Nov 01, 2017 7:41 pm
Posts: 35
1. How I implement the code of http://wiki.osdev.org/Higher_Half_x86_Bare_Bones to the old one?

2. I have a error when compiling, all ASM methods seens wrong, but the old file works fine, what's happen?

Code:
kernel/loader.s: Assembler messages:
kernel/loader.s: Warning: end of file not at end of a line; newline inserted
kernel/loader.s:1: Error: no such instruction: `global _loader'
kernel/loader.s:2: Error: no such instruction: `extern kernel_main'
kernel/loader.s:4: Error: no such instruction: `modulealign equ 1<<0'
kernel/loader.s:5: Error: no such instruction: `meminfo equ 1<<1'
kernel/loader.s:6: Error: no such instruction: `flags equ MODULEALIGN|MEMINFO'
kernel/loader.s:7: Error: no such instruction: `magic equ 0x1B4DB002'
kernel/loader.s:8: Error: no such instruction: `checksum equ -(MAGIC+FLAGS)'
kernel/loader.s:10: Error: no such instruction: `kernel_virtual_base equ 0xC0000000'
kernel/loader.s:11: Error: no such instruction: `kernel_page_number equ (KERNEL_VIRTUAL_BASE>>22)'
kernel/loader.s:13: Error: no such instruction: `section .data'
kernel/loader.s:14: Error: no such instruction: `align 0x1000'
kernel/loader.s:16: Error: no such instruction: `dd 0x00000083'
kernel/loader.s:17: Error: no such instruction: `times (KERNEL_PAGE_NUMBER - 1)dd 0'
kernel/loader.s:18: Error: no such instruction: `dd 0x00000083'
kernel/loader.s:19: Error: no such instruction: `times (1024 - KERNEL_PAGE_NUMBER - 1)dd 0'
kernel/loader.s:21: Error: no such instruction: `section .text'
kernel/loader.s:22: Error: no such instruction: `align 4'
kernel/loader.s:24: Error: no such instruction: `dd MAGIC'
kernel/loader.s:25: Error: no such instruction: `dd FLAGS'
kernel/loader.s:26: Error: no such instruction: `dd CHECKSUM'
kernel/loader.s:28: Error: no such instruction: `stack_size equ 0x4000'
kernel/loader.s:29: Error: no such instruction: `loader equ (_loader - 0xC0000000'
kernel/loader.s:30: Error: no such instruction: `global loader'
kernel/loader.s:33: Error: too many memory references for `mov'
kernel/loader.s:34: Error: too many memory references for `mov'
kernel/loader.s:36: Error: too many memory references for `mov'
kernel/loader.s:37: Error: too many memory references for `or'
kernel/loader.s:38: Error: too many memory references for `mov'
kernel/loader.s:40: Error: too many memory references for `mov'
kernel/loader.s:41: Error: too many memory references for `or'
kernel/loader.s:42: Error: too many memory references for `mov'
kernel/loader.s:44: Error: invalid char '[' beginning operand 2 `[StartInHH]'
kernel/loader.s:48: Error: junk `[BootPageDirectory]' after expression
kernel/loader.s:48: Error: too many memory references for `mov'
kernel/loader.s:49: Error: no such instruction: `invpg [0]'
kernel/loader.s:50: Error: too many memory references for `mov'
kernel/loader.s:57: Error: no such instruction: `section .bss'
kernel/loader.s:58: Error: no such instruction: `align 32'
kernel/loader.s:60: Error: no such instruction: `resb STACK_SIZE'



3. For the last, I need a direction to go, I don't know where I start but I'm learning using the "Diff metter" in wiki.

_________________
OS Development is awesome!

|AetherOS Project|


Top
 Profile  
 
 Post subject: Re: Questions about Higher Half Kernel
PostPosted: Sat Nov 04, 2017 7:38 pm 
Offline
Member
Member

Joined: Wed Nov 01, 2017 7:41 pm
Posts: 35
here's the code of loader.s

Code:
global _loader
extern kernel_main

MODULEALIGN equ 1<<0
MEMINFO    equ 1<<1
FLAGS      equ MODULEALIGN | MEMINFO
MAGIC      equ 0x1B4DB002
CHECKSUM   equ -(MAGIC+FLAGS)

KERNEL_VIRTUAL_BASE   equ 0xC0000000
KERNEL_PAGE_NUMBER   equ (KERNEL_VIRTUAL_BASE >> 22)

section .data
   align 0x1000
   BootPageDirectory:
      dd 0x00000083
      times (KERNEL_PAGE_NUMBER - 1) dd 0
      dd 0x00000083
      times (1024 - KERNEL_PAGE_NUMBER - 1) dd 0

section .text
   align 4
   MultiBootHeader:
      dd MAGIC
      dd FLAGS
      dd CHECKSUM
   
   STACK_SIZE   equ 0x4000
   loader equ (_loader - 0xC0000000
   global loader
   
_loader:
   mov ecx, (BootPageDirectory - KERNEL_VIRTUAL_BASE)
   mov cr3, ecx
   
   mov ecx, cr4
   or ecx, 0x00000010
   mov cr4, ecx
   
   mov ecx, cr0
   or ecx, 0x80000000
   mov cr0, ecx
   
   lea ecx, [StartInHH]
   jmp ecx
   
StartInHH:
   mov dword [BootPageDirectory], 0
   invpg [0]
   mov esp, stack+STACK_SIZE
   push eax
   push ebx
   
   call kernel_main
   hlt
   
section .bss
   align 32
   stack:
      resb STACK_SIZE

_________________
OS Development is awesome!

|AetherOS Project|


Top
 Profile  
 
 Post subject: Re: Questions about Higher Half Kernel
PostPosted: Sat Nov 04, 2017 7:39 pm 
Offline
Member
Member

Joined: Wed Nov 01, 2017 7:41 pm
Posts: 35
the old boot.s file:

Code:
.extern kernel_main
.global start

.set MB_MAGIC, 0x1BADB002
.set MB_FLAGS, (1 << 0) | (1 << 1)
.set MB_CHECKSUM, (0 - (MB_MAGIC + MB_FLAGS))

.section .multiboot
   .align 4
   .long MB_MAGIC
   .long MB_FLAGS
   .long MB_CHECKSUM

.section .bss
   .align 16
   stack_bottom:
      .skip 4096
   stack_top:

.section .text
   start:
      mov $stack_top, %esp
      call kernel_main

      hang:
         cli
         hlt
         jmp hang

_________________
OS Development is awesome!

|AetherOS Project|


Top
 Profile  
 
 Post subject: Re: Questions about Higher Half Kernel
PostPosted: Sat Nov 04, 2017 8:49 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 670
Your old boot.s is written for GNU Assembler (you assemble with as). Your new loader.s is written in NASM assembly syntax so you will need to assemble it with the nasm assembler. If you want to use as to assemble your loader.s you'd have to convert the assembly code by hand.


Top
 Profile  
 
 Post subject: Re: Questions about Higher Half Kernel
PostPosted: Sun Nov 05, 2017 12:47 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
For further flavor on what @MichaelPetch said, see the wiki pages Assembly and Opcode syntax, as well as the pages specifically about GAS and NASM.

Basically, even when they are targeting the same ISA, each different assembler can have its own syntax for things such as opcode names, order of operands, representations of different numeric bases and string formats, labels, and directives such as equates and origins.

While most x86 assemblers more or less follow the opcode syntax and argument ordering defined by Intel, the Gnu Assembler, GAS, uses an older opcode format going back to the original as assembler for AT&T Unix. There are a number of differences in the AT&T syntax from the Intel syntax, most notably that while Intel defines the argument order as 'destination, source', the AT&T syntax follows what I assume was the PDP-11 syntax of 'source, destination', meaning that for the Intel syntax, "eax += 3" (that is, add 3 to EAX and save the result in EAX) would be

Code:
    add eax, DWORD 3


but for the AT&T/Gnu syntax, it would be:

Code:
    addl $3, %eax


Where the '$' prefix indicates an immediate operand, the '%' prefix means a register argument, and the 'l' suffix means a long (32-bit double-word) operation.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: Questions about Higher Half Kernel
PostPosted: Sun Nov 05, 2017 3:11 pm 
Offline
Member
Member

Joined: Wed Nov 01, 2017 7:41 pm
Posts: 35
Thanks m8s! I'm new at osdev so I have a lot of questions, van someone teach me the art of osdeving :3

_________________
OS Development is awesome!

|AetherOS Project|


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group