Move El Torito base parsing to a separate C++ file. Move some built-in binaries to CPP files because including directly from a h file is rather dumb. This will require updating the Visual Studio project

This commit is contained in:
Jonathan Campbell 2024-03-23 10:00:17 -07:00
parent d2ff230d0d
commit 4e8ad95ba4
11 changed files with 132931 additions and 132863 deletions

4
include/eltorito.h Normal file
View File

@ -0,0 +1,4 @@
bool ElTorito_ChecksumRecord(unsigned char *entry/*32 bytes*/);
bool ElTorito_ScanForBootRecord(CDROM_Interface *drv,unsigned long &boot_record,unsigned long &el_torito_base);

File diff suppressed because it is too large Load Diff

132783
src/builtin/4dos.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,10 @@ libbuiltin_a_SOURCES = \
fdisk_exe.cpp \
format_exe.cpp \
chkdsk_exe.cpp \
textutil.cpp \
sys_com.cpp \
28_com.cpp \
50_com.cpp \
25_com.cpp
25_com.cpp \
4dos.cpp

51
src/builtin/textutil.cpp Normal file
View File

@ -0,0 +1,51 @@
#include "dos_inc.h"
static const unsigned char bin_cga_com[] = {
0xB8,0x00,0x12,0xB3,0x30,0xCD,0x10,0xB8,0x03,0x00,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_CGA_COM = {
/*recommended file name*/ "CGA.COM",
/*data*/ bin_cga_com,
/*length*/ sizeof(bin_cga_com)
};
static const unsigned char bin_clr_com[] = {
0xB4,0x0F,0xCD,0x10,0x24,0x7F,0x3C,0x03,0x76,0x10,0x3C,
0x07,0x74,0x0C,0x3C,0x54,0x74,0x08,0x3C,0x55,0x74,0x04,
0xB4,0x00,0xEB,0x1C,0xB4,0x06,0xB0,0x00,0xB7,0x07,0x33,
0xC9,0x8E,0xD9,0x8A,0x36,0x84,0x04,0x8A,0x16,0x4A,0x04,
0xFE,0xCA,0xCD,0x10,0xB4,0x02,0xB7,0x00,0x33,0xD2,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_CLR_COM = {
/*recommended file name*/ "CLR.COM",
/*data*/ bin_clr_com,
/*length*/ sizeof(bin_clr_com)
};
static const unsigned char bin_ega_com[] = {
0xB8,0x01,0x12,0xB3,0x30,0xCD,0x10,0xB8,0x03,0x00,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_EGA_COM = {
/*recommended file name*/ "EGA.COM",
/*data*/ bin_ega_com,
/*length*/ sizeof(bin_ega_com)
};
static const unsigned char bin_vga_com[] = {
0xB8,0x02,0x12,0xB3,0x30,0xCD,0x10,0xB8,0x03,0x00,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_VGA_COM = {
/*recommended file name*/ "VGA.COM",
/*data*/ bin_vga_com,
/*length*/ sizeof(bin_vga_com)
};

View File

@ -1,47 +1,6 @@
static const unsigned char bin_cga_com[] = {
0xB8,0x00,0x12,0xB3,0x30,0xCD,0x10,0xB8,0x03,0x00,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_CGA_COM = {
/*recommended file name*/ "CGA.COM",
/*data*/ bin_cga_com,
/*length*/ sizeof(bin_cga_com)
};
extern struct BuiltinFileBlob bfb_CGA_COM;
extern struct BuiltinFileBlob bfb_CLR_COM;
extern struct BuiltinFileBlob bfb_EGA_COM;
extern struct BuiltinFileBlob bfb_VGA_COM;
static const unsigned char bin_clr_com[] = {
0xB4,0x0F,0xCD,0x10,0x24,0x7F,0x3C,0x03,0x76,0x10,0x3C,
0x07,0x74,0x0C,0x3C,0x54,0x74,0x08,0x3C,0x55,0x74,0x04,
0xB4,0x00,0xEB,0x1C,0xB4,0x06,0xB0,0x00,0xB7,0x07,0x33,
0xC9,0x8E,0xD9,0x8A,0x36,0x84,0x04,0x8A,0x16,0x4A,0x04,
0xFE,0xCA,0xCD,0x10,0xB4,0x02,0xB7,0x00,0x33,0xD2,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_CLR_COM = {
/*recommended file name*/ "CLR.COM",
/*data*/ bin_clr_com,
/*length*/ sizeof(bin_clr_com)
};
static const unsigned char bin_ega_com[] = {
0xB8,0x01,0x12,0xB3,0x30,0xCD,0x10,0xB8,0x03,0x00,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_EGA_COM = {
/*recommended file name*/ "EGA.COM",
/*data*/ bin_ega_com,
/*length*/ sizeof(bin_ega_com)
};
static const unsigned char bin_vga_com[] = {
0xB8,0x02,0x12,0xB3,0x30,0xCD,0x10,0xB8,0x03,0x00,0xCD,
0x10,0xCD,0x20,
};
struct BuiltinFileBlob bfb_VGA_COM = {
/*recommended file name*/ "VGA.COM",
/*data*/ bin_vga_com,
/*length*/ sizeof(bin_vga_com)
};

View File

@ -7,7 +7,7 @@ libdos_a_SOURCES = dos.cpp dos_devices.cpp dos_execute.cpp dos_files.cpp dos_ioc
drives.cpp drives.h drive_virtual.cpp drive_local.cpp drive_cache.cpp drive_fat.cpp \
drive_overlay.cpp drive_physfs.cpp drive_iso.cpp dev_con.h dos_mscdex.cpp dos_keyboard_layout.cpp \
cdrom.h cdrom.cpp cdrom_ioctl_win32.cpp cdrom_aspi_win32.cpp cdrom_ioctl_linux.cpp cdrom_image.cpp \
cdrom_ioctl_os2.cpp
cdrom_ioctl_os2.cpp eltorito.cpp
if MACOSX
libdos_a_SOURCES += \

View File

@ -58,6 +58,7 @@
#include "menu.h"
#include "render.h"
#include "mouse.h"
#include "eltorito.h"
#include "../ints/int10.h"
#include "../output/output_opengl.h"
#include "paging.h"
@ -4701,49 +4702,10 @@ quit:
}
};
bool ElTorito_ChecksumRecord(unsigned char *entry/*32 bytes*/) {
unsigned int chk=0,i;
for (i=0;i < 16;i++) {
unsigned int word = ((unsigned int)entry[0]) + ((unsigned int)entry[1] << 8);
chk += word;
entry += 2;
}
chk &= 0xFFFF;
return (chk == 0);
}
static void INTRO_ProgramStart(Program * * make) {
*make=new INTRO;
}
bool ElTorito_ScanForBootRecord(CDROM_Interface *drv,unsigned long &boot_record,unsigned long &el_torito_base) {
unsigned char buffer[2048];
unsigned int sec;
for (sec=16;sec < 32;sec++) {
if (!drv->ReadSectorsHost(buffer,false,sec,1))
break;
/* stop at terminating volume record */
if (buffer[0] == 0xFF) break;
/* match boot record and whether it conforms to El Torito */
if (buffer[0] == 0x00 && memcmp(buffer+1,"CD001",5) == 0 && buffer[6] == 0x01 &&
memcmp(buffer+7,"EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0",32) == 0) {
boot_record = sec;
el_torito_base = (unsigned long)buffer[71] +
((unsigned long)buffer[72] << 8UL) +
((unsigned long)buffer[73] << 16UL) +
((unsigned long)buffer[74] << 24UL);
return true;
}
}
return false;
}
imageDiskMemory* CreateRamDrive(Bitu sizes[], const int reserved_cylinders, const bool forceFloppy, Program* obj) {
imageDiskMemory* dsk = NULL;
//if chs not specified

77
src/dos/eltorito.cpp Normal file
View File

@ -0,0 +1,77 @@
#include "dosbox.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <sys/stat.h>
#include "menudef.h"
#include "programs.h"
#include "support.h"
#include "drives.h"
#include "cross.h"
#include "regs.h"
#include "ide.h"
#include "cpu.h"
#include "callback.h"
#include "cdrom.h"
#include "bios_disk.h"
#include "dos_system.h"
#include "dos_inc.h"
#include "bios.h"
#include "inout.h"
#include "dma.h"
#include "bios_disk.h"
#include "qcow2_disk.h"
#include "shell.h"
#include "setup.h"
#include "control.h"
#include <time.h>
#include "menu.h"
#include "render.h"
#include "mouse.h"
#include "eltorito.h"
bool ElTorito_ChecksumRecord(unsigned char *entry/*32 bytes*/) {
unsigned int chk=0,i;
for (i=0;i < 16;i++) {
unsigned int word = ((unsigned int)entry[0]) + ((unsigned int)entry[1] << 8);
chk += word;
entry += 2;
}
chk &= 0xFFFF;
return (chk == 0);
}
bool ElTorito_ScanForBootRecord(CDROM_Interface *drv,unsigned long &boot_record,unsigned long &el_torito_base) {
unsigned char buffer[2048];
unsigned int sec;
for (sec=16;sec < 32;sec++) {
if (!drv->ReadSectorsHost(buffer,false,sec,1))
break;
/* stop at terminating volume record */
if (buffer[0] == 0xFF) break;
/* match boot record and whether it conforms to El Torito */
if (buffer[0] == 0x00 && memcmp(buffer+1,"CD001",5) == 0 && buffer[6] == 0x01 &&
memcmp(buffer+7,"EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0",32) == 0) {
boot_record = sec;
el_torito_base = (unsigned long)buffer[71] +
((unsigned long)buffer[72] << 8UL) +
((unsigned long)buffer[73] << 16UL) +
((unsigned long)buffer[74] << 24UL);
return true;
}
}
return false;
}

BIN
src/hardware/stAg5N9H Normal file

Binary file not shown.

BIN
src/hardware/stOv1VWI Normal file

Binary file not shown.