KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Functions
flashrom.h File Reference

Dreamcast flashrom read/write support. More...

#include <sys/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Data Structures

struct  flashrom_syscfg
 System configuration structure. More...
 
struct  flashrom_ispcfg
 ISP configuration structure. More...
 

Macros

#define FLASHROM_PT_SYSTEM   0
 Factory settings (read-only, 8K) More...
 
#define FLASHROM_PT_RESERVED   1
 reserved (all 0s, 8K) More...
 
#define FLASHROM_PT_BLOCK_1   2
 Block allocated (16K) More...
 
#define FLASHROM_PT_SETTINGS   3
 Game settings (block allocated, 32K) More...
 
#define FLASHROM_PT_BLOCK_2   4
 Block allocated (64K) More...
 
#define FLASHROM_B1_SYSCFG   0x05
 System config (BLOCK_1) More...
 
#define FLASHROM_B1_PW_SETTINGS_1   0x80
 PlanetWeb settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_SETTINGS_2   0x81
 PlanetWeb settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_SETTINGS_3   0x82
 PlanetWeb settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_SETTINGS_4   0x83
 PlanetWeb settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_SETTINGS_5   0x84
 PlanetWeb settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_PPP1   0xC0
 PlanetWeb PPP settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_PPP2   0xC1
 PlanetWeb PPP settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_DNS   0xC2
 PlanetWeb DNS settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_EMAIL1   0xC3
 PlanetWeb Email settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_EMAIL2   0xC4
 PlanetWeb Email settings (BLOCK_1) More...
 
#define FLASHROM_B1_PW_EMAIL_PROXY   0xC5
 PlanetWeb Email/Proxy settings (BLOCK_1) More...
 
#define FLASHROM_B1_IP_SETTINGS   0xE0
 IP settings for BBA (BLOCK_1) More...
 
#define FLASHROM_B1_EMAIL   0xE2
 Email address (BLOCK_1) More...
 
#define FLASHROM_B1_SMTP   0xE4
 SMTP server setting (BLOCK_1) More...
 
#define FLASHROM_B1_POP3   0xE5
 POP3 server setting (BLOCK_1) More...
 
#define FLASHROM_B1_POP3LOGIN   0xE6
 POP3 login setting (BLOCK_1) More...
 
#define FLASHROM_B1_POP3PASSWD   0xE7
 POP3 password setting + proxy (BLOCK_1) More...
 
#define FLASHROM_B1_PPPLOGIN   0xE8
 PPP username + proxy (BLOCK_1) More...
 
#define FLASHROM_B1_PPPPASSWD   0xE9
 PPP passwd (BLOCK_1) More...
 
#define FLASHROM_LANG_JAPANESE   0
 Japanese language code. More...
 
#define FLASHROM_LANG_ENGLISH   1
 English language code. More...
 
#define FLASHROM_LANG_GERMAN   2
 German language code. More...
 
#define FLASHROM_LANG_FRENCH   3
 French language code. More...
 
#define FLASHROM_LANG_SPANISH   4
 Spanish language code. More...
 
#define FLASHROM_LANG_ITALIAN   5
 Italian language code. More...
 
#define FLASHROM_REGION_UNKNOWN   0
 Unknown region. More...
 
#define FLASHROM_REGION_JAPAN   1
 Japanese region. More...
 
#define FLASHROM_REGION_US   2
 US/Canada region. More...
 
#define FLASHROM_REGION_EUROPE   3
 European region. More...
 
#define FLASHROM_ISP_DHCP   0
 DHCP-based ethernet. More...
 
#define FLASHROM_ISP_STATIC   1
 Static IP-based ethernet. More...
 
#define FLASHROM_ISP_DIALUP   2
 Dialup ISP. More...
 
#define FLASHROM_ISP_PPPOE   4
 PPPoE-based ethernet. More...
 
#define FLASHROM_ISP_IP   (1 << 0)
 Static IP address. More...
 
#define FLASHROM_ISP_NETMASK   (1 << 1)
 Netmask. More...
 
