flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Fail RETing

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
Code:
00000000000i[APIC?] local apic in  initializing
========================================================================
                       Bochs x86 Emulator 2.3.5
            Build from CVS snapshot, on September 16, 2007
========================================================================
00000000000i[     ] reading configuration from main.bxrc
00000000000i[     ] installing win32 module as the Bochs GUI
00000000000i[     ] using log file bochsout.txt
Next at t=0
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
<bochs:1> b 0x1006eb
<bochs:2> c
(0) Breakpoint 1, 0x00000000001006eb in ?? ()
Next at t=10375114
(0) [0x001006eb] 0008:00000000001006eb (unk. ctxt): mov ebx, 0xfffffc01       ;
bb01fcffff
<bochs:3> r
rax: 0x00000000:c0000000 rcx: 0x00000000:00000001
rdx: 0x00000000:0000cea0 rbx: 0x00000000:00000c00
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:001006eb
eflags 0x00000012
IOPL=0 id vip vif ac vm rf nt of df if tf sf zf AF pf cf
<bochs:4> print-stack
Stack address size 4
 | STACK 0x0009ffd4 [0x00000002]
 | STACK 0x0009ffd8 [0x001007fb]
 | STACK 0x0009ffdc [0x00000008]
 | STACK 0x0009ffe0 [0x00010012]
 | STACK 0x0009ffe4 [0x00100530]
 | STACK 0x0009ffe8 [0x00000000]
 | STACK 0x0009ffec [0x00000001]
 | STACK 0x0009fff0 [0xc0000000]
 | STACK 0x0009fff4 [0x00000011]
 | STACK 0x0009fff8 [0xc0000101]
 | STACK 0x0009fffc [0x00100512]
 | STACK 0x000a0000 [0xffffffff]
 | STACK 0x000a0004 [0xffffffff]
 | STACK 0x000a0008 [0xffffffff]
 | STACK 0x000a000c [0xffffffff]
 | STACK 0x000a0010 [0xffffffff]
<bochs:5> s
Next at t=10375115
(0) [0x001006f0] 0008:00000000001006f0 (unk. ctxt): test byte ptr ds:[ebx+0x7c00
], 0xff ; f683007c0000ff
<bochs:6> r
rax: 0x00000000:c0000000 rcx: 0x00000000:00000001
rdx: 0x00000000:0000cea0 rbx: 0x00000000:fffffc01
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:001006f0
eflags 0x00000012
IOPL=0 id vip vif ac vm rf nt of df if tf sf zf AF pf cf
<bochs:7> s
Next at t=10375116
(0) [0x001006f7] 0008:00000000001006f7 (unk. ctxt): jnz .+0x00000005 (0x001006fe
) ; 7505
<bochs:8> r
rax: 0x00000000:c0000000 rcx: 0x00000000:00000001
rdx: 0x00000000:0000cea0 rbx: 0x00000000:fffffc01
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:001006f7
eflags 0x00000002
IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af pf cf
<bochs:9> s
Next at t=10375117
(0) [0x001006fe] 0008:00000000001006fe (unk. ctxt): mov byte ptr ds:[ebx+0x7c00]
, 0x00 ; c683007c000000
<bochs:10> r
rax: 0x00000000:c0000000 rcx: 0x00000000:00000001
rdx: 0x00000000:0000cea0 rbx: 0x00000000:fffffc01
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:001006fe
eflags 0x00000002
IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af pf cf
<bochs:11> s
Next at t=10375118
(0) [0x00100705] 0008:0000000000100705 (unk. ctxt): shr eax, 0x16             ;
c1e816
<bochs:12> r
rax: 0x00000000:c0000000 rcx: 0x00000000:00000001
rdx: 0x00000000:0000cea0 rbx: 0x00000000:fffffc01
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:00100705
eflags 0x00000002
IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af pf cf
<bochs:13> s
Next at t=10375119
(0) [0x00100708] 0008:0000000000100708 (unk. ctxt): mov edx, cr3              ;
0f20da
<bochs:14> r
rax: 0x00000000:00000300 rcx: 0x00000000:00000001
rdx: 0x00000000:0000cea0 rbx: 0x00000000:fffffc01
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:00100708
eflags 0x00000806
IOPL=0 id vip vif ac vm rf nt OF df if tf sf zf af PF cf
<bochs:15> s
Next at t=10375120
(0) [0x0010070b] 0008:000000000010070b (unk. ctxt): shl ebx, 0x16             ;
c1e316
<bochs:16> r
rax: 0x00000000:00000300 rcx: 0x00000000:00000001
rdx: 0x00000000:00300000 rbx: 0x00000000:fffffc01
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:0010070b
eflags 0x00000806
IOPL=0 id vip vif ac vm rf nt OF df if tf sf zf af PF cf
<bochs:17> s
Next at t=10375121
(0) [0x0010070e] 0008:000000000010070e (unk. ctxt): mov bl, 0x87              ;
b387
<bochs:18> r
rax: 0x00000000:00000300 rcx: 0x00000000:00000001
rdx: 0x00000000:00300000 rbx: 0x00000000:00400000
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:0010070e
eflags 0x00000807
IOPL=0 id vip vif ac vm rf nt OF df if tf sf zf af PF CF
<bochs:19> print-stack
Stack address size 4
 | STACK 0x0009ffd4 [0x00000002]
 | STACK 0x0009ffd8 [0x001007fb]
 | STACK 0x0009ffdc [0x00000008]
 | STACK 0x0009ffe0 [0x00010012]
 | STACK 0x0009ffe4 [0x00100530]
 | STACK 0x0009ffe8 [0x00000000]
 | STACK 0x0009ffec [0x00000001]
 | STACK 0x0009fff0 [0xc0000000]
 | STACK 0x0009fff4 [0x00000011]
 | STACK 0x0009fff8 [0xc0000101]
 | STACK 0x0009fffc [0x00100512]
 | STACK 0x000a0000 [0xffffffff]
 | STACK 0x000a0004 [0xffffffff]
 | STACK 0x000a0008 [0xffffffff]
 | STACK 0x000a000c [0xffffffff]
 | STACK 0x000a0010 [0xffffffff]
