Page 2 of 3

Posted: Wed Apr 09, 2008 4:46 pm
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

Posted: Thu Apr 10, 2008 2:03 am
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

Posted: Thu Apr 10, 2008 10:28 am
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:

Posted: Thu Apr 10, 2008 12:14 pm
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

Posted: Thu Apr 10, 2008 1:10 pm
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

Posted: Thu Apr 10, 2008 4:37 pm
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.

Posted: Thu Apr 10, 2008 7:30 pm
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 :-)

Posted: Fri Apr 11, 2008 2:06 am
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

Posted: Fri Apr 11, 2008 6:02 am
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 ;)

Posted: Fri Apr 11, 2008 6:10 am
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

Posted: Fri Apr 11, 2008 7:14 am
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 .

Posted: Fri Apr 11, 2008 7:35 am
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

Posted: Fri Apr 11, 2008 7:45 am
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

Posted: Fri Apr 11, 2008 8:20 am
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

Posted: Fri Apr 11, 2008 9:41 am
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