Search
lxdream.org :: lxdream/src/bootstrap.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/bootstrap.c
changeset 26:ad258e3daaa5
prev25:fa2d21d57942
next35:21a4be098304
author nkeynes
date Sun Dec 25 05:57:00 2005 +0000 (18 years ago)
permissions -rw-r--r--
last change Change timeslice to nanoseconds (was microseconds)
Generize single step (now steps through active CPU)
Add lots of header blocks
file annotate diff log raw
1.1 --- a/src/bootstrap.c Sat Dec 24 03:33:08 2005 +0000
1.2 +++ b/src/bootstrap.c Sun Dec 25 05:57:00 2005 +0000
1.3 @@ -1,31 +1,43 @@
1.4 -#include <stdlib.h>
1.5 -#include <stdint.h>
1.6 -#include <string.h>
1.7 -#include <stdio.h>
1.8 -#include <unistd.h>
1.9 -#include <fcntl.h>
1.10 -#include <errno.h>
1.11 -#include <assert.h>
1.12 -#include <sys/stat.h>
1.13 -#include <sys/mman.h>
1.14 -#include "ipbin.h"
1.15 -#include "gui/gui.h"
1.16 +/**
1.17 + * $Id: bootstrap.c,v 1.4 2005-12-24 08:02:14 nkeynes Exp $
1.18 + *
1.19 + * CD Bootstrap header parsing. Mostly for informational purposes.
1.20 + *
1.21 + * Copyright (c) 2005 Nathan Keynes.
1.22 + *
1.23 + * This program is free software; you can redistribute it and/or modify
1.24 + * it under the terms of the GNU General Public License as published by
1.25 + * the Free Software Foundation; either version 2 of the License, or
1.26 + * (at your option) any later version.
1.27 + *
1.28 + * This program is distributed in the hope that it will be useful,
1.29 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.30 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.31 + * GNU General Public License for more details.
1.32 + */
1.33
1.34 -static char *dc_peripherals[] = { "Uses WinCE", "Unknown (0x0000002)",
1.35 - "Unknown (0x0000004)", "Unknown (0x0000008)",
1.36 - "VGA Box", "Unknown (0x0000020)",
1.37 - "Unknown (0x0000040)", "Unknown (0x0000080)",
1.38 - "Other Expansions", "Puru Puru pack",
1.39 - "Mike", "Memory card",
1.40 - "Basic controller", "C button",
1.41 - "D button", "X button",
1.42 - "Y button", "Z button",
1.43 - "Expanded direction buttons",
1.44 - "Analog R trigger", "Analog L trigger",
1.45 - "Analog horizontal", "Analog vertical",
1.46 - "Expanded analog horizontal",
1.47 - "Expanded analog vertical",
1.48 - "Gun", "Keyboard", "Mouse" };
1.49 +#include "dream.h"
1.50 +#include "bootstrap.h"
1.51 +
1.52 +/**
1.53 + * Bootstrap header structure
1.54 + */
1.55 +typedef struct dc_bootstrap_head {
1.56 + char hardware_id[16]; /* must be "SEGA SEGAKATANA " */
1.57 + char maker_id[16]; /* ditto, "SEGA ENTERPRISES" */
1.58 + char crc[4];
1.59 + char padding; /* normally ascii space */
1.60 + char gdrom_id[6];
1.61 + char disc_no[5];
1.62 + char regions[8];
1.63 + char peripherals[8];
1.64 + char product_id[10];
1.65 + char product_ver[6];
1.66 + char product_date[16];
1.67 + char boot_file[16];
1.68 + char vendor_id[16];
1.69 + char product_name[128];
1.70 +} *dc_bootstrap_head_t;
1.71
1.72 static uint32_t compute_crc16( dc_bootstrap_head_t h )
1.73 {
1.74 @@ -44,7 +56,55 @@
1.75 return n & 0xffff;
1.76 }
1.77
1.78 -void parse_ipbin( char *data )
1.79 +
1.80 +static char *dc_peripherals[] = { "Uses WinCE", "Unknown (0x0000002)",
1.81 + "Unknown (0x0000004)", "Unknown (0x0000008)",
1.82 + "VGA Box", "Unknown (0x0000020)",
1.83 + "Unknown (0x0000040)", "Unknown (0x0000080)",
1.84 + "Other Expansions", "Puru Puru pack",
1.85 + "Mike", "Memory card",
1.86 + "Basic controller", "C button",
1.87 + "D button", "X button",
1.88 + "Y button", "Z button",
1.89 + "Expanded direction buttons",
1.90 + "Analog R trigger", "Analog L trigger",
1.91 + "Analog horizontal", "Analog vertical",
1.92 + "Expanded analog horizontal",
1.93 + "Expanded analog vertical",
1.94 + "Gun", "Keyboard", "Mouse" };
1.95 +
1.96 +
1.97 +/* Expansion units */
1.98 +#define DC_PERIPH_WINCE 0x0000001
1.99 +#define DC_PERIPH_VGABOX 0x0000010
1.100 +#define DC_PERIPH_OTHER 0x0000100
1.101 +#define DC_PERIPH_PURUPURU 0x0000200
1.102 +#define DC_PERIPH_MIKE 0x0000400
1.103 +#define DC_PERIPH_MEMCARD 0x0000800
1.104 +/* Basic requirements */
1.105 +#define DC_PERIPH_BASIC 0x0001000 /* Basic controls - start, a, b, arrows */
1.106 +#define DC_PERIPH_C_BUTTON 0x0002000
1.107 +#define DC_PERIPH_D_BUTTON 0x0004000
1.108 +#define DC_PERIPH_X_BUTTON 0x0008000
1.109 +#define DC_PERIPH_Y_BUTTON 0x0010000
1.110 +#define DC_PERIPH_Z_BUTTON 0x0020000
1.111 +#define DC_PERIPH_EXP_DIR 0x0040000 /* Expanded direction buttons */
1.112 +#define DC_PERIPH_ANALOG_R 0x0080000 /* Analog R trigger */
1.113 +#define DC_PERIPH_ANALOG_L 0x0100000 /* Analog L trigger */
1.114 +#define DC_PERIPH_ANALOG_H 0x0200000 /* Analog horizontal controller */
1.115 +#define DC_PERIPH_ANALOG_V 0x0400000 /* Analog vertical controller */
1.116 +#define DC_PERIPH_EXP_AH 0x0800000 /* Expanded analog horizontal (?) */
1.117 +#define DC_PERIPH_EXP_AV 0x1000000 /* Expanded analog vertical (?) */
1.118 +/* Optional peripherals */
1.119 +#define DC_PERIPH_GUN 0x2000000
1.120 +#define DC_PERIPH_KEYBOARD 0x4000000
1.121 +#define DC_PERIPH_MOUSE 0x8000000
1.122 +
1.123 +/**
1.124 + * Dump the bootstrap info to the output log for infomational/debugging
1.125 + * purposes.
1.126 + */
1.127 +void bootstrap_dump( char *data )
1.128 {
1.129 struct dc_bootstrap_head *head;
1.130 int i, got, periph, crc, hcrc;
1.131 @@ -58,7 +118,7 @@
1.132 for( i=127; i>0 && buf[i] == ' '; i-- );
1.133 buf[i] = '\0';
1.134 periph = strtol( head->peripherals, NULL, 16 );
1.135 - INFO( "Bootstrap loaded, Name: %s Author: %-16.16s",
1.136 + INFO( "Bootstrap Name: %s Author: %-16.16s",
1.137 buf, head->vendor_id );
1.138 sprintf( buf, "%4.4s", head->crc );
1.139 crc = compute_crc16(head);
.