Hi everyone,
I have writen a tutorial on getting to user mode and would be greatfull if some of you would look over it for correctness, the link to the tutorial is Link to tutorial.
Any improvements or suggestions are welcome.
Thank you in advanced for your help.
New tutorial on getting to user mode
Re: New tutorial on getting to user mode
I haven't started the read yet, but I would recommend having both a PDF and HTML/In browser version (remember not all of us have PDF-Browser integration)
Re: New tutorial on getting to user mode
I have made a Html copy of the Tutorial, and it is available here
Re: New tutorial on getting to user mode
Hi,
that code was left over from the multiple CPU implimentation, I've now fixed it thank you for pointin it out. the links above now point to the updated version.
Thank You
that code was left over from the multiple CPU implimentation, I've now fixed it thank you for pointin it out. the links above now point to the updated version.
Thank You
Re: New tutorial on getting to user mode
I really was aiming at just giving people a idea of how it could be implemented, as when i was implementing it I found it somwhat hard to get all the right parts in it, and all the documents that i looked at to start off with whent over it with huge amounts of detail adding in parts that at the time i was not interested in implementing. My aim was more just to provide the information that you would need to get into user mode to start off with, I thought that it would be better if you could understand how to get to user mode and then start adding extras. As a result some of the detail has been left out just to make it a bit more understandable, off course once you've got into user mode I would still advise you to add to the implementation.
Thank you for your feedback, more is welcome of course.
Thank you for your feedback, more is welcome of course.
Re: New tutorial on getting to user mode
I thought it was pretty good, the first page in the HTML version doesn't seem to render as cleanly under Firefox where the second box around eflags forms but it's still readable. A brief explanation of a selector's RPL field and structure might help clarify how the code at the end actually functions as well.
Reserved for OEM use.
Re: New tutorial on getting to user mode
This is my first post here so ... Hello everyone
Nice little tutorial you've got there. But i noticed two things:
That's the way you set your TSS descriptor:
But the intel-docs say "The base address specifies the linear address of byte 0 of the TSS; the segment limit specifies the number of bytes in the TSS." (3A 2.4.4)
I set my limit like this and it works fine for me:
Not sure if it matters at all though
And I believe you misplaced the __attribute__((packed)) statement in your TSS structure:
This little demonstration will output something like "8 5 8".
My gcc even generates a warning on your struct ("warning: ‘packed’ attribute ignored"). But it doesn't matter in your case because you only have 32bit and 2x16bit types in your struct. In this case the compiler is "packing" them even if you don't explicitly tell him to do so.
I hope the above is correct and will help
Nice little tutorial you've got there. But i noticed two things:
That's the way you set your TSS descriptor:
Code: Select all
unsigned long addr=(unsigned long)tss;
int size = sizeof(tss_struct)+1;
gdt_set_gate(5,addr,addr+size,0x89,0xCF)
I set my limit like this and it works fine for me:
Code: Select all
gdt_set_entry(5, (uint32_t)&tss, sizeof(tss_t), 0x89, 0);
And I believe you misplaced the __attribute__((packed)) statement in your TSS structure:
Code: Select all
typedef volatile struct strtss{
/* ... */
} tss_struct __attribute__((packed));
Code: Select all
#include <stdio.h>
#include <stdint.h>
typedef struct {
uint8_t a;
uint32_t b;
} a_t;
typedef struct {
uint8_t a;
uint32_t b;
} __attribute__((packed)) b_t;
typedef struct {
uint8_t a;
uint32_t b;
} c_t __attribute__((packed));
int main(int argc, char **argv) {
printf("%u %u %u\n", sizeof(a_t), sizeof(b_t), sizeof(c_t));
return 0;
}
I hope the above is correct and will help
Re: New tutorial on getting to user mode
Thank you for pointing that out iv'e fixed the tutorial and updated the links. Any more comments would be appreciated.