Page 1 of 1
Programs in pmode
Posted: Fri Dec 03, 2004 12:00 am
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?
Re: Programs in pmode
Posted: Sat Dec 04, 2004 12:00 am
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
)
Re: Programs in pmode
Posted: Tue Dec 07, 2004 12:00 am
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)
Re: Programs in pmode
Posted: Tue Dec 07, 2004 12:00 am
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
Re: Programs in pmode
Posted: Sun Dec 12, 2004 12:00 am
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
Re: Programs in pmode
Posted: Mon Dec 13, 2004 12:00 am
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" ....
Re: Programs in pmode
Posted: Wed Jan 05, 2005 12:00 am
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.
Re: Programs in pmode
Posted: Sun Mar 13, 2005 12:00 am
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
Re: Programs in pmode
Posted: Sun Mar 13, 2005 12:00 am
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
Re: Programs in pmode
Posted: Mon Mar 14, 2005 12:00 am
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.