#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 193 of file bootblocktool.c.
#define BLOCK_START | ( | offset, | |||
blocksize | ) | (((offset) & ((blocksize) -1)) == 0) |
#define D | ( | x | ) |
Definition at line 242 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 174 of file bootblocktool.c.
Referenced by listParams(), and readParam().
#define ERR_END_OF_PARAMS -2 |
Definition at line 182 of file bootblocktool.c.
Referenced by listParams(), readParam(), and readParamAt().
#define ERR_NO_MAGIC -3 |
#define ERR_OTHER -1 |
Definition at line 183 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 186 of file bootblocktool.c.
#define NO_ERROR 0 |
Definition at line 184 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 189 of file bootblocktool.c.
Referenced by listParams(), readParam(), and writeParamAt().
enum Toutput_type |
static void die | ( | const char * | ) | [static] |
Definition at line 583 of file bootblocktool.c.
References 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(), and writeParam().
static int getChipParams | ( | void | ) | [static] |
Definition at line 1094 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 655 of file bootblocktool.c.
References BLOCK_START, blockSize, D, dev, die(), EMPTYMAGIC, ERR_END_OF_PARAMS, FlashEnd, FlashOffset, free(), NAMEVALUE, nandFlash, pageSize, PARAMMAGIC, read, readParamAt(), ROUND_UP, SCRIPT, skipBadBlocks(), and stderr.
Referenced by main().
Definition at line 295 of file bootblocktool.c.
References D, dev, exitStat, free(), HTML_END, listParams(), method, NAMEVALUE, NO_ERROR, PARAMMAGIC, PARAMMAGIC_BACKUP, printUsage(), readParam(), SCRIPT, setExitErr, setFlashParams(), stderr, useHTML, and writeParam().
static void printUsage | ( | void | ) | [static] |
Definition at line 769 of file bootblocktool.c.
References BLOCK_START, blockSize, D, dev, die(), EMPTYMAGIC, ERR_END_OF_PARAMS, ERR_NO_MAGIC, ERR_OTHER, FlashOffset, free(), nandFlash, NO_ERROR, pageSize, PARAMMAGIC, read, readParamAt(), ROUND_UP, 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 873 of file bootblocktool.c.
References buf, D, ERR_END_OF_PARAMS, ERR_OTHER, FlashEnd, free(), int, malloc(), and read.
Referenced by listParams(), and readParam().
static int setFlashParams | ( | void | ) | [static] |
Definition at line 1193 of file bootblocktool.c.
References fwinfo::bootblkpar_flash_addr, fwinfo::bootblkpar_flash_end, dev, FlashEnd, FlashOffset, getChipParams(), PARAMMAGIC, and PARAMMAGIC_PRIMARY.
Referenced by main().
Definition at line 1152 of file bootblocktool.c.
References blockSize, die(), FlashEnd, and MEMGETBADBLOCK.
Referenced by listParams(), and readParam().
static int writeParam | ( | const char * | name, | |
const char * | value | |||
) | [static] |
Definition at line 601 of file bootblocktool.c.
References D, dev, die(), ERR_NO_MAGIC, ERR_OTHER, MAX_PARAM_NAME_LEN, NO_ERROR, readParam(), writeMagic(), and writeParamAt().
Referenced by main().
Definition at line 289 of file bootblocktool.c.
Referenced by getChipParams(), listParams(), readParam(), skipBadBlocks(), and writeParamAt().
const char* dev = "/dev/part/rescue" [static] |
Definition at line 195 of file bootblocktool.c.
Referenced by checkSclSda(), fpga_read(), fpga_write(), getChipParams(), i2c_ctl(), i2c_getCMOSClock(), i2c_read256b(), i2c_readCMOSClock(), 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(), setupCamera(), smbus_send(), and writeParam().
Definition at line 285 of file bootblocktool.c.
Referenced by listParams(), readParamAt(), setFlashParams(), skipBadBlocks(), and writeParamAt().
int FlashOffset [static] |
Definition at line 284 of file bootblocktool.c.
Referenced by listParams(), readParam(), and setFlashParams().
const char HTML_END[] = " " |
Definition at line 287 of file bootblocktool.c.
Referenced by getChipParams(), listParams(), readParam(), writeMagic(), and writeParamAt().
Definition at line 290 of file bootblocktool.c.
Referenced by getChipParams(), listParams(), readParam(), writeMagic(), and writeParamAt().
int PARAMMAGIC = PARAMMAGIC_PRIMARY [static] |
Definition at line 282 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 197 of file bootblocktool.c.