Problem loading kernel

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
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Problem loading kernel

Post by BMW »

I am trying to load my kernel from my bootloader, however the int 0x13 refuses to load more than 2 sectors.

Can it only load 2 sectors at a time or something?
Last edited by BMW on Sun Jan 06, 2013 3:56 pm, edited 1 time in total.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
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: Loading sectors from disk only loading 2 sectors

Post by Combuster »

Int 0x13 can read many sectors depending on a whole range of other conditions.

Learn to check error codes.
"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
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Loading sectors from disk only loading 2 sectors

Post by iansjack »

The INT 13 functions can read more than two sectors at a time, although - obviously - it is limited by the number of sectors on the track, so clearly you are doing something wrong.

Without code it is less clear what that is.
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Loading sectors from disk only loading 2 sectors

Post by BMW »

I am reading 5 sectors from a hard drive (sectors 4-8).
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: Loading sectors from disk only loading 2 sectors

Post by Griwes »

iansjack wrote:Without code it is less clear what that is.
Also, which functions of int 0x13...? What device...?

We know almost exactly nothing from your description of problem; how are we supposed to be able to help?
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Loading sectors from disk only loading 2 sectors

Post by BMW »

Griwes wrote:
iansjack wrote:Without code it is less clear what that is.
Also, which functions of int 0x13...? What device...?

We know almost exactly nothing from your description of problem; how are we supposed to be able to help?
Sorry.
Function 0x02.
The device is a hard drive.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Loading sectors from disk only loading 2 sectors

Post by BMW »

Combuster wrote:Int 0x13 can read many sectors depending on a whole range of other conditions.

Learn to check error codes.
Hmmm... there is no error.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
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: Loading sectors from disk only loading 2 sectors

Post by Combuster »

How many more questions do we need to ask you before we are able to reproduce your problem?
"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
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Loading sectors from disk only loading 2 sectors

Post by BMW »

Combuster wrote:How many more questions do we need to ask you before we are able to reproduce your problem?
Ok, the problem is not with the loading of the kernel, but with the executing of it.

When you load a PE file, do you just load the whole thing then jump to the entry point? Or do you have to load different parts of it to different places?
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Problem loading kernel

Post by sortie »

Do you know what the file format of a PE file is? If you did, then you'd know the answer to your question.
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Problem loading kernel

Post by BMW »

sortie wrote:Do you know what the file format of a PE file is? If you did, then you'd know the answer to your question.
Ok sorry I see now. I have to use the relocation tables and move the sections to appropriate places.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Problem loading kernel

Post by BMW »

If I set the base address in visual studio to where I load the PE file, will this eliminate the need to change the offsets in the relocation table?
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Problem loading kernel

Post by Brendan »

Hi,
BMW wrote:If I set the base address in visual studio to where I load the PE file, will this eliminate the need to change the offsets in the relocation table?
A quick questionnaire:
  • Do you need relocatable code (e.g. will the kernel be loaded at "random" virtual addresses)?
  • Do you need dynamic linking (e.g. will unresolved references in the kernel be linked to something else when it's loaded)?
  • Do you need a real mode stub that displays "This program requires Windows" in case someone tries to execute your kernel on MS-DOS?
If the answer to these questions are all "no", then why do you want to use PE in the first place? Just use something (e.g. objcopy) to convert the PE into a flat binary and load the flat binary into memory "as is" (without any of the PE loader hassles or file format bloat).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Problem loading kernel

Post by BMW »

No. No. No.

What a good idea. Thanks.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Problem loading kernel

Post by BMW »

Brendan wrote:Hi,
BMW wrote:If I set the base address in visual studio to where I load the PE file, will this eliminate the need to change the offsets in the relocation table?
A quick questionnaire:
  • Do you need relocatable code (e.g. will the kernel be loaded at "random" virtual addresses)?
  • Do you need dynamic linking (e.g. will unresolved references in the kernel be linked to something else when it's loaded)?
  • Do you need a real mode stub that displays "This program requires Windows" in case someone tries to execute your kernel on MS-DOS?
If the answer to these questions are all "no", then why do you want to use PE in the first place? Just use something (e.g. objcopy) to convert the PE into a flat binary and load the flat binary into memory "as is" (without any of the PE loader hassles or file format bloat).


Cheers,

Brendan
Lol, chucked a 2.5KB PE file into objcopy, spat out a 9KB binary file 99% full of 0x00... im not putting up with that.

How can I fix this?
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Post Reply