OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 12, 2021 6:41 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 67 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: Sun Jun 03, 2007 4:35 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
Better idea: set the virtual mode CS to 0, others to some other value (I used 0x20, as that's my 16-bit data segment in the GDT).

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 03, 2007 4:56 pm 
Offline
Member
Member
User avatar

Joined: Fri Sep 29, 2006 8:59 am
Posts: 397
Hi...

I changed the cs to 0 and all other registers are 0x10 as my data
segment descripotr,but unfortunately I got GPF ,so now
my kernel is 1MB marked,cs=0, all other registers are 0x10.
Also when I set tss[1].eip=0x1000 I get stack fault exception
I think I've tried to fix every possible bug but nothing worked
I'm frustrated but I'll keep going untill I do it.

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 03, 2007 5:52 pm 
Offline
Member
Member

Joined: Sat Dec 30, 2006 2:31 pm
Posts: 729
Location: East Coast, USA
The value for ss0 and esp0 must be valid protected mode values. They will be the values that are used when the processor handles an interrupt and switches to PL0. Try this set eip to 0x1000 and set esp to a value less than 1mb. Also fix the values in ss0 and esp0 to proper protected mode ones. Then see what happens.

_________________
My OS: Fuzzy Logic


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 3:53 am 
Offline
Member
Member
User avatar

Joined: Fri Sep 29, 2006 8:59 am
Posts: 397
Hi...

I changed eip to 0x1000 esp to 0x8000 also ss0 is 0x10
esp0(dword)&PL0_stack, cs is 0 and I got stack fault exception.
Every time I set esp0 to 0x1000 I get stack fault exception
what ever the other values are..

I'm afraid we are missing something so here's the whole picture:
our multitasking consistes of two tasks:main() PL0 and the virtual task()
which is PL0 too.the virtual task is 1MB marked ,cs,ds fs,gs,ss and es are
all zero ,eip =0x1000 ,ss0=0x10,esp0=(dword)&pl0_stack,EFLAGS = 0x23202L
paging is not enabled and I'm usign long call to switch to the selector
of the virtual task.
With all this values I'm getting stack fault exception,but when I change
eip to tss[1].eip=(dword)&task I get general protection fault.

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 11:52 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9289
Location: On the balcony, where I can actually keep 1½m distance
What instruction is causing that stack fault?

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 12:54 pm 
Offline
Member
Member
User avatar

Joined: Fri Sep 29, 2006 8:59 am
Posts: 397
Hi...

Quote:
What instruction is causing that stack fault?


when I point my virtual task to 0x1000
like this :
tss[1].eip=(void *)0x1000
or this:
tss[1].eip=0x1000

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 1:00 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9289
Location: On the balcony, where I can actually keep 1½m distance
That wasn't what I asked. Verbosely: What compiled assembly instruction is executed at what adress with what values in the registers when the processor signals said stack fault.

It can't be tss[1].eip = 0x1000, as no exception is thrown when THAT statement is executed.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 4:04 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
abuashraf wrote:
Hi...

Quote:
What instruction is causing that stack fault?


when I point my virtual task to 0x1000
like this :
tss[1].eip=(void *)0x1000
or this:
tss[1].eip=0x1000

Thanx.


For your faults, you should dump the CPU state before the exception (all the general purpose registers, segment descriptors and CR0-CR3).

For the purposes of debugging your OS, I'd also suggest you print the opcode at the CS:EIP of the exception.

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 5:26 pm 
Offline
Member
Member
User avatar

Joined: Fri Sep 29, 2006 8:59 am
Posts: 397
Hi...

I'm usign QEMU and its mointor but unfortunaely it dosen't have break points
to stop the executing befor the exception the only thing the monitor
could help me by dump cpu register after the exception and take a look
into them.but all that after the exception,I'll get Bochs with debugger
as soon as I can ...
Here's an IMG file,would you please guys debuge it with bochs debugger
and see what's wrong with it,I'm so grateful for your help.
The values with this IMG are:
Code:
for(i;i<max_tasks;i++)
  {
   tss[i].trace=0;
   tss[i].io_map_addr=sizeof(TSS);
   tss[i].ldtr=0;
   if (i) {
   tss[i].fs=tss[i].gs=0;
   tss[i].ds=tss[i].es=tss[i].ss=0x0;
   tss[i].cs=0x0;
   tss[i].eflags=0x23202L;      //0x23202L VM=1 ,IOPL=3, interrupts are enabled
   tss[i].esp=(dword)&task_stack[i];   //points to task() stack top
   tss[i].ss0=0x10;
   tss[i].esp0=(dword)&pl0_stack[i];   //stack for kernel
   }
  }
memcpy( (void*) 0x1000, &task, 1024 );
tss[1].eip=&task;
ltr(0x28);

This IMG will give you general protection fault.

Thanx.


Attachments:
File comment: IMG
a.tar.gz [47.5 KiB]
Downloaded 20 times
Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 04, 2007 5:30 pm 
Offline
Member
Member

Joined: Sun Jan 14, 2007 9:15 pm
Posts: 2566
Location: Sydney, Australia (I come from a land down under!)
The TSS esp field should be under 1 MB mark as well, and aligned to a 4k boundary.

_________________
Pedigree | GitHub | Twitter | LinkedIn


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 1:16 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 21, 2006 5:29 pm
Posts: 275
Location: Brisbane Australia
Firstly read the F**king manual, it tells you what you need to set it up and how to set it up. As I could not be bothered looking up it my self(need to download it again as I it didn't name it correctly when I downloaded it and it's in a folder with names like 123456.pdf, 123465.pdf). If I remember correctly to get into v8086. You have to create a code segment and set the 16bit code flag and also set the base of the descriptor to the base address of the. the segemnt selectors should then be set the processos segements.

_________________
Image
Microsoft: "let everyone run after us. We'll just INNOV~1"


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 2:24 am 
Offline
Member
Member
User avatar

Joined: Fri Sep 29, 2006 8:59 am
Posts: 397
Hi...

Code:
memcpy((void *)0x2000,&task_stak,2048);
tss[1].esp=(dword)0x2000;


Doesn't this mean its 1MB mark and aligned to a 4K boundry?
but I got general protection fault.
And about the Intel manual I've read it for about ten times,

Also I saw that eip and esp don't change whatever I'm doing with them
I pointed esp to become tss[i].esp(dword *)0x2000 and it still 0x10789e0
also eip tss[1].eip=(dword *)0x1000 and it still 0x100fc2,this two fields
never changed.

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 2:55 am 
Offline
Member
Member

Joined: Mon Apr 09, 2007 12:10 pm
Posts: 775
Location: London, UK
abuashraf wrote:
I'll get Bochs with debugger
as soon as I can ...


As I said before, if you download the win32 installers from the bochs site (which you've said you did) then you get both bochs.exe and bochsdbg.exe in the bochs directory. If you run bochsdbg, you'll find that it is a bochs with debugging enabled.

John.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 9:01 am 
Offline
Member
Member
User avatar

Joined: Fri Sep 29, 2006 8:59 am
Posts: 397
i...
Okay now I'm using Bochsdbg.exe and I've been debugging my kernel
for more than two houres.
This values have never been changed what ever I do with code

EFLAGS=0x3002 eip=0x100fc2 esp=0x107830,cs=0x8
fs,gs,ds,ss are all 0x10

Also here's my init_task would you please take a look at it:

Code:
void init_task()
{
disable();
memcpy( (void *) 0x2000,(dword)&task_stack, 2048 );
unsigned int i=0;
for(i;i<max_tasks;i++)
  {
   tss[i].trace=0;
   tss[i].io_map_addr=sizeof(TSS);
   tss[i].ldtr=0;
   tss[i].fs=tss[i].gs=0;
   tss[i].ds=tss[i].es=tss[i].ss=0x0;
   tss[i].cs=0x0;
   tss[i].eflags=0x23202L;      //0x23202L VM=1 ,IOPL=3
   tss[i].esp=(dword *)0x2000;      
   tss[i].ss0=0x10;
   tss[i].esp0=(dword)&pl0_stack[i];   //stack for kernel
  }
memcpy( (void*) 0x1000, (dword)&task, 1024 );
//tss[1].eip=&task;
tss[1].eip=(dword *)0x1000;
ltr(0x28);
enable();
}


what's wrong with my code.... :?: :?: :?: :?:

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 9:20 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9289
Location: On the balcony, where I can actually keep 1½m distance
Once again,
Quote:
For your faults, you should dump the CPU state before the exception (all the general purpose registers, segment descriptors and CR0-CR3).

For the purposes of debugging your OS, I'd also suggest you print the opcode at the CS:EIP of the exception.
Until we got that information we can at best only guess what is going on.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 67 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group