cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; bootsector #2 kernel for big instruction testcases.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; VBoxManage setextradata bs-vbinstst-64-1 VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled 1
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Copyright (C) 2007-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; available from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; you can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; General Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; The contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; of the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; VirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; CDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; You may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; terms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; This is always the first include file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Include and execute the init code.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INIT_RM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_WITH_TRAPS
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_WITHOUT_RAW_MODE ; causes troubles with PIC/floppy.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_RM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_PE16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_PE32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_PP16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_PP32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_PAE16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_PAE32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_LM16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_LM32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync %define BS2_INC_LM64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncBEGINPROC main
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Set up the runtime environment.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnableA20_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; 16-bit real mode.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%undef BS2_API_TEMPLATE_ACTION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define BS2_API_TEMPLATE_ACTION(a_Name) mov dword [NAME(g_pfn %+ a_Name %+ _r86)], dword NAME(a_Name %+ _r86)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync BS2_API_TEMPLATE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; 16-bit protected mode.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%undef BS2_API_TEMPLATE_ACTION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define BS2_API_TEMPLATE_ACTION(a_Name) mov word [NAME(g_pfn %+ a_Name %+ _p16)], word NAME(a_Name %+ _p16)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync BS2_API_TEMPLATE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, BS2_SEL_CS16
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%undef BS2_API_TEMPLATE_ACTION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define BS2_API_TEMPLATE_ACTION(a_Name) mov [NAME(g_pfn %+ a_Name %+ _p16) + 2], ax
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync BS2_API_TEMPLATE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%undef BS2_API_TEMPLATE_ACTION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define BS2_API_TEMPLATE_ACTION(a_Name) mov dword [NAME(g_pfn %+ a_Name %+ _p32)], dword NAME(a_Name %+ _p32)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync BS2_API_TEMPLATE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%undef BS2_API_TEMPLATE_ACTION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define BS2_API_TEMPLATE_ACTION(a_Name) mov dword [NAME(g_pfn %+ a_Name %+ _p64)], dword NAME(a_Name %+ _p64)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync BS2_API_TEMPLATE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync xor eax, eax
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%undef BS2_API_TEMPLATE_ACTION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define BS2_API_TEMPLATE_ACTION(a_Name) mov dword [NAME(g_pfn %+ a_Name %+ _p64) + 4], eax
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync BS2_API_TEMPLATE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; The magic markers and version number.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov dword [g_u32Bs2ApiMagic], BS2_API_MAGIC
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov dword [g_u32Bs2ApiEndMagic], BS2_API_MAGIC
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov dword [g_u32Bs2ApiVersion], BS2_API_VERSION
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Load the extended image into high memory.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov dl, [g_bBootDrv]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call NAME(bs2LoadBigImage)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Hand control over to the extended image.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%ifdef BS2_BIG_IMAGE_LM64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnterMode_rm_lm64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_lm64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%elifdef BS2_BIG_IMAGE_PP32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnterMode_rm_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%elifdef BS2_BIG_IMAGE_PAE32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnterMode_rm_pae32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_pae32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Probe the image, looking for an executable format we can deal with.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Not doing a lot of checking here, but who cares right now...
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnterMode_rm_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp word [eax], IMAGE_DOS_SIGNATURE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jne .not_dos
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp dword [eax], IMAGE_NT_SIGNATURE
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .start_32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp word [edx + IMAGE_FILE_HEADER.Machine], IMAGE_FILE_MACHINE_I386
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .is_pe32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp word [edx + IMAGE_FILE_HEADER.Machine], IMAGE_FILE_MACHINE_AMD64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .is_pe64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .panic_32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync add edx, IMAGE_FILE_HEADER_size
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, [edx + IMAGE_OPTIONAL_HEADER32.AddressOfEntryPoint]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync add eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .start_32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync add edx, IMAGE_FILE_HEADER_size
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, [edx + IMAGE_OPTIONAL_HEADER64.AddressOfEntryPoint]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync add eax, BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .start_64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Start executing at eax in 32-bit mode (current).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Start executing at eax in 64-bit mode.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnterMode_rm_lm64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, eax
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_lm64
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2Panic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncENDPROC main
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Loads the big image off the floppy.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; This uses the the_end label to figure out the starting offset.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; The length is assumed to be the whole floppy.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; Clobbers nothing, except for 68KB of memory beyond the_end.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; @param dl The boot drive number (from BIOS).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncBEGINPROC bs2LoadBigImage
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx ebp, sp
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define bSavedDiskNo byte [bp - 02h]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define bMaxSector byte [bp - 04h]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define bMaxHead byte [bp - 06h]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define bMaxCylinder byte [bp - 08h]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define pbHighDst dword [bp - 0ch]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push dword BS2_BIG_LOAD_ADDR
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define SegTemp word [bp - 0eh]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync%define fStatus byte [bp - 10h]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Display message.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szLoadingBigImage
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintF_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Try figure the geometry. This defines how much we'll read.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov ah, 08h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync xor di, di ; (es:di = 0000:0000 works around some buggy bioses, says wikipedia.)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jc .param_error
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov bMaxSector, cl ; Do the cl[7:6]+ch stuff so we can address 255 sectors on the fake 63MB floppy.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov bMaxHead, dh
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov bMaxCylinder, ch ; See above.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov dl, bSavedDiskNo
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx ax, bMaxCylinder
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx cx, bMaxHead
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx ax, bMaxSector
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szDbgParam
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintF_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .dprintf_param_done
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szDbgParam:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync db 13, 10, 'Floppy params max: sectors=%RX16 heads=%RX16 cylinders=%RX16', 13, 10, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.dprintf_param_done:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Skip the kernel image (this could be done more efficiently, but this
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; also does the trick).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync lea eax, [dword the_end]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sub eax, start
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync shr eax, 9 ; sectors to skip
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov cx, 0001h ; sector (1-based), cylinder (0-based).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync xor dh, dh ; head (0-based).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.skip_one_more:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp cl, bMaxSector
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jbe .decrement_sector_count
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp dh, bMaxHead ; ASSUMES bMaxHead < 255.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jbe .decrement_sector_count
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.decrement_sector_count:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jnz .skip_one_more
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Load loop. We load and copy 64 KB at the time into the high location.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Fixed registers (above): dl=drive, cl[7:6]:ch=cylinder, dh=head, cl[5:0]=sector.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync lea eax, [dword the_end + 0ffffh]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and eax, 0ffff0000h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov SegTemp, ax ; the 64KB segment we use for temporary storage.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.the_load_loop:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov al, '.'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintChr_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Fill the segment with int3s (in case we don't read a full 64KB).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov eax, 0cccccccch
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov di, SegTemp
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync xor edi, edi
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov cx, 4000h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Load a bunch of sectors into the temp segment.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync xor ebx, ebx
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.the_sector_load_loop:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Figure how many sectors we can read without switching track or side.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx ax, bMaxSector
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync inc al ; al = sectors left to read in the current track on the current side.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync shr di, 9 ; bx/512 = current sector offset.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync add di, 10000h / 512 ; di = sectors left to read in the 64KB buffer.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp ax, di ; ax = min(ax, di)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jbe .use_ax_sector_count1
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.use_ax_sector_count1:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp ax, 64 ; ax = min(ax,64) - Our BIOS limitation is 72, play safe.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jbe .use_ax_sector_count2
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.use_ax_sector_count2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov di, ax ; save the number of sectors we read
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Do the reading.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szDbgRead
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintF_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .after_read_dprintf
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szDbgRead: db 'Reading CX=%RX16 DX=%RX16 AX=%RX16 BX=%RX16', 13, 10, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.after_read_dprintf:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov ah, 02h ; ah=read function
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jc .read_error
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; advance to the next sector/head/cylinder and address (lazy impl).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.advance_another_sector:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp cl, bMaxSector
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .next_head
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .adv_addr
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp dh, bMaxHead
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .next_cylinder
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .adv_addr
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.next_cylinder:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp ch, bMaxCylinder ; No the cl[7:6]+ch stuff so we can address 255 sectors on the fake 63MB floppy.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jb .update_ch
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov fStatus, 1
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .move_block
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync add bx, 512
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jnz .advance_another_sector
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync test bx, bx
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jnz .the_sector_load_loop
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.move_block:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Copy the memory into high mem.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov edi, pbHighDst
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szDbgMove
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintF_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .after_move_dprintf
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szDbgMove: db 'Moving memory to EDI=%RX32', 13, 10, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.after_move_dprintf:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2EnterMode_rm_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov edi, pbHighDst
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx esi, SegTemp
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov ecx, 10000h / 4
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov edi, pbHighDst
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync movzx esi, SegTemp
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov ecx, 10000h / 4
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .mem_verified_ok
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov fStatus, 2
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.mem_verified_ok:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov pbHighDst, edi
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2ExitMode_pp32
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Continue reading and copying?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp fStatus, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .the_load_loop
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Do we quit the loop on a failure?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cmp fStatus, 2
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync je .verify_failed_msg
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Done, so end the current message line.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintChr_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintChr_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ; Something went wrong, display a message.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.verify_failed_msg:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync mov edi, pbHighDst
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szVerifyFailed
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .print_message_and_panic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.param_error:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szParamError
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .print_message_and_panic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.read_error:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync push .s_szReadError
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .print_message_and_panic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.print_message_and_panic:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call PrintF_r86
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync call Bs2Panic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync jmp .print_message_and_panic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szReadError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync db 13, 10, 'Error reading: %RX8', 13, 10, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szParamError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync db 13, 10, 'Error getting params: %RX8', 13, 10, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szVerifyFailed:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync db 13, 10, 'Failed to move block high... (%RX32) Got enough memory configured?', 13, 10, 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync.s_szLoadingBigImage:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync db 'Loading 2nd image.', 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncENDPROC bs2LoadBigImage
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync; End sections and image.