mirror of https://github.com/inolen/redream.git
rename boot.c
This commit is contained in:
parent
4ffcb8d4ab
commit
1f32826adc
|
@ -172,7 +172,7 @@ set(REDREAM_SOURCES
|
|||
src/hw/pvr/ta.c
|
||||
src/hw/pvr/tr.c
|
||||
src/hw/pvr/trace.c
|
||||
src/hw/rom/boot.c
|
||||
src/hw/rom/bios.c
|
||||
src/hw/rom/flash.c
|
||||
src/hw/sh4/sh4.c
|
||||
src/hw/sh4/sh4_ccn.c
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "hw/memory.h"
|
||||
#include "hw/pvr/pvr.h"
|
||||
#include "hw/pvr/ta.h"
|
||||
#include "hw/rom/boot.h"
|
||||
#include "hw/rom/bios.h"
|
||||
#include "hw/rom/flash.h"
|
||||
#include "hw/scheduler.h"
|
||||
#include "hw/sh4/sh4.h"
|
||||
|
@ -154,7 +154,7 @@ int dc_init(struct dreamcast *dc) {
|
|||
dev->sh4 = dc->sh4;
|
||||
dev->arm = dc->arm;
|
||||
dev->aica = dc->aica;
|
||||
dev->boot = dc->boot;
|
||||
dev->bios = dc->bios;
|
||||
dev->flash = dc->flash;
|
||||
dev->gdrom = dc->gdrom;
|
||||
dev->holly = dc->holly;
|
||||
|
@ -252,7 +252,7 @@ void dc_destroy(struct dreamcast *dc) {
|
|||
holly_destroy(dc->holly);
|
||||
gdrom_destroy(dc->gdrom);
|
||||
flash_destroy(dc->flash);
|
||||
boot_destroy(dc->boot);
|
||||
bios_destroy(dc->bios);
|
||||
aica_destroy(dc->aica);
|
||||
arm7_destroy(dc->arm);
|
||||
sh4_destroy(dc->sh4);
|
||||
|
@ -276,7 +276,7 @@ struct dreamcast *dc_create() {
|
|||
dc->sh4 = sh4_create(dc);
|
||||
dc->arm = arm7_create(dc);
|
||||
dc->aica = aica_create(dc);
|
||||
dc->boot = boot_create(dc);
|
||||
dc->bios = bios_create(dc);
|
||||
dc->flash = flash_create(dc);
|
||||
dc->gdrom = gdrom_create(dc);
|
||||
dc->holly = holly_create(dc);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
struct aica;
|
||||
struct arm7;
|
||||
struct boot;
|
||||
struct bios;
|
||||
struct debugger;
|
||||
struct device;
|
||||
struct dreamcast;
|
||||
|
@ -109,7 +109,7 @@ struct device {
|
|||
struct sh4 *sh4;
|
||||
struct arm7 *arm;
|
||||
struct aica *aica;
|
||||
struct boot *boot;
|
||||
struct bios *bios;
|
||||
struct flash *flash;
|
||||
struct gdrom *gdrom;
|
||||
struct holly *holly;
|
||||
|
@ -140,6 +140,7 @@ struct dreamcast {
|
|||
struct sh4 *sh4;
|
||||
struct arm7 *arm;
|
||||
struct aica *aica;
|
||||
struct bios *bios;
|
||||
struct boot *boot;
|
||||
struct flash *flash;
|
||||
struct gdrom *gdrom;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include "hw/rom/boot.h"
|
||||
#include "hw/rom/bios.h"
|
||||
#include "core/md5.h"
|
||||
#include "core/option.h"
|
||||
#include "hw/dreamcast.h"
|
||||
|
@ -8,17 +8,17 @@ DEFINE_OPTION_STRING(bios, "dc_boot.bin", "Path to boot rom");
|
|||
|
||||
#define BIOS_SIZE 0x00200000
|
||||
|
||||
struct boot {
|
||||
struct bios {
|
||||
struct device;
|
||||
uint8_t rom[BIOS_SIZE];
|
||||
};
|
||||
|
||||
static uint32_t boot_rom_read(struct boot *boot, uint32_t addr,
|
||||
static uint32_t bios_rom_read(struct bios *bios, uint32_t addr,
|
||||
uint32_t data_mask) {
|
||||
return READ_DATA(&boot->rom[addr]);
|
||||
return READ_DATA(&bios->rom[addr]);
|
||||
}
|
||||
|
||||
static int boot_validate(struct boot *boot) {
|
||||
static int bios_validate(struct bios *bios) {
|
||||
static const char *valid_bios_md5[] = {
|
||||
"a5c6a00818f97c5e3e91569ee22416dc", /* chinese bios */
|
||||
"37c921eb47532cae8fb70e5d987ce91c", /* japanese bios */
|
||||
|
@ -29,7 +29,7 @@ static int boot_validate(struct boot *boot) {
|
|||
/* compare the rom's md5 against known good bios roms */
|
||||
MD5_CTX md5_ctx;
|
||||
MD5_Init(&md5_ctx);
|
||||
MD5_Update(&md5_ctx, boot->rom, BIOS_SIZE);
|
||||
MD5_Update(&md5_ctx, bios->rom, BIOS_SIZE);
|
||||
char result[33];
|
||||
MD5_Final(result, &md5_ctx);
|
||||
|
||||
|
@ -42,7 +42,7 @@ static int boot_validate(struct boot *boot) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int boot_load_rom(struct boot *boot, const char *path) {
|
||||
static int bios_load_rom(struct bios *bios, const char *path) {
|
||||
FILE *fp = fopen(path, "rb");
|
||||
if (!fp) {
|
||||
return 0;
|
||||
|
@ -58,11 +58,11 @@ static int boot_load_rom(struct boot *boot, const char *path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int n = (int)fread(boot->rom, sizeof(uint8_t), size, fp);
|
||||
int n = (int)fread(bios->rom, sizeof(uint8_t), size, fp);
|
||||
CHECK_EQ(n, size);
|
||||
fclose(fp);
|
||||
|
||||
if (!boot_validate(boot)) {
|
||||
if (!bios_validate(bios)) {
|
||||
LOG_WARNING("Invalid BIOS file");
|
||||
return 0;
|
||||
}
|
||||
|
@ -70,14 +70,14 @@ static int boot_load_rom(struct boot *boot, const char *path) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void boot_destroy(struct boot *boot) {
|
||||
dc_destroy_device((struct device *)boot);
|
||||
void bios_destroy(struct bios *bios) {
|
||||
dc_destroy_device((struct device *)bios);
|
||||
}
|
||||
|
||||
static int boot_init(struct device *dev) {
|
||||
struct boot *boot = (struct boot *)dev;
|
||||
static int bios_init(struct device *dev) {
|
||||
struct bios *bios = (struct bios *)dev;
|
||||
|
||||
if (!boot_load_rom(boot, OPTION_bios)) {
|
||||
if (!bios_load_rom(bios, OPTION_bios)) {
|
||||
LOG_WARNING("Failed to load boot rom");
|
||||
return 0;
|
||||
}
|
||||
|
@ -85,16 +85,17 @@ static int boot_init(struct device *dev) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct boot *boot_create(struct dreamcast *dc) {
|
||||
struct boot *boot =
|
||||
dc_create_device(dc, sizeof(struct boot), "boot", &boot_init, NULL);
|
||||
return boot;
|
||||
struct bios *bios_create(struct dreamcast *dc) {
|
||||
struct bios *bios =
|
||||
dc_create_device(dc, sizeof(struct bios), "bios", &bios_init, NULL);
|
||||
return bios;
|
||||
;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
AM_BEGIN(struct boot, boot_rom_map);
|
||||
AM_BEGIN(struct bios, boot_rom_map);
|
||||
AM_RANGE(0x00000000, 0x001fffff) AM_HANDLE("boot rom",
|
||||
(mmio_read_cb)&boot_rom_read,
|
||||
(mmio_read_cb)&bios_rom_read,
|
||||
NULL,
|
||||
NULL, NULL)
|
||||
AM_END();
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef BIOS_H
|
||||
#define BIOS_H
|
||||
|
||||
#include "hw/memory.h"
|
||||
|
||||
struct dreamcast;
|
||||
struct bios;
|
||||
|
||||
AM_DECLARE(boot_rom_map);
|
||||
|
||||
struct bios *bios_create(struct dreamcast *dc);
|
||||
void bios_destroy(struct bios *bios);
|
||||
|
||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef BOOT_H
|
||||
#define BOOT_H
|
||||
|
||||
#include "hw/memory.h"
|
||||
|
||||
struct dreamcast;
|
||||
struct boot;
|
||||
|
||||
AM_DECLARE(boot_rom_map);
|
||||
|
||||
struct boot *boot_create(struct dreamcast *dc);
|
||||
void boot_destroy(struct boot *boot);
|
||||
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
#include "hw/memory.h"
|
||||
#include "hw/pvr/pvr.h"
|
||||
#include "hw/pvr/ta.h"
|
||||
#include "hw/rom/boot.h"
|
||||
#include "hw/rom/bios.h"
|
||||
#include "hw/rom/flash.h"
|
||||
#include "hw/scheduler.h"
|
||||
#include "jit/frontend/sh4/sh4_fallback.h"
|
||||
|
@ -304,7 +304,7 @@ REG_R32(sh4_cb, PDTRA) {
|
|||
|
||||
/* clang-format off */
|
||||
AM_BEGIN(struct sh4, sh4_data_map)
|
||||
AM_RANGE(0x00000000, 0x001fffff) AM_DEVICE("boot", boot_rom_map)
|
||||
AM_RANGE(0x00000000, 0x001fffff) AM_DEVICE("bios", boot_rom_map)
|
||||
AM_RANGE(0x00200000, 0x0021ffff) AM_DEVICE("flash", flash_rom_map)
|
||||
AM_RANGE(0x0c000000, 0x0cffffff) AM_MOUNT("system ram")
|
||||
|
||||
|
|
Loading…
Reference in New Issue