#define FLASHROM_ISP_BROADCAST   (1 << 2)
 Broadcast address. More...
 
#define FLASHROM_ISP_GATEWAY   (1 << 3)
 Gateway address. More...
 
#define FLASHROM_ISP_DNS   (1 << 4)
 DNS servers. More...
 
#define FLASHROM_ISP_HOSTNAME   (1 << 5)
 Hostname. More...
 
#define FLASHROM_ISP_EMAIL   (1 << 6)
 Email address. More...
 
#define FLASHROM_ISP_SMTP   (1 << 7)
 SMTP server. More...
 
#define FLASHROM_ISP_POP3   (1 << 8)
 POP3 server. More...
 
#define FLASHROM_ISP_POP3_USER   (1 << 9)
 POP3 username. More...
 
#define FLASHROM_ISP_POP3_PASS   (1 << 10)
 POP3 password. More...
 
#define FLASHROM_ISP_PROXY_HOST   (1 << 11)
 Proxy hostname. More...
 
#define FLASHROM_ISP_PROXY_PORT   (1 << 12)
 Proxy port. More...
 
#define FLASHROM_ISP_PPP_USER   (1 << 13)
 PPP username. More...
 
#define FLASHROM_ISP_PPP_PASS   (1 << 14)
 PPP password. More...
 
#define FLASHROM_ISP_OUT_PREFIX   (1 << 15)
 Outside dial prefix. More...
 
#define FLASHROM_ISP_CW_PREFIX   (1 << 16)
 Call waiting prefix. More...
 
#define FLASHROM_ISP_REAL_NAME   (1 << 17)
 Real name. More...
 
#define FLASHROM_ISP_MODEM_INIT   (1 << 18)
 Modem init string. More...
 
#define FLASHROM_ISP_AREA_CODE   (1 << 19)
 Area code. More...
 
#define FLASHROM_ISP_LD_PREFIX   (1 << 20)
 Long distance prefix. More...
 
#define FLASHROM_ISP_PHONE1   (1 << 21)
 Phone number 1. More...
 
#define FLASHROM_ISP_PHONE2   (1 << 22)
 Phone number 2. More...
 
#define FLASHROM_ISP_DIAL_AREACODE   (1 << 0)
 Dial area code before number. More...
 
#define FLASHROM_ISP_USE_PROXY   (1 << 1)
 Proxy enabled. More...
 
#define FLASHROM_ISP_PULSE_DIAL   (1 << 2)
 Pulse dialing (instead of tone) More...
 
