Random Assortment of Questions

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.
Locked
brodeur235
Member
Member
Posts: 86
Joined: Sat Jun 06, 2009 11:55 am

Random Assortment of Questions

Post by brodeur235 »

I'm on a vacation in which I spend long periods of time in a cottage, on a beautiful beach on a lake in southern Canada. One problem: I sort of go into withdrawal when I don't have an internet connection for a while (and I don't there), so I began designing the memory management portion of my os while I was there on paper, writing down questions I came up with. I've answered some of them with quick research but the others I'll post here.

1. How can I read from and write to hard disk without BIOS interrupts in asm?

2. How can process code call a kernel function? (my os uses paging. So how can a process address a function outside of it's virtual memory?)

Warning: possibly a really stupid question.
3. I have no way of testing this on the machine that I have access to now (If I did, I wouldn't ask) but as it is I really want to know now. How can I compile a C file to flat binary using GCC? Does it automatically do this?

Brodeur235
madeofstaples
Member
Member
Posts: 204
Joined: Thu Apr 12, 2007 8:15 am
Location: Michigan

Re: Random Assortment of Questions

Post by madeofstaples »

brodeur235 wrote:1. How can I read from and write to hard disk without BIOS interrupts in asm?
It depends on the hardware. You are probably looking for ATA/ATAPI information.
brodeur235 wrote:2. How can process code call a kernel function? (my os uses paging. So how can a process address a function outside of it's virtual memory?)
See System Calls
brodeur235 wrote:3. I have no way of testing this on the machine that I have access to now (If I did, I wouldn't ask) but as it is I really want to know now. How can I compile a C file to flat binary using GCC? Does it automatically do this?
See Linker Scripts
Some people are offended by the verifiable truth; such people tend to remain blissfully unencumbered by fact.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
brodeur235
Member
Member
Posts: 86
Joined: Sat Jun 06, 2009 11:55 am

Re: Random Assortment of Questions

Post by brodeur235 »

My linker script isn't working. The 'ld' program doesn't recognize the -T option. Here are the sources:

begin.asm

Code: Select all

extern _main
call _main
kern.c

Code: Select all

void main()
{
	for(;;) { }
}
lkr.ld

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(begin)
bash script:

Code: Select all

echo Now compiling and linking your kernel . . .
echo 
echo Assembling "begin.asm" . . .
nasm begin.asm -f aout -o begin.o
echo Completed.
echo 
echo Compiling "kern.c" . . .
gcc kern.c -c -o kern.o
echo Completed.
echo 
echo Linking with script "lkr.ld" . . .
ld -o kernel.bin kern.o begin.o -T lkr.ld
echo Completed.
output:

Code: Select all

Now compiling and linking your kernel . . .

Assembling begin.asm . . .
Completed.

Compiling kern.c . . .
kern.c: In function 'main':
kern.c:2: warning: return type of 'main' is not 'int'
Completed.

Linking with script lkr.ld . . .
ld: unknown flag: -T
Completed.
What's the problem here?

Brodeur235
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: Random Assortment of Questions

Post by Combuster »

GCC Cross-Compiler

This whole thread also defeats the smart questions rule, and the first post is nothing but couldn't-google-questions. That makes three violations in two posts. :(
"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 ]
Locked