<bochs:20> s
Next at t=10375122
(0) [0x00100710] 0008:0000000000100710 (unk. ctxt): mov dword ptr ds:[edx+eax*4]
, ebx ; 891c82
<bochs:21> r
rax: 0x00000000:00000300 rcx: 0x00000000:00000001
rdx: 0x00000000:00300000 rbx: 0x00000000:00400087
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:00100710
eflags 0x00000807
IOPL=0 id vip vif ac vm rf nt OF df if tf sf zf af PF CF
<bochs:22> print-stack
Stack address size 4
 | STACK 0x0009ffd4 [0x00000002]
 | STACK 0x0009ffd8 [0x001007fb]
 | STACK 0x0009ffdc [0x00000008]
 | STACK 0x0009ffe0 [0x00010012]
 | STACK 0x0009ffe4 [0x00100530]
 | STACK 0x0009ffe8 [0x00000000]
 | STACK 0x0009ffec [0x00000001]
 | STACK 0x0009fff0 [0xc0000000]
 | STACK 0x0009fff4 [0x00000011]
 | STACK 0x0009fff8 [0xc0000101]
 | STACK 0x0009fffc [0x00100512]
 | STACK 0x000a0000 [0xffffffff]
 | STACK 0x000a0004 [0xffffffff]
 | STACK 0x000a0008 [0xffffffff]
 | STACK 0x000a000c [0xffffffff]
 | STACK 0x000a0010 [0xffffffff]
