creating constant size kernel image

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.
Post Reply
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

creating constant size kernel image

Post by Chandra »

Is there any way to create a constant size kernel image. In NASM, the times directive would do the job but how can this be done in C?
Any help would be outstanding.

Best Regards,
Chandra
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: creating constant size kernel image

Post by gravaera »

Code: Select all

const char        pad[OVER_9000_CHARS];
But somehow I don't think that's what you were looking for :wink: ...
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: creating constant size kernel image

Post by Solar »

You cannot do it in "pure" C, because the compiler has no notion of how big the binary will eventually be. (It being created by the backend, after the compiler has finished.)

So you would have to look at the Linker to do this stunt.
Every good solution is obvious once you've found it.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: creating constant size kernel image

Post by Brendan »

Hi,
Chandra wrote:Is there any way to create a constant size kernel image. In NASM, the times directive would do the job but how can this be done in C?
Any help would be outstanding.
It'd help to know why you'd consider wasting (tens, hundreds, thousands, millions) of bytes for the sake of padding. The only reason I can think of is that your boot loader (or your memory management initialisation, or paging initialisation) is broken and will only handle a fixed size kernel, and you couldn't be bothered fixing the real problem.

The only other thing I can think of is that (for some unknown but justifiable reason) you need to align sections (e.g. so that the ".bss" begins on a page boundary), where you don't actually want a fixed size kernel.


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
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: creating constant size kernel image

Post by Solar »

Brendan wrote:The only other thing I can think of is that (for some unknown but justifiable reason) you need to align sections (e.g. so that the ".bss" begins on a page boundary), where you don't actually want a fixed size kernel.
...which the linker can do that for you just fine (ALIGN ...)
Every good solution is obvious once you've found it.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: creating constant size kernel image

Post by Chandra »

Brendan wrote:Hi,
Chandra wrote:Is there any way to create a constant size kernel image. In NASM, the times directive would do the job but how can this be done in C?
Any help would be outstanding.
It'd help to know why you'd consider wasting (tens, hundreds, thousands, millions) of bytes for the sake of padding. The only reason I can think of is that your boot loader (or your memory management initialisation, or paging initialisation) is broken and will only handle a fixed size kernel, and you couldn't be bothered fixing the real problem.

The only other thing I can think of is that (for some unknown but justifiable reason) you need to align sections (e.g. so that the ".bss" begins on a page boundary), where you don't actually want a fixed size kernel.


Cheers,

Brendan
Unfortunately, you are wrong this time. Please donot expect me to be that kind of person who gives up his work, simply not being able to fix. I don't know how your guess came up. Anyway, the thing is not that major problem has caused me to do so. My Kernel is already 64 Kilobytes long and I have two kernels.
The first one is protected mode kernel and the second one is real mode kernel. The real mode kernel is for debugging and remote session only.My bootloader has to load both the kernels in the memory at different locations and I'm encountering problem due to number of sectors read, as the sectors consumed by the protected mode kernel goes on increasing as the development process continues.I am using custom Filesystem (TMFS) with 16 bytes entry which is encountering problems when the secotors of the kernel varies. So I just wondered if I could make the protected mode kernel fixed size(approx, 96 KB) and then continue to work on real mode kernel.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
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: creating constant size kernel image

Post by Combuster »

I am using custom Filesystem (TMFS) with 16 bytes entry which is encountering problems when the secotors of the kernel varies.
So you are working around bugs by making bloatware. And then saying you are not "that kind of person who gives up his work, simply not being able to fix.". Man, you are really late for halloween. :evil: [-X


This is exactly what Brendan's question was about - to find out if you are doing weird things that are completely unnecessary and can be solved more effectively. I would have asked the same thing.
"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 ]
Post Reply