1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

Fix coding style of flashrom by running indent on all files

indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs *.[ch]

Some minor fixups were required, and maybe a few more cosmetic
changes are needed.

Corresponding to flashrom svn r108 and coreboot v2 svn r2643.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
This commit is contained in:
Uwe Hermann 2007-05-09 10:17:44 +00:00
parent 7977f4ef2e
commit a7e0548cea
15 changed files with 709 additions and 775 deletions

View File

@ -124,8 +124,7 @@ uint8_t wait_82802ab(volatile uint8_t *bios)
int erase_82802ab_block(struct flashchip *flash, int offset) int erase_82802ab_block(struct flashchip *flash, int offset)
{ {
volatile uint8_t *bios = flash->virt_addr + offset; volatile uint8_t *bios = flash->virt_addr + offset;
volatile uint8_t *wrprotect = volatile uint8_t *wrprotect = flash->virt_addr_2 + offset + 2;
flash->virt_addr_2 + offset + 2;
uint8_t status; uint8_t status;
// clear status register // clear status register
@ -160,8 +159,8 @@ int erase_82802ab(struct flashchip *flash)
return (0); return (0);
} }
void write_page_82802ab(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *dst, void write_page_82802ab(volatile uint8_t *bios, uint8_t *src,
int page_size) volatile uint8_t *dst, int page_size)
{ {
int i; int i;
@ -177,8 +176,8 @@ void write_page_82802ab(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *
int write_82802ab(struct flashchip *flash, uint8_t *buf) int write_82802ab(struct flashchip *flash, uint8_t *buf)
{ {
int i; int i;
int total_size = flash->total_size * 1024, page_size = int total_size = flash->total_size * 1024;
flash->page_size; int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
erase_82802ab(flash); erase_82802ab(flash);
@ -191,8 +190,7 @@ int write_82802ab(struct flashchip *flash, uint8_t *buf)
printf("%04d at address: 0x%08x", i, i * page_size); printf("%04d at address: 0x%08x", i, i * page_size);
write_page_82802ab(bios, buf + i * page_size, write_page_82802ab(bios, buf + i * page_size,
bios + i * page_size, page_size); bios + i * page_size, page_size);
printf printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
} }
printf("\n"); printf("\n");
protect_82802ab(bios); protect_82802ab(bios);

View File

@ -30,38 +30,33 @@
#define W836_DATA 0x2F #define W836_DATA 0x2F
/* Enter extended functions */ /* Enter extended functions */
static void static void w836xx_ext_enter(void)
w836xx_ext_enter(void)
{ {
outb(0x87, W836_INDEX); outb(0x87, W836_INDEX);
outb(0x87, W836_INDEX); outb(0x87, W836_INDEX);
} }
/* Leave extended functions */ /* Leave extended functions */
static void static void w836xx_ext_leave(void)
w836xx_ext_leave(void)
{ {
outb(0xAA, W836_INDEX); outb(0xAA, W836_INDEX);
} }
/* General functions for read/writing WB SuperIOs */ /* General functions for read/writing WB SuperIOs */
static unsigned char static unsigned char wbsio_read(unsigned char index)
wbsio_read(unsigned char index)
{ {
outb(index, W836_INDEX); outb(index, W836_INDEX);
return inb(W836_DATA); return inb(W836_DATA);
} }
static void static void wbsio_write(unsigned char index, unsigned char data)
wbsio_write(unsigned char index, unsigned char data)
{ {
outb(index, W836_INDEX); outb(index, W836_INDEX);
outb(data, W836_DATA); outb(data, W836_DATA);
} }
static void static void
wbsio_mask(unsigned char index, unsigned char data, wbsio_mask(unsigned char index, unsigned char data, unsigned char mask)
unsigned char mask)
{ {
unsigned char tmp; unsigned char tmp;
@ -225,8 +220,8 @@ struct board_pciid_enable board_pciid_enables[] = {
* Require main pci-ids to match too as extra safety. * Require main pci-ids to match too as extra safety.
* *
*/ */
static struct board_pciid_enable * static struct board_pciid_enable *board_match_linuxbios_name(char *vendor,
board_match_linuxbios_name(char *vendor, char *part) char *part)
{ {
struct board_pciid_enable *board = board_pciid_enables; struct board_pciid_enable *board = board_pciid_enables;

View File

@ -80,15 +80,16 @@ static int enable_flash_piix4(struct pci_dev *dev, char *name)
old = pci_read_word(dev, xbcs); old = pci_read_word(dev, xbcs);
/* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to /* Set bit 9: 1-Meg Extended BIOS Enable (PCI master accesses to
FFF00000-FFF7FFFF are forwarded to ISA). * FFF00000-FFF7FFFF are forwarded to ISA).
Set bit 7: Extended BIOS Enable (PCI master accesses to * Set bit 7: Extended BIOS Enable (PCI master accesses to
FFF80000-FFFDFFFF are forwarded to ISA). * FFF80000-FFFDFFFF are forwarded to ISA).
Set bit 6: Lower BIOS Enable (PCI master, or ISA master accesses to * Set bit 6: Lower BIOS Enable (PCI master, or ISA master accesses to
the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top * the lower 64-Kbyte BIOS block (E0000-EFFFF) at the top
of 1 Mbyte, or the aliases at the top of 4 Gbyte * of 1 Mbyte, or the aliases at the top of 4 Gbyte
(FFFE0000-FFFEFFFF) result in the generation of BIOSCS#. * (FFFE0000-FFFEFFFF) result in the generation of BIOSCS#.
Note: Accesses to FFFF0000-FFFFFFFF are always forwarded to ISA. * Note: Accesses to FFFF0000-FFFFFFFF are always forwarded to ISA.
Set bit 2: BIOSCS# Write Enable (1=enable, 0=disable). */ * Set bit 2: BIOSCS# Write Enable (1=enable, 0=disable).
*/
new = old | 0x2c4; new = old | 0x2c4;
if (new == old) if (new == old)
@ -130,8 +131,7 @@ static int enable_flash_ich(struct pci_dev *dev, char *name, int bios_cntl)
pci_write_byte(dev, bios_cntl, new); pci_write_byte(dev, bios_cntl, new);
if (pci_read_byte(dev, bios_cntl) != new) { if (pci_read_byte(dev, bios_cntl) != new) {
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", bios_cntl, new, name);
bios_cntl, new, name);
return -1; return -1;
} }
return 0; return 0;
@ -150,8 +150,7 @@ static int enable_flash_ich_dc(struct pci_dev *dev, char *name)
/* /*
* *
*/ */
static int static int enable_flash_vt823x(struct pci_dev *dev, char *name)
enable_flash_vt823x(struct pci_dev *dev, char *name)
{ {
uint8_t val; uint8_t val;
@ -178,8 +177,7 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name)
new = pci_read_byte(dev, 0x52); new = pci_read_byte(dev, 0x52);
if (new != 0xee) { if (new != 0xee) {
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x52, new, name);
0x52, new, name);
return -1; return -1;
} }
@ -189,7 +187,6 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name)
return 0; return 0;
} }
static int enable_flash_sc1100(struct pci_dev *dev, char *name) static int enable_flash_sc1100(struct pci_dev *dev, char *name)
{ {
uint8_t new; uint8_t new;
@ -199,8 +196,7 @@ static int enable_flash_sc1100(struct pci_dev *dev, char *name)
new = pci_read_byte(dev, 0x52); new = pci_read_byte(dev, 0x52);
if (new != 0xee) { if (new != 0xee) {
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x52, new, name);
0x52, new, name);
return -1; return -1;
} }
return 0; return 0;
@ -221,8 +217,7 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
newer = pci_read_byte(dev, 0x45); newer = pci_read_byte(dev, 0x45);
if (newer != new) { if (newer != new) {
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x45, new, name);
0x45, new, name);
printf("Stuck at 0x%x\n", newer); printf("Stuck at 0x%x\n", newer);
return -1; return -1;
} }
@ -233,6 +228,7 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name)
{ {
/* register 4e.b gets or'ed with one */ /* register 4e.b gets or'ed with one */
uint8_t old, new; uint8_t old, new;
/* if it fails, it fails. There are so many variations of broken mobos /* if it fails, it fails. There are so many variations of broken mobos
* that it is hard to argue that we should quit at this point. * that it is hard to argue that we should quit at this point.
*/ */
@ -243,8 +239,7 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name)
if (new != old) { if (new != old) {
pci_write_byte(dev, 0x43, new); pci_write_byte(dev, 0x43, new);
if (pci_read_byte(dev, 0x43) != new) { if (pci_read_byte(dev, 0x43) != new) {
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x43, new, name);
0x43, new, name);
} }
} }
@ -255,8 +250,7 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name)
pci_write_byte(dev, 0x40, new); pci_write_byte(dev, 0x40, new);
if (pci_read_byte(dev, 0x40) != new) { if (pci_read_byte(dev, 0x40) != new) {
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x40, new, name);
0x40, new, name);
return -1; return -1;
} }
return 0; return 0;
@ -266,6 +260,7 @@ static int enable_flash_ck804(struct pci_dev *dev, char *name)
{ {
/* register 4e.b gets or'ed with one */ /* register 4e.b gets or'ed with one */
uint8_t old, new; uint8_t old, new;
/* if it fails, it fails. There are so many variations of broken mobos /* if it fails, it fails. There are so many variations of broken mobos
* that it is hard to argue that we should quit at this point. * that it is hard to argue that we should quit at this point.
*/ */
@ -277,8 +272,7 @@ static int enable_flash_ck804(struct pci_dev *dev, char *name)
if (new != old) { if (new != old) {
pci_write_byte(dev, 0x88, new); pci_write_byte(dev, 0x88, new);
if (pci_read_byte(dev, 0x88) != new) { if (pci_read_byte(dev, 0x88) != new) {
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x88, new, name);
0x88, new, name);
} }
} }
@ -289,8 +283,7 @@ static int enable_flash_ck804(struct pci_dev *dev, char *name)
pci_write_byte(dev, 0x6d, new); pci_write_byte(dev, 0x6d, new);
if (pci_read_byte(dev, 0x6d) != new) { if (pci_read_byte(dev, 0x6d) != new) {
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name);
0x6d, new, name);
return -1; return -1;
} }
return 0; return 0;
@ -371,7 +364,8 @@ static int enable_flash_mcp55(struct pci_dev *dev, char *name)
pci_write_byte(dev, 0x6d, new); pci_write_byte(dev, 0x6d, new);
if (pci_read_byte(dev, 0x6d) != new) { if (pci_read_byte(dev, 0x6d) != new) {
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", printf
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
0x6d, new, name); 0x6d, new, name);
return -1; return -1;
} }
@ -441,8 +435,7 @@ static FLASH_ENABLE enables[] = {
/* /*
* *
*/ */
int int chipset_flash_enable(void)
chipset_flash_enable(void)
{ {
struct pci_dev *dev = 0; struct pci_dev *dev = 0;
int ret = -2; /* nothing! */ int ret = -2; /* nothing! */

View File

@ -60,8 +60,7 @@ int fd_mem;
/* /*
* *
*/ */
struct pci_dev * struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device)
pci_dev_find(uint16_t vendor, uint16_t device)
{ {
struct pci_dev *temp; struct pci_dev *temp;
struct pci_filter filter; struct pci_filter filter;
@ -80,8 +79,7 @@ pci_dev_find(uint16_t vendor, uint16_t device)
/* /*
* *
*/ */
struct pci_dev * struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
pci_card_find(uint16_t vendor, uint16_t device,
uint16_t card_vendor, uint16_t card_device) uint16_t card_vendor, uint16_t card_device)
{ {
struct pci_dev *temp; struct pci_dev *temp;
@ -163,7 +161,8 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
printf("Verifying flash "); printf("Verifying flash ");
if(verbose) printf("address: 0x00000000\b\b\b\b\b\b\b\b\b\b"); if (verbose)
printf("address: 0x00000000\b\b\b\b\b\b\b\b\b\b");
for (idx = 0; idx < total_size; idx++) { for (idx = 0; idx < total_size; idx++) {
if (verbose && ((idx & 0xfff) == 0xfff)) if (verbose && ((idx & 0xfff) == 0xfff))
@ -187,12 +186,12 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
return 0; return 0;
} }
void usage(const char *name) void usage(const char *name)
{ {
printf("usage: %s [-rwvEVfh] [-c chipname] [-s exclude_start]\n", name); printf("usage: %s [-rwvEVfh] [-c chipname] [-s exclude_start]\n", name);
printf(" [-e exclude_end] [-m vendor:part] [-l file.layout] [-i imagename] [file]\n"); printf(" [-e exclude_end] [-m vendor:part] [-l file.layout] [-i imagename] [file]\n");
printf(" -r | --read: read flash and save into file\n" printf
(" -r | --read: read flash and save into file\n"
" -w | --write: write file into flash (default when\n" " -w | --write: write file into flash (default when\n"
" file is specified)\n" " file is specified)\n"
" -v | --verify: verify flash against file\n" " -v | --verify: verify flash against file\n"
@ -205,8 +204,7 @@ void usage(const char *name)
" -f | --force: force write without checking image\n" " -f | --force: force write without checking image\n"
" -l | --layout <file.layout>: read rom layout from file\n" " -l | --layout <file.layout>: read rom layout from file\n"
" -i | --image <name>: only flash image name from flash layout\n" " -i | --image <name>: only flash image name from flash layout\n"
"\n" "\n" " If no file is specified, then all that happens\n"
" If no file is specified, then all that happens\n"
" is that flash info is dumped.\n\n"); " is that flash info is dumped.\n\n");
exit(1); exit(1);
} }
@ -219,10 +217,7 @@ int main(int argc, char *argv[])
struct flashchip *flash; struct flashchip *flash;
int opt; int opt;
int option_index = 0; int option_index = 0;
int read_it = 0, int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
write_it = 0,
erase_it = 0,
verify_it = 0;
int ret = 0; int ret = 0;
static struct option long_options[] = { static struct option long_options[] = {
@ -244,7 +239,6 @@ int main(int argc, char *argv[])
char *filename = NULL; char *filename = NULL;
unsigned int exclude_start_position = 0, exclude_end_position = 0; // [x,y) unsigned int exclude_start_position = 0, exclude_end_position = 0; // [x,y)
char *tempstr = NULL, *tempstr2 = NULL; char *tempstr = NULL, *tempstr2 = NULL;
@ -257,8 +251,8 @@ int main(int argc, char *argv[])
} }
setbuf(stdout, NULL); setbuf(stdout, NULL);
while ((opt = getopt_long(argc, argv, "rwvVEfc:s:e:m:l:i:h", long_options, while ((opt = getopt_long(argc, argv, "rwvVEfc:s:e:m:l:i:h",
&option_index)) != EOF) { long_options, &option_index)) != EOF) {
switch (opt) { switch (opt) {
case 'r': case 'r':
read_it = 1; read_it = 1;
@ -331,7 +325,8 @@ int main(int argc, char *argv[])
#else #else
if (iopl(3) != 0) { if (iopl(3) != 0) {
#endif #endif
fprintf(stderr, "ERROR: iopl failed: \"%s\"\n", strerror(errno)); fprintf(stderr, "ERROR: iopl failed: \"%s\"\n",
strerror(errno));
exit(1); exit(1);
} }
@ -343,7 +338,8 @@ int main(int argc, char *argv[])
/* Open the memory device. A lot of functions need it */ /* Open the memory device. A lot of functions need it */
if ((fd_mem = open(MEM_DEV, O_RDWR)) < 0) { if ((fd_mem = open(MEM_DEV, O_RDWR)) < 0) {
perror("Error: Can not access memory using " MEM_DEV ". You need to be root."); perror("Error: Can not access memory using " MEM_DEV
". You need to be root.");
exit(1); exit(1);
} }
@ -358,13 +354,13 @@ int main(int argc, char *argv[])
* really need this to be done, etc., etc. * really need this to be done, etc., etc.
*/ */
ret = chipset_flash_enable(); ret = chipset_flash_enable();
if (ret == -2) if (ret == -2) {
printf("WARNING: No chipset found. Flash detection " printf("WARNING: No chipset found. Flash detection "
"will most likely fail.\n"); "will most likely fail.\n");
}
board_flash_enable(lb_vendor, lb_part); board_flash_enable(lb_vendor, lb_part);
if ((flash = probe_flash(flashchips)) == NULL) { if ((flash = probe_flash(flashchips)) == NULL) {
printf("No EEPROM/flash device found.\n"); printf("No EEPROM/flash device found.\n");
exit(1); exit(1);

View File

@ -163,8 +163,7 @@ retry:
src = s; src = s;
ok = 1; ok = 1;
for (i = 0; i < page_size; i++) { for (i = 0; i < page_size; i++) {
if ( *dst != *src ) if (*dst != *src) {
{
ok = 0; ok = 0;
break; break;
} }
@ -177,7 +176,8 @@ retry:
goto retry; goto retry;
} }
if (!ok) { if (!ok) {
fprintf( stderr, " page %d failed!\n", (unsigned int)(d-bios)/page_size ); fprintf(stderr, " page %d failed!\n",
(unsigned int)(d - bios) / page_size);
} }
return (!ok); return (!ok);
} }

View File

@ -25,12 +25,10 @@ romlayout_t rom_entries[MAX_ROMLAYOUT];
static char *def_name = "DEFAULT"; static char *def_name = "DEFAULT";
int show_id(uint8_t *bios, int size) int show_id(uint8_t *bios, int size)
{ {
unsigned int *walk; unsigned int *walk;
walk = (unsigned int *)(bios + size - 0x10); walk = (unsigned int *)(bios + size - 0x10);
walk--; walk--;
@ -53,12 +51,13 @@ int show_id(uint8_t *bios, int size)
printf_debug("LinuxBIOS last image size " printf_debug("LinuxBIOS last image size "
"(not rom size) is %d bytes.\n", *walk); "(not rom size) is %d bytes.\n", *walk);
walk--; mainboard_part=strdup((const char *)(bios+size-*walk)); walk--;
walk--; mainboard_vendor=strdup((const char *)(bios+size-*walk)); mainboard_part = strdup((const char *)(bios + size - *walk));
walk--;
mainboard_vendor = strdup((const char *)(bios + size - *walk));
printf_debug("MANUFACTURER: %s\n", mainboard_vendor); printf_debug("MANUFACTURER: %s\n", mainboard_vendor);
printf_debug("MAINBOARD ID: %s\n", mainboard_part); printf_debug("MAINBOARD ID: %s\n", mainboard_part);
/* /*
* If lb_vendor is not set, the linuxbios table was * If lb_vendor is not set, the linuxbios table was
* not found. Nor was -mVENDOR:PART specified * not found. Nor was -mVENDOR:PART specified
@ -89,7 +88,8 @@ int show_id(uint8_t *bios, int size)
"are absolutely sure that you\nare using a correct " "are absolutely sure that you\nare using a correct "
"image for this mainboard or override\nthe detected " "image for this mainboard or override\nthe detected "
"values with --mainboard <vendor>:<mainboard>.\n\n", "values with --mainboard <vendor>:<mainboard>.\n\n",
mainboard_vendor, mainboard_part, lb_vendor, lb_part); mainboard_vendor, mainboard_part, lb_vendor,
lb_part);
exit(1); exit(1);
} }
} }
@ -113,7 +113,8 @@ int read_romlayout(char *name)
while (!feof(romlayout)) { while (!feof(romlayout)) {
char *tstr1, *tstr2; char *tstr1, *tstr2;
fscanf(romlayout,"%s %s\n", tempstr, rom_entries[romimages].name); fscanf(romlayout, "%s %s\n", tempstr,
rom_entries[romimages].name);
#if 0 #if 0
// fscanf does not like arbitrary comments like that :( later // fscanf does not like arbitrary comments like that :( later
if (tempstr[0] == '#') { if (tempstr[0] == '#') {
@ -131,8 +132,7 @@ int read_romlayout(char *name)
for (i = 0; i < romimages; i++) { for (i = 0; i < romimages; i++) {
printf_debug("romlayout %08x - %08x named %s\n", printf_debug("romlayout %08x - %08x named %s\n",
rom_entries[i].start, rom_entries[i].start,
rom_entries[i].end, rom_entries[i].end, rom_entries[i].name);
rom_entries[i].name);
} }
fclose(romlayout); fclose(romlayout);
@ -143,7 +143,8 @@ int find_romentry(char *name)
{ {
int i; int i;
if(!romimages) return -1; if (!romimages)
return -1;
printf("Looking for \"%s\"... ", name); printf("Looking for \"%s\"... ", name);
@ -178,7 +179,6 @@ int handle_romentries(uint8_t *buffer, uint8_t *content)
// flash. Same thing if you specify -i normal -i all only // flash. Same thing if you specify -i normal -i all only
// normal will be updated and the rest will be kept. // normal will be updated and the rest will be kept.
for (i = 0; i < romimages; i++) { for (i = 0; i < romimages; i++) {
if (rom_entries[i].included) if (rom_entries[i].included)

View File

@ -52,7 +52,6 @@ static unsigned long compute_checksum(void *addr, unsigned long length)
((((char *)rec) + rec->size) <= (((char *)head) + sizeof(*head) + head->table_bytes)); \ ((((char *)rec) + rec->size) <= (((char *)head) + sizeof(*head) + head->table_bytes)); \
rec = (struct lb_record *)(((char *)rec) + rec->size)) rec = (struct lb_record *)(((char *)rec) + rec->size))
static int count_lb_records(struct lb_header *head) static int count_lb_records(struct lb_header *head)
{ {
struct lb_record *rec; struct lb_record *rec;
@ -64,14 +63,16 @@ static int count_lb_records(struct lb_header *head)
return count; return count;
} }
static struct lb_header *find_lb_table(void *base, unsigned long start,
static struct lb_header *find_lb_table(void *base, unsigned long start, unsigned long end) unsigned long end)
{ {
unsigned long addr; unsigned long addr;
/* For now be stupid.... */ /* For now be stupid.... */
for (addr = start; addr < end; addr += 16) { for (addr = start; addr < end; addr += 16) {
struct lb_header *head = (struct lb_header *)(((char*)base) + addr); struct lb_header *head =
struct lb_record *recs = (struct lb_record *)(((char*)base) + addr + sizeof(*head)); (struct lb_header *)(((char *)base) + addr);
struct lb_record *recs =
(struct lb_record *)(((char *)base) + addr + sizeof(*head));
if (memcmp(head->signature, "LBIO", 4) != 0) if (memcmp(head->signature, "LBIO", 4) != 0)
continue; continue;
printf_debug("Found canidate at: %08lx-%08lx\n", printf_debug("Found canidate at: %08lx-%08lx\n",
@ -121,8 +122,7 @@ static void find_mainboard(struct lb_record *ptr, unsigned long addr)
rec->strings + rec->part_number_idx); rec->strings + rec->part_number_idx);
if (lb_part) { if (lb_part) {
printf("overwritten by command line, vendor id: %s part id: %s\n", printf("overwritten by command line, vendor id: %s part id: %s\n", lb_vendor, lb_part);
lb_vendor, lb_part);
} else { } else {
lb_part = strdup(part); lb_part = strdup(part);
lb_vendor = strdup(vendor); lb_vendor = strdup(vendor);
@ -158,9 +158,11 @@ int linuxbios_init(void)
struct lb_header *lb_table; struct lb_header *lb_table;
struct lb_record *rec, *last; struct lb_record *rec, *last;
low_1MB = mmap(0, 1024*1024, PROT_READ, MAP_SHARED, fd_mem, 0x00000000); low_1MB = mmap(0, 1024 * 1024, PROT_READ, MAP_SHARED, fd_mem,
0x00000000);
if (low_1MB == MAP_FAILED) { if (low_1MB == MAP_FAILED) {
fprintf(stderr, "Can not mmap " MEM_DEV " at %08lx errno(%d):%s\n", fprintf(stderr,
"Can not mmap " MEM_DEV " at %08lx errno(%d):%s\n",
0x00000000UL, errno, strerror(errno)); 0x00000000UL, errno, strerror(errno));
exit(-2); exit(-2);
} }
@ -177,10 +179,10 @@ int linuxbios_init(void)
last = (struct lb_record *)(((char *)rec) + lb_table->table_bytes); last = (struct lb_record *)(((char *)rec) + lb_table->table_bytes);
printf_debug("LinuxBIOS header(%d) checksum: %04x table(%d) checksum: %04x entries: %d\n", printf_debug("LinuxBIOS header(%d) checksum: %04x table(%d) checksum: %04x entries: %d\n",
lb_table->header_bytes, lb_table->header_checksum, lb_table->header_bytes, lb_table->header_checksum,
lb_table->table_bytes, lb_table->table_checksum, lb_table->table_entries); lb_table->table_bytes, lb_table->table_checksum,
lb_table->table_entries);
search_lb_records(rec, last, addr + lb_table->header_bytes); search_lb_records(rec, last, addr + lb_table->header_bytes);
} } else {
else {
printf("No LinuxBIOS table found.\n"); printf("No LinuxBIOS table found.\n");
return -1; return -1;
} }

View File

@ -64,10 +64,7 @@ static inline struct lb_uint64 pack_lb64(uint64_t value)
return result; return result;
} }
struct lb_header {
struct lb_header
{
uint8_t signature[4]; /* LBIO */ uint8_t signature[4]; /* LBIO */
uint32_t header_bytes; uint32_t header_bytes;
uint32_t header_checksum; uint32_t header_checksum;
@ -167,7 +164,6 @@ struct cmos_entries {
variable length int aligned */ variable length int aligned */
}; };
/* cmos enumerations record /* cmos enumerations record
This record is variable length. The text field may be This record is variable length. The text field may be
shorter than CMOS_MAX_TEXT_LENGTH. shorter than CMOS_MAX_TEXT_LENGTH.
@ -211,6 +207,4 @@ struct cmos_checksum {
#define CHECKSUM_PCBIOS 1 #define CHECKSUM_PCBIOS 1
}; };
#endif /* LINUXBIOS_TABLES_H */ #endif /* LINUXBIOS_TABLES_H */

View File

@ -49,7 +49,6 @@ int probe_m29f400bt(struct flashchip *flash)
printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
if (id1 == flash->manufacture_id && id2 == flash->model_id) if (id1 == flash->manufacture_id && id2 == flash->model_id)
return 1; return 1;
@ -95,8 +94,8 @@ int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst)
int write_m29f400bt(struct flashchip *flash, uint8_t *buf) int write_m29f400bt(struct flashchip *flash, uint8_t *buf)
{ {
int i; int i;
int total_size = flash->total_size * 1024, page_size = int total_size = flash->total_size * 1024;
flash->page_size; int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
//erase_m29f400bt (flash); //erase_m29f400bt (flash);
@ -122,29 +121,24 @@ int write_m29f400bt(struct flashchip *flash, uint8_t *buf)
block_erase_m29f400bt(bios, bios + i * page_size); block_erase_m29f400bt(bios, bios + i * page_size);
write_page_m29f400bt(bios, buf + i * page_size, write_page_m29f400bt(bios, buf + i * page_size,
bios + i * page_size, page_size); bios + i * page_size, page_size);
printf printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
} }
printf("%04d at address: 0x%08x\n", 7, 0x70000); printf("%04d at address: 0x%08x\n", 7, 0x70000);
block_erase_m29f400bt(bios, bios + 0x70000); block_erase_m29f400bt(bios, bios + 0x70000);
write_page_m29f400bt(bios, buf + 0x70000, bios + 0x70000, write_page_m29f400bt(bios, buf + 0x70000, bios + 0x70000, 32 * 1024);
32 * 1024);
printf("%04d at address: 0x%08x\n", 8, 0x78000); printf("%04d at address: 0x%08x\n", 8, 0x78000);
block_erase_m29f400bt(bios, bios + 0x78000); block_erase_m29f400bt(bios, bios + 0x78000);
write_page_m29f400bt(bios, buf + 0x78000, bios + 0x78000, write_page_m29f400bt(bios, buf + 0x78000, bios + 0x78000, 8 * 1024);
8 * 1024);
printf("%04d at address: 0x%08x\n", 9, 0x7a000); printf("%04d at address: 0x%08x\n", 9, 0x7a000);
block_erase_m29f400bt(bios, bios + 0x7a000); block_erase_m29f400bt(bios, bios + 0x7a000);
write_page_m29f400bt(bios, buf + 0x7a000, bios + 0x7a000, write_page_m29f400bt(bios, buf + 0x7a000, bios + 0x7a000, 8 * 1024);
8 * 1024);
printf("%04d at address: 0x%08x\n", 10, 0x7c000); printf("%04d at address: 0x%08x\n", 10, 0x7c000);
block_erase_m29f400bt(bios, bios + 0x7c000); block_erase_m29f400bt(bios, bios + 0x7c000);
write_page_m29f400bt(bios, buf + 0x7c000, bios + 0x7c000, write_page_m29f400bt(bios, buf + 0x7c000, bios + 0x7c000, 16 * 1024);
16 * 1024);
printf("\n"); printf("\n");
//protect_m29f400bt (bios); //protect_m29f400bt (bios);
@ -174,23 +168,19 @@ int write_linuxbios_m29f400bt(struct flashchip *flash, uint8_t *buf)
*********************************/ *********************************/
printf("%04d at address: 0x%08x\n", 7, 0x00000); printf("%04d at address: 0x%08x\n", 7, 0x00000);
block_erase_m29f400bt(bios, bios + 0x00000); block_erase_m29f400bt(bios, bios + 0x00000);
write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000, write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000, 64 * 1024);
64 * 1024);
printf("%04d at address: 0x%08x\n", 7, 0x10000); printf("%04d at address: 0x%08x\n", 7, 0x10000);
block_erase_m29f400bt(bios, bios + 0x10000); block_erase_m29f400bt(bios, bios + 0x10000);
write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000, write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000, 64 * 1024);
64 * 1024);
printf("%04d at address: 0x%08x\n", 7, 0x20000); printf("%04d at address: 0x%08x\n", 7, 0x20000);
block_erase_m29f400bt(bios, bios + 0x20000); block_erase_m29f400bt(bios, bios + 0x20000);
write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000, write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000, 64 * 1024);
64 * 1024);
printf("%04d at address: 0x%08x\n", 7, 0x30000); printf("%04d at address: 0x%08x\n", 7, 0x30000);
block_erase_m29f400bt(bios, bios + 0x30000); block_erase_m29f400bt(bios, bios + 0x30000);
write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000, write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000, 64 * 1024);
64 * 1024);
printf("\n"); printf("\n");
//protect_m29f400bt (bios); //protect_m29f400bt (bios);

View File

@ -5,10 +5,10 @@
extern int probe_m29f400bt(struct flashchip *flash); extern int probe_m29f400bt(struct flashchip *flash);
extern int erase_m29f400bt(struct flashchip *flash); extern int erase_m29f400bt(struct flashchip *flash);
extern int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst); extern int block_erase_m29f400bt(volatile uint8_t *bios,
volatile uint8_t *dst);
extern int write_m29f400bt(struct flashchip *flash, uint8_t *buf); extern int write_m29f400bt(struct flashchip *flash, uint8_t *buf);
extern int write_linuxbios_m29f400bt(struct flashchip *flash, extern int write_linuxbios_m29f400bt(struct flashchip *flash, uint8_t *buf);
uint8_t *buf);
extern __inline__ void toggle_ready_m29f400bt(volatile uint8_t *dst) extern __inline__ void toggle_ready_m29f400bt(volatile uint8_t *dst)
{ {
@ -51,7 +51,8 @@ extern __inline__ void protect_m29f400bt(volatile uint8_t *bios)
usleep(200); usleep(200);
} }
extern __inline__ void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src, extern __inline__ void write_page_m29f400bt(volatile uint8_t *bios,
uint8_t *src,
volatile uint8_t *dst, volatile uint8_t *dst,
int page_size) int page_size)
{ {

View File

@ -19,27 +19,18 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "flash.h" #include "flash.h"
#include "msys_doc.h" #include "msys_doc.h"
#include "debug.h" #include "debug.h"
static int doc_wait(volatile uint8_t *bios, int timeout); static int doc_wait(volatile uint8_t *bios, int timeout);
static uint8_t doc_read_chipid(volatile uint8_t *bios); static uint8_t doc_read_chipid(volatile uint8_t *bios);
static uint8_t doc_read_docstatus(volatile uint8_t *bios); static uint8_t doc_read_docstatus(volatile uint8_t *bios);
static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios); static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios);
static void doc_write_cdsncontrol(volatile uint8_t *bios, uint8_t data); static void doc_write_cdsncontrol(volatile uint8_t *bios, uint8_t data);
int probe_md2802(struct flashchip *flash) int probe_md2802(struct flashchip *flash)
{ {
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
@ -72,11 +63,9 @@ int probe_md2802(struct flashchip *flash)
printf("%s: switching off write protection ...\n", __FUNCTION__); printf("%s: switching off write protection ...\n", __FUNCTION__);
doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios) & (~0x08)); doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios) & (~0x08));
printf("%s: switching off write protection ... done\n", printf("%s: switching off write protection ... done\n", __FUNCTION__);
__FUNCTION__);
printf("%s:\n", __FUNCTION__); printf("%s:\n", __FUNCTION__);
chipid = doc_read_chipid(bios); chipid = doc_read_chipid(bios);
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING #ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
id_0x55 = doc_read(bios, IPL_0x0000); id_0x55 = doc_read(bios, IPL_0x0000);
@ -140,8 +129,7 @@ int probe_md2802(struct flashchip *flash)
printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a, printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a,
toggle_b); toggle_b);
if (chipid == flash->model_id if (chipid == flash->model_id && ((toggle_a == 5 && toggle_b == 0)
&& ((toggle_a == 5 && toggle_b == 0)
|| (toggle_a == 0 && toggle_b == 5)) || (toggle_a == 0 && toggle_b == 5))
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING #ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
&& id_0x55 == 0x55 && id_0xAA == 0xaa && id_0x55 == 0x55 && id_0xAA == 0xaa
@ -153,16 +141,12 @@ int probe_md2802(struct flashchip *flash)
return (0); return (0);
} /* int probe_md2802(struct flashchip *flash) */ } /* int probe_md2802(struct flashchip *flash) */
int read_md2802(struct flashchip *flash, uint8_t *buf) int read_md2802(struct flashchip *flash, uint8_t *buf)
{ {
return (0); return (0);
} /* int read_md2802(struct flashchip *flash, uint8_t *buf) */ } /* int read_md2802(struct flashchip *flash, uint8_t *buf) */
int erase_md2802(struct flashchip *flash) int erase_md2802(struct flashchip *flash)
{ {
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
@ -177,13 +161,11 @@ int erase_md2802(struct flashchip *flash)
*(volatile uint8_t *)(bios + 0x5555) = 0x10; *(volatile uint8_t *)(bios + 0x5555) = 0x10;
} /* int erase_md2802(struct flashchip *flash) */ } /* int erase_md2802(struct flashchip *flash) */
int write_md2802(struct flashchip *flash, uint8_t *buf) int write_md2802(struct flashchip *flash, uint8_t *buf)
{ {
int i; int i;
int total_size = flash->total_size * 1024, page_size = int total_size = flash->total_size * 1024;
flash->page_size; int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
return (1); return (1);
@ -205,11 +187,6 @@ int write_md2802(struct flashchip *flash, uint8_t *buf)
return 0; return 0;
} /* int write_md2802(struct flashchip *flash, uint8_t *buf) */ } /* int write_md2802(struct flashchip *flash, uint8_t *buf) */
/* /*
wait timeout msec for doc to become ready wait timeout msec for doc to become ready
return: return:
@ -237,8 +214,6 @@ static int doc_wait(volatile uint8_t *bios, int timeout)
return (0); return (0);
} /* static int doc_wait(volatile uint8_t *bios, int timeout) */ } /* static int doc_wait(volatile uint8_t *bios, int timeout) */
static uint8_t doc_read_docstatus(volatile uint8_t *bios) static uint8_t doc_read_docstatus(volatile uint8_t *bios)
{ {
doc_read(bios, CDSNSlowIO); doc_read(bios, CDSNSlowIO);
@ -247,8 +222,6 @@ static uint8_t doc_read_docstatus(volatile uint8_t *bios)
return (doc_read(bios, _DOCStatus)); return (doc_read(bios, _DOCStatus));
} /* static uint8_t doc_read_docstatus(volatile uint8_t *bios) */ } /* static uint8_t doc_read_docstatus(volatile uint8_t *bios) */
static uint8_t doc_read_chipid(volatile uint8_t *bios) static uint8_t doc_read_chipid(volatile uint8_t *bios)
{ {
doc_read(bios, CDSNSlowIO); doc_read(bios, CDSNSlowIO);
@ -257,8 +230,6 @@ static uint8_t doc_read_chipid(volatile uint8_t *bios)
return (doc_read(bios, _ChipID)); return (doc_read(bios, _ChipID));
} /* static uint8_t doc_read_chipid(volatile uint8_t *bios) */ } /* static uint8_t doc_read_chipid(volatile uint8_t *bios) */
static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios) static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios)
{ {
uint8_t value; uint8_t value;
@ -273,8 +244,6 @@ static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios)
return (value); return (value);
} /* static uint8_t doc_read_chipid(volatile char *bios) */ } /* static uint8_t doc_read_chipid(volatile char *bios) */
static void doc_write_cdsncontrol(volatile uint8_t *bios, uint8_t data) static void doc_write_cdsncontrol(volatile uint8_t *bios, uint8_t data)
{ {
doc_write(data, bios, _CDSNControl); doc_write(data, bios, _CDSNControl);

View File

@ -86,7 +86,8 @@ int probe_lhf00l04(struct flashchip *flash)
} }
flash->virt_addr_2 = bios; flash->virt_addr_2 = bios;
printf("bios %p, *bios 0x%x, bios[1] 0x%x\n", bios, *bios, bios[1]); printf("bios %p, *bios 0x%x, bios[1] 0x%x\n", bios, *bios,
bios[1]);
return 1; return 1;
} }
@ -124,8 +125,7 @@ uint8_t wait_lhf00l04(volatile uint8_t *bios)
int erase_lhf00l04_block(struct flashchip *flash, int offset) int erase_lhf00l04_block(struct flashchip *flash, int offset)
{ {
volatile uint8_t *bios = flash->virt_addr + offset; volatile uint8_t *bios = flash->virt_addr + offset;
volatile uint8_t *wrprotect = volatile uint8_t *wrprotect = flash->virt_addr_2 + offset + 2;
flash->virt_addr_2 + offset + 2;
uint8_t status; uint8_t status;
// clear status register // clear status register
@ -162,8 +162,8 @@ int erase_lhf00l04(struct flashchip *flash)
return (0); return (0);
} }
void write_page_lhf00l04(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *dst, void write_page_lhf00l04(volatile uint8_t *bios, uint8_t *src,
int page_size) volatile uint8_t *dst, int page_size)
{ {
int i; int i;
@ -179,8 +179,8 @@ void write_page_lhf00l04(volatile uint8_t *bios, uint8_t *src, volatile uint8_t
int write_lhf00l04(struct flashchip *flash, uint8_t *buf) int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
{ {
int i; int i;
int total_size = flash->total_size * 1024, page_size = int total_size = flash->total_size * 1024;
flash->page_size; int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
erase_lhf00l04(flash); erase_lhf00l04(flash);
@ -193,8 +193,7 @@ int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
printf("%04d at address: 0x%08x", i, i * page_size); printf("%04d at address: 0x%08x", i, i * page_size);
write_page_lhf00l04(bios, buf + i * page_size, write_page_lhf00l04(bios, buf + i * page_size,
bios + i * page_size, page_size); bios + i * page_size, page_size);
printf printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
} }
printf("\n"); printf("\n");
protect_lhf00l04(bios); protect_lhf00l04(bios);

View File

@ -150,8 +150,8 @@ int erase_28sf040(struct flashchip *flash)
int write_28sf040(struct flashchip *flash, uint8_t *buf) int write_28sf040(struct flashchip *flash, uint8_t *buf)
{ {
int i; int i;
int total_size = flash->total_size * 1024, page_size = int total_size = flash->total_size * 1024;
flash->page_size; int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
unprotect_28sf040(bios); unprotect_28sf040(bios);

View File

@ -50,7 +50,6 @@
#define STATUS_ESS (1 << 6) #define STATUS_ESS (1 << 6)
#define STATUS_WSMS (1 << 7) #define STATUS_WSMS (1 << 7)
static __inline__ int write_lockbits_49lfxxxc(volatile uint8_t *bios, int size, static __inline__ int write_lockbits_49lfxxxc(volatile uint8_t *bios, int size,
unsigned char bits) unsigned char bits)
{ {
@ -75,7 +74,6 @@ static __inline__ int write_lockbits_49lfxxxc(volatile uint8_t *bios, int size,
//printf("lockbits at address=0x%08lx is 0x%01x\n", (unsigned long)0xFFc00000 - size + address + 2, *(bios + address + 2) ); //printf("lockbits at address=0x%08lx is 0x%01x\n", (unsigned long)0xFFc00000 - size + address + 2, *(bios + address + 2) );
*(bios + address + 2) = bits; *(bios + address + 2) = bits;
return (0); return (0);
} }
@ -180,11 +178,10 @@ int erase_49lfxxxc(struct flashchip *flash)
int write_49lfxxxc(struct flashchip *flash, uint8_t *buf) int write_49lfxxxc(struct flashchip *flash, uint8_t *buf)
{ {
int i; int i;
int total_size = flash->total_size * 1024, page_size = int total_size = flash->total_size * 1024;
flash->page_size; int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr; volatile uint8_t *bios = flash->virt_addr;
write_lockbits_49lfxxxc(flash->virt_addr_2, total_size, 0); write_lockbits_49lfxxxc(flash->virt_addr_2, total_size, 0);
printf("Programming Page: "); printf("Programming Page: ");
for (i = 0; i < total_size / page_size; i++) { for (i = 0; i < total_size / page_size; i++) {