From 1f32826adcfb65d9b6d23863581953f9a2b6e9a2 Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Fri, 2 Jun 2017 18:22:14 -0400 Subject: [PATCH] rename boot.c --- CMakeLists.txt | 2 +- src/hw/dreamcast.c | 8 +++---- src/hw/dreamcast.h | 5 +++-- src/hw/rom/{boot.c => bios.c} | 41 ++++++++++++++++++----------------- src/hw/rom/bios.h | 14 ++++++++++++ src/hw/rom/boot.h | 14 ------------ src/hw/sh4/sh4.c | 4 ++-- 7 files changed, 45 insertions(+), 43 deletions(-) rename src/hw/rom/{boot.c => bios.c} (65%) create mode 100644 src/hw/rom/bios.h delete mode 100644 src/hw/rom/boot.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f531a08..4b47534e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/hw/dreamcast.c b/src/hw/dreamcast.c index 493be507..a8dc2191 100644 --- a/src/hw/dreamcast.c +++ b/src/hw/dreamcast.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); diff --git a/src/hw/dreamcast.h b/src/hw/dreamcast.h index 971145c3..6bee30d1 100644 --- a/src/hw/dreamcast.h +++ b/src/hw/dreamcast.h @@ -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; diff --git a/src/hw/rom/boot.c b/src/hw/rom/bios.c similarity index 65% rename from src/hw/rom/boot.c rename to src/hw/rom/bios.c index 40aef2fc..8436f282 100644 --- a/src/hw/rom/boot.c +++ b/src/hw/rom/bios.c @@ -1,5 +1,5 @@ #include -#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(); diff --git a/src/hw/rom/bios.h b/src/hw/rom/bios.h new file mode 100644 index 00000000..dcd245f8 --- /dev/null +++ b/src/hw/rom/bios.h @@ -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 diff --git a/src/hw/rom/boot.h b/src/hw/rom/boot.h deleted file mode 100644 index 611d38d2..00000000 --- a/src/hw/rom/boot.h +++ /dev/null @@ -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 diff --git a/src/hw/sh4/sh4.c b/src/hw/sh4/sh4.c index 4650fd13..087880d9 100644 --- a/src/hw/sh4/sh4.c +++ b/src/hw/sh4/sh4.c @@ -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")