<bochs:23> s
Next at t=10375123
(0) [0x00100713] 0008:0000000000100713 (unk. ctxt): iretd                     ;
cf
<bochs:24> r
rax: 0x00000000:00000300 rcx: 0x00000000:00000001
rdx: 0x00000000:00300000 rbx: 0x00000000:00400087
rsp: 0x00000000:0009ffd4 rbp: 0x00000000:00000000
rsi: 0x00000000:00100c30 rdi: 0x00000000:c0000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:00100713
eflags 0x00000807
IOPL=0 id vip vif ac vm rf nt OF df if tf sf zf af PF CF
<bochs:25> print-stack
Stack address size 4
 | STACK 0x0009ffd4 [0x00000002]
 | STACK 0x0009ffd8 [0x001007fb]
 | STACK 0x0009ffdc [0x00000008]
 | STACK 0x0009ffe0 [0x00010012]
 | STACK 0x0009ffe4 [0x00100530]
 | STACK 0x0009ffe8 [0x00000000]
 | STACK 0x0009ffec [0x00000001]
 | STACK 0x0009fff0 [0xc0000000]
 | STACK 0x0009fff4 [0x00000011]
 | STACK 0x0009fff8 [0xc0000101]
 | STACK 0x0009fffc [0x00100512]
 | STACK 0x000a0000 [0xffffffff]
 | STACK 0x000a0004 [0xffffffff]
 | STACK 0x000a0008 [0xffffffff]
 | STACK 0x000a000c [0xffffffff]
 | STACK 0x000a0010 [0xffffffff]
<bochs:26> s
Next at t=10375123
(0) [0x00100713] 0008:100713 (unk. ctxt): iretd                     ; cf
<bochs:27> r
rax: 0x00000000:00000000 rcx: 0x00000000:00000000
rdx: 0x00000000:00000f20 rbx: 0x00000000:00000000
rsp: 0x00000000:00000000 rbp: 0x00000000:00000000
rsi: 0x00000000:00000000 rdi: 0x00000000:00000000
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:0000fff0
eflags 0x00000002
IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af pf cf
<bochs:28> print-stack
Stack address size 2
 | STACK 0x0000 [0xff53]
 | STACK 0x0002 [0xf000]
 | STACK 0x0004 [0xff53]
 | STACK 0x0006 [0xf000]
 | STACK 0x0008 [0xff53]
 | STACK 0x000a [0xf000]
 | STACK 0x000c [0xff53]
 | STACK 0x000e [0xf000]
 | STACK 0x0010 [0xff53]
 | STACK 0x0012 [0xf000]
 | STACK 0x0014 [0xff53]
 | STACK 0x0016 [0xf000]
 | STACK 0x0018 [0xff53]
 | STACK 0x001a [0xf000]
 | STACK 0x001c [0xff53]
 | STACK 0x001e [0xf000]
<bochs:29>    

Code:
00010375123e[CPU0 ] fetch_raw_descriptor: GDT: index (7ff)ff > limit (30)
00010375123i[CPU0 ] protected mode
00010375123i[CPU0 ] CS.d_b = 32 bit
00010375123i[CPU0 ] SS.d_b = 32 bit
00010375123i[CPU0 ] EFER   = 0x00000000
00010375123i[CPU0 ] | RAX=0000000000000300  RBX=0000000000400087
00010375123i[CPU0 ] | RCX=0000000000000001  RDX=0000000000300000
00010375123i[CPU0 ] | RSP=000000000009ffd4  RBP=0000000000000000
00010375123i[CPU0 ] | RSI=0000000000100c30  RDI=00000000c0000000
00010375123i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00010375123i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00010375123i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00010375123i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00010375123i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt OF df if tf sf zf af PF CF
00010375123i[CPU0 ] | SEG selector     base    limit G D
00010375123i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00010375123i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00010375123i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00010375123i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00010375123i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 1 1
00010375123i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00010375123i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00010375123i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00010375123i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00010375123i[CPU0 ] | RIP=0000000000100713 (0000000000100713)
00010375123i[CPU0 ] | CR0=0x80000011 CR1=0x0 CR2=0x00000000c0000000
00010375123i[CPU0 ] | CR3=0x00300000 CR4=0x00000010
00010375123i[CPU0 ] >> iretd  : CF
00010375123e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00010375123i[SYS  ] bx_pc_system_c::Reset(SOFTWARE) called
00010375123i[APIC0] local apic in CPU 0 initializing
00010375123e[CPU0 ] CPU_LOOP bx_guard.interrupt_requested=1    

(I disabled some interrupt to get a triple fault so some message get clearer)
Post 01 Oct 2015, 14:38
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
Code:
Code:
int_page: 
        mov eax, cr2
        mov ebx, 1-0x400
.lp:    test [ebx+0x7c00], byte 0xff
        jnz .ok
        inc ebx
        jnz .lp
        jmp int_fault
