You are not logged in.


#41 2005-11-26 20:01:25

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

Re: Program loading

Wow, you've been busy... smile
Ok notoka, I see your point. But what if the OS has a total of maybe 4000 drivers, not going to happen with BOS but anyway...
That would take, hmm.., 80mb.
Now, if i only need maybe 4 drivers on my computer, and those four drivers was made last of the total 4000 it would mean that almost 80mb of RAM goes to waste, since i don't use those drivers and can't use that space for anything else.
with 256mb or more in total RAM i guess that you'll say "So what?", but in my opinion, thats bad design. really bad design. I rather go for paging.. wink

Anyway, we can quit this now. I'm going to use the GDT and segmentation. It's by far the easiest solution. If i ever start coding for 64-bit it has to be on a completly new OS and done in BOS on my future "C" compiler.. smile

/ Christoffer

Offline

 

#42 2005-11-26 20:40:03

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: Program loading

For a 64bit, you will have too use paging sad .

Offline

 

#43 2005-11-27 01:36:09

DennisCGc
Member
From: Zoetermeer, The Netherlands
Registered: 2005-03-01
Posts: 49
PM  Website

Re: Program loading

Oh come on notoka, are you being plain serious? You just can't reserver 20 megabytes. That's a waste of memory. If an OS would reserve 20 megabytes of memory just for a few drivers, then I seriously would throw that OS out of my window. Although memory is cheap, doesn't mean you can easily reserve 24 megabytes. I really don't wish to your OS then smile. And I won't this implement in my OS. I'll go for relocation. smile

PS. You seem to have rather small drivers. 1024 bytes (1 kilobyte) isn't enough for a nic driver. smile

@64 bit: yeah, fortunately they left out the segment-sh*t. IMO segments are not needed anymore. But that's just my opinion ;-)

Offline

 

#44 2005-11-27 01:45:12

DennisCGc
Member
From: Zoetermeer, The Netherlands
Registered: 2005-03-01
Posts: 49
PM  Website

Re: Program loading

@notoka regarding Linus Torvalds and some other things I forgot to include:

