Bochs keeps reseting when calling C++ code.

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
yByonic
Posts: 13
Joined: Mon Aug 24, 2020 2:25 pm

Bochs keeps reseting when calling C++ code.

Post by yByonic »

Hello everybody. I'm following a youtube tutorial on how to make an operating system and I came across an error that I'm not getting over. Basically, I have a bootloader that starts a program outside of the first bootsector (ExtendedProgram.asm). This activates protected mode and then long mode. Then, as shown in the code below, I call a function written in c++. The problem is that when I make the call and start Bochs (if I remove the "call _start" line, the program runs normally), it alternates between a black and blue window and the console is spammed with messages (shown below).
Does anyone know how to fix the problem?
Thanks in advance.

The Tutorial Series: https://www.youtube.com/watch?v=-v6uRjp ... nel=Poncho

Code: Select all

...
[bits 64]
[extern _start]

Start64Bit:
    mov edi, 0xb8000
    mov rax, 0x1f201f201f201f20
    mov ecx, 500
    rep stosq
    ;call _start
    jmp $
...

Code: Select all

extern "C" void _start(){
    return;
}
bochsrc.bxrc
00000000000i[ ] installing win32 module as the Bochs GUI
00000000000i[ ] Bochs x86 Emulator 2.6.11
00000000000i[ ] Built from SVN snapshot on January 5, 2020
00000000000i[ ] Timestamp: Sun Jan 5 08:36:00 CET 2020
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] IPS is set to 4000000
00000000000i[ ] CPU configuration
00000000000i[ ] SMP support: no
00000000000i[ ] level: 6
00000000000i[ ] APIC support: xapic
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] 3dnow! support: no
00000000000i[ ] SEP support: yes
00000000000i[ ] SIMD support: sse2
00000000000i[ ] XSAVE support: no
00000000000i[ ] AES support: no
00000000000i[ ] SHA support: no
00000000000i[ ] MOVBE support: no
00000000000i[ ] ADX support: no
00000000000i[ ] x86-64 support: yes
00000000000i[ ] 1G paging support: no
00000000000i[ ] MWAIT support: yes
00000000000i[ ] VMX support: 1
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: yes
00000000000i[ ] Fast function calls: yes
00000000000i[ ] Handlers Chaining speedups: yes
00000000000i[ ] Devices configuration
00000000000i[ ] PCI support: i440FX i430FX i440BX
00000000000i[ ] Networking support: NE2000 E1000
00000000000i[ ] Sound support: SB16 ES1370
00000000000i[ ] USB support: UHCI OHCI EHCI xHCI
00000000000i[ ] VGA extension support: vbe cirrus voodoo
00000000000i[MEM0 ] allocated memory at 000001AC04575040. after alignment, vector=000001AC04576000
00000000000i[MEM0 ] 32,00MB
00000000000i[MEM0 ] mem block size = 0x00020000, blocks=256
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('C:\Program Files\Bochs-2.6.11/BIOS-bochs-latest')
00000000000i[PLUGIN] init_dev of 'pci' plugin device by virtual method
00000000000i[DEV ] i440FX PMC present at device 0, function 0
00000000000i[PLUGIN] init_dev of 'pci2isa' plugin device by virtual method
00000000000i[DEV ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[PLUGIN] init_dev of 'cmos' plugin device by virtual method
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Tue Jul 20 20:08:11 2021 (time0=1626808091)
00000000000i[PLUGIN] init_dev of 'dma' plugin device by virtual method
00000000000i[DMA ] channel 4 used by cascade
00000000000i[PLUGIN] init_dev of 'pic' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'pit' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'vga' plugin device by virtual method
00000000000i[MEM0 ] Register memory access handlers: 0x0000000a0000 - 0x0000000bffff
00000000000i[VGA ] interval=200000, mode=realtime
00000000000i[VGA ] VSYNC using standard mode
00000000000i[MEM0 ] Register memory access handlers: 0x0000e0000000 - 0x0000e0ffffff
00000000000i[BXVGA ] VBE Bochs Display Extension Enabled
00000000000i[WINGUI] Desktop Window dimensions: 1920 x 1080
00000000000i[WINGUI] Number of Mouse Buttons = 5
00000000000i[WINGUI] IME disabled
00000000000i[MEM0 ] rom at 0xc0000/41984 ('C:\Program Files\Bochs-2.6.11/VGABIOS-lgpl-latest')
00000000000i[PLUGIN] init_dev of 'floppy' plugin device by virtual method
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[FLOPPY] fd0: 'C:\Users\ybyon\OneDrive\Ambiente de Trabalho\Ficheiros\Projetos\bos\src\bootloader.flp' ro=0, h=2,t=80,spt=15
00000000000i[FLOPPY] Using boot sequence floppy, none, none
00000000000i[FLOPPY] Floppy boot signature check is enabled
00000000000i[PLUGIN] init_dev of 'acpi' plugin device by virtual method
00000000000i[DEV ] ACPI Controller present at device 1, function 3
00000000000i[PLUGIN] init_dev of 'hpet' plugin device by virtual method
00000000000i[HPET ] initializing HPET
00000000000i[MEM0 ] Register memory access handlers: 0x0000fed00000 - 0x0000fed003ff
00000000000i[PLUGIN] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAPIC] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0x0000fec00000 - 0x0000fec00fff
00000000000i[IOAPIC] IOAPIC enabled (base address = 0xfec00000)
00000000000i[PLUGIN] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 400 keyboard ticks
00000000000i[PLUGIN] init_dev of 'harddrv' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'pci_ide' plugin device by virtual method
00000000000i[DEV ] PIIX3 PCI IDE controller present at device 1, function 1
00000000000i[PLUGIN] init_dev of 'unmapped' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'biosdev' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'speaker' plugin device by virtual method
00000000000i[PCSPK ] Using lowlevel sound support for output
00000000000i[PLUGIN] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[PLUGIN] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4 (mode: null)
00000000000i[PLUGIN] init_dev of 'gameport' plugin device by virtual method
00000000000i[PLUGIN] init_dev of 'usb_uhci' plugin device by virtual method
00000000000i[DEV ] USB UHCI present at device 1, function 2
00000000000i[UHCI ] USB UHCI initialized
00000000000i[PLUGIN] register state of 'pci' plugin device by virtual method
00000000000i[PLUGIN] register state of 'pci2isa' plugin device by virtual method
00000000000i[PLUGIN] register state of 'cmos' plugin device by virtual method
00000000000i[PLUGIN] register state of 'dma' plugin device by virtual method
00000000000i[PLUGIN] register state of 'pic' plugin device by virtual method
00000000000i[PLUGIN] register state of 'pit' plugin device by virtual method
00000000000i[PLUGIN] register state of 'vga' plugin device by virtual method
00000000000i[PLUGIN] register state of 'floppy' plugin device by virtual method
00000000000i[PLUGIN] register state of 'unmapped' plugin device by virtual method
00000000000i[PLUGIN] register state of 'biosdev' plugin device by virtual method
00000000000i[PLUGIN] register state of 'speaker' plugin device by virtual method
00000000000i[PLUGIN] register state of 'extfpuirq' plugin device by virtual method
00000000000i[PLUGIN] register state of 'parallel' plugin device by virtual method
00000000000i[PLUGIN] register state of 'serial' plugin device by virtual method
00000000000i[PLUGIN] register state of 'gameport' plugin device by virtual method
00000000000i[PLUGIN] register state of 'usb_uhci' plugin device by virtual method
00000000000i[PLUGIN] register state of 'acpi' plugin device by virtual method
00000000000i[PLUGIN] register state of 'hpet' plugin device by virtual method
00000000000i[PLUGIN] register state of 'ioapic' plugin device by virtual method
00000000000i[PLUGIN] register state of 'keyboard' plugin device by virtual method
00000000000i[PLUGIN] register state of 'harddrv' plugin device by virtual method
00000000000i[PLUGIN] register state of 'pci_ide' plugin device by virtual method
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0 ] allocate APIC id=0 (MMIO enabled) to 0x0000fee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 00000005 756e6547 6c65746e 49656e69
00000000000i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00002028 1fcbfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000005]: 00000040 00000040 00000003 00000020
00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100000
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00000000000i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00000000000i[CPU0 ] CPU Features supported:
00000000000i[CPU0 ] x87
00000000000i[CPU0 ] 486ni
00000000000i[CPU0 ] pentium_ni
00000000000i[CPU0 ] p6ni
00000000000i[CPU0 ] mmx
00000000000i[CPU0 ] debugext
00000000000i[CPU0 ] vme
00000000000i[CPU0 ] pse
00000000000i[CPU0 ] pae
00000000000i[CPU0 ] pge
00000000000i[CPU0 ] pse36
00000000000i[CPU0 ] mtrr
00000000000i[CPU0 ] pat
00000000000i[CPU0 ] sysenter_sysexit
00000000000i[CPU0 ] clflush
00000000000i[CPU0 ] sse
00000000000i[CPU0 ] sse2
00000000000i[CPU0 ] mwait
00000000000i[CPU0 ] vmx
00000000000i[CPU0 ] longmode
00000000000i[CPU0 ] lm_lahf_sahf
00000000000i[CPU0 ] nx
00000000000i[CPU0 ] cmpxhg16b
00000000000i[CPU0 ] rdtscp
00000000000i[CPU0 ] ffxsr
00000000000i[CPU0 ] xapic
00000000000i[PLUGIN] reset of 'pci' plugin device by virtual method
00000000000i[PLUGIN] reset of 'pci2isa' plugin device by virtual method
00000000000i[PLUGIN] reset of 'cmos' plugin device by virtual method
00000000000i[PLUGIN] reset of 'dma' plugin device by virtual method
00000000000i[PLUGIN] reset of 'pic' plugin device by virtual method
00000000000i[PLUGIN] reset of 'pit' plugin device by virtual method
00000000000i[PLUGIN] reset of 'vga' plugin device by virtual method
00000000000i[PLUGIN] reset of 'floppy' plugin device by virtual method
00000000000i[PLUGIN] reset of 'acpi' plugin device by virtual method
00000000000i[PLUGIN] reset of 'hpet' plugin device by virtual method
00000000000i[PLUGIN] reset of 'ioapic' plugin device by virtual method
00000000000i[PLUGIN] reset of 'keyboard' plugin device by virtual method
00000000000i[PLUGIN] reset of 'harddrv' plugin device by virtual method
00000000000i[PLUGIN] reset of 'pci_ide' plugin device by virtual method
00000000000i[PLUGIN] reset of 'unmapped' plugin device by virtual method
00000000000i[PLUGIN] reset of 'biosdev' plugin device by virtual method
00000000000i[PLUGIN] reset of 'speaker' plugin device by virtual method
00000000000i[PLUGIN] reset of 'extfpuirq' plugin device by virtual method
00000000000i[PLUGIN] reset of 'parallel' plugin device by virtual method
00000000000i[PLUGIN] reset of 'serial' plugin device by virtual method
00000000000i[PLUGIN] reset of 'gameport' plugin device by virtual method
00000000000i[PLUGIN] reset of 'usb_uhci' plugin device by virtual method
00000004635i[BIOS ] $Revision: 13752 $ $Date: 2019-12-30 14:16:18 +0100 (Mon, 30 Dec 2019) $
00000318039i[KBD ] reset-disable command received
00000320741i[BIOS ] Starting rombios32
00000321184i[BIOS ] Shutdown flag 0
00000321754i[BIOS ] ram_size=0x02000000
00000322211i[BIOS ] ram_end=32MB
00000620324i[WINGUI] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8
00001131361i[BIOS ] Found 1 cpu(s)
00001145003i[BIOS ] bios_table_addr: 0x000f9db8 end=0x000fcc00
00001472003i[PCI ] i440FX PMC write to PAM register 59 (TLB Flush)
00001800818i[P2ISA ] PCI IRQ routing: PIRQA# set to 0x0b
00001800844i[P2ISA ] PCI IRQ routing: PIRQB# set to 0x09
00001800844i[P2ISA ] PCI IRQ routing: PIRQC# set to 0x0b
00001800844i[P2ISA ] PCI IRQ routing: PIRQD# set to 0x09
00001800844i[P2ISA ] write: ELCR2 = 0x0a
00001801531i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
00001815008i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
00001817311i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
00001819463i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
00001820019i[PIDE ] BAR #4: i/o base address = 0xc000
00001820559i[BIOS ] region 4: 0x0000c000
00001822356i[BIOS ] PCI: bus=0 devfn=0x0a: vendor_id=0x8086 device_id=0x7020 class=0x0c03
00001822874i[UHCI ] BAR #4: i/o base address = 0xc020
00001823430i[BIOS ] region 4: 0x0000c020
00001823663i[UHCI ] new IRQ line = 9
00001825241i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
00001825599i[ACPI ] new IRQ line = 11
00001825839i[ACPI ] new IRQ line = 9
00001825860i[ACPI ] new PM base address: 0xb000
00001825860i[ACPI ] new SM base address: 0xb100
00001825892i[PCI ] setting SMRAM control register to 0x4a
00001990012i[CPU0 ] Enter to System Management Mode
00001990012i[CPU0 ] enter_system_management_mode: temporary disable VMX while in SMM mode
00001990016i[CPU0 ] RSM: Resuming from System Management Mode
00002154038i[PCI ] setting SMRAM control register to 0x0a
00002180453i[BIOS ] MP table addr=0x000f9e90 MPC table addr=0x000f9dc0 size=0xc8
00002182484i[BIOS ] SMBIOS table addr=0x000f9ea0
00002184460i[BIOS ] ACPI tables: RSDP addr=0x000f9fd0 ACPI DATA addr=0x01ff0000 size=0xff8
00002188002i[BIOS ] Firmware waking vector 0x1ff00cc
00002190524i[PCI ] i440FX PMC write to PAM register 59 (TLB Flush)
00002191105i[BIOS ] bios_table_cur_addr: 0x000f9ff4
00002320118i[VBIOS ] VGABios $Id: vgabios.c 226 2020-01-02 21:36:23Z vruppert $
00002320201i[BXVGA ] VBE known Display Interface b0c0
00002320220i[BXVGA ] VBE known Display Interface b0c5
00002322864i[VBIOS ] VBE Bios $Id: vbe.c 228 2020-01-02 23:09:02Z vruppert $
00014927801i[BIOS ] Booting from 0000:7c00
00015273179e[CPU0 ] access_read_linear(): canonical failure
00015273179e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00015273179e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00015273179i[CPU0 ] CPU is in long mode (active)
00015273179i[CPU0 ] CS.mode = 64 bit
00015273179i[CPU0 ] SS.mode = 64 bit
00015273179i[CPU0 ] EFER = 0x00000500
00015273179i[CPU0 ] | RAX=1f201f201f201f20 RBX=0000000000200003
00015273179i[CPU0 ] | RCX=0000000000000000 RDX=0000000000000000
00015273179i[CPU0 ] | RSP=0000000000007bf8 RBP=0000000000007c00
00015273179i[CPU0 ] | RSI=00000000000e0000 RDI=00000000000b8fa0
00015273179i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00015273179i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00015273179i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00015273179i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00015273179i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf af PF cf
00015273179i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00015273179i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 0
00015273179i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00015273179i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00015273179i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00015273179i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00015273179i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00015273179i[CPU0 ] | MSR_FS_BASE:0000000000000000
00015273179i[CPU0 ] | MSR_GS_BASE:0000000000000000
00015273179i[CPU0 ] | RIP=0000000000008600 (0000000000008600)
00015273179i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
00015273179i[CPU0 ] | CR3=0x0000000000001000 CR4=0x00000020
00015273179i[CPU0 ] 0x0000000000008600>> add byte ptr ds:[rax], al : 0000
00015273179e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00015273179i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00015273179i[CPU0 ] cpu hardware reset
00015273179i[APIC0 ] allocate APIC id=0 (MMIO enabled) to 0x0000fee00000
00015273179i[CPU0 ] CPUID[0x00000000]: 00000005 756e6547 6c65746e 49656e69
00015273179i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00002028 1fcbfbff
00015273179i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00015273179i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00015273179i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00015273179i[CPU0 ] CPUID[0x00000005]: 00000040 00000040 00000003 00000020
00015273179i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00015273179i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100000
00015273179i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00015273179i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00015273179i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00015273179i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
00015273179i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00015273179i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00015273179i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00015273179i[CPU0 ] CPU Features supported:
00015273179i[CPU0 ] x87
00015273179i[CPU0 ] 486ni
00015273179i[CPU0 ] pentium_ni
00015273179i[CPU0 ] p6ni
00015273179i[CPU0 ] mmx
00015273179i[CPU0 ] debugext
00015273179i[CPU0 ] vme
00015273179i[CPU0 ] pse
00015273179i[CPU0 ] pae
00015273179i[CPU0 ] pge
00015273179i[CPU0 ] pse36
00015273179i[CPU0 ] mtrr
00015273179i[CPU0 ] pat
00015273179i[CPU0 ] sysenter_sysexit
00015273179i[CPU0 ] clflush
00015273179i[CPU0 ] sse
00015273179i[CPU0 ] sse2
00015273179i[CPU0 ] mwait
00015273179i[CPU0 ] vmx
00015273179i[CPU0 ] longmode
00015273179i[CPU0 ] lm_lahf_sahf
00015273179i[CPU0 ] nx
00015273179i[CPU0 ] cmpxhg16b
00015273179i[CPU0 ] rdtscp
00015273179i[CPU0 ] ffxsr
00015273179i[CPU0 ] xapic
00015273179i[PLUGIN] reset of 'pci' plugin device by virtual method
00015273179i[PLUGIN] reset of 'pci2isa' plugin device by virtual method
00015273179i[PLUGIN] reset of 'cmos' plugin device by virtual method
00015273179i[PLUGIN] reset of 'dma' plugin device by virtual method
00015273179i[PLUGIN] reset of 'pic' plugin device by virtual method
00015273179i[PLUGIN] reset of 'pit' plugin device by virtual method
00015273179i[PLUGIN] reset of 'vga' plugin device by virtual method
00015273179i[PLUGIN] reset of 'floppy' plugin device by virtual method
00015273179i[PLUGIN] reset of 'acpi' plugin device by virtual method
00015273179i[PLUGIN] reset of 'hpet' plugin device by virtual method
00015273179i[PLUGIN] reset of 'ioapic' plugin device by virtual method
00015273179i[PLUGIN] reset of 'keyboard' plugin device by virtual method
00015273179i[PLUGIN] reset of 'harddrv' plugin device by virtual method
00015273179i[PLUGIN] reset of 'pci_ide' plugin device by virtual method
00015273179i[PLUGIN] reset of 'unmapped' plugin device by virtual method
00015273179i[PLUGIN] reset of 'biosdev' plugin device by virtual method
00015273179i[PLUGIN] reset of 'speaker' plugin device by virtual method
00015273179i[PLUGIN] reset of 'extfpuirq' plugin device by virtual method
00015273179i[PLUGIN] reset of 'parallel' plugin device by virtual method
00015273179i[PLUGIN] reset of 'serial' plugin device by virtual method
00015273179i[PLUGIN] reset of 'gameport' plugin device by virtual method
00015273179i[PLUGIN] reset of 'usb_uhci' plugin device by virtual method
00015277815i[BIOS ] $Revision: 13752 $ $Date: 2019-12-30 14:16:18 +0100 (Mon, 30 Dec 2019) $
00015591067i[KBD ] reset-disable command received
00015593731i[BIOS ] Starting rombios32
00015594174i[BIOS ] Shutdown flag 0
00015594744i[BIOS ] ram_size=0x02000000
00015595201i[BIOS ] ram_end=32MB
00016541367i[BIOS ] Found 1 cpu(s)
00016555004i[BIOS ] bios_table_addr: 0x000f9db8 end=0x000fcc00
00016882004i[PCI ] i440FX PMC write to PAM register 59 (TLB Flush)
00017210824i[P2ISA ] PCI IRQ routing: PIRQA# set to 0x0b
00017210850i[P2ISA ] PCI IRQ routing: PIRQB# set to 0x09
00017210850i[P2ISA ] PCI IRQ routing: PIRQC# set to 0x0b
00017210850i[P2ISA ] PCI IRQ routing: PIRQD# set to 0x09
00017210850i[P2ISA ] write: ELCR2 = 0x0a
00017211537i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
00017225004i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
00017227317i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
00017229469i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
00017230565i[BIOS ] region 4: 0x0000c000
00017232362i[BIOS ] PCI: bus=0 devfn=0x0a: vendor_id=0x8086 device_id=0x7020 class=0x0c03
00017233436i[BIOS ] region 4: 0x0000c020
00017233669i[UHCI ] new IRQ line = 9
00017235247i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
00017235605i[ACPI ] new IRQ line = 11
00017235845i[ACPI ] new IRQ line = 9
00017235898i[PCI ] setting SMRAM control register to 0x4a
00017400018i[CPU0 ] Enter to System Management Mode
00017400018i[CPU0 ] enter_system_management_mode: temporary disable VMX while in SMM mode
00017400022i[CPU0 ] RSM: Resuming from System Management Mode
00017564044i[PCI ] setting SMRAM control register to 0x0a
00017590459i[BIOS ] MP table addr=0x000f9e90 MPC table addr=0x000f9dc0 size=0xc8
00017592490i[BIOS ] SMBIOS table addr=0x000f9ea0
00017594466i[BIOS ] ACPI tables: RSDP addr=0x000f9fd0 ACPI DATA addr=0x01ff0000 size=0xff8
00017598003i[BIOS ] Firmware waking vector 0x1ff00cc
00017600530i[PCI ] i440FX PMC write to PAM register 59 (TLB Flush)
00017601111i[BIOS ] bios_table_cur_addr: 0x000f9ff4
VGABios $Id: vgabios.c 226 2020-01-02 21:36:23Z vruppert $
00017730207i[BXVGA ] VBE known Display Interface b0c0
00017730226i[BXVGA ] VBE known Display Interface b0c5
00017732870i[VBIOS ] VBE Bios $Id: vbe.c 228 2020-01-02 23:09:02Z vruppert $
00030201002i[BIOS ] Booting from 0000:7c00
00030546355e[CPU0 ] access_read_linear(): canonical failure
00030546355e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00030546355e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00030546355i[CPU0 ] CPU is in long mode (active)
00030546355i[CPU0 ] CS.mode = 64 bit
00030546355i[CPU0 ] SS.mode = 64 bit
00030546355i[CPU0 ] EFER = 0x00000500
00030546355i[CPU0 ] | RAX=1f201f201f201f20 RBX=0000000000200003
00030546355i[CPU0 ] | RCX=0000000000000000 RDX=0000000000000000
00030546355i[CPU0 ] | RSP=0000000000007bf8 RBP=0000000000007c00
00030546355i[CPU0 ] | RSI=00000000000e0000 RDI=00000000000b8fa0
00030546355i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00030546355i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00030546355i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00030546355i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00030546355i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf af PF cf
00030546355i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00030546355i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 0
00030546355i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00030546355i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00030546355i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00030546355i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00030546355i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00030546355i[CPU0 ] | MSR_FS_BASE:0000000000000000
00030546355i[CPU0 ] | MSR_GS_BASE:0000000000000000
00030546355i[CPU0 ] | RIP=0000000000008600 (0000000000008600)
00030546355i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
00030546355i[CPU0 ] | CR3=0x0000000000001000 CR4=0x00000020
00030546355i[CPU0 ] 0x0000000000008600>> add byte ptr ds:[rax], al : 0000
00030546355e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00030546355i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00030546355i[CPU0 ] cpu hardware reset
00030546355i[APIC0 ] allocate APIC id=0 (MMIO enabled) to 0x0000fee00000
00030546355i[CPU0 ] CPUID[0x00000000]: 00000005 756e6547 6c65746e 49656e69
00030546355i[CPU0 ] CPUID[0x00000001]: 00000633 00010800 00002028 1fcbfbff
00030546355i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00030546355i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00030546355i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00030546355i[CPU0 ] CPUID[0x00000005]: 00000040 00000040 00000003 00000020
00030546355i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00030546355i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100000
00030546355i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00030546355i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00030546355i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00030546355i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
00030546355i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00030546355i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00030546355i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00030546355i[CPU0 ] CPU Features supported:
00030546355i[CPU0 ] x87
00030546355i[CPU0 ] 486ni
00030546355i[CPU0 ] pentium_ni
00030546355i[CPU0 ] p6ni
00030546355i[CPU0 ] mmx
00030546355i[CPU0 ] debugext
00030546355i[CPU0 ] vme
00030546355i[CPU0 ] pse
00030546355i[CPU0 ] pae
00030546355i[CPU0 ] pge
00030546355i[CPU0 ] pse36
00030546355i[CPU0 ] mtrr
00030546355i[CPU0 ] pat
00030546355i[CPU0 ] sysenter_sysexit
00030546355i[CPU0 ] clflush
00030546355i[CPU0 ] sse
00030546355i[CPU0 ] sse2
00030546355i[CPU0 ] mwait
00030546355i[CPU0 ] vmx
00030546355i[CPU0 ] longmode
00030546355i[CPU0 ] lm_lahf_sahf
00030546355i[CPU0 ] nx
00030546355i[CPU0 ] cmpxhg16b
00030546355i[CPU0 ] rdtscp
00030546355i[CPU0 ] ffxsr
00030546355i[CPU0 ] xapic
00030546355i[PLUGIN] reset of 'pci' plugin device by virtual method
00030546355i[PLUGIN] reset of 'pci2isa' plugin device by virtual method
00030546355i[PLUGIN] reset of 'cmos' plugin device by virtual method
00030546355i[PLUGIN] reset of 'dma' plugin device by virtual method
00030546355i[PLUGIN] reset of 'pic' plugin device by virtual method
00030546355i[PLUGIN] reset of 'pit' plugin device by virtual method
00030546355i[PLUGIN] reset of 'vga' plugin device by virtual method
00030546355i[PLUGIN] reset of 'floppy' plugin device by virtual method
00030546355i[PLUGIN] reset of 'acpi' plugin device by virtual method
00030546355i[PLUGIN] reset of 'hpet' plugin device by virtual method
00030546355i[PLUGIN] reset of 'ioapic' plugin device by virtual method
00030546355i[PLUGIN] reset of 'keyboard' plugin device by virtual method
00030546355i[PLUGIN] reset of 'harddrv' plugin device by virtual method
00030546355i[PLUGIN] reset of 'pci_ide' plugin device by virtual method
00030546355i[PLUGIN] reset of 'unmapped' plugin device by virtual method
00030546355i[PLUGIN] reset of 'biosdev' plugin device by virtual method
00030546355i[PLUGIN] reset of 'speaker' plugin device by virtual method
00030546355i[PLUGIN] reset of 'extfpuirq' plugin device by virtual method
00030546355i[PLUGIN] reset of 'parallel' plugin device by virtual method
00030546355i[PLUGIN] reset of 'serial' plugin device by virtual method
00030546355i[PLUGIN] reset of 'gameport' plugin device by virtual method
00030546355i[PLUGIN] reset of 'usb_uhci' plugin device by virtual method
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Bochs keeps reseting when calling C++ code.

