Programs in pmode

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
ComputerPsi
Member
Member
Posts: 83
Joined: Fri Oct 22, 2004 11:00 pm

Programs in pmode

Post by ComputerPsi »

Hello. Before, when programming in real mode, then to load and run a program, I would simply read it from the disk into some free memory position, and then jump to the beginning of that program. Now, that I transfered into protected mode, I suppose in need to change a few settings or something.. I'm not sure.. right now, my GDT has the linear data selection, the code selection, and data selection. I have no LDT, and I have a IDT filled with different handlers. What should I change, and how, to be able to load and execute a program, that has lower permitions then the OS? How would I do this so I can load and unload many programs into memory?
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Programs in pmode

Post by [AlAdDiN] »

hello
first i would like to precise that the goal of a kernel is NOT to run programs but to manage system ressources (loading/running applications is shell's task)
in PMOD u can continue using the "trash method" (loading a program into memory an jump to it) if u have no paging support in ur OS, coz in this case linear addr=physical addr

but it would be more interesting that u write an ELF format support so that u can run ur programms in any type of memory organization (imagine ur OS able to run programms compilled statically under linux ;) )
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Programs in pmode

Post by JAAman »

first i would like to precise that the goal of a kernel is NOT to run programs but to manage system ressources (loading/running applications is shell's task)
this is only partialy true:
it is still the kernels job to CREATE THREADS and that is exactly what the question is about furthur the shell is a program that must be started by the kernel

first you need to create a new page table(usually) and process with the code loaded into it(can be anyware in memory)you dont need LDT but you will need GDT entries for level 3 code and data

you may want to initialize some kernel tables for the new task (video, disk, etc)

then switch to it like a task switch(or just enter it into your task que and let your task schedular handle that)

the previous response is about loading executable code from drive which yes is the shells responsablility but setting up a new task is something ONLY your kernel can do (if other programs could it would be a dangerous security breach since they should not have access to the page tables or other kernel-level tables and the schedular)
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Programs in pmode

Post by [AlAdDiN] »

ya i agree with u about threads.
but i thought that ComputerPSI, was speaking about loading/running programms from disk (coz he compared it to real mode) , and this is a FAQ when we transfer to pmode ;)
Last edited by [AlAdDiN] on Tue Dec 07, 2004 12:00 am, edited 1 time in total.
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Programs in pmode

Post by JAAman »

in real mode its very simple but in pmode the only difference is what the kernel does the shells job is very similler and very implementation specific

also the author prob was talking about both but the only thing thats difficult is the kernel job -- loading off the disc is very simple but also requires the kernel to do its part

both are required to launch a new task and comming from a rm perspective the author might not even know theres a difference
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Programs in pmode

Post by [AlAdDiN] »

JAAman wrote:in real mode its very simple but in pmode the only difference is what the kernel does the shells job is very similler and very implementation specific

also the author prob was talking about both but the only thing thats difficult is the kernel job -- loading off the disc is very simple but also requires the kernel to do its part

both are required to launch a new task and comming from a rm perspective the author might not even know theres a difference

it's not hard to load and run a binary while in pmod, but, that bring us to the same problem as in real mode, the monotasking
while in pmode, we want our kernel to be multitask, so if u want to run programs, u have to write a task manager, then a task switching policy, then a scheduler, and this is the hardes part, also, u have to manage "correctly" tasks' memory mapping, to make ur kernel "flexible" ....
Last edited by [AlAdDiN] on Mon Dec 13, 2004 12:00 am, edited 1 time in total.
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Programs in pmode

Post by Da_Maestro »

Setting up a TSS (Task State Segment) is definately the answer. If you want programs to run at different privellege levels, you need to set up a stack for each privellege level, and the only way to do this is using a TSS.

When the processor switches between privellege levels, it will choose a stack appropriate for that level and automatically use it, but you need to set up the TSS to do that.

Otherwise, you will loose all the protection mechanisms provided by the processor, and basically be in VOODOO mode (big real mode).

I suggest reading the Intel docs.
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
frizzz
Member
Member
Posts: 36
Joined: Sat Oct 30, 2004 11:00 pm
Location: Germany
Contact:

Re: Programs in pmode

Post by frizzz »

I think, the first question was: how to start a program as simple as in real mode?
If Your are able to omit those silly things: priviledge level, paging, multi-anything...
I can help You with a fully debugged code. Look at my homepage and find an assemblerOS, which contains a new IDE-ATA-Driver and a very simple filesystem for harddisks - goto
www.rcfriz.de
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: Programs in pmode

Post by rexlunae »

frizzz wrote:I think, the first question was: how to start a program as simple as in real mode?
If Your are able to omit those silly things: priviledge level, paging, multi-anything...
I can help You with a fully debugged code. Look at my homepage and find an assemblerOS, which contains a new IDE-ATA-Driver and a very simple filesystem for harddisks - goto
www.rcfriz.de
Dear fritzzz:

I am writing this post in response to the large number of spam-ish posts which you have made to numberous threads recently. I would accuse you of blatant spamming, except that it is obvious from your posts that you actually read the threads you posted to. Let me tell you so that you will know...no one is that interrested in your operating system written in NASM. We did see the first time you posted information on your OS, when you posted to every thread on the first page, and most of us probably thought to ourselves "Gee, an OS written in NASM. NOT INTERRESTING". I, personally, would be happy to see you join the osdev.org community, but please, if you post to a thread, make sure it is on topic. And posting essentially the same message to multiple threads is really annoying. And it is particularly annoying to see a thread from more than two months ago dragged back up to the top so that you can try to make people download your OS when they ignorred the first eight spams you sent.

Thank you,
-rl
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Programs in pmode

Post by [AlAdDiN] »

@rexlunae : i agree
@frizzz : there is a section called "Project Announcements" , open a thread and post your link there, it's the best place in this forum to make ppl test your OS.
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
Post Reply