mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
This patch is a rework of Adam Kaufman's Solaris patch
* flash.h: - add a license header - add system definitions * flash_enable.c: - put io priviledge access in one single place - add includes required for Solaris. * lbtable.c, flash_rom.c, 82802ab.c: - use MEM_DEV so it works on Solaris * sst49lfxxxc.c, sharplhf00l04.c, sst_fwhub.c, 82802ab.c - drop unneeded include to sys/io.h * Makefile - adapt to Solaris specifics. Corresponding to flashrom svn r88 and coreboot v2 svn r2550. Signed-off-by: Adam Kaufman <adam.kaufman@pinnacle.com> Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Adam Kaufman <adam.kaufman@pinnacle.com>
This commit is contained in:
parent
474230ad42
commit
064b1f23fa
@ -26,7 +26,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/io.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -83,7 +82,7 @@ int probe_82802ab(struct flashchip *flash)
|
|||||||
flash->fd_mem, (off_t) (0 - 0x400000 - size));
|
flash->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 /dev/mem");
|
perror("Error MMAP memory using " MEM_DEV );
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
Makefile
9
Makefile
@ -12,8 +12,13 @@ INSTALL = /usr/bin/install
|
|||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
#CFLAGS = -O2 -g -Wall -Werror
|
#CFLAGS = -O2 -g -Wall -Werror
|
||||||
CFLAGS = -Os -Wall -Werror -DDISABLE_DOC # -DTS5300
|
CFLAGS = -Os -Wall -Werror -DDISABLE_DOC # -DTS5300
|
||||||
|
OS_ARCH = $(shell uname)
|
||||||
|
ifeq ($(OS_ARCH), SunOS)
|
||||||
|
LDFLAGS = -lpci -lz
|
||||||
|
else
|
||||||
LDFLAGS = -lpci -lz -static
|
LDFLAGS = -lpci -lz -static
|
||||||
|
STRIP_ARGS = -s
|
||||||
|
endif
|
||||||
|
|
||||||
OBJS = flash_enable.o udelay.o jedec.o sst28sf040.o am29f040b.o mx29f002.o \
|
OBJS = flash_enable.o udelay.o jedec.o sst28sf040.o am29f040b.o mx29f002.o \
|
||||||
sst39sf020.o m29f400bt.o w49f002u.o 82802ab.o msys_doc.o pm49fl004.o \
|
sst39sf020.o m29f400bt.o w49f002u.o 82802ab.o msys_doc.o pm49fl004.o \
|
||||||
@ -24,7 +29,7 @@ all: pciutils dep $(PROGRAM)
|
|||||||
|
|
||||||
$(PROGRAM): $(OBJS)
|
$(PROGRAM): $(OBJS)
|
||||||
$(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
|
$(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
|
||||||
$(STRIP) -s $(PROGRAM)
|
$(STRIP) $(STRIP_ARGS) $(PROGRAM)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *~
|
rm -f *.o *~
|
||||||
|
38
flash.h
38
flash.h
@ -1,7 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* flash.h: flash programming utility - central include file
|
||||||
|
*
|
||||||
|
* Copyright 2000 Silicon Integrated System Corporation
|
||||||
|
* Copyright 2000 Ronald G. Minnich <rminnich@gmail.com>
|
||||||
|
* Copyright 2005 coresystems GmbH <stepan@coresystems.de>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __FLASH_H__
|
#ifndef __FLASH_H__
|
||||||
#define __FLASH_H__ 1
|
#define __FLASH_H__ 1
|
||||||
|
|
||||||
|
#if defined(__GLIBC__)
|
||||||
#include <sys/io.h>
|
#include <sys/io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -92,7 +119,18 @@ extern struct flashchip flashchips[];
|
|||||||
#define S29C51004T 0x03 /* SyncMOS S29C51004T/B */
|
#define S29C51004T 0x03 /* SyncMOS S29C51004T/B */
|
||||||
#define S29C31004T 0x63 /* SyncMOS S29C31004T */
|
#define S29C31004T 0x63 /* SyncMOS S29C31004T */
|
||||||
|
|
||||||
|
/* function prototypes from udelay.h */
|
||||||
|
|
||||||
extern void myusec_delay(int time);
|
extern void myusec_delay(int time);
|
||||||
extern void myusec_calibrate_delay();
|
extern void myusec_calibrate_delay();
|
||||||
extern int enable_flash_write(void);
|
extern int enable_flash_write(void);
|
||||||
|
|
||||||
|
/* physical memory mapping device */
|
||||||
|
|
||||||
|
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
||||||
|
# define MEM_DEV "/dev/xsvc"
|
||||||
|
#else
|
||||||
|
# define MEM_DEV "/dev/mem"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* !__FLASH_H__ */
|
#endif /* !__FLASH_H__ */
|
||||||
|
@ -11,12 +11,18 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/io.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <pci/pci.h>
|
#include <pci/pci.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
||||||
|
#include <strings.h>
|
||||||
|
#include <sys/sysi86.h>
|
||||||
|
#include <sys/psw.h>
|
||||||
|
#include <asm/sunddi.h>
|
||||||
|
#endif
|
||||||
|
#include "flash.h"
|
||||||
#include "lbtable.h"
|
#include "lbtable.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
@ -27,12 +33,6 @@ static int enable_flash_sis630(struct pci_dev *dev, char *name)
|
|||||||
{
|
{
|
||||||
char b;
|
char b;
|
||||||
|
|
||||||
/* get io privilege access PCI configuration space */
|
|
||||||
if (iopl(3) != 0) {
|
|
||||||
perror("Can not set io priviliage");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */
|
/* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */
|
||||||
outl(0x80000840, 0x0cf8);
|
outl(0x80000840, 0x0cf8);
|
||||||
b = inb(0x0cfc) | 0x0b;
|
b = inb(0x0cfc) | 0x0b;
|
||||||
@ -164,12 +164,6 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
|
|||||||
unsigned int base;
|
unsigned int base;
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
/* get io privilege access PCI configuration space */
|
|
||||||
if (iopl(3) != 0) {
|
|
||||||
perror("Can not set io priviliage");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
old = pci_read_byte(dev, 0x40);
|
old = pci_read_byte(dev, 0x40);
|
||||||
|
|
||||||
new = old | 0x10;
|
new = old | 0x10;
|
||||||
@ -347,12 +341,6 @@ static int enable_flash_sb400(struct pci_dev *dev, char *name)
|
|||||||
struct pci_filter f;
|
struct pci_filter f;
|
||||||
struct pci_dev *smbusdev;
|
struct pci_dev *smbusdev;
|
||||||
|
|
||||||
/* get io privilege access */
|
|
||||||
if (iopl(3) != 0) {
|
|
||||||
perror("Can not set io priviliage");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
||||||
@ -491,12 +479,6 @@ static int mbenable_island_aruma(void)
|
|||||||
* connected to the WinBond w83627hf GPIO 24.
|
* connected to the WinBond w83627hf GPIO 24.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* get io privilege access winbond config space */
|
|
||||||
if (iopl(3) != 0) {
|
|
||||||
perror("Can not set io priviliage");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Disabling mainboard flash write protection.\n");
|
printf("Disabling mainboard flash write protection.\n");
|
||||||
|
|
||||||
outb(0x87, EFIR); // sequence to unlock extended functions
|
outb(0x87, EFIR); // sequence to unlock extended functions
|
||||||
@ -552,6 +534,18 @@ int enable_flash_write()
|
|||||||
struct pci_dev *dev = 0;
|
struct pci_dev *dev = 0;
|
||||||
FLASH_ENABLE *enable = 0;
|
FLASH_ENABLE *enable = 0;
|
||||||
|
|
||||||
|
/* get io privilege access PCI configuration space */
|
||||||
|
#if defined (__sun) && (defined(__i386) || defined(__amd64))
|
||||||
|
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0){
|
||||||
|
#else
|
||||||
|
if (iopl(3) != 0) {
|
||||||
|
#endif
|
||||||
|
perror("Can not set io privilege");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize PCI access */
|
||||||
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 */
|
||||||
|
@ -52,8 +52,8 @@ struct flashchip *probe_flash(struct flashchip *flash)
|
|||||||
volatile uint8_t *bios;
|
volatile uint8_t *bios;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
if ((fd_mem = open(MEM_DEV, O_RDWR)) < 0) {
|
||||||
perror("Error: Can not open /dev/mem. You need to be root.");
|
perror("Error: Can not access memory using " MEM_DEV ". You need to be root.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include "flash.h"
|
||||||
#include "../../src/include/boot/linuxbios_tables.h"
|
#include "../../src/include/boot/linuxbios_tables.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
@ -158,14 +159,14 @@ int linuxbios_init(void)
|
|||||||
struct lb_record *rec, *last;
|
struct lb_record *rec, *last;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
fd = open("/dev/mem", O_RDONLY);
|
fd = open(MEM_DEV, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "Can not open /dev/mem\n");
|
fprintf(stderr, "Can not access memory using " MEM_DEV "\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
low_1MB = mmap(0, 1024*1024, PROT_READ, MAP_SHARED, fd, 0x00000000);
|
low_1MB = mmap(0, 1024*1024, PROT_READ, MAP_SHARED, fd, 0x00000000);
|
||||||
if (low_1MB == ((void *) -1)) {
|
if (low_1MB == ((void *) -1)) {
|
||||||
fprintf(stderr, "Can not mmap /dev/mem 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);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/io.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/io.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "jedec.h"
|
#include "jedec.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/io.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user