Commit 12ef0312 authored by Donald Haase's avatar Donald Haase
Browse files

Move more common functions to DCInfo.c. Add BIOSTest.

parent d396bdc1
Loading
Loading
Loading
Loading

BIOSTest.c

0 → 100644
+37 −0
Original line number Diff line number Diff line
/*

    Part of DCInfo by Donald Haase.

    I wrote this originally as part of an update to httpd-ack that 
    would give easy information to note if a BIOS was already known 
    to me, or if I should dump it for review as an unknown version.    

*/
#include <kos.h>
#include "DCInfo.h"
#include <kos/net.h>

/*	
	These are the three BIOSes I've been able to get from my own DCs and devkit, 
	there are definitely more devkit BIOS revisions, but I don't know of any other 
	regular DC model revisions (that allow for MIL-CDs)
*/

static unsigned int bios_crc_32_known[] = {0x89F2B1A1, 0x2186E0E5, 0x5454841F};

unsigned int BIOS_Test (void)
{
	unsigned int i = 0;    
    unsigned int bios_crc_32 = 0;
	
	printf("Your CRC-32 of your DC's BIOS is: [%08X] \n", bios_crc_32 = net_crc32le(0, 0x200000));
	printf("It's version ID at 0x7C0 is: %.64s\n", (unsigned char*)0x7C0);
    
	for(; i<sizeof(bios_crc_32_known); i++)	
		if(bios_crc_32==bios_crc_32_known[i]) break;

	if(i == sizeof(bios_crc_32_known)) 
		printf("Your DC's BIOS doesn't match any I know of. Please let me know about it!\n");	

	return bios_crc_32;
}
 No newline at end of file
+43 −0
Original line number Diff line number Diff line
@@ -18,6 +18,46 @@ typedef struct info_mod {

} info_mod_t;
*/

volatile bool __wdt_timeout_running = true;
void __wdt_timeout_callback(void*)
{
    __wdt_timeout_running = false;
    wdt_disable();
}

void out32(unsigned int addr,unsigned int data)
{
    volatile unsigned int * p=(volatile unsigned int *)addr;
    *p=data;
}
void out16(unsigned int addr,unsigned short data)
{
    volatile unsigned short * p=(volatile unsigned short *)addr;
    *p=data;
}
void out8(unsigned int addr,unsigned char data)
{
    volatile unsigned char * p=(volatile unsigned char  *)addr;
    *p=data;
}

unsigned int in32(unsigned int addr)
{
    volatile unsigned int * p=(volatile unsigned int *)addr;
    return *p;
}
unsigned short in16(unsigned int addr)
{
    volatile unsigned short * p=(volatile unsigned short *)addr;
    return *p;
}
unsigned char in8(unsigned int addr)
{
    volatile unsigned char * p=(volatile unsigned char  *)addr;
    return *p;
}

/* My patented awesome data output that I did for MapleTest */
void awesome_data_print(unsigned char *data, unsigned int size)
{
@@ -51,7 +91,10 @@ int main (void)
    printf("REVISION    : 0x%.4x\n", in16(REVISION));

    gdinfo_print();

    print_all_device_allinfo(2);

    BIOS_Test();

    return 0;
}
 No newline at end of file
+10 −6
Original line number Diff line number Diff line

void out32(unsigned int addr,unsigned int data);
void out16(unsigned int addr,unsigned short data);
void out8(unsigned int addr,unsigned char data);

unsigned int in32(unsigned int addr);
unsigned short in16(unsigned int addr);
unsigned char in8(unsigned int addr);

void awesome_data_print(unsigned char *data, unsigned int size);

/* 
Trying to set up a reusable simple way to protect a while loop that has 
a risk of stalling. Replace a while(X) with wdt_timeout_while(X, time)
*/
static volatile bool __wdt_timeout_running = true;
static void __wdt_timeout_callback(void*) 
{
    __wdt_timeout_running = false;
    wdt_disable();
}
extern volatile bool __wdt_timeout_running;
void __wdt_timeout_callback(void*);
    
#define wdt_timeout_while(COND, WAIT) \
    __wdt_timeout_running = true; \
+0 −32
Original line number Diff line number Diff line
@@ -17,38 +17,6 @@
#include "gdinfo.h"
#include "DCInfo.h"

void out32(unsigned int addr,unsigned int data)
{
    volatile unsigned int * p=(volatile unsigned int *)addr;
    *p=data;
}
void out16(unsigned int addr,unsigned short data)
{
    volatile unsigned short * p=(volatile unsigned short *)addr;
    *p=data;
}
void out8(unsigned int addr,unsigned char data)
{
    volatile unsigned char * p=(volatile unsigned char  *)addr;
    *p=data;
}

unsigned int in32(unsigned int addr)
{
    volatile unsigned int * p=(volatile unsigned int *)addr;
    return *p;
}
unsigned short in16(unsigned int addr)
{
    volatile unsigned short * p=(volatile unsigned short *)addr;
    return *p;
}
unsigned char in8(unsigned int addr)
{
    volatile unsigned char * p=(volatile unsigned char  *)addr;
    return *p;
}

unsigned int gd_error(void)
{
    return  in8(GD_ALTSTAT_Read)&ST_CHECK;
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ NAME = DCInfo
TARGET = $(NAME).elf


OBJS= MapleTest.o gdinfo.o DCInfo.o	
OBJS= MapleTest.o gdinfo.o DCInfo.o	BIOSTest.o

all: rm-elf $(TARGET)