/* * flash_rom.c: Flash programming utility for SiS 630/950 M/Bs * * * Copyright 2000 Silicon Integrated System Corporation * Copyright 2004 Tyan Corp * yhlu yhlu@tyan.com add exclude start and end option * * 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. * * * Reference: * 1. SiS 630 Specification * 2. SiS 950 Specification * * $Id: flash_rom.c,v 1.21 2005/01/11 02:48:22 ollie Exp $ */ #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd_mem; volatile short *bios; unsigned long off,valint; unsigned short val; if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) { perror("Can not open /dev/mem"); exit(1); } sscanf(argv[1], "%x=%x", &off, &valint); val = valint&0xffff; bios = mmap(0, 0x40000, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, (off_t) (0x70000000)); if (bios == MAP_FAILED) { perror("Error MMAP /dev/mem"); exit(1); } printf("Offset: 0x%x=%02x\n", off, val); bios[off] = val; munmap((void *) bios, 0x40000); return 0; }