Posted: Sun Oct 21, 2007 3:06 pm
either prefix 'TSS tss[max_tasks];' with static making 'static TSS tss[max_tasks];' or put the line outside the function. The later being the preferred method.
Code: Select all
#define ACS_TSS_GATE 0x09
#define max_tasks 1
task();
initialize_tasks()
{
typedef struct {
unsigned long link,
esp0,
ss0,
esp1,
ss1,
esp2,
ss2,
cr3,
eip,
eflags,
eax,
ecx,
edx,
ebx,
esp,
ebp,
esi,
edi,
es,
cs,
ss,
ds,
fs,
gs,
ldtr;
unsigned short trace,
io_map_addr;
}__attribute__((packed))TSS;
TSS tss[max_tasks];
/* number base limit type granularity */
gdt_set_gate(3 , tss[0], sizeof(TSS), ACS_TSS_GATE, 0xCF); /*selector is 0x18*/
gdt_flush();
tss[0].cs = 0x08;
tss[0].eip = (unsigned int)&task;
tss[0].eflags = 0x202L;
__asm__ __volatile__("ltr 0x18 \n\t"
"jmp 0x18\n\t");
}
task()
{
puts("i am task one!!!\n");
__asm__ __volatile__("iret");
for(;;);
}
I have suggested this to him before. It has been ignored.Combuster wrote:I tend to agree with brynet-inc - You do not know your language well enough to be programming operating systems.
Kowing the base language for development inside out is a definate requirement. You must know what the compiler does with what code, and have a good idea about the machine code generated by it. That way you can see from the code what the processor should do. Next there's a bit of experience - if you have written a few large projects you know what you can and cannot do with a language. Based on the fact that you have half the top 10 of beginners errors in your code and being unable to see it I can only conclude that this subject is too advanced for you.
I suggest you start a smaller project and run it to completion on your own, then work on some larger projects and make them work properly. After that, your knowledge of C will hopefully be at such a level that writing the code is the easier part of OS development.
Well then, I hope it helps if more people tell him that this is not the right place.JamesM wrote:I have suggested this to him before. It has been ignored.
Code: Select all
#define ACS_TSS_GATE 0x09
#define max_tasks 1
task();
typedef struct {
unsigned long link,
esp0,
ss0,
esp1,
ss1,
esp2,
ss2,
cr3,
eip,
eflags,
eax,
ecx,
edx,
ebx,
esp,
ebp,
esi,
edi,
es,
cs,
ss,
ds,
fs,
gs,
ldtr;
unsigned short trace,
io_map_addr;
}__attribute__((packed))TSS;
TSS tss[max_tasks];
initialize_tasks()
{
/* number base limit type granularity */
gdt_set_gate(3 , tss[0], sizeof(TSS), ACS_TSS_GATE, 0xCF); /*selector is 0x18*/
gdt_flush();
tss[0].cs = 0x08;
tss[0].eip = (unsigned int)&task;
tss[0].eflags = 0x202L;
__asm__ __volatile__("ltr 0x18 \n\t"
"jmp 0x18\n\t");
}
task()
{
puts("i am task one!!!\n");
__asm__ __volatile__("iret");
for(;;);
}
Bull. not allocating global things on the stack is a rule in all projects, not just OSdeveasy on me guys i never worked with those low level things in C even if i made a million of projects it won't tell me how to play with the stack !
Yes and? Many of the useful responses have been given before:a general protection fault exception happened
2) You do not switch tasks with LTR. If you are using hardware task switching, you set up a blank TSS for the current task to save its state in to and call LTR on that. You would then have a second TSS for the new task and far jump to the new TSS to initialise it.
Do you have the output of bochsout.txt (or whatever your error log file is called)? That will help no end with trying to debug the problem further.
4) are you doing software or hardware switching? This seems to be a mush of the two (not in a good way).
6) your debugging SUCKS. Have you actually tried to isolate the line that kills your kernel? I assume it's the LTR line but it might not be.
7) The way you ask questions SUCKS. "This is my code, it doesn't work. Why doesn't it work? ?!?!?!!1 fix it 4 mez kthxbai lolz!!!111"
Did you even understand what people have been telling you?
I can almost guess what message bochs's throwing at you. It is the answer to your problem.You do not know your language well enough to be programming operating systems.