dump: Prepair for new code
This commit is contained in:
1 parent
bc9441ddd6
commit
34b55a222e
2 files changed
+44
-14
No files matched your search
+16
-14
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
||||||
|
* Copyright (C) 2012 Pali Rohár <pali.rohar@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,12 +17,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include "hexdump.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "dump.h"
|
||||||
|
#include "hexdump.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extracts a piece from an mtd device
|
* Extracts a piece from an mtd device
|
||||||
* -----------------------------------
|
* -----------------------------------
|
||||||
@@ -29,7 +31,7 @@
|
|||||||
* badblocks and oob data. It is replaced by nanddump(), but will
|
* badblocks and oob data. It is replaced by nanddump(), but will
|
||||||
* probably be fixed in the future or it will die.
|
* probably be fixed in the future or it will die.
|
||||||
*/
|
*/
|
||||||
int rf_extract(char *dev, off_t from, off_t to, char *file)
|
/*int rf_extract(char *dev, off_t from, off_t to, char *file)
|
||||||
{
|
{
|
||||||
off_t i, blk = 0xfffff;
|
off_t i, blk = 0xfffff;
|
||||||
char buf[0xfffff];
|
char buf[0xfffff];
|
||||||
@@ -63,7 +65,7 @@ __rf_extract_exit:
|
|||||||
if (fd) fclose(fd);
|
if (fd) fclose(fd);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function was covardly copied from nanddump.c @ mtd-utils-20060907
|
* This function was covardly copied from nanddump.c @ mtd-utils-20060907
|
||||||
@@ -94,7 +96,7 @@ __rf_extract_exit:
|
|||||||
#define M_OMITBAD 0x00000011
|
#define M_OMITBAD 0x00000011
|
||||||
#define M_OMITECC 0x00000012
|
#define M_OMITECC 0x00000012
|
||||||
|
|
||||||
int mtd_open(char *file, mtd_info_t *meminfo, int *oobinfochanged,
|
static int mtd_open(char *file, mtd_info_t *meminfo, int *oobinfochanged,
|
||||||
struct nand_oobinfo *old_oobinfo, int *eccstats, int flags)
|
struct nand_oobinfo *old_oobinfo, int *eccstats, int flags)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@@ -124,7 +126,7 @@ int mtd_open(char *file, mtd_info_t *meminfo, int *oobinfochanged,
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtd_close(int fd, struct nand_oobinfo *old_oobinfo, int oobinfochanged)
|
static int mtd_close(int fd, struct nand_oobinfo *old_oobinfo, int oobinfochanged)
|
||||||
{
|
{
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -235,8 +237,8 @@ int check_badblocks(char *mtddev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write out OOB data */
|
/* Write out OOB data */
|
||||||
if (badblock)
|
// if (badblock)
|
||||||
D dump_bytes(oobbuf, meminfo.oobsize);
|
// D dump_bytes(oobbuf, meminfo.oobsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtd_close(fd, &old_oobinfo, oobinfochanged);
|
mtd_close(fd, &old_oobinfo, oobinfochanged);
|
||||||
@@ -406,7 +408,7 @@ int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write out OOB data */
|
/* Write out OOB data */
|
||||||
D dump_bytes(oobbuf, meminfo.oobsize);
|
// D dump_bytes(oobbuf, meminfo.oobsize);
|
||||||
write(ofd, oobbuf, meminfo.oobsize);
|
write(ofd, oobbuf, meminfo.oobsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +423,7 @@ int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rf_strip(char *file)
|
static int rf_strip(char *file)
|
||||||
{
|
{
|
||||||
FILE *fd = fopen(file, "rw");
|
FILE *fd = fopen(file, "rw");
|
||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
@@ -457,7 +459,7 @@ __done:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_n900()
|
static int is_n900(void)
|
||||||
{
|
{
|
||||||
int n900 = 0;
|
int n900 = 0;
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
@@ -473,7 +475,7 @@ static int is_n900()
|
|||||||
return n900;
|
return n900;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_n800()
|
static int is_n800(void)
|
||||||
{
|
{
|
||||||
int n800 = 0;
|
int n800 = 0;
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
@@ -489,7 +491,7 @@ static int is_n800()
|
|||||||
return n800;
|
return n800;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dump_config()
|
int dump_config(void)
|
||||||
{
|
{
|
||||||
mtd_info_t meminfo;
|
mtd_info_t meminfo;
|
||||||
int fd = open("/dev/mtd1", O_RDONLY);
|
int fd = open("/dev/mtd1", O_RDONLY);
|
||||||
@@ -556,7 +558,7 @@ int dump_config()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reverse_extract_pieces_n900(char *dir)
|
static int reverse_extract_pieces_n900(char *dir)
|
||||||
{
|
{
|
||||||
char reply;
|
char reply;
|
||||||
chdir(dir);
|
chdir(dir);
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
|
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
||||||
|
* Copyright (C) 2012 Pali Rohár <pali.rohar@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DUMP_H
|
||||||
|
#define DUMP_H
|
||||||
|
|
||||||
|
int check_badblocks(char *mtddev);
|
||||||
|
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob);
|
||||||
|
int dump_config(void);
|
||||||
|
int reverse_extract_pieces(char *dir);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in new issue
Block a user