I have a project for which I have to implement parameter passing through stack between different protection levels. The information about the number of variables needed to be passed at the function must be given through DWORD Count of Call gate

For this project I have to:

A) Create 4 code segments
1) Real mode
2) Protected mode 16bit - privilege level 0
3) Protected mode 32bit - privilege level 0
4) Protected mode 32bit - privilege level 3

B) Enter protected mode - PL0

C) Adjust GDT, IDT, TSS, Stscks for the 3 privilege levels

D) Create the appropriate Call gate

E) Enter PL3

F) Execute a algorithm that uses a function at PL0 through Call Gate

G) Return to Real mode


My first question is how do I create the 4 code segments needed? can anyone help me?

Thanks you very much in advance

Just declare them like any other segment. What their attributes are will be diddled by protected mode code somewhere, not the assembler.

I have a project for which I have to implement parameter passing through stack between different protection levels. The information about the number of variables needed to be passed at the function must be given through DWORD Count of Call gate

For this project I have to:

A) Create 4 code segments
1) Real mode
2) Protected mode 16bit - privilege level 0
3) Protected mode 32bit - privilege level 0
4) Protected mode 32bit - privilege level 3

B) Enter protected mode - PL0

C) Adjust GDT, IDT, TSS, Stscks for the 3 privilege levels

D) Create the appropriate Call gate

E) Enter PL3

F) Execute a algorithm that uses a function at PL0 through Call Gate

G) Return to Real mode


My first question is how do I create the 4 code segments needed? can anyone help me?

Thanks you very much in advance

------------------------------------------------
Hi,

This is garni,

well your ? is good, ok lets 1st make your question clear.

So now you owns the entire responsibility of the entire system(i.e you want to boot the system with your own machine code)?

then establish proper segments in memory .

then create descriptor in memory and then move the base address of corresponding segments in memory to that particular descriptor.

then you want to do a call to the procedure via call gate is that?

1 st confirm me that all of the things that i have typed above are right? then i will be able to answer you properly.

there is nothing like switching to previlege level 3, it is just a matter of "call" macro instruction.

the only thing that determines the previlege level is the 2 bit CPL (Current Previlege Level) that is part of the 16- bit Code Segment Value when the processor is in protected mode.

so when you do a call to a procedure that is in a segment which is of previlege level 3 (the descriptor for particular segment in memory holds a 2 bit descriptor value of 3 )then thats it you are done with processor will load that selector in CS, so Obviously your CPL will get changed by this time so now your are in PL3,

so finally the only difficulty you will face is switching to protected mode, and switching back to real mode.

that is also simple but you need t have prior idea about the structure of the descriptor, and how we can mix both 16 bit and 32 bit code in a same segment using operand size prefix and address size prefix.

will help u more if you bit elaborate your question.

thx,
Garni.

If you can find a copy, the Intel 386 "Operating System Writer's Guide" explains a lot of this stuff in detail.

------------------------------------------------
Hi,

This is garni,

well your ? is good, ok lets 1st make your question clear.

So now you owns the entire responsibility of the entire system(i.e you want to boot the system with your own machine code)?

then establish proper segments in memory .

then create descriptor in memory and then move the base address of corresponding segments in memory to that particular descriptor.

then you want to do a call to the procedure via call gate is that?

1 st confirm me that all of the things that i have typed above are right? then i will be able to answer you properly.

there is nothing like switching to previlege level 3, it is just a matter of "call" macro instruction.

the only thing that determines the previlege level is the 2 bit CPL (Current Previlege Level) that is part of the 16- bit Code Segment Value when the processor is in protected mode.

so when you do a call to a procedure that is in a segment which is of previlege level 3 (the descriptor for particular segment in memory holds a 2 bit descriptor value of 3 )then thats it you are done with processor will load that selector in CS, so Obviously your CPL will get changed by this time so now your are in PL3,

so finally the only difficulty you will face is switching to protected mode, and switching back to real mode.

that is also simple but you need t have prior idea about the structure of the descriptor, and how we can mix both 16 bit and 32 bit code in a same segment using operand size prefix and address size prefix.

will help u more if you bit elaborate your question.

thx,
Garni.

First of all I would like to apologise for not thanking you months ago for your answer. I live in Greece and during the last few months we had enormous problems with university education and as a result the project was postponed, so totally forgot it.


If you 're still willing to help me (if not it would be totally logical after my behaviour) I would like to give you some more information.

What you said I want to do is true. Switching to protected mode and back isn' t a problem. I have already written thw code for that transition.

What I don 't know how to do is how to create the appropriate call gate, how to enter PL3 and how to execute an algorithm that uses a function at PL0 through Call Gate.

Thank you for your time and I' m very sorry again for the negligence.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.