mirror of https://github.com/bochs-emu/Bochs
Some work on the hdimage code for bximage support.
- Enabled self registering code for the bximage case to simplify mode detection. - Fixed vpc image format check for mode detection case.
This commit is contained in:
parent
38a04afe8e
commit
59ee157575
|
@ -33,13 +33,6 @@
|
|||
#include "cdrom_win32.h"
|
||||
#endif
|
||||
#include "hdimage.h"
|
||||
#ifdef BXIMAGE
|
||||
#include "vbox.h"
|
||||
#include "vmware3.h"
|
||||
#include "vmware4.h"
|
||||
#include "vpc.h"
|
||||
#include "vvfat.h"
|
||||
#endif
|
||||
|
||||
#if BX_HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
|
@ -194,6 +187,8 @@ cdrom_base_c* bx_hdimage_ctl_c::init_cdrom(const char *dev)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif // ifndef BXIMAGE
|
||||
|
||||
hdimage_locator_c *hdimage_locator_c::all = NULL;
|
||||
Bit8u hdimage_locator_c::count = 0;
|
||||
|
||||
|
@ -269,7 +264,7 @@ bool hdimage_locator_c::module_present(const char *mode)
|
|||
|
||||
void hdimage_locator_c::cleanup()
|
||||
{
|
||||
#if BX_PLUGINS
|
||||
#if BX_PLUGINS && !defined(BXIMAGE)
|
||||
while (all != NULL) {
|
||||
PLUG_unload_plugin_type(all->mode, PLUGTYPE_IMG);
|
||||
}
|
||||
|
@ -306,8 +301,6 @@ bool hdimage_locator_c::detect_image_mode(int fd, Bit64u disk_size,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif // ifndef BXIMAGE
|
||||
|
||||
// helper functions
|
||||
int bx_read_image(int fd, Bit64s offset, void *buf, int count)
|
||||
{
|
||||
|
@ -454,23 +447,8 @@ bool hdimage_detect_image_mode(const char *pathname, const char **image_mode)
|
|||
} else if (growing_image_t::check_format(fd, image_size) == HDIMAGE_FORMAT_OK) {
|
||||
*image_mode = "growing";
|
||||
result = true;
|
||||
#ifdef BXIMAGE
|
||||
} else if (vbox_image_t::check_format(fd, image_size) >= HDIMAGE_FORMAT_OK) {
|
||||
*image_mode = "vbox";
|
||||
result = true;
|
||||
} else if (vmware3_image_t::check_format(fd, image_size) == HDIMAGE_FORMAT_OK) {
|
||||
*image_mode = "vmware3";
|
||||
result = true;
|
||||
} else if (vmware4_image_t::check_format(fd, image_size) == HDIMAGE_FORMAT_OK) {
|
||||
*image_mode = "vmware4";
|
||||
result = true;
|
||||
} else if (vpc_image_t::check_format(fd, image_size) >= HDIMAGE_FORMAT_OK) {
|
||||
*image_mode = "vpc";
|
||||
result = true;
|
||||
#else
|
||||
} else if (hdimage_locator_c::detect_image_mode(fd, image_size, image_mode)) {
|
||||
result = true;
|
||||
#endif
|
||||
} else if (flat_image_t::check_format(fd, image_size) == HDIMAGE_FORMAT_OK) {
|
||||
*image_mode = "flat";
|
||||
result = true;
|
||||
|
|
|
@ -616,6 +616,8 @@ public:
|
|||
|
||||
BOCHSAPI extern bx_hdimage_ctl_c bx_hdimage_ctl;
|
||||
|
||||
#endif // ifndef BXIMAGE
|
||||
|
||||
//
|
||||
// The hdimage_locator class is used by device_image_t classes to register
|
||||
// their name. The common hdimage code uses the static 'create' method
|
||||
|
@ -641,6 +643,4 @@ private:
|
|||
const char *mode;
|
||||
};
|
||||
|
||||
#endif // BXIMAGE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Contact: fys [at] fysnet [dot] net
|
||||
*
|
||||
* Copyright (C) 2015 Benjamin D Lunt.
|
||||
* Copyright (C) 2006-2020 The Bochs Project
|
||||
* Copyright (C) 2006-2021 The Bochs Project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -69,6 +69,8 @@ void CDECL libvbox_img_plugin_fini(void)
|
|||
// Nothing here yet
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Define the static class that registers the derived device image class,
|
||||
// and allocates one on request.
|
||||
|
@ -85,8 +87,6 @@ protected:
|
|||
}
|
||||
} bx_vbox_match;
|
||||
|
||||
#endif
|
||||
|
||||
vbox_image_t::vbox_image_t()
|
||||
: file_descriptor(-1),
|
||||
mtlb(0),
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Contact: snrrrub@yahoo.com
|
||||
*
|
||||
* Copyright (C) 2003 Net Integration Technologies, Inc.
|
||||
* Copyright (C) 2003-2020 The Bochs Project
|
||||
* Copyright (C) 2003-2021 The Bochs Project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -64,6 +64,8 @@ void CDECL libvmware3_img_plugin_fini(void)
|
|||
// Nothing here yet
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Define the static class that registers the derived device image class,
|
||||
// and allocates one on request.
|
||||
|
@ -80,8 +82,6 @@ protected:
|
|||
}
|
||||
} bx_vmware3_match;
|
||||
|
||||
#endif
|
||||
|
||||
int vmware3_image_t::check_format(int fd, Bit64u imgsize)
|
||||
{
|
||||
COW_Header header;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Contact: snrrrub@gmail.com
|
||||
*
|
||||
* Copyright (C) 2006 Sharvil Nanavati.
|
||||
* Copyright (C) 2006-2020 The Bochs Project
|
||||
* Copyright (C) 2006-2021 The Bochs Project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -62,6 +62,8 @@ void CDECL libvmware4_img_plugin_fini(void)
|
|||
// Nothing here yet
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Define the static class that registers the derived device image class,
|
||||
// and allocates one on request.
|
||||
|
@ -78,8 +80,6 @@ protected:
|
|||
}
|
||||
} bx_vmware4_match;
|
||||
|
||||
#endif
|
||||
|
||||
vmware4_image_t::vmware4_image_t()
|
||||
: file_descriptor(-1),
|
||||
tlb(0),
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
// Copyright (c) 2005 Alex Beregszaszi
|
||||
// Copyright (c) 2009 Kevin Wolf <kwolf@suse.de>
|
||||
// Copyright (C) 2012-2020 The Bochs Project
|
||||
// Copyright (C) 2012-2021 The Bochs Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -60,6 +60,8 @@ void CDECL libvpc_img_plugin_fini(void)
|
|||
// Nothing here yet
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Define the static class that registers the derived device image class,
|
||||
// and allocates one on request.
|
||||
|
@ -72,12 +74,10 @@ protected:
|
|||
return (new vpc_image_t());
|
||||
}
|
||||
int check_format(int fd, Bit64u disk_size) {
|
||||
return (vpc_image_t::check_format(fd, disk_size));
|
||||
return ((vpc_image_t::check_format(fd, disk_size) > 0) ? HDIMAGE_FORMAT_OK : -1);
|
||||
}
|
||||
} bx_vpc_match;
|
||||
|
||||
#endif
|
||||
|
||||
Bit32u vpc_checksum(Bit8u *buf, size_t size)
|
||||
{
|
||||
Bit32u res = 0;
|
||||
|
|
Loading…
Reference in New Issue