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
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

JamesM wrote:
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.)
It pagefaults, while not in userland.

-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 »

Alboin wrote:For 64bit linux boxes:

Code: Select all

CFLAGS=-nostdlib -nostdinc -fno-builtin -m32
LDFLAGS=-Tlink.ld -m elf_i386
Ah yes, I'll add that in, thanks for that.

Piranha, the clone_directory and clone_table functions really shouldn't have changed at all. I'm looking at a diff now between multitasking.tar.gz and user_mode.tar.gz...

There's a temporary line which i forgot to remove: in initialise_paging(), the while() loop, it has placement_address+0x1000 commented out and 0x400000 put in instead. Remove that, and see what happens?

PS: More specifically - *how* does it pagefault? what's the address of the pagefault? the mode bits?

Cheers,

James
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post by White-spirit »

White-spirit wrote: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 .
Combuster, please read what I write :roll:
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

OK, piranha's pagefault is fixed, thanks for pointing that out to me. I'll retar it tomorrow and put it back online, (avoiding the tarbomb this time!)

The problem stemmed from me being retarded, and forgetting a pair of brackets thus:

Code: Select all

if (blah & (some+calculation) != 0)
Which should obviously have parentheses around the two left terms. The precedence of & always catches me out :(

This caused the heap to allocate address-aligned regions *twice*, causing a heap corruption, and also page table corruption. Fixed now.

Cheers,

James
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Post by astrocrep »

I haven't tested it or even looked through the code, but I must say thank you. Your tutorials are always amazing, and I look forward to reading the accompining html pages...

What is your tutorial plan of action after user-land & syscalls?

Thanks and keep it up,
Rich
Mouse Pad - Coming in the distant future...
Kernel: Indigo Kernel - v0.0.1

Thanks to JamesM and BrokenThorn for there tutorials!
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 »

White-spirit wrote:Combuster, please read what I write :roll:
Your point? You didn't explain why the standard cygwin gcc doesn't work.
"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 ]
zerosum
Member
Member
Posts: 63
Joined: Wed Apr 09, 2008 6:57 pm

Post by zerosum »

I haven't looked at this (yet), and this is somewhat O/T, but I'd just like to say thanks for your tutorial, JamesM. I have it bookmarked and it's a great resource for those people who, like me, are just starting out and haven't a clue :-)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

astrocrep wrote:I haven't tested it or even looked through the code, but I must say thank you. Your tutorials are always amazing, and I look forward to reading the accompining html pages...

What is your tutorial plan of action after user-land & syscalls?

Thanks and keep it up,
Rich
Hi, and thanks!

The plan of action is (loosely):

- user mode and syscalls (done)
- loading executables (ELF)
- kernel modules
- porting an app, and this will be the end. Possibly nasm and dash, at least some kind of shell :)

Cheers,

James
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post by White-spirit »

Combuster wrote:
White-spirit wrote:Combuster, please read what I write :roll:
Your point? You didn't explain why the standard cygwin gcc doesn't work.
It's because Windows adds calls to malloc & co to test the memory, so you have to remove them .
Also, GCC must output an elf object, so you need a cross compiler ;)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

It's because Windows adds calls to malloc & co to test the memory
Yeh wha?!?! *boggles* - why on earth would (a) a memory test need to occur when an application is started and (b) malloc() be used to test it?! Are you sure you didn't just pull that out of your derriere? (also note that __alloca != malloc by any stretch of the imagination)

Oh, and your commands to compile my kernel tutorial create a binary object linked at 0x1000 instead of an ELF object linked at 0x100000, so it's pretty misleading.

DISCLAIMER: I don't know much about cygwin (first paragraph).
Cheers,

James
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post by White-spirit »

I meant alloca sorry :oops: ( it's probably because i'm recoding malloc for my OS at this moment so ... ) , and this _alloca is incorporated by the compiler ( only Windows as I see ) for conducting tests of memory allocation on the status of the stack, it is possible to specify not to incorporate this test with the keyword -mno-stack-arg-probe .
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Post by astrocrep »

JamesM wrote:
astrocrep wrote:I haven't tested it or even looked through the code, but I must say thank you. Your tutorials are always amazing, and I look forward to reading the accompining html pages...

What is your tutorial plan of action after user-land & syscalls?

Thanks and keep it up,
Rich
Hi, and thanks!

The plan of action is (loosely):

- user mode and syscalls (done)
- loading executables (ELF)
- kernel modules
- porting an app, and this will be the end. Possibly nasm and dash, at least some kind of shell :)

Cheers,

James
Wow... sounds very exciting... I look forward to more to come!

-Rich
Mouse Pad - Coming in the distant future...
Kernel: Indigo Kernel - v0.0.1

Thanks to JamesM and BrokenThorn for there tutorials!
User avatar
zaleschiemilgabriel
Member
Member
Posts: 232
Joined: Mon Feb 04, 2008 3:58 am

Post by zaleschiemilgabriel »

I took a look at the code, and I must say, I like the way you put everything just at the right spot, and made everything in separate source files.
JamesM wrote:and this will be the end
That's funny. :)

Thanks,
Gabriel
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

zaleschiemilgabriel wrote:I took a look at the code, and I must say, I like the way you put everything just at the right spot, and made everything in separate source files.
JamesM wrote:and this will be the end
That's funny. :)

Thanks,
Gabriel
Hi,

Thanks! although I don't get what's funny... Damn! It seems my infallible British sense of humour has let me down!

Cheers,

James
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

..and mine.

maybe its just that other nationalities have a more obscure sense of humour? i happen to like the dry british one :D
~ Lukem95 [ Cake ]
Release: 0.08b
Image
Post Reply