LINEAR_ADRESS causes error in nasm

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
hex
Posts: 5
Joined: Sat Nov 01, 2008 5:18 am
Location: Erfurt - Germany

LINEAR_ADRESS causes error in nasm

Post by hex »

Hello!

I am sorry, if I ask an obvious question here, but I tried searching the forum with no result.

I had some trouble getting Interrupts to work, so I looked into the wiki-section about getting this to work.
When I try to bring the asm-example from http://wiki.osdev.org/I_Cant_Get_Interrupts_Working to compile with nasm, I get an error about the LINEAR_ADRESS thing: "error: comma expected after operand 1".
It refers to this line: "dd LINEAR_ADDRESS(idt)"
Why a comma after this operand and where? And what after it?

Can anybody help me and explain to me, what is wrong there?

Thanks!
Who is General Error - and why is he reading my harddisk?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: LINEAR_ADRESS causes error in nasm

Post by Combuster »

The idea is that you fill that macro in for yourself :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
hex
Posts: 5
Joined: Sat Nov 01, 2008 5:18 am
Location: Erfurt - Germany

Re: LINEAR_ADRESS causes error in nasm

Post by hex »

Aaah!
Okay :D

Then another question comes to my mind: How?
I'am sorry - I'm quite new to this and now I am confused, how to get a linear address?
Who is General Error - and why is he reading my harddisk?
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: LINEAR_ADRESS causes error in nasm

Post by CodeCat »

It depends on how your kernel is linked. If it's supposed to run at 0xC0100000 and the bootloader loads it at 0x00100000, then the macro just has to subtract 0xC0000000 from a pointer to get its physical (linear) address.
hex
Posts: 5
Joined: Sat Nov 01, 2008 5:18 am
Location: Erfurt - Germany

Re: LINEAR_ADRESS causes error in nasm

Post by hex »

thx :)
Who is General Error - and why is he reading my harddisk?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: LINEAR_ADRESS causes error in nasm

Post by Combuster »

The linear address is the address after segmentation (before is virtual address), but before page translation (which turns it into a physical address). So if your kernel is at 0xC0000000, then the linear address is somewhere in 0xC0000000. If you're in real mode, then you'll need to add the segment offset, i.e. if your code runs at 0x1000:0x0000, then the linear address is idt_offset + 16 * segment, or 0x10000 + idt

@Codecat: time to fix your GDT and IDT code :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
hex
Posts: 5
Joined: Sat Nov 01, 2008 5:18 am
Location: Erfurt - Germany

Re: LINEAR_ADRESS causes error in nasm

Post by hex »

I currently have not Paging ;)

By the way: I have no clue, where exactly Grub puts my Kernel in Memory :oops:
I think this information may be obtained using the multiboot-structure?
Who is General Error - and why is he reading my harddisk?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: LINEAR_ADRESS causes error in nasm

Post by Combuster »

Grub puts you exactly where you told it to.

Assuming that you have an ELF kernel - look at your linker script and see what its puts into the headers for GRUB to find
Amusingly enough, it makes the same changes in the binary, meaning that if you grab the address of something you already have its true address. But having met the required knowledge you should've known that :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
hex
Posts: 5
Joined: Sat Nov 01, 2008 5:18 am
Location: Erfurt - Germany

Re: LINEAR_ADRESS causes error in nasm

Post by hex »

Ah :)
You know - I am really unsure about, what I got right and what I got wrong. But with this, I was right in the first place and then considered it as wrong. Dammit.
Who is General Error - and why is he reading my harddisk?
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: LINEAR_ADRESS causes error in nasm

Post by CodeCat »

Combuster wrote:@Codecat: time to fix your GDT and IDT code :wink:
Oops, I mixed up linear and physical addresses in that post.
Post Reply