summaryrefslogtreecommitdiff
path: root/src/satmkboot.c
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2015-07-11 11:56:16 -0500
committerBobby Bingham <koorogi@koorogi.info>2015-09-15 22:43:32 -0500
commite3cbe8f7712fe97d90ff1fb5c675df9a1632eb45 (patch)
tree657ed072fe2e24223e32dc086363c6d190152550 /src/satmkboot.c
parentd9a15195a48be307abea623d883144dbd7f3a51d (diff)
make systemid structure match memory layout
This will be useful when it comes time to share this structure definition with the bootloader code. Additionally, it makes the write_output function simpler, as we can output most of the fields with a single write() call.
Diffstat (limited to 'src/satmkboot.c')
-rw-r--r--src/satmkboot.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/satmkboot.c b/src/satmkboot.c
index b86a769..3b71fe5 100644
--- a/src/satmkboot.c
+++ b/src/satmkboot.c
@@ -1,4 +1,5 @@
#include <errno.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -8,7 +9,7 @@
#include "symbols.h"
static struct systemid sysid = {
- .title = "TEST TITLE ",
+ .magic = "SEGA SEGASATURN ",
.maker = "SEGA TP T-000 ",
.product = "T-000000G ",
.version = "V0.001",
@@ -16,6 +17,8 @@ static struct systemid sysid = {
.device = "CD-1/1 ",
.regions = " ",
.peripherals = " ",
+ .padding1 = " ",
+ .title = "TEST TITLE ",
.bootsize = 0xe00,
.stack_master = 0,
.stack_slave = 0,
@@ -41,29 +44,19 @@ static void serialize_region_code(char *out, const struct symbolname *region)
static int write_output(FILE *fp)
{
- static const unsigned char zeros[16];
extern const unsigned char securitycode[];
extern const size_t securitycode_size;
/* system id - 0x100 bytes */
- WRITE (fp, "SEGA SEGASATURN ", 16);
- WRITE (fp, sysid.maker, 16);
- WRITE (fp, sysid.product, 10);
- WRITE (fp, sysid.version, 6);
- WRITE (fp, sysid.reldate, 8);
- WRITE (fp, sysid.device, 8);
- WRITE (fp, sysid.regions, 10);
- WRITE (fp, " ", 6);
- WRITE (fp, sysid.peripherals, 16);
- WRITE (fp, sysid.title, 112);
- WRITE (fp, zeros, 16); /* reserved bytes */
+ WRITE (fp, &sysid, offsetof(struct systemid, bootsize));
WRITE32(fp, sysid.bootsize);
- WRITE (fp, zeros, 4); /* reserved bytes */
+ WRITE32(fp, 0); /* reserved bytes */
WRITE32(fp, sysid.stack_master);
WRITE32(fp, sysid.stack_slave);
WRITE32(fp, sysid.load_addr);
WRITE32(fp, sysid.load_size);
- WRITE (fp, zeros, 8); /* reserved bytes */
+ WRITE32(fp, 0); /* reserved bytes */
+ WRITE32(fp, 0); /* reserved bytes */
/* security code */
WRITE(fp, securitycode, securitycode_size);