Am 04.06.2012 14:26 schrieb Carl-Daniel Hailfinger:
Run ./build_new_driver.sh and recompile. You have a new driver, and it's linked in at the appropriate places. Patch needs work for anything which is not a bitbang SPI driver.
Added a man page template and print/print_wiki stuff.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-programmer_template/build_new_driver.sh =================================================================== --- flashrom-programmer_template/build_new_driver.sh (Revision 0) +++ flashrom-programmer_template/build_new_driver.sh (Revision 0) @@ -0,0 +1,262 @@ +#!/bin/bash +# flashrom programmer driver skeleton builder. +# Copyright 2012 Carl-Daniel Hailfinger +# Licensed under the GNU GPL v2 + +# Fill in all info in the block below, and don't touch anything else. +PROGRAMMERNAME=ezo +PROGRAMMERDESCR="EZo+Willem Programmer" +PROGRAMMERMANUF="EZo and Willem" +PROGRAMMERURL="http://www.ezoflash.com/" +AUTHORNAME="Carl-Daniel Hailfinger" +# Does the programmer need a map/unmap function? +HAVE_MAP=no +# Does the programmer have its own delay function? +HAVE_DELAY=no +# Does the programmer need some sort of direct hardware access? +NEED_PCI=yes +# Does the programmer need some sort of serial port access? +NEED_SERIAL=no +# Does the programmer use Parallel/LPC/FWH functionality? +NEED_PARLPCFWH=no +# Does the programmer use the bitbanging SPI infrastructure? +NEED_BITBANG_SPI=yes + +# No user serviceable parts below. +if test $HAVE_MAP = yes; then MAPNAME=$PROGRAMMERNAME; else MAPNAME=fallback; fi +if test $HAVE_DELAY = yes; then DELAYNAME=$PROGRAMMERNAME; else DELAYNAME=internal; fi +PROGRAMMERNAMECAPS=$(echo -n $PROGRAMMERNAME|tr "[[:lower:]]" "[[:upper:]]") +CONFIGNAME=CONFIG_$PROGRAMMERNAMECAPS +ENUMNAME=PROGRAMMER_$PROGRAMMERNAMECAPS +BITBANG_SPI_ENUMNAME=BITBANG_SPI_MASTER_$PROGRAMMERNAMECAPS +if test $NEED_PCI = yes; then NEEDS="NEED_PCI := yes\n"; fi +if test $NEED_SERIAL = yes; then NEEDS+="NEED_SERIAL := yes\n"; fi + +sed "s-^//PLACEHOLDER_NEWPROG_PROGRAMMER_ARRAY-\ +#if ${CONFIGNAME} == 1\n\ + {\n\ + .name = "${PROGRAMMERNAME}",\n\ + .init = ${PROGRAMMERNAME}_init,\n\ + .map_flash_region = ${MAPNAME}_map,\n\ + .unmap_flash_region = ${MAPNAME}_unmap,\n\ + .delay = ${DELAYNAME}_delay,\n\ + },\n\ +#endif\n\ +\n\0-" flashrom.c >flashrom.c.mine + +sed -e "s/^#PLACEHOLDER_NEWPROG_DEFAULTCONFIG/\ +# Enable ${PROGRAMMERDESCR} for now.\n\ +${CONFIGNAME} ?= yes\n\ +\n\0/" \ +-e "s/^#PLACEHOLDER_NEWPROG_COMPILERULE/\ +ifeq ($(${CONFIGNAME}), yes)\n\ +FEATURE_CFLAGS += -D'${CONFIGNAME}=1'\n\ +PROGRAMMER_OBJS += ${PROGRAMMERNAME}.o\n\ +${NEEDS}\ +endif\n\ +\n\0/" Makefile >Makefile.mine1 + +if test $NEED_BITBANG_SPI = yes; then +sed -e "s/^#PLACEHOLDER_NEWPROG_BITBANGSPICONFIG1/\ +ifeq ($(${CONFIGNAME}), yes)\n\ +override CONFIG_BITBANG_SPI = yes\n\ +else\n\ +\0/" \ +-e "s/^#PLACEHOLDER_NEWPROG_BITBANGSPICONFIG2/\ +\0\n\ +endif/;" Makefile.mine1 >Makefile.mine +rm Makefile.mine1 +else +mv Makefile.mine1 Makefile.mine +fi + +sed -e "s-^//PLACEHOLDER_NEWPROG_PROGRAMMER_ENUM-\ +#if ${CONFIGNAME} == 1\n\ + ${ENUMNAME},\n\ +#endif\n\ +\0-" \ +-e "s-//PLACEHOLDER_NEWPROG_PUBLICFUNCTIONS-\ +/* ${PROGRAMMERNAME}.c */\n\ +#if ${CONFIGNAME} == 1\n\ +int ${PROGRAMMERNAME}_init(void);\n\ +#endif\n\ +\n\0-" programmer.h >programmer.h.mine1 + +if test $NEED_BITBANG_SPI = yes; then +sed -e "s-^//PLACEHOLDER_NEWPROG_PROGRAMMER_BITBANG_ENUM-\ +#if ${CONFIGNAME} == 1\n\ + ${BITBANG_SPI_ENUMNAME},\n\ +#endif\n\ +\0-" \ +-e "s-//PLACEHOLDER_NEWPROG_SELECT_SPI_BITBANG$-\ +|| ${CONFIGNAME} == 1 \0-" programmer.h.mine1 >programmer.h.mine +rm programmer.h.mine1 +else +mv programmer.h.mine1 programmer.h.mine +fi + +sed -e "s-PLACEHOLDER_NEWPROG_CHECK_PROGRAMMERCOUNT-\ +${CONFIGNAME}+\0-" \ +-e "s-^//PLACEHOLDER_NEWPROG_PROGRAMMER_ENUMDEFAULT-\ +#if ${CONFIGNAME} == 1\n\ + ${ENUMNAME}\n\ +#endif\n\ +\0-" cli_classic.c >cli_classic.c.mine + +sed -e "s-^//PLACEHOLDER_NEWPROG_PROGRAMMER_PRINT-\ +#if ${CONFIGNAME} == 1\n\ + msg_ginfo("\\nSupported devices for the %s programmer:\\n",\n\ + programmer_table[${ENUMNAME}].name);\n\ + /* Print the supported devices here. */\n\ +#endif\n\ +\0-" print.c >print.c.mine + +sed -e "s-//PLACEHOLDER_NEWPROG_PROGRAMMER_PRINT-\ +#if ${CONFIGNAME} == 1\n\ + /* Print the supported devices here. */\n\ +#endif\n\ +\0-" print_wiki.c >print_wiki.c.mine + +cat >$PROGRAMMERNAME.c <<EOF +/* + * This file is part of the flashrom project. + * + * Copyright (C) $(date +%Y) ${AUTHORNAME} + * + * 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; version 2 of the License. + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Driver for the ${PROGRAMMERDESCR} hardware by ${PROGRAMMERMANUF}. + * See ${PROGRAMMERURL} for more info. + */ + +#include "flash.h" +#include "programmer.h" + +EOF + +if test $NEED_PARLPCFWH = yes; then +cat >>$PROGRAMMERNAME.c <<EOF +static const struct par_programmer par_programmer_${PROGRAMMERNAME} = { + .chip_readb = ${PROGRAMMERNAME}_chip_readb, + .chip_readw = fallback_chip_readw, + .chip_readl = fallback_chip_readl, + .chip_readn = fallback_chip_readn, + .chip_writeb = ${PROGRAMMERNAME}_chip_writeb, + .chip_writew = fallback_chip_writew, + .chip_writel = fallback_chip_writel, + .chip_writen = fallback_chip_writen, +}; + +EOF +fi + +if test $NEED_BITBANG_SPI = yes; then +cat >>$PROGRAMMERNAME.c <<EOF +static void ${PROGRAMMERNAME}_bitbang_set_cs(int val) +{ + /* Set/clear the CS# line. */ +} + +static void ${PROGRAMMERNAME}_bitbang_set_sck(int val) +{ + /* Set/clear the SCLK line. */ +} + +static void ${PROGRAMMERNAME}_bitbang_set_mosi(int val) +{ + /* Set/clear the MOSI line. */ +} + +static int ${PROGRAMMERNAME}_bitbang_get_miso(void) +{ + /* Get the state of the MISO line and return it. */ + /* Set it to 1 to get the template to compile. */ + int misoval = 0; + + return misoval; +} + +/* If this programmer does not support requesting/releasing the SPI bus, remove + * the functions ${PROGRAMMERNAME}_request_spibus and ${PROGRAMMERNAME}_release_spibus + * and set bitbang_spi_master_${PROGRAMMERNAME} members .request_bus and .release_bus + * to NULL. + */ +static void ${PROGRAMMERNAME}_request_spibus(void) +{ +} + +static void ${PROGRAMMERNAME}_release_spibus(void) +{ +} + +static const struct bitbang_spi_master bitbang_spi_master_${PROGRAMMERNAME} = { + .type = ${BITBANG_SPI_ENUMNAME}, + .set_cs = ${PROGRAMMERNAME}_bitbang_set_cs, + .set_sck = ${PROGRAMMERNAME}_bitbang_set_sck, + .set_mosi = ${PROGRAMMERNAME}_bitbang_set_mosi, + .get_miso = ${PROGRAMMERNAME}_bitbang_get_miso, + .request_bus = ${PROGRAMMERNAME}_request_spibus, + .release_bus = ${PROGRAMMERNAME}_release_spibus, + .half_period = 1, /* Delay in microseconds before each SCLK level change. */ +}; + +EOF +fi + +# No idea if roff supports hidden comments. Hook up to hopefully unchanged sequences. +sed -e "s/^Some programmers have optional or mandatory parameters/\ +.BR "* ${PROGRAMMERNAME}" " (${PROGRAMMERDESCR})"\n\ +.sp\n\ +\0/" \ +-e "s/^.SH EXIT STATUS/\ +.SS\n\ +.BR "${PROGRAMMERNAME} " programmer\n\ +Please describe the programmer parameters here.\n\ +\0/" flashrom.8 > flashrom.8.mine + +cat >>$PROGRAMMERNAME.c <<EOF +static int ${PROGRAMMERNAME}_shutdown(void *data) +{ + /* Shutdown stuff. */ + return 0; +} + +int ${PROGRAMMERNAME}_init(void) +{ + /* Init stuff (i.e. parameter parsing) here which does not need to be + * undone. + */ + + /* If your shutdown function takes a parameter, replace NULL with it. */ + register_shutdown(${PROGRAMMERNAME}_shutdown, NULL); + + /* Init stuff which needs to be undone on shutdown. */ + +EOF + +if test $NEED_BITBANG_SPI = yes; then +cat >>$PROGRAMMERNAME.c <<EOF + /* 1 usec halfperiod delay, change as needed. */ + if (bitbang_spi_init(&bitbang_spi_master_${PROGRAMMERNAME})) + return 1; + +EOF +fi + +cat >>$PROGRAMMERNAME.c <<EOF + return 0; +} +EOF +
Eigenschaftsänderungen: flashrom-programmer_template/build_new_driver.sh ___________________________________________________________________ Hinzugefügt: svn:executable + *
Index: flashrom-programmer_template/Makefile =================================================================== --- flashrom-programmer_template/Makefile (Revision 1539) +++ flashrom-programmer_template/Makefile (Arbeitskopie) @@ -344,6 +344,8 @@ # Enable Linux spidev interface by default. We disable it on non-Linux targets. CONFIG_LINUX_SPI ?= yes
+#PLACEHOLDER_NEWPROG_DEFAULTCONFIG + # Disable wiki printing by default. It is only useful if you have wiki access. CONFIG_PRINT_WIKI ?= no
@@ -363,7 +365,9 @@ ifeq ($(CONFIG_OGP_SPI), yes) override CONFIG_BITBANG_SPI = yes else +#PLACEHOLDER_NEWPROG_BITBANGSPICONFIG1 CONFIG_BITBANG_SPI ?= no +#PLACEHOLDER_NEWPROG_BITBANGSPICONFIG2 endif endif endif @@ -503,6 +507,8 @@ PROGRAMMER_OBJS += linux_spi.o endif
+#PLACEHOLDER_NEWPROG_COMPILERULE + ifeq ($(NEED_SERIAL), yes) LIB_OBJS += serial.o endif Index: flashrom-programmer_template/cli_classic.c =================================================================== --- flashrom-programmer_template/cli_classic.c (Revision 1539) +++ flashrom-programmer_template/cli_classic.c (Arbeitskopie) @@ -41,7 +41,7 @@ * if more than one of them is selected. If only one is selected, it is clear * that the user wants that one to become the default. */ -#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_FT2232_SPI+CONFIG_SERPROG+CONFIG_BUSPIRATE_SPI+CONFIG_DEDIPROG+CONFIG_RAYER_SPI+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV > 1 +#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_FT2232_SPI+CONFIG_SERPROG+CONFIG_BUSPIRATE_SPI+CONFIG_DEDIPROG+CONFIG_RAYER_SPI+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV+PLACEHOLDER_NEWPROG_CHECK_PROGRAMMERCOUNT > 1 #error Please enable either CONFIG_DUMMY or CONFIG_INTERNAL or disable support for all programmers except one. #endif static enum programmer default_programmer = @@ -96,6 +96,7 @@ #if CONFIG_LINUX_SPI == 1 PROGRAMMER_LINUX_SPI #endif +//PLACEHOLDER_NEWPROG_PROGRAMMER_ENUMDEFAULT ; #endif
Index: flashrom-programmer_template/print_wiki.c =================================================================== --- flashrom-programmer_template/print_wiki.c (Revision 1539) +++ flashrom-programmer_template/print_wiki.c (Arbeitskopie) @@ -338,6 +338,7 @@ #if CONFIG_SATAMV == 1 print_supported_pcidevs_wiki(satas_mv); #endif +//PLACEHOLDER_NEWPROG_PROGRAMMER_PRINT_WIKI printf("\n|}\n"); }
Index: flashrom-programmer_template/flashrom.c =================================================================== --- flashrom-programmer_template/flashrom.c (Revision 1539) +++ flashrom-programmer_template/flashrom.c (Arbeitskopie) @@ -261,6 +261,7 @@ }, #endif
+//PLACEHOLDER_NEWPROG_PROGRAMMER_ARRAY {}, /* This entry corresponds to PROGRAMMER_INVALID. */ };
Index: flashrom-programmer_template/programmer.h =================================================================== --- flashrom-programmer_template/programmer.h (Revision 1539) +++ flashrom-programmer_template/programmer.h (Arbeitskopie) @@ -87,6 +87,7 @@ #if CONFIG_LINUX_SPI == 1 PROGRAMMER_LINUX_SPI, #endif +//PLACEHOLDER_NEWPROG_PROGRAMMER_ENUM PROGRAMMER_INVALID /* This must always be the last entry. */ };
@@ -127,6 +128,7 @@ #if CONFIG_OGP_SPI == 1 BITBANG_SPI_MASTER_OGP, #endif +//PLACEHOLDER_NEWPROG_PROGRAMMER_BITBANG_ENUM };
struct bitbang_spi_master { @@ -461,6 +463,8 @@ int dediprog_init(void); #endif
+//PLACEHOLDER_NEWPROG_PUBLICFUNCTIONS + /* flashrom.c */ struct decode_sizes { uint32_t parallel; @@ -505,7 +509,7 @@ #if CONFIG_DEDIPROG == 1 SPI_CONTROLLER_DEDIPROG, #endif -#if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || CONFIG_PONY_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__))) +#if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || CONFIG_PONY_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__))) //PLACEHOLDER_NEWPROG_SELECT_SPI_BITBANG SPI_CONTROLLER_BITBANG, #endif #if CONFIG_LINUX_SPI == 1 Index: flashrom-programmer_template/print.c =================================================================== --- flashrom-programmer_template/print.c (Revision 1539) +++ flashrom-programmer_template/print.c (Arbeitskopie) @@ -538,6 +538,7 @@ programmer_table[PROGRAMMER_LINUX_SPI].name); msg_ginfo("Device files /dev/spidev*.*\n"); #endif +//PLACEHOLDER_NEWPROG_PROGRAMMER_PRINT }
#if CONFIG_INTERNAL == 1