Page 1 of 3

Tutorial test request

Posted: Wed Apr 09, 2008 1:52 am
by JamesM
Hi,

I've created the code for a new tutorial - on entering usermode and syscalls. If anyone's got the time spare I'd really appreciate it if you could maybe (a) have a test of the image file/compile the code, see if it works (it should print "Hello, user world!"), and/or (b) have a look through the source and see if you understand it - more comments needed? less comments?

http://www.jamesmolloy.co.uk/downloads/user_mode.tar.gz

Thanks.

James

Posted: Wed Apr 09, 2008 2:15 am
by AJ
Hi James,

I have tested the image on Bochs 2.3.5, VPC and real hardware and it works as you say it should on all 3.

I have attempted a compile on Cygwin and get the error:

Code: Select all

cc1: error: unrecognised command line option "-fno-stack-protector"
On removing this option, it all compiles with warnings:

Code: Select all

interrupt.s:70: warning: signed byte value exceeds bounds
paging.c:157: warning: passing arg 2 of `register_interrupt_handler' from incompatible pointer type
syscall.c:56: warning: `return' with a value, in function returning void
...and none of it links. Before you start worrying too much, I have compiled with cygwin's default compiler (*old*) as I ususally use a custom toolchain and didn't think it was much use to you to compile with that. Although that probably explains the linking issue, the warnings above obviously still need looking at (not meant to sound patronising!).

Unfortunately, I don't have enough time to look through code at the moment.

HTH,
Adam

Posted: Wed Apr 09, 2008 2:23 am
by einsteinjunior
I also have the same error and warning messages here,but i will look at the source code later in the day (in say 2 hours).

Posted: Wed Apr 09, 2008 2:38 am
by JamesM
Hi,

AJ, einsteinjunior: Thanks so much for testing it out so quickly!

I've uploaded a new tarfile with the -fno-stack-protector flag removed (not exactly sure how it crept back in there, i'd removed it in all other tarfiles!) and the warnings fixed.

I'm not sure about your link problem AJ - It links perfectly on my system! :S

Thanks again,

James

New tarfile can be found at the same place: http://www.jamesmolloy.co.uk/downloads/user_mode.tar.gz

Posted: Wed Apr 09, 2008 2:43 am
by einsteinjunior
Will test right away......But source code still has to wait.

Posted: Wed Apr 09, 2008 5:15 am
by White-spirit
Try this to compile the kernel on cygwin ;) :

Code: Select all

i586-elf-gcc -ffreestanding -mno-stack-arg-probe -c kernel.c -o kernel.o

i586-elf-ld -e kernel_main -Ttext 0x1000 -o kernel anotherobject.o kernel.o
i586-elf-objcopy -R .note -R .comment -S -O binary kernel kernel.bin
You must build a cross compiler ( look at the OsFaq ) :P .

Posted: Wed Apr 09, 2008 5:40 am
by Stevo14
Nice tutorial. It compiled and ran perfectly in qemu using standard gcc and ld on Ubuntu. I'm looking to move to user mode soon so this will be a big help.

Posted: Wed Apr 09, 2008 5:55 am
by JamesM
Thanks stevo :)

Posted: Wed Apr 09, 2008 5:57 am
by Brynet-Inc
Gah! Nice tarbomb JamesM.. :(

Not cool, not cool at all... :roll:

Posted: Wed Apr 09, 2008 6:14 am
by JamesM
oh yeah, woops! :-) I'm sure you can deal with it, I'm surprised you don't extract tarfiles in a temporary folder anyway.

Posted: Wed Apr 09, 2008 6:58 am
by Brynet-Inc
JamesM wrote:oh yeah, woops! :-) I'm sure you can deal with it, I'm surprised you don't extract tarfiles in a temporary folder anyway.
I usually do, but this morning... I broke with tradition, regardless.. I blame you.. ;)

Posted: Wed Apr 09, 2008 8:37 am
by piranha
Could someone test forking? Without the switch_to_user_land call, it pagefaults for me.

-JL

Posted: Wed Apr 09, 2008 8:49 am
by JamesM
piranha wrote:Could someone test forking? Without the switch_to_user_land call, it pagefaults for me.

-JL
*without* the switch to user land? are you sure you didn't mean *with* it?

(Because I would expect that - the fork function should run in kernel mode! You'll have to add a syscall for it.)

Posted: Wed Apr 09, 2008 4:20 pm
by Combuster
with cygwin's gcc, it fails at the linking step (leading underscores, reference to __alloca and friends). Using my standard cross-compiler makes it compile cleanly. The floppy image works as expected.

and of course, the sudo/loopback device scripts don't work on a windows platform. :(

I've quickly glanced over the source code and it looks decent.

Posted: Wed Apr 09, 2008 4:33 pm
by Alboin
For 64bit linux boxes:

Code: Select all

CFLAGS=-nostdlib -nostdinc -fno-builtin -m32
LDFLAGS=-Tlink.ld -m elf_i386