strange problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
shindow
Member
Member
Posts: 26
Joined: Thu Feb 25, 2010 7:35 am

strange problem

Post 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
Last edited by quok on Thu Feb 25, 2010 2:11 pm, edited 1 time in total.
Reason: Sigh, yet another person that doesn't use [code][/code] tags... fixed.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: strange problem

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
shindow
Member
Member
Posts: 26
Joined: Thu Feb 25, 2010 7:35 am

Re: strange problem

Post 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
Last edited by quok on Thu Feb 25, 2010 2:12 pm, edited 1 time in total.
Reason: Removed color tags (don't use colors, it's against forum rules!) and put in [code][/code] tags. Next time the post gets deleted!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: strange problem

Post 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.
"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 ]
Post Reply