No, Bruce Evans was the minix386 god. smile It was also mentioned in his (Linus Torvalds') book. He just created a new OS, because he was unhappy using the terminal emulator which came with Minix. So in short, Linux was NEVER pre-designed. Instead, he used the ideas of Unix. (the everything-is-a-file concept), which can't be always a good thing.

Now I am really wondering, are [b]you[/b] writing an OS? I am also wandering if you have any proof of concept on your method of managing drivers. I think management of drivers also is an important issue. And just assigning a driver to a fixed address is a waste of time. My time, your time, the developers time, etc. I just don't fscking care if a drivers loads 0,1 sec. more in time (because of relocation) than when I have all the drivers assigned.. And btw, Windows has a [b]lot[/b] more than just 2000 drivers. I think it'll reach the 100000 limit. (could be more though)

DennisCGc.

Offline

 

#45 2005-11-28 15:02:31

AxelDominatoR
Member
From: Reggio Calabria, Italy
Registered: 2005-03-07
Posts: 43
PM  Website

Re: Program loading

Hi to all! Sorry for disappearing for so much time sad ...
If you create a simple relocatable format you could use it for both executables and drivers. It will only need to have tags for position-dependent code that will be changed at driver/application loading time by the loader to reflect the real addresses.
I don't have too much time to write now... I promise that I will make some examples later... ( and maybe read more accurately all the discussion because I jumped a post or two tongue )

Axel


---
Axel DominatoR ^^^ HC

Offline

 

#46 2005-11-29 14:54:26

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

Re: Program loading

Hi!

Sorry for disappearing for so much time

No problem.

If you create a simple relocatable format you could use it for both executables and drivers. It will only need to have tags for position-dependent code that will be changed at driver/application loading time by the loader to reflect the real addresses.

I know to little about this, and don't really have any time to research it... sad

I don't have too much time to write now... I promise that I will make some examples later... ( and maybe read more accurately all the discussion because I jumped a post or two tongue )

Ok, i look forward to it..

  Christoffer

Offline

 

#47 2005-11-29 19:13:26

AxelDominatoR
Member
From: Reggio Calabria, Italy
Registered: 2005-03-07
Posts: 43
PM  Website

Re: Program loading

I'll share with you an idea about a possible position independent format that I want to use in my os:

Reloc
Data
Code

Ok... Data contains initialized and non-initialized data. Code contains the real program instructions.
Reloc contains the informations about relocation. For example:

Reloc:
-location- is at 0x01 from the start of the binary.

Code:
call -location-

Your code calls a location which memory address is known only at runtime. Your loader, when loading the application/driver will know the starting location, so it can calculate the -location- and substitute it with the empty/dummy value at the ( exe start location + relative -location- address specified in Reloc )

I hope it's not too much confusing... maybe we could discuss it if you're interested... IMHO it's not too much complicated to implement, but I'm surely missing some other problems/features to insert in it.

Axel


---
Axel DominatoR ^^^ HC

Offline

 

#48 2005-11-29 19:25:07

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: Program loading

@AxelDominatoR, if i understand your idea right, thats what the above code does wink.

Offline

 

#49 2005-11-29 20:34:53

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

Re: Program loading

Ok, so then i "only" need to specify the format and change fasm to assembly files that
follow those rules. Should be simple... Or..?
Dex, would you like to help with this? Maybe we can have the same format all three of us,
making it our own standard.. smile

Offline

 

#50 2005-11-29 21:16:15

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: Program loading

bubach wrote:

Dex, would you like to help with this? Maybe we can have the same format all three of us,
making it our own standard.. smile

bubach you read my mind wink, so yes count me in.

Offline

 

#51 2005-11-30 06:35:55

AxelDominatoR
Member
From: Reggio Calabria, Italy
Registered: 2005-03-07
Posts: 43
PM  Website

Re: Program loading

@Dex:
Oooooopppssss ... sorry! I jumped over your post hmm
It's exactly the same thing you said!
We could make a standard structure. For example:
Header
Data
Code

The header may contain an initial tag to identify the executable type ( magic numer ) and the architecture ( Dex4u, BOS, etc ). Then, following the same structure, every OS could implement some "proprietary" tag along with the standard ones...
For example, my os will need to have some additional informations about routines/functions in the Code... and I'll add a subsection in the header.


---
Axel DominatoR ^^^ HC

Offline

 

#52 2005-11-30 07:30:13

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

Re: Program loading

So, how to we start this.. Every point in the program where we access a label, like jumps
or "mov eax, my_variable" have to be changed to add the program base..?
I'm not to sure that i will be of any help here, becasue my lacking knowledge in this subject.. sad
If you have to the time to make the first draft i could test it on BOS without to much work, i already
have testing functions to "load" a binary file thats included right after the kernel but it relays on
segmentation.

Offline

 

#53 2005-11-30 12:12:26

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: Program loading

@bubach, As we have not written our own assembler we are all, not 100% shore on this subject, so the best think we can do, is write 2  program with jumps etc, one with org 100 and one with org 0, we can then test what will need patching or not, by checking the code with a hex-editor.

This way we will learn how it works in the real world, rather than read  bits here and bits there,  and still not understand it.
Heres what we know so far, but we need to find where else it is added eg: "call print",i think we would need to add the base to the lable "print" .
**************************************************************************************************
Question:
What is org 7c00h ?

Answer:

It is very similar to org 100h. This directive instructs the assembler to add 7C00h to all addresses of all variables that are declared in your program. It operates exactly the same way as ORG 100h directive, but instead of adding 100h (or 256 bytes) it adds 7C00h.

For example if you write this code:
mov ax, var1

and the address of var1 is 10h

without ORG 100h directive assembler produces the following machine code:
mov ax, [10h]

however with ORG 100h directive assembler automatically updates the machine code to:
mov ax, [10h+100h]

and it is equivalent to this code:
mov ax, [110h]

org 7C00h directive must be used because the computer loads boot records into the memory at address 0000:7C00.

If program is not using variable names and only operates directly with numeric address values (such as [2001h] or [0000:1232h]... etc, and not var1, var2...) and it does not use any labels then there is no practical use for ORG directive. generally it's much more convenient to use names for specific memory locations (variables), for these cases ORG directive can save a lot of time for the programmer, by calculating the correct offset automatically.
*************************************************************************************************
All we need do, once we know what needs patching, is get whats at the address, add the base and put it back.

Offline

 

#54 2005-11-30 14:37:58

AxelDominatoR
Member
From: Reggio Calabria, Italy
Registered: 2005-03-07
Posts: 43
PM  Website

Re: Program loading

Quick "shot" because I'm going to work...
Most of assembly instructions are not position-dependent, because they often use relative addressing. IIRC calls and some types of jump are the most troublesome.
I'll get more info when I'll be back from work.


---
Axel DominatoR ^^^ HC

Offline

 

#55 2005-12-02 09:38:15

bubach
Administrator
From: Trollhättan, Sweden
Registered: 2005-02-15
Posts: 367
PM  Website

Re: Program loading

Isn't it just short jumps that are position independent, like jc etc? All "normal" jumps
and calls would use a absolute address.

Offline

 

#56 2005-12-03 21:02:13

smiddy
Active member
Registered: 2005-02-15
Posts: 183
PM

Re: Program loading

Sorry for my long leave too...been real busy with relocation and the new job. I'll keep an eye on what is happening from a far until after I get into my new house in February or March. You guys are onto something here...good stuff!


- [color=red]s[/color][color=blue]m[/color][color=red]i[/color][color=blue]d[/color][color=red]d[/color][color=blue]y[/color]

Offline

 

#57 2005-12-04 00:19:12

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: Program loading

@smiddy, nice to hear from you, keep us informed about your job and house.

PS: your talents have been noted on the menuet forum wink : http://menuet.2.forumer.com/index.php?s … &st=15

Offline

 

#58 2005-12-13 01:23:22

smiddy
Active member
Registered: 2005-02-15
Posts: 183
PM

Re: Program loading

Currently it is freezing and they can't pour our basement. ;'-( So, we hope to be in by February, but we'll see.

I can't wait to start coding again, but alas I am tied to making certain my house goes up right, and keeping my family happy presently. The outlook looks very promising.

WOW! I'm (in)famous...thanks for the link. I'll have to live up to the promise then, eh? :-)

I'll be popping in from time to time. After the house is done I will get busy trying to help out, it all looks so promising.


- [color=red]s[/color][color=blue]m[/color][color=red]i[/color][color=blue]d[/color][color=red]d[/color][color=blue]y[/color]

Offline

 

#59 2005-12-13 02:37:56

Dex4u
Active member
Registered: 2005-02-19
Posts: 132
PM

Re: Program loading

That will be good, once you have sorted the house out, as we need "really clever people like that Smiddy dude" wink .

Offline

 

#60 2006-04-25 03:43:42

Amos
Guest

Re: Program loading

Forgive me if this is overly simplistic, but, couldn't you just make an assembler that only outputs relative jumps?  I know they have a limited range, but I've seen plenty of code that uses a "leapfrog" system to go from a "jne" to a "jmp" for longer distances.  The same principle would apply.

Just my 64 Kwacha...

 

 

Board footer

Powered by PunBB
BOS homepage © Copyright 2005 Christoffer Bubach
Strict XHTML and valid CSS.