Tutorial test request

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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Tutorial test request

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post 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).
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Will test right away......But source code still has to wait.
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 .
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Post 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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Thanks stevo :)
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Gah! Nice tarbomb JamesM.. :(

Not cool, not cool at all... :roll:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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.. ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Could someone test forking? Without the switch_to_user_land call, it pagefaults for me.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.)
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:

Post 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.
"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 ]
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

For 64bit linux boxes:

Code: Select all

CFLAGS=-nostdlib -nostdinc -fno-builtin -m32
LDFLAGS=-Tlink.ld -m elf_i386
C8H10N4O2 | #446691 | Trust the nodes.
Post Reply