Page 1 of 1

strange problem

Posted: Thu Feb 25, 2010 7:49 am
by shindow
hello,everybody,i am so confused about my procedure,i really don't know what it is on earth going on

there are 2 files,page.s and manager.c .And i think there are totally not any connection between them,and i think the c functio is okay,if we drop the c code,the os will be okay.
When i add function Allocate,errors ocurrs.....AllocateTmp function is not implemented yet.It is like this:

Code: Select all

u32 AllocateTmp(u32 size)						
{
	int num,page;
	u32 address=0;
	if(size<PAGE){
		num=1;
	}
	else if((size%PAGE)!=0){
		num=size/PAGE+1;
	}
	else
		num=size/PAGE;
	return address;
}
Error is like this:

Code: Select all

00030776996i[CPU0 ] CPU is in protected mode (active)
00030776996i[CPU0 ] CS.d_b = 32 bit
00030776996i[CPU0 ] SS.d_b = 32 bit
00030776996i[CPU0 ] | EAX=00181007  EBX=00001604  ECX=00000000  EDX=00022f00
00030776996i[CPU0 ] | ESP=00022fd0  EBP=00022fd0  ESI=00021b11  EDI=00000410
00030776996i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df IF tf sf zf af pf cf
00030776996i[CPU0 ] | SEG selector     base    limit G D
00030776996i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00030776996i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 0 1
00030776996i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 0 1
00030776996i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 0 1
00030776996i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 0 1
00030776996i[CPU0 ] |  FS:4020( 0005| 0|  0) 00040200 0000ffff 0 0
00030776996i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00030776996i[CPU0 ] | EIP=0002196c (0002196c)
00030776996i[CPU0 ] | CR0=0x60000011 CR1=0 CR2=0x00000000
00030776996i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
(0).[30776996] [0x0002196c] 0008:0002196c (unk. ctxt): cmp ebx, 0x00005000       ; 81fb00500000
00030776996e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00030776996i[SYS  ] bx_pc_system_c::Reset(SOFTWARE) called
00030776996i[CPU0 ] cpu software reset
00030776996i[APIC0] local apic in CPU 0 initializing
00030776996i[CPU0 ] CPU[0] is the bootstrap processor
and i debug the code,the error is at page.s ,in the loop of L3 .Actually,i think the code is okay,i really don't know what is going on

Code: Select all

setup_page:				;一共1个PDE,4个PTE
	push ebp
	mov ebp,esp
	xor ecx,ecx
	
	mov eax,0			;把一共1个PDE,4个PTE清零
	mov ebx,0
	mov cx,5120
L1:	
	mov dword [ebx],eax
	add ebx,4
	dec cx
	cmp cx,0
	jnz L1

	mov ebx,0			;set  page directory
	mov eax,0x1007
	mov cx,4
L2:					
	mov dword [ebx],eax	
	add ebx,4
	add eax,0x1000
	dec cx
	cmp cx,0
	jnz L2			
	
	mov eax,0x7			;set page table
	mov ebx,0x1000
L3:					
	mov dword [ebx],eax	
	add ebx,4
	add eax,0x1000
	cmp ebx,0x5000
	jnz L3	
	pop ebp
	ret

Re: strange problem

Posted: Thu Feb 25, 2010 7:57 am
by thepowersgang
1. Please use the code tag, it makes life so much easier.
2. I see you are using bochs, good job. Now, try using the builtin debugger and singlestepping through your code until you get to the error and see what happens.

Re: strange problem

Posted: Thu Feb 25, 2010 9:31 am
by shindow
thank you. I have used builtin debugger and singlestepping and for a long time. And more stange thing happens,if the data(and code) in the .img file have more than 24 sectors, error happens, like this:

Code: Select all

00030776996i[CPU0 ] CPU is in protected mode (active)
00030776996i[CPU0 ] CS.d_b = 32 bit
00030776996i[CPU0 ] SS.d_b = 32 bit
00030776996i[CPU0 ] | EAX=00181007 EBX=00001604 ECX=00000000 EDX=00022f00
00030776996i[CPU0 ] | ESP=00022fd0 EBP=00022fd0 ESI=00021b11 EDI=00000410
00030776996i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df IF tf sf zf af pf cf
00030776996i[CPU0 ] | SEG selector base limit G D
00030776996i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00030776996i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 0 1
00030776996i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 0 1
00030776996i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 0 1
00030776996i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 000fffff 0 1
00030776996i[CPU0 ] | FS:4020( 0005| 0| 0) 00040200 0000ffff 0 0
00030776996i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00030776996i[CPU0 ] | EIP=0002196c (0002196c)
00030776996i[CPU0 ] | CR0=0x60000011 CR1=0 CR2=0x00000000
00030776996i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
(0).[30776996] [0x0002196c] 0008:0002196c (unk. ctxt): cmp ebx, 0x00005000 ; 81fb00500000
00030776996e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00030776996i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
00030776996i[CPU0 ] cpu software reset
00030776996i[APIC0] local apic in CPU 0 initializing
00030776996i[CPU0 ] CPU[0] is the bootstrap processor
if i don't use the paging mechanism, no errors

Re: strange problem

Posted: Thu Feb 25, 2010 12:17 pm
by Combuster
Looks like an interrupt messing things up. Is bochs reporting any errors before this dump? (any line starting with a number followed by an e)

Also, use code tags and don't use colours.