mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 07:02:34 +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:
parent
7977f4ef2e
commit
a7e0548cea
48
82802ab.c
48
82802ab.c
@ -52,9 +52,9 @@ int probe_82802ab(struct flashchip *flash)
|
|||||||
uint8_t id1, id2;
|
uint8_t id1, id2;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x90;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x90;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*bios = 0xff;
|
*bios = 0xff;
|
||||||
@ -62,13 +62,13 @@ int probe_82802ab(struct flashchip *flash)
|
|||||||
*bios = 0x90;
|
*bios = 0x90;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xF0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
@ -82,7 +82,7 @@ int probe_82802ab(struct flashchip *flash)
|
|||||||
fd_mem, (off_t) (0 - 0x400000 - size));
|
fd_mem, (off_t) (0 - 0x400000 - size));
|
||||||
if (bios == MAP_FAILED) {
|
if (bios == MAP_FAILED) {
|
||||||
// it's this part but we can't map it ...
|
// it's this part but we can't map it ...
|
||||||
perror("Error MMAP memory using " MEM_DEV );
|
perror("Error MMAP memory using " MEM_DEV);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ uint8_t wait_82802ab(volatile uint8_t *bios)
|
|||||||
|
|
||||||
*bios = 0x70;
|
*bios = 0x70;
|
||||||
if ((*bios & 0x80) == 0) { // it's busy
|
if ((*bios & 0x80) == 0) { // it's busy
|
||||||
while ((*bios & 0x80) == 0);
|
while ((*bios & 0x80) == 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = *bios;
|
status = *bios;
|
||||||
@ -111,21 +111,20 @@ uint8_t wait_82802ab(volatile uint8_t *bios)
|
|||||||
*bios = 0x90;
|
*bios = 0x90;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
// this is needed to jam it out of "read id" mode
|
// this is needed to jam it out of "read id" mode
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xF0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
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
|
||||||
@ -138,8 +137,8 @@ int erase_82802ab_block(struct flashchip *flash, int offset)
|
|||||||
//printf("write protect is 0x%x\n", *(wrprotect));
|
//printf("write protect is 0x%x\n", *(wrprotect));
|
||||||
|
|
||||||
// now start it
|
// now start it
|
||||||
*(volatile uint8_t *) (bios) = 0x20;
|
*(volatile uint8_t *)(bios) = 0x20;
|
||||||
*(volatile uint8_t *) (bios) = 0xd0;
|
*(volatile uint8_t *)(bios) = 0xd0;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
// now let's see what the register is
|
// now let's see what the register is
|
||||||
status = wait_82802ab(flash->virt_addr);
|
status = wait_82802ab(flash->virt_addr);
|
||||||
@ -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);
|
||||||
|
255
board_enable.c
255
board_enable.c
@ -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;
|
||||||
|
|
||||||
@ -83,7 +78,7 @@ static int w83627hf_gpio24_raise(const char *name)
|
|||||||
w836xx_ext_enter();
|
w836xx_ext_enter();
|
||||||
|
|
||||||
/* Is this the w83627hf? */
|
/* Is this the w83627hf? */
|
||||||
if (wbsio_read(0x20) != 0x52) { /* SIO device ID register */
|
if (wbsio_read(0x20) != 0x52) { /* SIO device ID register */
|
||||||
fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n",
|
fprintf(stderr, "\nERROR: %s: W83627HF: Wrong ID: 0x%02X.\n",
|
||||||
name, wbsio_read(0x20));
|
name, wbsio_read(0x20));
|
||||||
w836xx_ext_leave();
|
w836xx_ext_leave();
|
||||||
@ -93,15 +88,15 @@ static int w83627hf_gpio24_raise(const char *name)
|
|||||||
/* PIN89S: WDTO/GP24 multiplex -> GPIO24 */
|
/* PIN89S: WDTO/GP24 multiplex -> GPIO24 */
|
||||||
wbsio_mask(0x2B, 0x10, 0x10);
|
wbsio_mask(0x2B, 0x10, 0x10);
|
||||||
|
|
||||||
wbsio_write(0x07, 0x08); /* Select logical device 8: GPIO port 2 */
|
wbsio_write(0x07, 0x08); /* Select logical device 8: GPIO port 2 */
|
||||||
|
|
||||||
wbsio_mask(0x30, 0x01, 0x01); /* Activate logical device. */
|
wbsio_mask(0x30, 0x01, 0x01); /* Activate logical device. */
|
||||||
|
|
||||||
wbsio_mask(0xF0, 0x00, 0x10); /* GPIO24 -> output */
|
wbsio_mask(0xF0, 0x00, 0x10); /* GPIO24 -> output */
|
||||||
|
|
||||||
wbsio_mask(0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */
|
wbsio_mask(0xF2, 0x00, 0x10); /* Clear GPIO24 inversion */
|
||||||
|
|
||||||
wbsio_mask(0xF1, 0x10, 0x10); /* Raise GPIO24 */
|
wbsio_mask(0xF1, 0x10, 0x10); /* Raise GPIO24 */
|
||||||
|
|
||||||
w836xx_ext_leave();
|
w836xx_ext_leave();
|
||||||
|
|
||||||
@ -116,30 +111,30 @@ static int w83627hf_gpio24_raise(const char *name)
|
|||||||
|
|
||||||
static int board_via_epia_m(const char *name)
|
static int board_via_epia_m(const char *name)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev;
|
struct pci_dev *dev;
|
||||||
unsigned int base;
|
unsigned int base;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
|
|
||||||
dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
|
dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
|
fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GPIO12-15 -> output */
|
/* GPIO12-15 -> output */
|
||||||
val = pci_read_byte(dev, 0xE4);
|
val = pci_read_byte(dev, 0xE4);
|
||||||
val |= 0x10;
|
val |= 0x10;
|
||||||
pci_write_byte(dev, 0xE4, val);
|
pci_write_byte(dev, 0xE4, val);
|
||||||
|
|
||||||
/* Get Power Management IO address. */
|
/* Get Power Management IO address. */
|
||||||
base = pci_read_word(dev, 0x88) & 0xFF80;
|
base = pci_read_word(dev, 0x88) & 0xFF80;
|
||||||
|
|
||||||
/* enable GPIO15 which is connected to write protect. */
|
/* enable GPIO15 which is connected to write protect. */
|
||||||
val = inb(base + 0x4D);
|
val = inb(base + 0x4D);
|
||||||
val |= 0x80;
|
val |= 0x80;
|
||||||
outb(val, base + 0x4D);
|
outb(val, base + 0x4D);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -149,29 +144,29 @@ static int board_via_epia_m(const char *name)
|
|||||||
|
|
||||||
static int board_asus_a7v8x_mx(const char *name)
|
static int board_asus_a7v8x_mx(const char *name)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev;
|
struct pci_dev *dev;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
|
|
||||||
dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
|
dev = pci_dev_find(0x1106, 0x3177); /* VT8235 ISA bridge */
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
|
fprintf(stderr, "\nERROR: VT8235 ISA Bridge not found.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This bit is marked reserved actually */
|
/* This bit is marked reserved actually */
|
||||||
val = pci_read_byte(dev, 0x59);
|
val = pci_read_byte(dev, 0x59);
|
||||||
val &= 0x7F;
|
val &= 0x7F;
|
||||||
pci_write_byte(dev, 0x59, val);
|
pci_write_byte(dev, 0x59, val);
|
||||||
|
|
||||||
/* Raise ROM MEMW# line on Winbond w83697 SuperIO */
|
/* Raise ROM MEMW# line on Winbond w83697 SuperIO */
|
||||||
w836xx_ext_enter();
|
w836xx_ext_enter();
|
||||||
|
|
||||||
if (!(wbsio_read(0x24) & 0x02)) /* flash rom enabled? */
|
if (!(wbsio_read(0x24) & 0x02)) /* flash rom enabled? */
|
||||||
wbsio_mask(0x24, 0x08, 0x08); /* enable MEMW# */
|
wbsio_mask(0x24, 0x08, 0x08); /* enable MEMW# */
|
||||||
|
|
||||||
w836xx_ext_leave();
|
w836xx_ext_leave();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -185,39 +180,39 @@ static int board_asus_a7v8x_mx(const char *name)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct board_pciid_enable {
|
struct board_pciid_enable {
|
||||||
/* Any device, but make it sensible, like the isa bridge. */
|
/* Any device, but make it sensible, like the isa bridge. */
|
||||||
uint16_t first_vendor;
|
uint16_t first_vendor;
|
||||||
uint16_t first_device;
|
uint16_t first_device;
|
||||||
uint16_t first_card_vendor;
|
uint16_t first_card_vendor;
|
||||||
uint16_t first_card_device;
|
uint16_t first_card_device;
|
||||||
|
|
||||||
/* Any device, but make it sensible, like
|
/* Any device, but make it sensible, like
|
||||||
* the host bridge. May be NULL
|
* the host bridge. May be NULL
|
||||||
*/
|
*/
|
||||||
uint16_t second_vendor;
|
uint16_t second_vendor;
|
||||||
uint16_t second_device;
|
uint16_t second_device;
|
||||||
uint16_t second_card_vendor;
|
uint16_t second_card_vendor;
|
||||||
uint16_t second_card_device;
|
uint16_t second_card_device;
|
||||||
|
|
||||||
/* From linuxbios table */
|
/* From linuxbios table */
|
||||||
char *lb_vendor;
|
char *lb_vendor;
|
||||||
char *lb_part;
|
char *lb_part;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
int (*enable)(const char *name);
|
int (*enable) (const char *name);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct board_pciid_enable board_pciid_enables[] = {
|
struct board_pciid_enable board_pciid_enables[] = {
|
||||||
{ 0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
{0x1022, 0x7468, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
"iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise },
|
"iwill", "dk8_htx", "IWILL DK8-HTX", w83627hf_gpio24_raise},
|
||||||
{ 0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000,
|
{0x1022, 0x746B, 0x1022, 0x36C0, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
"AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise },
|
"AGAMI", "ARUMA", "agami Aruma", w83627hf_gpio24_raise},
|
||||||
{ 0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01,
|
{0x1106, 0x3177, 0x1106, 0xAA01, 0x1106, 0x3123, 0x1106, 0xAA01,
|
||||||
NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m },
|
NULL, NULL, "VIA EPIA M/MII/...", board_via_epia_m},
|
||||||
{ 0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118,
|
{0x1106, 0x3177, 0x1043, 0x80A1, 0x1106, 0x3205, 0x1043, 0x8118,
|
||||||
NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx },
|
NULL, NULL, "ASUS A7V8-MX SE", board_asus_a7v8x_mx},
|
||||||
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL } /* Keep this */
|
{0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL} /* Keep this */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -225,27 +220,27 @@ 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;
|
||||||
|
|
||||||
for (; board->name; board++) {
|
for (; board->name; board++) {
|
||||||
if (!board->lb_vendor || strcmp(board->lb_vendor, vendor))
|
if (!board->lb_vendor || strcmp(board->lb_vendor, vendor))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!board->lb_part || strcmp(board->lb_part, part))
|
if (!board->lb_part || strcmp(board->lb_part, part))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!pci_dev_find(board->first_vendor, board->first_device))
|
if (!pci_dev_find(board->first_vendor, board->first_device))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (board->second_vendor &&
|
if (board->second_vendor &&
|
||||||
!pci_dev_find(board->second_vendor, board->second_device))
|
!pci_dev_find(board->second_vendor, board->second_device))
|
||||||
continue;
|
continue;
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -254,35 +249,35 @@ board_match_linuxbios_name(char *vendor, char *part)
|
|||||||
*/
|
*/
|
||||||
static struct board_pciid_enable *board_match_pci_card_ids(void)
|
static struct board_pciid_enable *board_match_pci_card_ids(void)
|
||||||
{
|
{
|
||||||
struct board_pciid_enable *board = board_pciid_enables;
|
struct board_pciid_enable *board = board_pciid_enables;
|
||||||
|
|
||||||
for (; board->name; board++) {
|
for (; board->name; board++) {
|
||||||
if (!board->first_card_vendor || !board->first_card_device)
|
if (!board->first_card_vendor || !board->first_card_device)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!pci_card_find(board->first_vendor, board->first_device,
|
if (!pci_card_find(board->first_vendor, board->first_device,
|
||||||
board->first_card_vendor,
|
board->first_card_vendor,
|
||||||
board->first_card_device))
|
board->first_card_device))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (board->second_vendor) {
|
if (board->second_vendor) {
|
||||||
if (board->second_card_vendor) {
|
if (board->second_card_vendor) {
|
||||||
if (!pci_card_find(board->second_vendor,
|
if (!pci_card_find(board->second_vendor,
|
||||||
board->second_device,
|
board->second_device,
|
||||||
board->second_card_vendor,
|
board->second_card_vendor,
|
||||||
board->second_card_device))
|
board->second_card_device))
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (!pci_dev_find(board->second_vendor,
|
if (!pci_dev_find(board->second_vendor,
|
||||||
board->second_device))
|
board->second_device))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -290,25 +285,25 @@ static struct board_pciid_enable *board_match_pci_card_ids(void)
|
|||||||
*/
|
*/
|
||||||
int board_flash_enable(char *vendor, char *part)
|
int board_flash_enable(char *vendor, char *part)
|
||||||
{
|
{
|
||||||
struct board_pciid_enable *board = NULL;
|
struct board_pciid_enable *board = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (vendor && part)
|
if (vendor && part)
|
||||||
board = board_match_linuxbios_name(vendor, part);
|
board = board_match_linuxbios_name(vendor, part);
|
||||||
|
|
||||||
if (!board)
|
if (!board)
|
||||||
board = board_match_pci_card_ids();
|
board = board_match_pci_card_ids();
|
||||||
|
|
||||||
if (board) {
|
if (board) {
|
||||||
printf("Found board \"%s\": Enabling flash write... ",
|
printf("Found board \"%s\": Enabling flash write... ",
|
||||||
board->name);
|
board->name);
|
||||||
|
|
||||||
ret = board->enable(board->name);
|
ret = board->enable(board->name);
|
||||||
if (ret)
|
if (ret)
|
||||||
printf("Failed!\n");
|
printf("Failed!\n");
|
||||||
else
|
else
|
||||||
printf("OK.\n");
|
printf("OK.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
251
chipset_enable.c
251
chipset_enable.c
@ -75,20 +75,21 @@ static int enable_flash_sis630(struct pci_dev *dev, char *name)
|
|||||||
static int enable_flash_piix4(struct pci_dev *dev, char *name)
|
static int enable_flash_piix4(struct pci_dev *dev, char *name)
|
||||||
{
|
{
|
||||||
uint16_t old, new;
|
uint16_t old, new;
|
||||||
uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */
|
uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */
|
||||||
|
|
||||||
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)
|
||||||
@ -113,7 +114,7 @@ static int enable_flash_ich(struct pci_dev *dev, char *name, int bios_cntl)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, but
|
/* Note: the ICH0-ICH5 BIOS_CNTL register is actually 16 bit wide, but
|
||||||
* just treating it as 8 bit wide seems to work fine in practice.
|
* just treating it as 8 bit wide seems to work fine in practice.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* see ie. page 375 of "Intel ICH7 External Design Specification"
|
/* see ie. page 375 of "Intel ICH7 External Design Specification"
|
||||||
@ -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,23 +150,22 @@ 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;
|
||||||
|
|
||||||
/* ROM Write enable */
|
/* ROM Write enable */
|
||||||
val = pci_read_byte(dev, 0x40);
|
val = pci_read_byte(dev, 0x40);
|
||||||
val |= 0x10;
|
val |= 0x10;
|
||||||
pci_write_byte(dev, 0x40, val);
|
pci_write_byte(dev, 0x40, val);
|
||||||
|
|
||||||
if (pci_read_byte(dev, 0x40) != val) {
|
if (pci_read_byte(dev, 0x40) != val) {
|
||||||
printf("\nWARNING: Failed to enable ROM Write on \"%s\"\n",
|
printf("\nWARNING: Failed to enable ROM Write on \"%s\"\n",
|
||||||
name);
|
name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int enable_flash_cs5530(struct pci_dev *dev, char *name)
|
static int enable_flash_cs5530(struct pci_dev *dev, char *name)
|
||||||
@ -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;
|
||||||
@ -264,47 +258,46 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name)
|
|||||||
|
|
||||||
static int enable_flash_ck804(struct pci_dev *dev, char *name)
|
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
|
|
||||||
* that it is hard to argue that we should quit at this point.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* dump_pci_device(dev); */
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
old = pci_read_byte(dev, 0x88);
|
/* dump_pci_device(dev); */
|
||||||
new = old | 0xc0;
|
|
||||||
if (new != old) {
|
|
||||||
pci_write_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",
|
|
||||||
0x88, new, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
old = pci_read_byte(dev, 0x6d);
|
old = pci_read_byte(dev, 0x88);
|
||||||
new = old | 0x01;
|
new = old | 0xc0;
|
||||||
if (new == old)
|
if (new != old) {
|
||||||
return 0;
|
pci_write_byte(dev, 0x88, new);
|
||||||
pci_write_byte(dev, 0x6d, new);
|
if (pci_read_byte(dev, 0x88) != new) {
|
||||||
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x88, new, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pci_read_byte(dev, 0x6d) != new) {
|
old = pci_read_byte(dev, 0x6d);
|
||||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
new = old | 0x01;
|
||||||
0x6d, new, name);
|
if (new == old)
|
||||||
return -1;
|
return 0;
|
||||||
}
|
pci_write_byte(dev, 0x6d, new);
|
||||||
return 0;
|
|
||||||
|
if (pci_read_byte(dev, 0x6d) != new) {
|
||||||
|
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n", 0x6d, new, name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int enable_flash_sb400(struct pci_dev *dev, char *name)
|
static int enable_flash_sb400(struct pci_dev *dev, char *name)
|
||||||
{
|
{
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
|
|
||||||
struct pci_filter f;
|
struct pci_filter f;
|
||||||
struct pci_dev *smbusdev;
|
struct pci_dev *smbusdev;
|
||||||
|
|
||||||
/* then look for the smbus device */
|
/* then look for the smbus device */
|
||||||
pci_filter_init((struct pci_access *) 0, &f);
|
pci_filter_init((struct pci_access *)0, &f);
|
||||||
f.vendor = 0x1002;
|
f.vendor = 0x1002;
|
||||||
f.device = 0x4372;
|
f.device = 0x4372;
|
||||||
|
|
||||||
@ -314,26 +307,26 @@ static int enable_flash_sb400(struct pci_dev *dev, char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!smbusdev) {
|
if (!smbusdev) {
|
||||||
fprintf(stderr, "ERROR: SMBus device not found. aborting\n");
|
fprintf(stderr, "ERROR: SMBus device not found. aborting\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable some smbus stuff */
|
/* enable some smbus stuff */
|
||||||
tmp=pci_read_byte(smbusdev, 0x79);
|
tmp = pci_read_byte(smbusdev, 0x79);
|
||||||
tmp|=0x01;
|
tmp |= 0x01;
|
||||||
pci_write_byte(smbusdev, 0x79, tmp);
|
pci_write_byte(smbusdev, 0x79, tmp);
|
||||||
|
|
||||||
/* change southbridge */
|
/* change southbridge */
|
||||||
tmp=pci_read_byte(dev, 0x48);
|
tmp = pci_read_byte(dev, 0x48);
|
||||||
tmp|=0x21;
|
tmp |= 0x21;
|
||||||
pci_write_byte(dev, 0x48, tmp);
|
pci_write_byte(dev, 0x48, tmp);
|
||||||
|
|
||||||
/* now become a bit silly. */
|
/* now become a bit silly. */
|
||||||
tmp=inb(0xc6f);
|
tmp = inb(0xc6f);
|
||||||
outb(tmp,0xeb);
|
|
||||||
outb(tmp, 0xeb);
|
outb(tmp, 0xeb);
|
||||||
tmp|=0x40;
|
outb(tmp, 0xeb);
|
||||||
|
tmp |= 0x40;
|
||||||
outb(tmp, 0xc6f);
|
outb(tmp, 0xc6f);
|
||||||
outb(tmp, 0xeb);
|
outb(tmp, 0xeb);
|
||||||
outb(tmp, 0xeb);
|
outb(tmp, 0xeb);
|
||||||
@ -343,38 +336,39 @@ static int enable_flash_sb400(struct pci_dev *dev, char *name)
|
|||||||
|
|
||||||
static int enable_flash_mcp55(struct pci_dev *dev, char *name)
|
static int enable_flash_mcp55(struct pci_dev *dev, char *name)
|
||||||
{
|
{
|
||||||
/* register 4e.b gets or'ed with one */
|
/* register 4e.b gets or'ed with one */
|
||||||
unsigned char old, new, byte;
|
unsigned char old, new, byte;
|
||||||
unsigned short word;
|
unsigned short word;
|
||||||
|
|
||||||
/* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* dump_pci_device(dev); */
|
/* dump_pci_device(dev); */
|
||||||
|
|
||||||
/* Set the 4MB enable bit bit */
|
/* Set the 4MB enable bit bit */
|
||||||
byte = pci_read_byte(dev, 0x88);
|
byte = pci_read_byte(dev, 0x88);
|
||||||
byte |= 0xff; /* 256K */
|
byte |= 0xff; /* 256K */
|
||||||
pci_write_byte(dev, 0x88, byte);
|
pci_write_byte(dev, 0x88, byte);
|
||||||
byte = pci_read_byte(dev, 0x8c);
|
byte = pci_read_byte(dev, 0x8c);
|
||||||
byte |= 0xff; /* 1M */
|
byte |= 0xff; /* 1M */
|
||||||
pci_write_byte(dev, 0x8c, byte);
|
pci_write_byte(dev, 0x8c, byte);
|
||||||
word = pci_read_word(dev, 0x90);
|
word = pci_read_word(dev, 0x90);
|
||||||
word |= 0x7fff; /* 15M */
|
word |= 0x7fff; /* 15M */
|
||||||
pci_write_word(dev, 0x90, word);
|
pci_write_word(dev, 0x90, word);
|
||||||
|
|
||||||
old = pci_read_byte(dev, 0x6d);
|
old = pci_read_byte(dev, 0x6d);
|
||||||
new = old | 0x01;
|
new = old | 0x01;
|
||||||
if (new == old)
|
if (new == old)
|
||||||
return 0;
|
return 0;
|
||||||
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
|
||||||
0x6d, new, name);
|
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
return -1;
|
0x6d, new, name);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -410,61 +404,60 @@ static FLASH_ENABLE enables[] = {
|
|||||||
{0x1106, 0x8231, "VT8231", enable_flash_vt823x},
|
{0x1106, 0x8231, "VT8231", enable_flash_vt823x},
|
||||||
{0x1106, 0x3177, "VT8235", enable_flash_vt823x},
|
{0x1106, 0x3177, "VT8235", enable_flash_vt823x},
|
||||||
{0x1106, 0x3227, "VT8237", enable_flash_vt823x},
|
{0x1106, 0x3227, "VT8237", enable_flash_vt823x},
|
||||||
{0x1106, 0x8324, "CX700" , enable_flash_vt823x},
|
{0x1106, 0x8324, "CX700", enable_flash_vt823x},
|
||||||
{0x1106, 0x0686, "VT82C686", enable_flash_amd8111},
|
{0x1106, 0x0686, "VT82C686", enable_flash_amd8111},
|
||||||
{0x1078, 0x0100, "CS5530", enable_flash_cs5530},
|
{0x1078, 0x0100, "CS5530", enable_flash_cs5530},
|
||||||
{0x100b, 0x0510, "SC1100", enable_flash_sc1100},
|
{0x100b, 0x0510, "SC1100", enable_flash_sc1100},
|
||||||
{0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
|
{0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
|
||||||
{0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
|
{0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
|
||||||
/* this fallthrough looks broken. */
|
/* this fallthrough looks broken. */
|
||||||
{0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, /* LPC */
|
{0x10de, 0x0050, "NVIDIA CK804", enable_flash_ck804}, /* LPC */
|
||||||
{0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, /* Pro */
|
{0x10de, 0x0051, "NVIDIA CK804", enable_flash_ck804}, /* Pro */
|
||||||
{0x10de, 0x00d3, "NVIDIA CK804", enable_flash_ck804}, /* Slave, should not be here, to fix known bug for A01. */
|
{0x10de, 0x00d3, "NVIDIA CK804", enable_flash_ck804}, /* Slave, should not be here, to fix known bug for A01. */
|
||||||
|
|
||||||
{0x10de, 0x0260, "NVidia MCP51", enable_flash_ck804},
|
{0x10de, 0x0260, "NVidia MCP51", enable_flash_ck804},
|
||||||
{0x10de, 0x0261, "NVidia MCP51", enable_flash_ck804},
|
{0x10de, 0x0261, "NVidia MCP51", enable_flash_ck804},
|
||||||
{0x10de, 0x0262, "NVidia MCP51", enable_flash_ck804},
|
{0x10de, 0x0262, "NVidia MCP51", enable_flash_ck804},
|
||||||
{0x10de, 0x0263, "NVidia MCP51", enable_flash_ck804},
|
{0x10de, 0x0263, "NVidia MCP51", enable_flash_ck804},
|
||||||
|
|
||||||
{0x10de, 0x0360, "NVIDIA MCP55", enable_flash_mcp55}, /* Gigabyte m57sli-s4 */
|
{0x10de, 0x0360, "NVIDIA MCP55", enable_flash_mcp55}, /* Gigabyte m57sli-s4 */
|
||||||
{0x10de, 0x0361, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
{0x10de, 0x0361, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
||||||
{0x10de, 0x0362, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
{0x10de, 0x0362, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
||||||
{0x10de, 0x0363, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
{0x10de, 0x0363, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
||||||
{0x10de, 0x0364, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
{0x10de, 0x0364, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
||||||
{0x10de, 0x0365, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
{0x10de, 0x0365, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
||||||
{0x10de, 0x0366, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
{0x10de, 0x0366, "NVIDIA MCP55", enable_flash_mcp55}, /* LPC */
|
||||||
{0x10de, 0x0367, "NVIDIA MCP55", enable_flash_mcp55}, /* Pro */
|
{0x10de, 0x0367, "NVIDIA MCP55", enable_flash_mcp55}, /* Pro */
|
||||||
|
|
||||||
{0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */
|
{0x1002, 0x4377, "ATI SB400", enable_flash_sb400}, /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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! */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* now let's try to find the chipset we have ... */
|
/* now let's try to find the chipset we have ... */
|
||||||
for (i = 0; i < sizeof(enables) / sizeof(enables[0]); i++) {
|
for (i = 0; i < sizeof(enables) / sizeof(enables[0]); i++) {
|
||||||
dev = pci_dev_find(enables[i].vendor, enables[i].device);
|
dev = pci_dev_find(enables[i].vendor, enables[i].device);
|
||||||
if (dev)
|
if (dev)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (dev) {
|
|
||||||
printf("Found chipset \"%s\": Enabling flash write... ",
|
|
||||||
enables[i].name);
|
|
||||||
|
|
||||||
ret = enables[i].doit(dev, enables[i].name);
|
|
||||||
if (ret)
|
|
||||||
printf("Failed!\n");
|
|
||||||
else
|
|
||||||
printf("OK.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
if (dev) {
|
||||||
|
printf("Found chipset \"%s\": Enabling flash write... ",
|
||||||
|
enables[i].name);
|
||||||
|
|
||||||
|
ret = enables[i].doit(dev, enables[i].name);
|
||||||
|
if (ret)
|
||||||
|
printf("Failed!\n");
|
||||||
|
else
|
||||||
|
printf("OK.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
10
flash.h
10
flash.h
@ -132,13 +132,13 @@ void myusec_delay(int time);
|
|||||||
void myusec_calibrate_delay();
|
void myusec_calibrate_delay();
|
||||||
|
|
||||||
/* pci handling for board/chipset_enable */
|
/* pci handling for board/chipset_enable */
|
||||||
struct pci_access *pacc; /* For board and chipset_enable */
|
struct pci_access *pacc; /* For board and chipset_enable */
|
||||||
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
|
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
|
||||||
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
|
struct pci_dev *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);
|
||||||
|
|
||||||
int board_flash_enable(char *vendor, char *part); /* board_enable.c */
|
int board_flash_enable(char *vendor, char *part); /* board_enable.c */
|
||||||
int chipset_flash_enable(void); /* chipset_enable.c */
|
int chipset_flash_enable(void); /* chipset_enable.c */
|
||||||
|
|
||||||
/* physical memory mapping device */
|
/* physical memory mapping device */
|
||||||
|
|
||||||
|
238
flashrom.c
238
flashrom.c
@ -51,54 +51,52 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
char *chip_to_probe = NULL;
|
char *chip_to_probe = NULL;
|
||||||
struct pci_access *pacc; /* For board and chipset_enable */
|
struct pci_access *pacc; /* For board and chipset_enable */
|
||||||
int exclude_start_page, exclude_end_page;
|
int exclude_start_page, exclude_end_page;
|
||||||
int force=0, verbose=0;
|
int force = 0, verbose = 0;
|
||||||
|
|
||||||
int fd_mem;
|
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;
|
||||||
|
|
||||||
pci_filter_init(NULL, &filter);
|
pci_filter_init(NULL, &filter);
|
||||||
filter.vendor = vendor;
|
filter.vendor = vendor;
|
||||||
filter.device = device;
|
filter.device = device;
|
||||||
|
|
||||||
for (temp = pacc->devices; temp; temp = temp->next)
|
for (temp = pacc->devices; temp; temp = temp->next)
|
||||||
if (pci_filter_match(&filter, temp))
|
if (pci_filter_match(&filter, temp))
|
||||||
return temp;
|
return temp;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
struct pci_filter filter;
|
struct pci_filter filter;
|
||||||
|
|
||||||
pci_filter_init(NULL, &filter);
|
pci_filter_init(NULL, &filter);
|
||||||
filter.vendor = vendor;
|
filter.vendor = vendor;
|
||||||
filter.device = device;
|
filter.device = device;
|
||||||
|
|
||||||
for (temp = pacc->devices; temp; temp = temp->next)
|
for (temp = pacc->devices; temp; temp = temp->next)
|
||||||
if (pci_filter_match(&filter, temp)) {
|
if (pci_filter_match(&filter, temp)) {
|
||||||
if ((card_vendor == pci_read_word(temp, 0x2C)) &&
|
if ((card_vendor == pci_read_word(temp, 0x2C)) &&
|
||||||
(card_device == pci_read_word(temp, 0x2E)))
|
(card_device == pci_read_word(temp, 0x2E)))
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct flashchip *probe_flash(struct flashchip *flash)
|
struct flashchip *probe_flash(struct flashchip *flash)
|
||||||
@ -111,8 +109,8 @@ struct flashchip *probe_flash(struct flashchip *flash)
|
|||||||
flash++;
|
flash++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf_debug("Probing for %s, %d KB\n",
|
printf_debug("Probing for %s, %d KB\n",
|
||||||
flash->name, flash->total_size);
|
flash->name, flash->total_size);
|
||||||
|
|
||||||
size = flash->total_size * 1024;
|
size = flash->total_size * 1024;
|
||||||
|
|
||||||
@ -132,11 +130,11 @@ struct flashchip *probe_flash(struct flashchip *flash)
|
|||||||
if (getpagesize() > size) {
|
if (getpagesize() > size) {
|
||||||
size = getpagesize();
|
size = getpagesize();
|
||||||
printf("WARNING: size: %d -> %ld (page size)\n",
|
printf("WARNING: size: %d -> %ld (page size)\n",
|
||||||
flash->total_size * 1024, (unsigned long) size);
|
flash->total_size * 1024, (unsigned long)size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||||
fd_mem, (off_t)flash_baseaddr );
|
fd_mem, (off_t) flash_baseaddr);
|
||||||
if (bios == MAP_FAILED) {
|
if (bios == MAP_FAILED) {
|
||||||
perror("Error: Can't mmap " MEM_DEV ".");
|
perror("Error: Can't mmap " MEM_DEV ".");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -148,7 +146,7 @@ struct flashchip *probe_flash(struct flashchip *flash)
|
|||||||
flash->name, flash_baseaddr);
|
flash->name, flash_baseaddr);
|
||||||
return flash;
|
return flash;
|
||||||
}
|
}
|
||||||
munmap((void *) bios, size);
|
munmap((void *)bios, size);
|
||||||
|
|
||||||
flash++;
|
flash++;
|
||||||
}
|
}
|
||||||
@ -162,11 +160,12 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
|
|||||||
volatile uint8_t *bios = flash->virt_addr;
|
volatile uint8_t *bios = flash->virt_addr;
|
||||||
|
|
||||||
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))
|
||||||
printf("0x%08x", idx);
|
printf("0x%08x", idx);
|
||||||
|
|
||||||
if (*(bios + idx) != *(buf + idx)) {
|
if (*(bios + idx) != *(buf + idx)) {
|
||||||
@ -176,38 +175,37 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
|
|||||||
printf("- FAILED\n");
|
printf("- FAILED\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose && ( (idx & 0xfff) == 0xfff ))
|
if (verbose && ((idx & 0xfff) == 0xfff))
|
||||||
printf("\b\b\b\b\b\b\b\b\b\b");
|
printf("\b\b\b\b\b\b\b\b\b\b");
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("\b\b\b\b\b\b\b\b\b\b ");
|
printf("\b\b\b\b\b\b\b\b\b\b ");
|
||||||
|
|
||||||
printf("- VERIFIED \n");
|
printf("- VERIFIED \n");
|
||||||
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
|
||||||
" -w | --write: write file into flash (default when\n"
|
(" -r | --read: read flash and save into file\n"
|
||||||
" file is specified)\n"
|
" -w | --write: write file into flash (default when\n"
|
||||||
" -v | --verify: verify flash against file\n"
|
" file is specified)\n"
|
||||||
" -E | --erase: erase flash device\n"
|
" -v | --verify: verify flash against file\n"
|
||||||
" -V | --verbose: more verbose output\n"
|
" -E | --erase: erase flash device\n"
|
||||||
" -c | --chip <chipname>: probe only for specified flash chip\n"
|
" -V | --verbose: more verbose output\n"
|
||||||
" -s | --estart <addr>: exclude start position\n"
|
" -c | --chip <chipname>: probe only for specified flash chip\n"
|
||||||
" -e | --eend <addr>: exclude end postion\n"
|
" -s | --estart <addr>: exclude start position\n"
|
||||||
" -m | --mainboard <vendor:part>: override mainboard settings\n"
|
" -e | --eend <addr>: exclude end postion\n"
|
||||||
" -f | --force: force write without checking image\n"
|
" -m | --mainboard <vendor:part>: override mainboard settings\n"
|
||||||
" -l | --layout <file.layout>: read rom layout from file\n"
|
" -f | --force: force write without checking image\n"
|
||||||
" -i | --image <name>: only flash image name from flash layout\n"
|
" -l | --layout <file.layout>: read rom layout from file\n"
|
||||||
"\n"
|
" -i | --image <name>: only flash image name from flash layout\n"
|
||||||
" If no file is specified, then all that happens\n"
|
"\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,46 +217,42 @@ 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[] = {
|
||||||
{ "read", 0, 0, 'r' },
|
{"read", 0, 0, 'r'},
|
||||||
{ "write", 0, 0, 'w' },
|
{"write", 0, 0, 'w'},
|
||||||
{ "erase", 0, 0, 'E' },
|
{"erase", 0, 0, 'E'},
|
||||||
{ "verify", 0, 0, 'v' },
|
{"verify", 0, 0, 'v'},
|
||||||
{ "chip", 1, 0, 'c' },
|
{"chip", 1, 0, 'c'},
|
||||||
{ "estart", 1, 0, 's' },
|
{"estart", 1, 0, 's'},
|
||||||
{ "eend", 1, 0, 'e' },
|
{"eend", 1, 0, 'e'},
|
||||||
{ "mainboard", 1, 0, 'm' },
|
{"mainboard", 1, 0, 'm'},
|
||||||
{ "verbose", 0, 0, 'V' },
|
{"verbose", 0, 0, 'V'},
|
||||||
{ "force", 0, 0, 'f' },
|
{"force", 0, 0, 'f'},
|
||||||
{ "layout", 1, 0, 'l' },
|
{"layout", 1, 0, 'l'},
|
||||||
{ "image", 1, 0, 'i' },
|
{"image", 1, 0, 'i'},
|
||||||
{ "help", 0, 0, 'h' },
|
{"help", 0, 0, 'h'},
|
||||||
{ 0, 0, 0, 0 }
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
/* Yes, print them. */
|
/* Yes, print them. */
|
||||||
int i;
|
int i;
|
||||||
printf_debug ("The arguments are:\n");
|
printf_debug("The arguments are:\n");
|
||||||
for (i = 1; i < argc; ++i)
|
for (i = 1; i < argc; ++i)
|
||||||
printf_debug ("%s\n", argv[i]);
|
printf_debug("%s\n", argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -280,34 +274,34 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
tempstr = strdup(optarg);
|
tempstr = strdup(optarg);
|
||||||
sscanf(tempstr,"%x",&exclude_start_position);
|
sscanf(tempstr, "%x", &exclude_start_position);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
tempstr = strdup(optarg);
|
tempstr = strdup(optarg);
|
||||||
sscanf(tempstr,"%x",&exclude_end_position);
|
sscanf(tempstr, "%x", &exclude_end_position);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
tempstr = strdup(optarg);
|
tempstr = strdup(optarg);
|
||||||
strtok(tempstr, ":");
|
strtok(tempstr, ":");
|
||||||
tempstr2=strtok(NULL, ":");
|
tempstr2 = strtok(NULL, ":");
|
||||||
if (tempstr2) {
|
if (tempstr2) {
|
||||||
lb_vendor=tempstr;
|
lb_vendor = tempstr;
|
||||||
lb_part=tempstr2;
|
lb_part = tempstr2;
|
||||||
} else {
|
} else {
|
||||||
printf("warning: ignored wrong format of"
|
printf("warning: ignored wrong format of"
|
||||||
" mainboard: %s\n", tempstr);
|
" mainboard: %s\n", tempstr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
force=1;
|
force = 1;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
tempstr=strdup(optarg);
|
tempstr = strdup(optarg);
|
||||||
if (read_romlayout(tempstr))
|
if (read_romlayout(tempstr))
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
tempstr=strdup(optarg);
|
tempstr = strdup(optarg);
|
||||||
find_romentry(tempstr);
|
find_romentry(tempstr);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -325,17 +319,18 @@ int main(int argc, char *argv[])
|
|||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
filename = argv[optind++];
|
filename = argv[optind++];
|
||||||
|
|
||||||
/* First get full io access */
|
/* First get full io access */
|
||||||
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
||||||
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0){
|
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
|
||||||
#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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize PCI access for flash enables */
|
/* Initialize PCI access for flash enables */
|
||||||
pacc = pci_alloc(); /* Get the pci_access structure */
|
pacc = pci_alloc(); /* Get the pci_access structure */
|
||||||
/* Set all options you want -- here we stick with the defaults */
|
/* Set all options you want -- here we stick with the defaults */
|
||||||
pci_init(pacc); /* Initialize the PCI library */
|
pci_init(pacc); /* Initialize the PCI library */
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,13 +353,13 @@ int main(int argc, char *argv[])
|
|||||||
/* try to enable it. Failure IS an option, since not all motherboards
|
/* try to enable it. Failure IS an option, since not all motherboards
|
||||||
* 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");
|
||||||
@ -380,11 +376,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
size = flash->total_size * 1024;
|
size = flash->total_size * 1024;
|
||||||
buf = (uint8_t *) calloc(size, sizeof(char));
|
buf = (uint8_t *) calloc(size, sizeof(char));
|
||||||
|
|
||||||
if (erase_it) {
|
if (erase_it) {
|
||||||
printf("Erasing flash chip\n");
|
printf("Erasing flash chip\n");
|
||||||
flash->erase(flash);
|
flash->erase(flash);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (read_it) {
|
} else if (read_it) {
|
||||||
if ((image = fopen(filename, "w")) == NULL) {
|
if ((image = fopen(filename, "w")) == NULL) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
@ -392,13 +388,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
printf("Reading Flash...");
|
printf("Reading Flash...");
|
||||||
if (flash->read == NULL)
|
if (flash->read == NULL)
|
||||||
memcpy(buf, (const char *) flash->virt_addr, size);
|
memcpy(buf, (const char *)flash->virt_addr, size);
|
||||||
else
|
else
|
||||||
flash->read(flash, buf);
|
flash->read(flash, buf);
|
||||||
|
|
||||||
if (exclude_end_position - exclude_start_position > 0)
|
if (exclude_end_position - exclude_start_position > 0)
|
||||||
memset(buf+exclude_start_position, 0,
|
memset(buf + exclude_start_position, 0,
|
||||||
exclude_end_position-exclude_start_position);
|
exclude_end_position - exclude_start_position);
|
||||||
|
|
||||||
fwrite(buf, sizeof(char), size, image);
|
fwrite(buf, sizeof(char), size, image);
|
||||||
fclose(image);
|
fclose(image);
|
||||||
@ -414,7 +410,7 @@ int main(int argc, char *argv[])
|
|||||||
perror(filename);
|
perror(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(image_stat.st_size!=flash->total_size*1024) {
|
if (image_stat.st_size != flash->total_size * 1024) {
|
||||||
fprintf(stderr, "Error: Image size doesnt match\n");
|
fprintf(stderr, "Error: Image size doesnt match\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -430,26 +426,26 @@ int main(int argc, char *argv[])
|
|||||||
* it to the rom layout feature below and drop exclude range
|
* it to the rom layout feature below and drop exclude range
|
||||||
* completely once all flash chips can do rom layouts. stepan
|
* completely once all flash chips can do rom layouts. stepan
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
if (exclude_end_position - exclude_start_position > 0)
|
if (exclude_end_position - exclude_start_position > 0)
|
||||||
memcpy(buf+exclude_start_position,
|
memcpy(buf + exclude_start_position,
|
||||||
(const char *) flash->virt_addr+exclude_start_position,
|
(const char *)flash->virt_addr + exclude_start_position,
|
||||||
exclude_end_position-exclude_start_position);
|
exclude_end_position - exclude_start_position);
|
||||||
|
|
||||||
exclude_start_page = exclude_start_position/flash->page_size;
|
exclude_start_page = exclude_start_position / flash->page_size;
|
||||||
if ((exclude_start_position%flash->page_size) != 0) {
|
if ((exclude_start_position % flash->page_size) != 0) {
|
||||||
exclude_start_page++;
|
exclude_start_page++;
|
||||||
}
|
}
|
||||||
exclude_end_page = exclude_end_position/flash->page_size;
|
exclude_end_page = exclude_end_position / flash->page_size;
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// This should be moved into each flash part's code to do it
|
// This should be moved into each flash part's code to do it
|
||||||
// cleanly. This does the job.
|
// cleanly. This does the job.
|
||||||
handle_romentries(buf, (uint8_t *)flash->virt_addr);
|
handle_romentries(buf, (uint8_t *) flash->virt_addr);
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (write_it)
|
if (write_it)
|
||||||
ret |= flash->write(flash, buf);
|
ret |= flash->write(flash, buf);
|
||||||
|
|
||||||
|
98
jedec.c
98
jedec.c
@ -39,23 +39,23 @@ int probe_jedec(struct flashchip *flash)
|
|||||||
uint8_t id1, id2;
|
uint8_t id1, id2;
|
||||||
|
|
||||||
/* Issue JEDEC Product ID Entry command */
|
/* Issue JEDEC Product ID Entry command */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x90;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x90;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
/* Read product ID */
|
/* Read product ID */
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
/* Issue JEDEC Product ID Exit command */
|
/* Issue JEDEC Product ID Exit command */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xF0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
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);
|
||||||
@ -68,18 +68,18 @@ int probe_jedec(struct flashchip *flash)
|
|||||||
int erase_sector_jedec(volatile uint8_t *bios, unsigned int page)
|
int erase_sector_jedec(volatile uint8_t *bios, unsigned int page)
|
||||||
{
|
{
|
||||||
/* Issue the Sector Erase command */
|
/* Issue the Sector Erase command */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x80;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x80;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + page) = 0x30;
|
*(volatile uint8_t *)(bios + page) = 0x30;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
/* wait for Toggle bit ready */
|
/* wait for Toggle bit ready */
|
||||||
@ -91,18 +91,18 @@ int erase_sector_jedec(volatile uint8_t *bios, unsigned int page)
|
|||||||
int erase_block_jedec(volatile uint8_t *bios, unsigned int block)
|
int erase_block_jedec(volatile uint8_t *bios, unsigned int block)
|
||||||
{
|
{
|
||||||
/* Issue the Sector Erase command */
|
/* Issue the Sector Erase command */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x80;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x80;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + block) = 0x50;
|
*(volatile uint8_t *)(bios + block) = 0x50;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
/* wait for Toggle bit ready */
|
/* wait for Toggle bit ready */
|
||||||
@ -116,18 +116,18 @@ int erase_chip_jedec(struct flashchip *flash)
|
|||||||
volatile uint8_t *bios = flash->virt_addr;
|
volatile uint8_t *bios = flash->virt_addr;
|
||||||
|
|
||||||
/* Issue the JEDEC Chip Erase command */
|
/* Issue the JEDEC Chip Erase command */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x80;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x80;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x10;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x10;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
toggle_ready_jedec(bios);
|
toggle_ready_jedec(bios);
|
||||||
@ -144,14 +144,14 @@ int write_page_write_jedec(volatile uint8_t *bios, uint8_t *src,
|
|||||||
|
|
||||||
retry:
|
retry:
|
||||||
/* Issue JEDEC Data Unprotect comand */
|
/* Issue JEDEC Data Unprotect comand */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xA0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xA0;
|
||||||
|
|
||||||
/* transfer data from source to destination */
|
/* transfer data from source to destination */
|
||||||
for (i = start_index; i < page_size; i++) {
|
for (i = start_index; i < page_size; i++) {
|
||||||
/* If the data is 0xFF, don't program it */
|
/* If the data is 0xFF, don't program it */
|
||||||
if (*src != 0xFF )
|
if (*src != 0xFF)
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
dst++;
|
dst++;
|
||||||
src++;
|
src++;
|
||||||
@ -163,21 +163,21 @@ 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;
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok && tried++ < MAX_REFLASH_TRIES) {
|
if (!ok && tried++ < MAX_REFLASH_TRIES) {
|
||||||
start_index = i;
|
start_index = i;
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -194,20 +194,20 @@ int write_byte_program_jedec(volatile uint8_t *bios, uint8_t *src,
|
|||||||
|
|
||||||
retry:
|
retry:
|
||||||
/* Issue JEDEC Byte Program command */
|
/* Issue JEDEC Byte Program command */
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xA0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xA0;
|
||||||
|
|
||||||
/* transfer data from source to destination */
|
/* transfer data from source to destination */
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
toggle_ready_jedec(bios);
|
toggle_ready_jedec(bios);
|
||||||
|
|
||||||
if (*dst != *src && tried++ < MAX_REFLASH_TRIES) {
|
if (*dst != *src && tried++ < MAX_REFLASH_TRIES) {
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tried >= MAX_REFLASH_TRIES)
|
if (tried >= MAX_REFLASH_TRIES)
|
||||||
ok=0;
|
ok = 0;
|
||||||
|
|
||||||
return (!ok);
|
return (!ok);
|
||||||
}
|
}
|
||||||
@ -233,13 +233,13 @@ int write_jedec(struct flashchip *flash, uint8_t *buf)
|
|||||||
volatile uint8_t *bios = flash->virt_addr;
|
volatile uint8_t *bios = flash->virt_addr;
|
||||||
|
|
||||||
erase_chip_jedec(flash);
|
erase_chip_jedec(flash);
|
||||||
// dumb check if erase was successful.
|
// dumb check if erase was successful.
|
||||||
for (i=0; i < total_size; i++) {
|
for (i = 0; i < total_size; i++) {
|
||||||
if (bios[i] != (uint8_t)0xff) {
|
if (bios[i] != (uint8_t) 0xff) {
|
||||||
printf("ERASE FAILED\n");
|
printf("ERASE FAILED\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
|
136
layout.c
136
layout.c
@ -6,9 +6,9 @@
|
|||||||
#include "lbtable.h"
|
#include "lbtable.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
char * mainboard_vendor=NULL;
|
char *mainboard_vendor = NULL;
|
||||||
char * mainboard_part=NULL;
|
char *mainboard_part = NULL;
|
||||||
int romimages=0;
|
int romimages = 0;
|
||||||
|
|
||||||
extern int force;
|
extern int force;
|
||||||
|
|
||||||
@ -25,131 +25,132 @@ 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--;
|
||||||
|
|
||||||
walk=(unsigned int *)(bios+size-0x10);
|
if ((*walk) == 0 || ((*walk) & 0x3ff) != 0) {
|
||||||
walk--;
|
|
||||||
|
|
||||||
if((*walk)==0 || ((*walk)&0x3ff) != 0) {
|
|
||||||
/* We might have an Nvidia chipset bios
|
/* We might have an Nvidia chipset bios
|
||||||
* which stores the id information at a
|
* which stores the id information at a
|
||||||
* different location.
|
* different location.
|
||||||
*/
|
*/
|
||||||
walk=(unsigned int *)(bios+size-0x80);
|
walk = (unsigned int *)(bios + size - 0x80);
|
||||||
walk--;
|
walk--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((*walk)==0 || ((*walk)&0x3ff) != 0) {
|
if ((*walk) == 0 || ((*walk) & 0x3ff) != 0) {
|
||||||
printf("Flash image seems to be a legacy BIOS. Disabling checks.\n");
|
printf("Flash image seems to be a legacy BIOS. Disabling checks.\n");
|
||||||
mainboard_vendor=def_name;
|
mainboard_vendor = def_name;
|
||||||
mainboard_part=def_name;
|
mainboard_part = def_name;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!lb_vendor || !lb_part) {
|
if (!lb_vendor || !lb_part) {
|
||||||
printf("Note: If the following flash access fails, "
|
printf("Note: If the following flash access fails, "
|
||||||
"you might need to specify -m <vendor>:<mainboard>\n");
|
"you might need to specify -m <vendor>:<mainboard>\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These comparisons are case insensitive to make things
|
/* These comparisons are case insensitive to make things
|
||||||
* a little less user^Werror prone.
|
* a little less user^Werror prone.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!strcasecmp(mainboard_vendor, lb_vendor) &&
|
if (!strcasecmp(mainboard_vendor, lb_vendor) &&
|
||||||
!strcasecmp(mainboard_part, lb_part)) {
|
!strcasecmp(mainboard_part, lb_part)) {
|
||||||
printf_debug("This firmware image matches "
|
printf_debug("This firmware image matches "
|
||||||
"this motherboard.\n");
|
"this motherboard.\n");
|
||||||
} else {
|
} else {
|
||||||
if(force) {
|
if (force) {
|
||||||
printf("WARNING: This firmware image does not "
|
printf("WARNING: This firmware image does not "
|
||||||
"seem to fit to this machine - forcing it.\n");
|
"seem to fit to this machine - forcing it.\n");
|
||||||
} else {
|
} else {
|
||||||
printf("ERROR: Your firmware image (%s:%s) does not "
|
printf("ERROR: Your firmware image (%s:%s) does not "
|
||||||
"appear to\n be correct for the detected "
|
"appear to\n be correct for the detected "
|
||||||
"mainboard (%s:%s)\n\nOverride with --force if you "
|
"mainboard (%s:%s)\n\nOverride with --force if you "
|
||||||
"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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_romlayout(char *name)
|
int read_romlayout(char *name)
|
||||||
{
|
{
|
||||||
FILE *romlayout;
|
FILE *romlayout;
|
||||||
char tempstr[256];
|
char tempstr[256];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
romlayout=fopen (name, "r");
|
romlayout = fopen(name, "r");
|
||||||
|
|
||||||
if(!romlayout) {
|
if (!romlayout) {
|
||||||
fprintf(stderr, "ERROR: Could not open rom layout (%s).\n",
|
fprintf(stderr, "ERROR: Could not open rom layout (%s).\n",
|
||||||
name);
|
name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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] == '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
tstr1=strtok(tempstr,":");
|
tstr1 = strtok(tempstr, ":");
|
||||||
tstr2=strtok(NULL,":");
|
tstr2 = strtok(NULL, ":");
|
||||||
rom_entries[romimages].start=strtol(tstr1, (char **)NULL, 16);
|
rom_entries[romimages].start = strtol(tstr1, (char **)NULL, 16);
|
||||||
rom_entries[romimages].end=strtol(tstr2, (char **)NULL, 16);
|
rom_entries[romimages].end = strtol(tstr2, (char **)NULL, 16);
|
||||||
rom_entries[romimages].included=0;
|
rom_entries[romimages].included = 0;
|
||||||
romimages++;
|
romimages++;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int find_romentry(char *name)
|
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);
|
||||||
|
|
||||||
for (i=0; i<romimages; i++) {
|
for (i = 0; i < romimages; i++) {
|
||||||
if(!strcmp(rom_entries[i].name, name)) {
|
if (!strcmp(rom_entries[i].name, name)) {
|
||||||
rom_entries[i].included=1;
|
rom_entries[i].included = 1;
|
||||||
printf("found.\n");
|
printf("found.\n");
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -178,15 +179,14 @@ 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)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
memcpy (buffer+rom_entries[i].start,
|
memcpy(buffer + rom_entries[i].start,
|
||||||
content+rom_entries[i].start,
|
content + rom_entries[i].start,
|
||||||
rom_entries[i].end-rom_entries[i].start);
|
rom_entries[i].end - rom_entries[i].start);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
88
lbtable.c
88
lbtable.c
@ -11,13 +11,13 @@
|
|||||||
#include "linuxbios_tables.h"
|
#include "linuxbios_tables.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
char *lb_part=NULL, *lb_vendor=NULL;
|
char *lb_part = NULL, *lb_vendor = NULL;
|
||||||
|
|
||||||
static unsigned long compute_checksum(void *addr, unsigned long length)
|
static unsigned long compute_checksum(void *addr, unsigned long length)
|
||||||
{
|
{
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
volatile union {
|
volatile union {
|
||||||
uint8_t byte[2];
|
uint8_t byte[2];
|
||||||
uint16_t word;
|
uint16_t word;
|
||||||
} value;
|
} value;
|
||||||
unsigned long sum;
|
unsigned long sum;
|
||||||
@ -27,7 +27,7 @@ static unsigned long compute_checksum(void *addr, unsigned long length)
|
|||||||
*/
|
*/
|
||||||
sum = 0;
|
sum = 0;
|
||||||
ptr = addr;
|
ptr = addr;
|
||||||
for(i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
value = ptr[i];
|
value = ptr[i];
|
||||||
if (i & 1) {
|
if (i & 1) {
|
||||||
@ -50,10 +50,9 @@ static unsigned long compute_checksum(void *addr, unsigned long length)
|
|||||||
(((char *)rec) < (((char *)head) + sizeof(*head) + head->table_bytes)) && \
|
(((char *)rec) < (((char *)head) + sizeof(*head) + head->table_bytes)) && \
|
||||||
(rec->size >= 1) && \
|
(rec->size >= 1) && \
|
||||||
((((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;
|
||||||
int count;
|
int count;
|
||||||
@ -64,18 +63,20 @@ 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",
|
||||||
addr, addr + head->table_bytes);
|
addr, addr + head->table_bytes);
|
||||||
if (head->header_bytes != sizeof(*head)) {
|
if (head->header_bytes != sizeof(*head)) {
|
||||||
fprintf(stderr, "Header bytes of %d are incorrect\n",
|
fprintf(stderr, "Header bytes of %d are incorrect\n",
|
||||||
head->header_bytes);
|
head->header_bytes);
|
||||||
@ -86,12 +87,12 @@ static struct lb_header *find_lb_table(void *base, unsigned long start, unsigned
|
|||||||
head->table_entries);
|
head->table_entries);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (compute_checksum((uint8_t *)head, sizeof(*head)) != 0) {
|
if (compute_checksum((uint8_t *) head, sizeof(*head)) != 0) {
|
||||||
fprintf(stderr, "bad header checksum\n");
|
fprintf(stderr, "bad header checksum\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (compute_checksum(recs, head->table_bytes)
|
if (compute_checksum(recs, head->table_bytes)
|
||||||
!= head->table_checksum) {
|
!= head->table_checksum) {
|
||||||
fprintf(stderr, "bad table checksum: %04x\n",
|
fprintf(stderr, "bad table checksum: %04x\n",
|
||||||
head->table_checksum);
|
head->table_checksum);
|
||||||
continue;
|
continue;
|
||||||
@ -111,21 +112,20 @@ static void find_mainboard(struct lb_record *ptr, unsigned long addr)
|
|||||||
rec = (struct lb_mainboard *)ptr;
|
rec = (struct lb_mainboard *)ptr;
|
||||||
max_size = rec->size - sizeof(*rec);
|
max_size = rec->size - sizeof(*rec);
|
||||||
printf("vendor id: %.*s part id: %.*s\n",
|
printf("vendor id: %.*s part id: %.*s\n",
|
||||||
max_size - rec->vendor_idx,
|
max_size - rec->vendor_idx,
|
||||||
rec->strings + rec->vendor_idx,
|
rec->strings + rec->vendor_idx,
|
||||||
max_size - rec->part_number_idx,
|
max_size - rec->part_number_idx,
|
||||||
rec->strings + rec->part_number_idx);
|
rec->strings + rec->part_number_idx);
|
||||||
snprintf(vendor, 255, "%.*s", max_size - rec->vendor_idx,
|
snprintf(vendor, 255, "%.*s", max_size - rec->vendor_idx,
|
||||||
rec->strings + rec->vendor_idx);
|
rec->strings + rec->vendor_idx);
|
||||||
snprintf(part, 255, "%.*s", max_size - rec->part_number_idx,
|
snprintf(part, 255, "%.*s", max_size - rec->part_number_idx,
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,33 +134,35 @@ static struct lb_record *next_record(struct lb_record *rec)
|
|||||||
return (struct lb_record *)(((char *)rec) + rec->size);
|
return (struct lb_record *)(((char *)rec) + rec->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void search_lb_records(struct lb_record *rec, struct lb_record *last,
|
static void search_lb_records(struct lb_record *rec, struct lb_record *last,
|
||||||
unsigned long addr)
|
unsigned long addr)
|
||||||
{
|
{
|
||||||
struct lb_record *next;
|
struct lb_record *next;
|
||||||
int count;
|
int count;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
for(next = next_record(rec); (rec < last) && (next <= last);
|
for (next = next_record(rec); (rec < last) && (next <= last);
|
||||||
rec = next, addr += rec->size) {
|
rec = next, addr += rec->size) {
|
||||||
next = next_record(rec);
|
next = next_record(rec);
|
||||||
count++;
|
count++;
|
||||||
if(rec->tag == LB_TAG_MAINBOARD) {
|
if (rec->tag == LB_TAG_MAINBOARD) {
|
||||||
find_mainboard(rec,addr);
|
find_mainboard(rec, addr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int linuxbios_init(void)
|
int linuxbios_init(void)
|
||||||
{
|
{
|
||||||
uint8_t *low_1MB;
|
uint8_t *low_1MB;
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -168,19 +170,19 @@ int linuxbios_init(void)
|
|||||||
if (!lb_table)
|
if (!lb_table)
|
||||||
lb_table = find_lb_table(low_1MB, 0x00000, 0x1000);
|
lb_table = find_lb_table(low_1MB, 0x00000, 0x1000);
|
||||||
if (!lb_table)
|
if (!lb_table)
|
||||||
lb_table = find_lb_table(low_1MB, 0xf0000, 1024*1024);
|
lb_table = find_lb_table(low_1MB, 0xf0000, 1024 * 1024);
|
||||||
if (lb_table) {
|
if (lb_table) {
|
||||||
unsigned long addr;
|
unsigned long addr;
|
||||||
addr = ((char *)lb_table) - ((char *)low_1MB);
|
addr = ((char *)lb_table) - ((char *)low_1MB);
|
||||||
printf_debug("lb_table found at address %p\n", lb_table);
|
printf_debug("lb_table found at address %p\n", lb_table);
|
||||||
rec = (struct lb_record *)(((char *)lb_table) + lb_table->header_bytes);
|
rec = (struct lb_record *)(((char *)lb_table) + lb_table->header_bytes);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -50,25 +50,22 @@ struct lb_uint64 {
|
|||||||
|
|
||||||
static inline uint64_t unpack_lb64(struct lb_uint64 value)
|
static inline uint64_t unpack_lb64(struct lb_uint64 value)
|
||||||
{
|
{
|
||||||
uint64_t result;
|
uint64_t result;
|
||||||
result = value.hi;
|
result = value.hi;
|
||||||
result = (result << 32) + value.lo;
|
result = (result << 32) + value.lo;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct lb_uint64 pack_lb64(uint64_t value)
|
static inline struct lb_uint64 pack_lb64(uint64_t value)
|
||||||
{
|
{
|
||||||
struct lb_uint64 result;
|
struct lb_uint64 result;
|
||||||
result.lo = (value >> 0) & 0xffffffff;
|
result.lo = (value >> 0) & 0xffffffff;
|
||||||
result.hi = (value >> 32) & 0xffffffff;
|
result.hi = (value >> 32) & 0xffffffff;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct lb_header {
|
||||||
|
uint8_t signature[4]; /* LBIO */
|
||||||
struct lb_header
|
|
||||||
{
|
|
||||||
uint8_t signature[4]; /* LBIO */
|
|
||||||
uint32_t header_bytes;
|
uint32_t header_bytes;
|
||||||
uint32_t header_checksum;
|
uint32_t header_checksum;
|
||||||
uint32_t table_bytes;
|
uint32_t table_bytes;
|
||||||
@ -117,9 +114,9 @@ struct lb_hwrpb {
|
|||||||
struct lb_mainboard {
|
struct lb_mainboard {
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t vendor_idx;
|
uint8_t vendor_idx;
|
||||||
uint8_t part_number_idx;
|
uint8_t part_number_idx;
|
||||||
uint8_t strings[0];
|
uint8_t strings[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LB_TAG_VERSION 0x0004
|
#define LB_TAG_VERSION 0x0004
|
||||||
@ -135,16 +132,16 @@ struct lb_mainboard {
|
|||||||
struct lb_string {
|
struct lb_string {
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t string[0];
|
uint8_t string[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The following structures are for the cmos definitions table */
|
/* The following structures are for the cmos definitions table */
|
||||||
#define LB_TAG_CMOS_OPTION_TABLE 200
|
#define LB_TAG_CMOS_OPTION_TABLE 200
|
||||||
/* cmos header record */
|
/* cmos header record */
|
||||||
struct cmos_option_table {
|
struct cmos_option_table {
|
||||||
uint32_t tag; /* CMOS definitions table type */
|
uint32_t tag; /* CMOS definitions table type */
|
||||||
uint32_t size; /* size of the entire table */
|
uint32_t size; /* size of the entire table */
|
||||||
uint32_t header_length; /* length of header */
|
uint32_t header_length; /* length of header */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* cmos entry record
|
/* cmos entry record
|
||||||
@ -156,31 +153,30 @@ struct cmos_option_table {
|
|||||||
*/
|
*/
|
||||||
#define LB_TAG_OPTION 201
|
#define LB_TAG_OPTION 201
|
||||||
struct cmos_entries {
|
struct cmos_entries {
|
||||||
uint32_t tag; /* entry type */
|
uint32_t tag; /* entry type */
|
||||||
uint32_t size; /* length of this record */
|
uint32_t size; /* length of this record */
|
||||||
uint32_t bit; /* starting bit from start of image */
|
uint32_t bit; /* starting bit from start of image */
|
||||||
uint32_t length; /* length of field in bits */
|
uint32_t length; /* length of field in bits */
|
||||||
uint32_t config; /* e=enumeration, h=hex, r=reserved */
|
uint32_t config; /* e=enumeration, h=hex, r=reserved */
|
||||||
uint32_t config_id; /* a number linking to an enumeration record */
|
uint32_t config_id; /* a number linking to an enumeration record */
|
||||||
#define CMOS_MAX_NAME_LENGTH 32
|
#define CMOS_MAX_NAME_LENGTH 32
|
||||||
uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
|
uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name of entry in ascii,
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
#define LB_TAG_OPTION_ENUM 202
|
#define LB_TAG_OPTION_ENUM 202
|
||||||
struct cmos_enums {
|
struct cmos_enums {
|
||||||
uint32_t tag; /* enumeration type */
|
uint32_t tag; /* enumeration type */
|
||||||
uint32_t size; /* length of this record */
|
uint32_t size; /* length of this record */
|
||||||
uint32_t config_id; /* a number identifying the config id */
|
uint32_t config_id; /* a number identifying the config id */
|
||||||
uint32_t value; /* the value associated with the text */
|
uint32_t value; /* the value associated with the text */
|
||||||
#define CMOS_MAX_TEXT_LENGTH 32
|
#define CMOS_MAX_TEXT_LENGTH 32
|
||||||
uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
|
uint8_t text[CMOS_MAX_TEXT_LENGTH]; /* enum description in ascii,
|
||||||
variable length int aligned */
|
variable length int aligned */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* cmos defaults record
|
/* cmos defaults record
|
||||||
@ -188,16 +184,16 @@ struct cmos_enums {
|
|||||||
*/
|
*/
|
||||||
#define LB_TAG_OPTION_DEFAULTS 203
|
#define LB_TAG_OPTION_DEFAULTS 203
|
||||||
struct cmos_defaults {
|
struct cmos_defaults {
|
||||||
uint32_t tag; /* default type */
|
uint32_t tag; /* default type */
|
||||||
uint32_t size; /* length of this record */
|
uint32_t size; /* length of this record */
|
||||||
uint32_t name_length; /* length of the following name field */
|
uint32_t name_length; /* length of the following name field */
|
||||||
uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
|
uint8_t name[CMOS_MAX_NAME_LENGTH]; /* name identifying the default */
|
||||||
#define CMOS_IMAGE_BUFFER_SIZE 128
|
#define CMOS_IMAGE_BUFFER_SIZE 128
|
||||||
uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
|
uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LB_TAG_OPTION_CHECKSUM 204
|
#define LB_TAG_OPTION_CHECKSUM 204
|
||||||
struct cmos_checksum {
|
struct cmos_checksum {
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
/* In practice everything is byte aligned, but things are measured
|
/* In practice everything is byte aligned, but things are measured
|
||||||
@ -211,6 +207,4 @@ struct cmos_checksum {
|
|||||||
#define CHECKSUM_PCBIOS 1
|
#define CHECKSUM_PCBIOS 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif /* LINUXBIOS_TABLES_H */
|
||||||
|
|
||||||
#endif /* LINUXBIOS_TABLES_H */
|
|
||||||
|
70
m29f400bt.c
70
m29f400bt.c
@ -32,24 +32,23 @@ int probe_m29f400bt(struct flashchip *flash)
|
|||||||
volatile uint8_t *bios = flash->virt_addr;
|
volatile uint8_t *bios = flash->virt_addr;
|
||||||
uint8_t id1, id2;
|
uint8_t id1, id2;
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0x90;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0x90;
|
||||||
|
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x02);
|
id2 = *(volatile uint8_t *)(bios + 0x02);
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xF0;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xF0;
|
||||||
|
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -60,13 +59,13 @@ int erase_m29f400bt(struct flashchip *flash)
|
|||||||
{
|
{
|
||||||
volatile uint8_t *bios = flash->virt_addr;
|
volatile uint8_t *bios = flash->virt_addr;
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0x80;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0x80;
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0x10;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0x10;
|
||||||
|
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
toggle_ready_m29f400bt(bios);
|
toggle_ready_m29f400bt(bios);
|
||||||
@ -77,12 +76,12 @@ int erase_m29f400bt(struct flashchip *flash)
|
|||||||
int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst)
|
int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst)
|
||||||
{
|
{
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0x80;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0x80;
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
//*(volatile uint8_t *) (bios + 0xAAA) = 0x10;
|
//*(volatile uint8_t *) (bios + 0xAAA) = 0x10;
|
||||||
*dst = 0x30;
|
*dst = 0x30;
|
||||||
|
|
||||||
@ -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);
|
||||||
|
21
m29f400bt.h
21
m29f400bt.h
@ -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)
|
||||||
{
|
{
|
||||||
@ -44,23 +44,24 @@ extern __inline__ void data_polling_m29f400bt(volatile uint8_t *dst,
|
|||||||
|
|
||||||
extern __inline__ void protect_m29f400bt(volatile uint8_t *bios)
|
extern __inline__ void protect_m29f400bt(volatile uint8_t *bios)
|
||||||
{
|
{
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xA0;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xA0;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < page_size; i++) {
|
for (i = 0; i < page_size; i++) {
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xAA;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x555) = 0x55;
|
*(volatile uint8_t *)(bios + 0x555) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0xAAA) = 0xA0;
|
*(volatile uint8_t *)(bios + 0xAAA) = 0xA0;
|
||||||
|
|
||||||
/* transfer data from source to destination */
|
/* transfer data from source to destination */
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
|
53
msys_doc.c
53
msys_doc.c
@ -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,9 +129,8 @@ 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
|
||||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||||
@ -153,37 +141,31 @@ 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;
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x80;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x80;
|
||||||
|
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(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);
|
||||||
|
@ -51,9 +51,9 @@ int probe_lhf00l04(struct flashchip *flash)
|
|||||||
uint8_t id1, id2;
|
uint8_t id1, id2;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0x90;
|
*(volatile uint8_t *)(bios + 0x5555) = 0x90;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*bios = 0xff;
|
*bios = 0xff;
|
||||||
@ -61,13 +61,13 @@ int probe_lhf00l04(struct flashchip *flash)
|
|||||||
*bios = 0x90;
|
*bios = 0x90;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xF0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ uint8_t wait_lhf00l04(volatile uint8_t *bios)
|
|||||||
|
|
||||||
*bios = 0x70;
|
*bios = 0x70;
|
||||||
if ((*bios & 0x80) == 0) { // it's busy
|
if ((*bios & 0x80) == 0) { // it's busy
|
||||||
while ((*bios & 0x80) == 0);
|
while ((*bios & 0x80) == 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = *bios;
|
status = *bios;
|
||||||
@ -111,21 +112,20 @@ uint8_t wait_lhf00l04(volatile uint8_t *bios)
|
|||||||
*bios = 0x90;
|
*bios = 0x90;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
// this is needed to jam it out of "read id" mode
|
// this is needed to jam it out of "read id" mode
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xAA;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xAA;
|
||||||
*(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
|
*(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
|
||||||
*(volatile uint8_t *) (bios + 0x5555) = 0xF0;
|
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
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
|
||||||
@ -140,8 +140,8 @@ int erase_lhf00l04_block(struct flashchip *flash, int offset)
|
|||||||
printf("write protect is 0x%x\n", *(wrprotect));
|
printf("write protect is 0x%x\n", *(wrprotect));
|
||||||
|
|
||||||
// now start it
|
// now start it
|
||||||
*(volatile uint8_t *) (bios) = 0x20;
|
*(volatile uint8_t *)(bios) = 0x20;
|
||||||
*(volatile uint8_t *) (bios) = 0xd0;
|
*(volatile uint8_t *)(bios) = 0xd0;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
// now let's see what the register is
|
// now let's see what the register is
|
||||||
status = wait_lhf00l04(flash->virt_addr);
|
status = wait_lhf00l04(flash->virt_addr);
|
||||||
@ -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);
|
||||||
@ -192,9 +192,8 @@ int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
|
|||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
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);
|
||||||
|
36
sst28sf040.c
36
sst28sf040.c
@ -43,13 +43,13 @@ static __inline__ void protect_28sf040(volatile uint8_t *bios)
|
|||||||
/* ask compiler not to optimize this */
|
/* ask compiler not to optimize this */
|
||||||
volatile uint8_t tmp;
|
volatile uint8_t tmp;
|
||||||
|
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x1823);
|
tmp = *(volatile uint8_t *)(bios + 0x1823);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x1820);
|
tmp = *(volatile uint8_t *)(bios + 0x1820);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x1822);
|
tmp = *(volatile uint8_t *)(bios + 0x1822);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x0418);
|
tmp = *(volatile uint8_t *)(bios + 0x0418);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x041B);
|
tmp = *(volatile uint8_t *)(bios + 0x041B);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x0419);
|
tmp = *(volatile uint8_t *)(bios + 0x0419);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x040A);
|
tmp = *(volatile uint8_t *)(bios + 0x040A);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void unprotect_28sf040(volatile uint8_t *bios)
|
static __inline__ void unprotect_28sf040(volatile uint8_t *bios)
|
||||||
@ -57,13 +57,13 @@ static __inline__ void unprotect_28sf040(volatile uint8_t *bios)
|
|||||||
/* ask compiler not to optimize this */
|
/* ask compiler not to optimize this */
|
||||||
volatile uint8_t tmp;
|
volatile uint8_t tmp;
|
||||||
|
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x1823);
|
tmp = *(volatile uint8_t *)(bios + 0x1823);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x1820);
|
tmp = *(volatile uint8_t *)(bios + 0x1820);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x1822);
|
tmp = *(volatile uint8_t *)(bios + 0x1822);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x0418);
|
tmp = *(volatile uint8_t *)(bios + 0x0418);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x041B);
|
tmp = *(volatile uint8_t *)(bios + 0x041B);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x0419);
|
tmp = *(volatile uint8_t *)(bios + 0x0419);
|
||||||
tmp = *(volatile uint8_t *) (bios + 0x041A);
|
tmp = *(volatile uint8_t *)(bios + 0x041A);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int erase_sector_28sf040(volatile uint8_t *bios,
|
static __inline__ int erase_sector_28sf040(volatile uint8_t *bios,
|
||||||
@ -116,9 +116,9 @@ int probe_28sf040(struct flashchip *flash)
|
|||||||
|
|
||||||
*bios = READ_ID;
|
*bios = READ_ID;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
*bios = RESET;
|
*bios = RESET;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
@ -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);
|
||||||
|
@ -50,9 +50,8 @@
|
|||||||
#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)
|
||||||
{
|
{
|
||||||
int i, left = size;
|
int i, left = size;
|
||||||
unsigned long address;
|
unsigned long address;
|
||||||
@ -63,24 +62,23 @@ static __inline__ int write_lockbits_49lfxxxc(volatile uint8_t *bios, int size,
|
|||||||
*(bios + (i * 65536) + 2) = bits;
|
*(bios + (i * 65536) + 2) = bits;
|
||||||
}
|
}
|
||||||
address = i * 65536;
|
address = i * 65536;
|
||||||
//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;
|
||||||
address += 32768;
|
address += 32768;
|
||||||
//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;
|
||||||
address += 8192;
|
address += 8192;
|
||||||
//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;
|
||||||
address += 8192;
|
address += 8192;
|
||||||
//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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int erase_sector_49lfxxxc(volatile uint8_t *bios,
|
static __inline__ int erase_sector_49lfxxxc(volatile uint8_t *bios,
|
||||||
unsigned long address)
|
unsigned long address)
|
||||||
{
|
{
|
||||||
unsigned char status;
|
unsigned char status;
|
||||||
|
|
||||||
@ -88,21 +86,21 @@ static __inline__ int erase_sector_49lfxxxc(volatile uint8_t *bios,
|
|||||||
*(bios + address) = ERASE;
|
*(bios + address) = ERASE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
status = *bios;
|
status = *bios;
|
||||||
if (status & (STATUS_ESS | STATUS_BPS)) {
|
if (status & (STATUS_ESS | STATUS_BPS)) {
|
||||||
printf("sector erase FAILED at address=0x%08lx status=0x%01x\n", (unsigned long)bios + address, status);
|
printf("sector erase FAILED at address=0x%08lx status=0x%01x\n", (unsigned long)bios + address, status);
|
||||||
*bios = CLEAR_STATUS;
|
*bios = CLEAR_STATUS;
|
||||||
return(-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} while (!(status & STATUS_WSMS));
|
} while (!(status & STATUS_WSMS));
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int write_sector_49lfxxxc(volatile uint8_t *bios,
|
static __inline__ int write_sector_49lfxxxc(volatile uint8_t *bios,
|
||||||
uint8_t *src,
|
uint8_t *src,
|
||||||
volatile uint8_t *dst,
|
volatile uint8_t *dst,
|
||||||
unsigned int page_size)
|
unsigned int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char status;
|
unsigned char status;
|
||||||
@ -122,9 +120,9 @@ static __inline__ int write_sector_49lfxxxc(volatile uint8_t *bios,
|
|||||||
do {
|
do {
|
||||||
status = *bios;
|
status = *bios;
|
||||||
if (status & (STATUS_ESS | STATUS_BPS)) {
|
if (status & (STATUS_ESS | STATUS_BPS)) {
|
||||||
printf("sector write FAILED at address=0x%08lx status=0x%01x\n", (unsigned long)dst, status);
|
printf("sector write FAILED at address=0x%08lx status=0x%01x\n", (unsigned long)dst, status);
|
||||||
*bios = CLEAR_STATUS;
|
*bios = CLEAR_STATUS;
|
||||||
return(-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} while (!(status & STATUS_WSMS));
|
} while (!(status & STATUS_WSMS));
|
||||||
}
|
}
|
||||||
@ -141,8 +139,8 @@ int probe_49lfxxxc(struct flashchip *flash)
|
|||||||
*bios = RESET;
|
*bios = RESET;
|
||||||
|
|
||||||
*bios = READ_ID;
|
*bios = READ_ID;
|
||||||
id1 = *(volatile uint8_t *) bios;
|
id1 = *(volatile uint8_t *)bios;
|
||||||
id2 = *(volatile uint8_t *) (bios + 0x01);
|
id2 = *(volatile uint8_t *)(bios + 0x01);
|
||||||
|
|
||||||
*bios = RESET;
|
*bios = RESET;
|
||||||
|
|
||||||
@ -170,8 +168,8 @@ int erase_49lfxxxc(struct flashchip *flash)
|
|||||||
|
|
||||||
write_lockbits_49lfxxxc(bios2, total_size, 0);
|
write_lockbits_49lfxxxc(bios2, total_size, 0);
|
||||||
for (i = 0; i < total_size; i += flash->page_size)
|
for (i = 0; i < total_size; i += flash->page_size)
|
||||||
if (erase_sector_49lfxxxc(bios, i) != 0 )
|
if (erase_sector_49lfxxxc(bios, i) != 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
*bios = RESET;
|
*bios = RESET;
|
||||||
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++) {
|
||||||
@ -194,7 +191,7 @@ int write_49lfxxxc(struct flashchip *flash, uint8_t *buf)
|
|||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_sector_49lfxxxc(bios, buf + i * page_size,
|
write_sector_49lfxxxc(bios, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size);
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user