#define FLASHROM_ISP_BLIND_DIAL   (1 << 3)
 Blind dial (don't wait for tone) More...
 

Typedefs

typedef struct flashrom_syscfg flashrom_syscfg_t
 System configuration structure. More...
 
typedef struct flashrom_ispcfg flashrom_ispcfg_t
 ISP configuration structure. More...
 

Functions

int flashrom_info (int part, int *start_out, int *size_out)
 Retrieve information about the given partition. More...
 
int flashrom_read (int offset, void *buffer_out, int bytes)
 Read data from the flashrom. More...
 
int flashrom_write (int offset, void *buffer, int bytes)
 Write data to the flashrom. More...
 
int flashrom_delete (int offset)
 Delete data from the flashrom. More...
 
int flashrom_get_block (int partid, int blockid, uint8 *buffer_out)
 Get a logical block from the specified partition. More...
 
int flashrom_get_syscfg (flashrom_syscfg_t *out)
 Retrieve the current system configuration settings. More...
 
int flashrom_get_region ()
 Retrieve the console's region code. More...
 
int flashrom_get_ispcfg (flashrom_ispcfg_t *out)
 Retrieve DreamPassport's ISP configuration. More...
 
int flashrom_get_pw_ispcfg (flashrom_ispcfg_t *out)
 Retrieve PlanetWeb's ISP configuration. More...
 

Detailed Description

Dreamcast flashrom read/write support.

This file implements wrappers for the BIOS flashrom syscalls, and some utilities to make it easier to use the flashrom info. Note that because the flash writing can be such a dangerous thing potentially (I haven't deleted my flash to see what happens, but given the info stored here it sounds like a Bad Idea(tm)) the syscalls for the WRITE and DELETE operations are not enabled by default. If you are 100% sure you really want to be writing to the flash and you know what you're doing, then you can edit flashrom.c and re-enable them there.

Author
Dan Potter
Lawrence Sebald

Typedef Documentation

ISP configuration structure.

This structure will be filled in by flashrom_get_ispcfg() (DreamPassport) or flashrom_get_pw_ispcfg() (PlanetWeb). Thanks to Sam Steele for the information about DreamPassport's ISP settings.

System configuration structure.

This structure is filled in with the settings set in the BIOS from the flashrom_get_syscfg() function.

Function Documentation

int flashrom_delete ( int  offset)

Delete data from the flashrom.

This function implements the FLASHROM_DELETE syscall; given a partition offset, that entire partition of the flashrom will be deleted and all data will be reset to 0xFF bytes.

Parameters
offsetThe partition to erase.
Return values
0On success.
-1On error.
int flashrom_get_block ( int  partid,
int  blockid,
uint8 buffer_out 
)

Get a logical block from the specified partition.

This function retrieves the specified block ID from the given partition. The newest version of the data is returned.

Parameters
partidThe partition ID to look in.
blockidThe logical block ID to look for.
buffer_outSpace to store the data. Must be at least 60 bytes.
Returns
0 on success, <0 on error.
int flashrom_get_ispcfg ( flashrom_ispcfg_t out)

Retrieve DreamPassport's ISP configuration.

This function retrieves the console's ISP settings as set by DreamPassport, if they exist. You should check the valid_fields bitfield for the part of the struct you want before relying on the data.

Parameters
outStorage for the structure.
Return values
0On success.
-1On error (no settings found, or other errors).
int flashrom_get_pw_ispcfg ( flashrom_ispcfg_t out)

Retrieve PlanetWeb's ISP configuration.

This function retrieves the console's ISP settings as set by PlanetWeb (1.0 and 2.1 have been verified to work), if they exist. You should check the valid_fields bitfield for the part of the struct you want before relying on the data.

Parameters
outStorage for the structure.
Return values
0On success.
-1On error (i.e, no PlanetWeb settings found).
int flashrom_get_region ( )

Retrieve the console's region code.

This function attempts to find the region of the Dreamcast. It may or may not work on 100% of Dreamcasts, apparently.

Returns
A region code, or -1 on error.
See also
Region settings possible in the system
int flashrom_get_syscfg ( flashrom_syscfg_t out)

Retrieve the current system configuration settings.

Parameters
outStorage for the configuration.
Returns
0 on success, <0 on error.
int flashrom_info ( int  part,
int *  start_out,
int *  size_out 
)

Retrieve information about the given partition.

This function implements the FLASHROM_INFO syscall; given a partition ID, return two ints specifying the beginning and the size of the partition (respectively) inside the flashrom.

Parameters
partThe partition ID in question.
start_outBuffer for storing the start address.
size_outBuffer for storing the size of the partition.
Return values
0On success.
-1On error.
int flashrom_read ( int  offset,
void *  buffer_out,
int  bytes 
)

Read data from the flashrom.

This function implements the FLASHROM_READ syscall; given a flashrom offset, an output buffer, and a count, this reads data from the flashrom.

Parameters
offsetThe offset to read from.
buffer_outSpace to read into.
bytesThe number of bytes to read.
Returns
The number of bytes read if successful, or -1 otherwise.
int flashrom_write ( int  offset,
void *  buffer,
int  bytes 
)

Write data to the flashrom.

This function implements the FLASHROM_WRITE syscall; given a flashrom offset, an input buffer, and a count, this writes data to the flashrom.

Note
It is not possible to write ones to the flashrom over zeros. If you want to do this, you must save the old data in the flashrom, delete it out, and save the new data back.
Parameters
offsetThe offset to write at.
bufferThe data to write.
bytesThe number of bytes to write.
Returns
The number of bytes written if successful, -1 otherwise.