#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <syslog.h>
#include <sys/ioctl.h>
#include <linux/version.h>
#include <mtd/mtd-user.h>
Include dependency graph for bootblocktool.c:
Go to the source code of this file.
Defines | |
#define | EMPTYMAGIC 0xffffffff |
#define | PARAMMAGIC_PRIMARY 0xbeefcace |
#define | PARAMMAGIC_BACKUP 0xdeadbabe |
#define | MAX_PARAM_NAME_LEN 0xff |
#define | MAX_RECORD_LEN 0xffff |
#define | ERR_NO_MAGIC -3 |
#define | ERR_END_OF_PARAMS -2 |
#define | ERR_OTHER -1 |
#define | NO_ERROR 0 |
#define | NAND_NOR_COMPATIBILITY_MODE (1) |
#define | ROUND_UP(len, pagesize) ((((len) - 1) & ~((pagesize) - 1)) + (pagesize)) |
#define | BLOCK_START(offset, blocksize) (((offset) & ((blocksize) -1)) == 0) |
#define | BLOCK_ADDR(offset, blocksize) ((offset) & ~((blocksize) -1)) |
#define | D(x) |
Enumerations | |
enum | Toutput_type { SCRIPT, NAMEVALUE } |
Functions | |
static void | printUsage (void) |
static void | die (const char *) |
static void | listParams (Toutput_type output_type) |
static int | readParam (const char *name, char **value, int *firstfree) |
static int | writeParam (const char *name, const char *value) |
static int | writeMagic (int file, int *offset) |
static int | readParamAt (int f, int offset, char **name, int *nameLen, char **value, int *valueLen, int *totlen) |
static int | writeParamAt (int f, int offset, const char *name, const char *value) |
static void | skipBadBlocks (int fd, int *offset) |
static int | getChipParams (void) |
static int | setFlashParams (void) |
int | main (int argc, char **argv) |
Variables | |
static const char * | dev = "/dev/part/rescue" |
const char | usage [] |
const char | HTML_END [] = " " |
static int | useHTML = 0 |
static int | setExitErr = 0 |
static int | exitStat = 0 |
static int | PARAMMAGIC = PARAMMAGIC_PRIMARY |
static int | FlashOffset |
static int | FlashEnd |
static int | nandFlash = 0 |
static unsigned int | blockSize |
static unsigned int | pageSize |
#define BLOCK_ADDR | ( | offset, | |||
blocksize | ) | ((offset) & ~((blocksize) -1)) |
Definition at line 196 of file bootblocktool.c.
#define BLOCK_START | ( | offset, | |||
blocksize | ) | (((offset) & ((blocksize) -1)) == 0) |
#define D | ( | x | ) |
Definition at line 245 of file bootblocktool.c.
#define EMPTYMAGIC 0xffffffff |
*************************************************************************** ! ! FILE NAME : bootblocktool.c ! ! DESCRIPTION: Handles bootblock parameters ! ! --------------------------------------------------------------------------- ! (C) Copyright 2000-2007, Axis Communications AB, LUND, SWEDEN ! ! 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. ! --------------------------------------------------------------------------- ! HISTORY ! ! DATE NAME CHANGES ! ---- ---- ------- !
Definition at line 177 of file bootblocktool.c.
Referenced by listParams(), and readParam().
#define ERR_END_OF_PARAMS -2 |
Definition at line 185 of file bootblocktool.c.
Referenced by listParams(), readParam(), and readParamAt().
#define ERR_NO_MAGIC -3 |
#define ERR_OTHER -1 |
Definition at line 186 of file bootblocktool.c.
Referenced by readParam(), readParamAt(), writeMagic(), writeParam(), and writeParamAt().
#define MAX_PARAM_NAME_LEN 0xff |
#define MAX_RECORD_LEN 0xffff |
#define NAND_NOR_COMPATIBILITY_MODE (1) |
Definition at line 189 of file bootblocktool.c.
#define NO_ERROR 0 |
Definition at line 187 of file bootblocktool.c.
Referenced by main(), readParam(), writeMagic(), writeParam(), and writeParamAt().
#define PARAMMAGIC_BACKUP 0xdeadbabe |
#define PARAMMAGIC_PRIMARY 0xbeefcace |
#define ROUND_UP | ( | len, | |||
pagesize | ) | ((((len) - 1) & ~((pagesize) - 1)) + (pagesize)) |
Definition at line 192 of file bootblocktool.c.
Referenced by listParams(), readParam(), and writeParamAt().
enum Toutput_type |
static void die | ( | const char * | ) | [static] |
Definition at line 586 of file bootblocktool.c.
References exit, HTML_END, stderr, and useHTML.
Referenced by change_broadcast(), change_gateway(), change_ip(), change_netmask(), changeIP(), getChipParams(), listParams(), read_broadcast(), read_gateway(), read_ip(), read_netmask(), readParam(), skipBadBlocks(), xml_simple::stop_element(), and writeParam().
static int getChipParams | ( | void | ) | [static] |
Definition at line 1097 of file bootblocktool.c.
References blockSize, D, dev, die(), mtd_info_user::erasesize, fd, MEMGETINFO, MTD_NANDFLASH, nandFlash, mtd_info_user::oobblock, pageSize, and mtd_info_user::type.
Referenced by setFlashParams().
static void listParams | ( | Toutput_type | output_type | ) | [static] |
Definition at line 658 of file bootblocktool.c.
References BLOCK_START, blockSize, D, dev, die(), EMPTYMAGIC, ERR_END_OF_PARAMS, f, FlashEnd, FlashOffset, free(), NAMEVALUE, nandFlash, pageSize, PARAMMAGIC, read, readParamAt(), ROUND_UP, SCRIPT, SEEK_SET, skipBadBlocks(), and stderr.
Referenced by main().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 298 of file bootblocktool.c.
References D, dev, exitStat, free(), HTML_END, listParams(), method, name, NAMEVALUE, NO_ERROR, PARAMMAGIC, PARAMMAGIC_BACKUP, printUsage(), readParam(), SCRIPT, setExitErr, setFlashParams(), stderr, useHTML, value, and writeParam().
static void printUsage | ( | void | ) | [static] |
static int readParam | ( | const char * | name, | |
char ** | value, | |||
int * | firstfree | |||
) | [static] |
Definition at line 772 of file bootblocktool.c.
References BLOCK_START, blockSize, D, dev, die(), EMPTYMAGIC, ERR_END_OF_PARAMS, ERR_NO_MAGIC, ERR_OTHER, f, FlashOffset, free(), nandFlash, NO_ERROR, pageSize, PARAMMAGIC, read, readParamAt(), ROUND_UP, SEEK_SET, and skipBadBlocks().
Referenced by main(), and writeParam().
static int readParamAt | ( | int | f, | |
int | offset, | |||
char ** | name, | |||
int * | nameLen, | |||
char ** | value, | |||
int * | valueLen, | |||
int * | totlen | |||
) | [static] |
Definition at line 876 of file bootblocktool.c.
References buf, D, ERR_END_OF_PARAMS, ERR_OTHER, FlashEnd, free(), int, malloc(), read, and SEEK_SET.
Referenced by listParams(), and readParam().
static int setFlashParams | ( | void | ) | [static] |
Definition at line 1196 of file bootblocktool.c.
References fwinfo::bootblkpar_flash_addr, fwinfo::bootblkpar_flash_end, dev, FlashEnd, FlashOffset, getChipParams(), PARAMMAGIC, and PARAMMAGIC_PRIMARY.
Referenced by main().
static void skipBadBlocks | ( | int | fd, | |
int * | offset | |||
) | [static] |
Definition at line 1155 of file bootblocktool.c.
References blockSize, die(), FlashEnd, and MEMGETBADBLOCK.
Referenced by listParams(), and readParam().
static int writeMagic | ( | int | file, | |
int * | offset | |||
) | [static] |
static int writeParam | ( | const char * | name, | |
const char * | value | |||
) | [static] |
Definition at line 604 of file bootblocktool.c.
References D, dev, die(), ERR_NO_MAGIC, ERR_OTHER, f, MAX_PARAM_NAME_LEN, NO_ERROR, readParam(), writeMagic(), and writeParamAt().
Referenced by main().
static int writeParamAt | ( | int | f, | |
int | offset, | |||
const char * | name, | |||
const char * | value | |||
) | [static] |
unsigned int blockSize [static] |
Definition at line 292 of file bootblocktool.c.
Referenced by getChipParams(), listParams(), readParam(), skipBadBlocks(), and writeParamAt().
const char* dev = "/dev/part/rescue" [static] |
Definition at line 198 of file bootblocktool.c.
Referenced by checkSclSda(), fpga_read(), fpga_write(), getChipParams(), i2c_ctl(), i2c_getCMOSClock(), i2c_read256b(), i2c_receive(), i2c_send(), i2c_setCMOSClock(), i2c_write256b(), i2cread16(), listParams(), main(), net_init(), read_fpga_reg(), readParam(), receive347(), receive_i2c(), receive_i2c_4(), receive_i2c_n(), send347(), send_i2c(), send_i2c_4(), send_i2c_4_nc(), send_i2c_4a(), sendi2c16(), senspars_read(), senspars_write(), seq_receive(), setFlashParams(), smbus_send(), snd_func_pcm_args_by_class(), and writeParam().
int exitStat = 0 [static] |
int FlashEnd [static] |
Definition at line 288 of file bootblocktool.c.
Referenced by listParams(), readParamAt(), setFlashParams(), skipBadBlocks(), and writeParamAt().
int FlashOffset [static] |
Definition at line 287 of file bootblocktool.c.
Referenced by listParams(), readParam(), and setFlashParams().
const char HTML_END[] = " " |
int nandFlash = 0 [static] |
Definition at line 290 of file bootblocktool.c.
Referenced by getChipParams(), listParams(), readParam(), writeMagic(), and writeParamAt().
unsigned int pageSize [static] |
Definition at line 293 of file bootblocktool.c.
Referenced by getChipParams(), listParams(), readParam(), writeMagic(), and writeParamAt().
int PARAMMAGIC = PARAMMAGIC_PRIMARY [static] |
Definition at line 285 of file bootblocktool.c.
Referenced by listParams(), main(), readParam(), setFlashParams(), and writeMagic().
int setExitErr = 0 [static] |
const char usage[] |
Initial value:
"Usage: bootblocktool [options] command\n" "Options:\n" " -backup Makes all subsequent parameters pertain to the backup block\n" " -nocgi Disable CGI detection\n" " -d device The device to use\n" " -err Set exit status != 0 on parameter errors\n" "Commands:\n" " -x name1 name2 ... ; get\n" " -c name:name2:name3 ; get/check\n" " -a name1 value1 name2 value2 ... ; set\n" " -w name=value:name2=value2 ; set\n" " -l ; list parameters\n" " -lenv ; list parameters in setenv format\n"
Definition at line 200 of file bootblocktool.c.
int useHTML = 0 [static] |