.ok:    mov [ebx+0x7c00], byte 0x00
        shr eax, 22
        mov edx, cr3
        shl ebx, 22
        mov bl, 10000111b
        mov [edx+eax*4], ebx
        iret    
(INT 14)
Post 01 Oct 2015, 14:42
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
macro reach ptr { db (ptr)-$ dup 0 }
sti equ cli
macro debug x {
;mov [0xb8000+160], byte x
}
macro displayint y {
local x
x = y
if x < 0
x = -x
display '-'
end if
irp t,10000000000000000000,1000000000000000000,100000000000000000,10000000000000000,1000000000000000,100000000000000,10000000000000,1000000000000,100000000000,10000000000,1000000000,100000000,10000000,1000000,100000,10000,1000,100,10 \{
if x >= t
display (x/t) mod 10 + 48
end if
\}
display x mod 10 + 48
}
disknum equ 0x7e00
org 0x7c00
boot: cli
lgdt [0x7df8]
lidt [segs]
mov eax, cr0
inc ax
mov cr0, eax
jmp pword 8:.main
use32
.main: mov ax, 16
mov ds, ax
mov es, ax
mov ss, ax
mov esp, 0xa0000
;Paging
mov eax, cr4
or al, 16 ;PSE
mov cr4, eax
;Clear 0x300000 - 0x3fffff
xor eax, eax
mov ecx, 0x40000
mov edi, 0x300000
cld
rep stosd

mov eax, 0x00300000 ;In: Nothing
mov dword [eax], 10000011b
mov cr3, eax
;TSS
mov [TSS+4], esp
mov eax, ss
mov [TSS+8], eax
mov ax, 40
ltr ax
;Paging
mov eax, cr0
bts eax, 31
mov cr0, eax
mov [0xc0000001], byte 7
jmp $

align 8
intCount = (idtend-idt)/8
macro newidt p, t {
if p eq int_fault
dq 0
else
dq ((p)*$1'0000'0001)and $ffff'0000'0000'ffff or ((t) shl 32) or $80000
end if
}
.gTask equ 0x8d00
.gInt equ 0x8e00
.gInt3 equ 0xee00
.gTrap equ 0x8f00
intb:
idt: newidt int_fault, .gInt ;Divide error
newidt int_fault, .gInt ;Single-step/debug exception
newidt int_fault, .gInt ;Nonmaskable interrupt
newidt int_fault, .gInt ;Breakpoint
newidt int_fault, .gInt ;Overflow
newidt int_fault, .gInt ;Bounds check (BOUND instruction)
newidt int_fault, .gInt ;Invalid opcode
newidt int_fault, .gInt ;Coprocessor not available
newidt int_fault, .gInt ;Double fault
newidt int_fault, .gInt ;Coprocessor segment overrun
newidt int_fault, .gInt ;Invalid TSS
newidt int_fault, .gInt ;Segment not present
newidt int_fault, .gInt ;Stack exception
newidt int_fault, .gInt ;General protection violation
newidt int_page, .gInt ;Page fault
idtend:
int_page: ;jmp $
int_fault:
int_clock:
int_keyboard:
int_mouse:
int_unused:
int_user:
iret

reach 0x7dfe - (segsend-segs)
segs: dw 8*intCount
dd intb
dw 0
dw 0ffffh,0 ; 4Gbytes, start at linear 0
db 0,10011010b,11001111b,0 ; granularity = 64Kbytes, code segment, ring 0, read only,etc...
dw 0ffffh,0 ; 4Gbytes, start at linear 0
db 0,10010010b,11001111b,0 ; granularity = 64Kbytes, data segment, ring 0, read/write,etc...
dw 0ffffh,0 ; 4Gbytes, start at linear 0
db 0,11111010b,11001111b,0 ; granularity = 64Kbytes, code segment, ring 3, read only,etc...
dw 0ffffh,0 ; 4Gbytes, start at linear 0
db 0,11110010b,11001111b,0 ; granularity = 64Kbytes, data segment, ring 3, read/write,etc...
TSS = 0x8000-104
dw 104,TSS
db 0, 1'11'01001b,00000000b,0 ; TSS
dw (segsend-segs)-6
dd segs
segsend:
dw 0xaa55
org 0x100200

use32
starting:
Post 01 Oct 2015, 14:48
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.