Post by iansjack »

Could you post a link to a repository of your code, please. Otherwise it's just guesswork.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bochs keeps reseting when calling C++ code.

Post by Octocontrabass »

yByonic wrote:

Code: Select all

00015273179i[CPU0  ] | RAX=1f201f201f201f20  RBX=0000000000200003
00015273179i[CPU0  ] 0x0000000000008600>> add byte ptr ds:[rax], al : 0000
This instruction is causing a triple fault.

Other than that, it's all guesswork. (But my crystal ball says you didn't load your binary into memory correctly.)
yByonic
Posts: 13
Joined: Mon Aug 24, 2020 2:25 pm

Re: Bochs keeps reseting when calling C++ code.

Post by yByonic »

The git repository: https://github.com/Jmallone/os-dev/tree/main/pt6 (note that the repo is not mine, but a copy from the tutorial series whitch is equals to mine)

@Octocontrabass @iansjack
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Bochs keeps reseting when calling C++ code.

Post by nexos »

That instruction "add byte ptr ds:[rax], al" looks very familiar to me. It means your code jumped to the wrong place, or that your binary was loaded wrong. Basically, that is how Bochs interprets an opcode of zero. Because memory is zero initialized in VMs, that mean you went to a place that had not been initialized.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
yByonic
Posts: 13
Joined: Mon Aug 24, 2020 2:25 pm

Re: Bochs keeps reseting when calling C++ code.

Post by yByonic »

Issue Fixed!

For everyone with the same error:

Turns out, in the file DiskRead.asm I setted the number of sectors to read from the disk to 4 (mov al, 4), 2048 bytes. The problem is that entire area is already occupied by the ExtendedProgram.asm, so the kernel is never read into memory. The fix is getting this value higher (like mov al, 32).

Thanks to borrrden by leaving a comment in the video explaining the error. Here is his channel: https://www.youtube.com/channel/UCQ_Lrx ... rVdto-4jSA
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bochs keeps reseting when calling C++ code.

Post by Octocontrabass »

yByonic wrote:The git repository: https://github.com/Jmallone/os-dev/tree/main/pt6 (note that the repo is not mine, but a copy from the tutorial series whitch is equals to mine)
Is this really the same as your code? It uses uninitialized segment registers. I'm surprised you're able to get all the way to long mode with such a major bug.
Post Reply