Merge branch 'master' into next
Conflicts: drivers/ata/disk_drive.c Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
commit
e0f4fb2c98
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
VERSION = 2011
|
VERSION = 2011
|
||||||
PATCHLEVEL = 10
|
PATCHLEVEL = 11
|
||||||
SUBLEVEL = 0
|
SUBLEVEL = 0
|
||||||
EXTRAVERSION =
|
EXTRAVERSION =
|
||||||
NAME = Amissive Actinocutious Kiwi
|
NAME = Amissive Actinocutious Kiwi
|
||||||
|
|
|
@ -103,8 +103,6 @@ static int loco_devices_init(void)
|
||||||
armlinux_set_bootparams((void *)0x70000100);
|
armlinux_set_bootparams((void *)0x70000100);
|
||||||
armlinux_set_architecture(MACH_TYPE_MX53_LOCO);
|
armlinux_set_architecture(MACH_TYPE_MX53_LOCO);
|
||||||
|
|
||||||
loco_fec_reset();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,13 +61,14 @@
|
||||||
* Twrph1 = 1 (-> 20ns)
|
* Twrph1 = 1 (-> 20ns)
|
||||||
* Cycle time = 80ns
|
* Cycle time = 80ns
|
||||||
*/
|
*/
|
||||||
#define A9M2440_TACLS 1
|
#define MINI2440_TACLS 1
|
||||||
#define A9M2440_TWRPH0 3
|
#define MINI2440_TWRPH0 3
|
||||||
#define A9M2440_TWRPH1 1
|
#define MINI2440_TWRPH1 1
|
||||||
|
|
||||||
/* needed in the generic NAND boot code only */
|
/* needed in the generic NAND boot code only */
|
||||||
#ifdef CONFIG_S3C24XX_NAND_BOOT
|
#ifdef CONFIG_S3C24XX_NAND_BOOT
|
||||||
# define BOARD_DEFAULT_NAND_TIMING CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1)
|
# define BOARD_DEFAULT_NAND_TIMING \
|
||||||
|
CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0, MINI2440_TWRPH1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
#include <mach/fb.h>
|
#include <mach/fb.h>
|
||||||
|
|
||||||
static struct s3c24x0_nand_platform_data nand_info = {
|
static struct s3c24x0_nand_platform_data nand_info = {
|
||||||
.nand_timing = CALC_NFCONF_TIMING(A9M2440_TACLS, A9M2440_TWRPH0, A9M2440_TWRPH1),
|
.nand_timing = CALC_NFCONF_TIMING(MINI2440_TACLS, MINI2440_TWRPH0,
|
||||||
|
MINI2440_TWRPH1),
|
||||||
.flash_bbt = 1, /* same as the kernel */
|
.flash_bbt = 1, /* same as the kernel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
CONFIG_ARCH_IMX=y
|
CONFIG_ARCH_IMX=y
|
||||||
CONFIG_CACHE_L2X0=y
|
CONFIG_CACHE_L2X0=y
|
||||||
|
CONFIG_ARCH_IMX_EXTERNAL_BOOT=y
|
||||||
CONFIG_ARCH_IMX35=y
|
CONFIG_ARCH_IMX35=y
|
||||||
CONFIG_MACH_PCM043=y
|
CONFIG_MACH_PCM043=y
|
||||||
CONFIG_IMX_CLKO=y
|
CONFIG_IMX_CLKO=y
|
||||||
|
|
|
@ -95,7 +95,7 @@ void imx_nand_set_layout(int writesize, int datawidth)
|
||||||
FMCR = fmcr;
|
FMCR = fmcr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined CONFIG_ARCH_IMX51
|
#elif defined CONFIG_ARCH_IMX51 || defined CONFIG_ARCH_IMX53
|
||||||
|
|
||||||
void imx_nand_set_layout(int writesize, int datawidth)
|
void imx_nand_set_layout(int writesize, int datawidth)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef _ASM_NIOS_UNALIGNED_H
|
||||||
|
#define _ASM_NIOS_UNALIGNED_H
|
||||||
|
|
||||||
|
#include <linux/unaligned/le_byteshift.h>
|
||||||
|
#include <linux/unaligned/be_byteshift.h>
|
||||||
|
#include <linux/unaligned/generic.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Select endianness
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define get_unaligned __get_unaligned_le
|
||||||
|
#define put_unaligned __put_unaligned_le
|
||||||
|
|
||||||
|
#endif /* _ASM_NIOS_UNALIGNED_H */
|
|
@ -44,6 +44,7 @@ protected_mode_jump:
|
||||||
|
|
||||||
/* Transition to 32-bit flat mode */
|
/* Transition to 32-bit flat mode */
|
||||||
data32 ljmp $__BOOT_CS, $in_pm32
|
data32 ljmp $__BOOT_CS, $in_pm32
|
||||||
|
.size protected_mode_jump, .-protected_mode_jump
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
@ -83,5 +84,5 @@ in_pm32:
|
||||||
|
|
||||||
jmp uboot_entry
|
jmp uboot_entry
|
||||||
|
|
||||||
.size protected_mode_jump, .-protected_mode_jump
|
.size in_pm32, .-in_pm32
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ typedef unsigned short u16;
|
||||||
|
|
||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
|
|
||||||
|
typedef unsigned long long u64;
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
#endif /* __ASM_X86_TYPES_H */
|
#endif /* __ASM_X86_TYPES_H */
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef _ASM_X86_UNALIGNED_H
|
||||||
|
#define _ASM_X86_UNALIGNED_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The x86 can do unaligned accesses itself.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/unaligned/access_ok.h>
|
||||||
|
#include <linux/unaligned/generic.h>
|
||||||
|
|
||||||
|
#define get_unaligned __get_unaligned_le
|
||||||
|
#define put_unaligned __put_unaligned_le
|
||||||
|
|
||||||
|
#endif /* _ASM_X86_UNALIGNED_H */
|
|
@ -72,6 +72,7 @@ real_to_prot:
|
||||||
|
|
||||||
/* jump to relocation, flush prefetch queue, and reload %cs */
|
/* jump to relocation, flush prefetch queue, and reload %cs */
|
||||||
DATA32 ljmp $__BOOT_CS, $return_to_flatmode
|
DATA32 ljmp $__BOOT_CS, $return_to_flatmode
|
||||||
|
.size real_to_prot, .-real_to_prot
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
.section .boot.text.return_to_flatmode, "ax"
|
.section .boot.text.return_to_flatmode, "ax"
|
||||||
|
@ -102,8 +103,7 @@ return_to_flatmode:
|
||||||
/* flag we returned happy here */
|
/* flag we returned happy here */
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
ret
|
ret
|
||||||
|
.size return_to_flatmode, .-return_to_flatmode
|
||||||
.size real_to_prot, .-real_to_prot
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
@ -140,13 +140,16 @@ prot_to_real:
|
||||||
|
|
||||||
/* at last, also limit the code segment to 16 bit */
|
/* at last, also limit the code segment to 16 bit */
|
||||||
ljmp $__REAL_CS, $return_to_realmode
|
ljmp $__REAL_CS, $return_to_realmode
|
||||||
|
.size prot_to_real, .-prot_to_real
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
.section .boot.text.return_to_realmode, "ax"
|
.section .boot.text.return_to_realmode, "ax"
|
||||||
return_to_realmode:
|
.globl return_to_realmode
|
||||||
|
.type return_to_realmode, @function
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
|
return_to_realmode:
|
||||||
/* disable protected mode */
|
/* disable protected mode */
|
||||||
movl %cr0, %eax
|
movl %cr0, %eax
|
||||||
andl $(~0x00000001), %eax
|
andl $(~0x00000001), %eax
|
||||||
|
@ -176,5 +179,5 @@ enter_realmode:
|
||||||
/* return on realmode stack! */
|
/* return on realmode stack! */
|
||||||
DATA32 ret
|
DATA32 ret
|
||||||
|
|
||||||
.size prot_to_real, .-prot_to_real
|
.size return_to_realmode, .-return_to_realmode
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,13 @@ static int do_mkdir(struct command *cmdtp, int argc, char *argv[])
|
||||||
return COMMAND_ERROR_USAGE;
|
return COMMAND_ERROR_USAGE;
|
||||||
|
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
if (parent)
|
if (parent) {
|
||||||
ret = make_directory(argv[optind]);
|
ret = make_directory(argv[optind]);
|
||||||
else
|
if (ret == -EEXIST)
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
ret = mkdir(argv[optind], 0);
|
ret = mkdir(argv[optind], 0);
|
||||||
|
}
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("could not create %s: %s\n", argv[optind], errno_str());
|
printf("could not create %s: %s\n", argv[optind], errno_str());
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -40,7 +40,7 @@ static int do_mount(struct command *cmdtp, int argc, char *argv[])
|
||||||
entry = mtab_next_entry(entry);
|
entry = mtab_next_entry(entry);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
printf("%s on %s type %s\n",
|
printf("%s on %s type %s\n",
|
||||||
entry->parent_device ? entry->parent_device->name : "none",
|
entry->parent_device ? dev_name(entry->parent_device) : "none",
|
||||||
entry->path,
|
entry->path,
|
||||||
entry->dev->name);
|
entry->dev->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,27 +292,32 @@ int fputc(int fd, char c)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(fputc);
|
EXPORT_SYMBOL(fputc);
|
||||||
|
|
||||||
void console_puts(unsigned int ch, const char *str)
|
int console_puts(unsigned int ch, const char *str)
|
||||||
{
|
{
|
||||||
const char *s = str;
|
const char *s = str;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
while (*s) {
|
while (*s) {
|
||||||
if (*s == '\n')
|
if (*s == '\n') {
|
||||||
console_putc(ch, '\r');
|
console_putc(ch, '\r');
|
||||||
|
n++;
|
||||||
|
}
|
||||||
console_putc(ch, *s);
|
console_putc(ch, *s);
|
||||||
|
n++;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(console_puts);
|
EXPORT_SYMBOL(console_puts);
|
||||||
|
|
||||||
int fputs(int fd, const char *s)
|
int fputs(int fd, const char *s)
|
||||||
{
|
{
|
||||||
if (fd == 1)
|
if (fd == 1)
|
||||||
puts(s);
|
return puts(s);
|
||||||
else if (fd == 2)
|
else if (fd == 2)
|
||||||
eputs(s);
|
return eputs(s);
|
||||||
else
|
else
|
||||||
return write(fd, s, strlen(s));
|
return write(fd, s, strlen(s));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(fputs);
|
EXPORT_SYMBOL(fputs);
|
||||||
|
|
||||||
|
@ -327,7 +332,7 @@ void console_flush(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(console_flush);
|
EXPORT_SYMBOL(console_flush);
|
||||||
|
|
||||||
void fprintf (int file, const char *fmt, ...)
|
int fprintf(int file, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
uint i;
|
uint i;
|
||||||
|
@ -342,7 +347,7 @@ void fprintf (int file, const char *fmt, ...)
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
/* Print the string */
|
/* Print the string */
|
||||||
fputs (file, printbuffer);
|
return fputs(file, printbuffer);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(fprintf);
|
EXPORT_SYMBOL(fprintf);
|
||||||
|
|
||||||
|
|
|
@ -247,8 +247,7 @@ int export(const char *varname)
|
||||||
if (val) {
|
if (val) {
|
||||||
setenv_raw(context->global, varname, val);
|
setenv_raw(context->global, varname, val);
|
||||||
setenv_raw(context->local, varname, NULL);
|
setenv_raw(context->local, varname, NULL);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(export);
|
EXPORT_SYMBOL(export);
|
||||||
|
|
|
@ -42,13 +42,12 @@ int password(unsigned char *passwd, size_t length, int flags, int timeout)
|
||||||
unsigned char *buf = passwd;
|
unsigned char *buf = passwd;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
uint64_t start, second;
|
uint64_t start;
|
||||||
|
|
||||||
if (!passwd)
|
if (!passwd)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
start = get_time_ns();
|
start = get_time_ns();
|
||||||
second = start;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (tstc()) {
|
if (tstc()) {
|
||||||
|
|
|
@ -778,10 +778,12 @@ static int m25p_probe(struct device_d *dev)
|
||||||
m25p80_ops.write = m25p80_write;
|
m25p80_ops.write = m25p80_write;
|
||||||
|
|
||||||
/* prefer "small sector" erase if possible */
|
/* prefer "small sector" erase if possible */
|
||||||
if (info->flags & SECT_4K)
|
if (info->flags & SECT_4K) {
|
||||||
flash->erase_opcode = OPCODE_BE_4K;
|
flash->erase_opcode = OPCODE_BE_4K;
|
||||||
else
|
flash->erasesize = 4096;
|
||||||
|
} else {
|
||||||
flash->erase_opcode = OPCODE_SE;
|
flash->erase_opcode = OPCODE_SE;
|
||||||
|
}
|
||||||
|
|
||||||
flash->page_size = info->page_size;
|
flash->page_size = info->page_size;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ static int s3c24x0_serial_init_port(struct console_device *cdev)
|
||||||
writew(0x0245, base + UCON);
|
writew(0x0245, base + UCON);
|
||||||
|
|
||||||
#ifdef CONFIG_DRIVER_SERIAL_S3C24X0_AUTOSYNC
|
#ifdef CONFIG_DRIVER_SERIAL_S3C24X0_AUTOSYNC
|
||||||
|
writeb(0x10, base + UMCON); /* enable auto flow control */
|
||||||
|
#else
|
||||||
writeb(0x01, base + UMCON); /* RTS up */
|
writeb(0x01, base + UMCON); /* RTS up */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
|
||||||
struct spi_transfer *t = NULL;
|
struct spi_transfer *t = NULL;
|
||||||
unsigned int bits = spi->bits_per_word;
|
unsigned int bits = spi->bits_per_word;
|
||||||
|
|
||||||
|
mesg->actual_length = 0;
|
||||||
ret = master->setup(spi);
|
ret = master->setup(spi);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_dbg(master->dev, "transfer: master setup failed\n");
|
dev_dbg(master->dev, "transfer: master setup failed\n");
|
||||||
|
@ -210,6 +211,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
|
||||||
u32 tx_val;
|
u32 tx_val;
|
||||||
int i = 0, rx_val;
|
int i = 0, rx_val;
|
||||||
|
|
||||||
|
mesg->actual_length += t->len;
|
||||||
if (bits <= 8) {
|
if (bits <= 8) {
|
||||||
const u8 *txbuf = t->tx_buf;
|
const u8 *txbuf = t->tx_buf;
|
||||||
u8 *rxbuf = t->rx_buf;
|
u8 *rxbuf = t->rx_buf;
|
||||||
|
|
|
@ -7,3 +7,7 @@ config USB_EHCI_OMAP
|
||||||
|
|
||||||
config USB_OHCI
|
config USB_OHCI
|
||||||
bool "OHCI driver"
|
bool "OHCI driver"
|
||||||
|
|
||||||
|
config USB_OHCI_AT91
|
||||||
|
depends on ARCH_AT91
|
||||||
|
bool "AT91 OHCI driver"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
obj-$(CONFIG_USB_EHCI) += ehci-hcd.o
|
obj-$(CONFIG_USB_EHCI) += ehci-hcd.o
|
||||||
obj-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
|
obj-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
|
||||||
obj-$(CONFIG_USB_OHCI) += ohci-hcd.o
|
obj-$(CONFIG_USB_OHCI) += ohci-hcd.o
|
||||||
obj-$(CONFIG_ARCH_AT91) += ohci-at91.o
|
obj-$(CONFIG_USB_OHCI_AT91) += ohci-at91.o
|
||||||
|
|
|
@ -714,7 +714,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||||
goto unknown;
|
goto unknown;
|
||||||
}
|
}
|
||||||
/* unblock posted writes */
|
/* unblock posted writes */
|
||||||
ehci_readl(&ehci->hcor->or_usbcmd);
|
(void) ehci_readl(&ehci->hcor->or_usbcmd);
|
||||||
break;
|
break;
|
||||||
case USB_REQ_CLEAR_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8):
|
case USB_REQ_CLEAR_FEATURE | ((USB_DIR_OUT | USB_RT_PORT) << 8):
|
||||||
reg = ehci_readl(status_reg);
|
reg = ehci_readl(status_reg);
|
||||||
|
@ -743,7 +743,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||||
}
|
}
|
||||||
ehci_writel(status_reg, reg);
|
ehci_writel(status_reg, reg);
|
||||||
/* unblock posted write */
|
/* unblock posted write */
|
||||||
ehci_readl(&ehci->hcor->or_usbcmd);
|
(void) ehci_readl(&ehci->hcor->or_usbcmd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug("Unknown request\n");
|
debug("Unknown request\n");
|
||||||
|
|
|
@ -354,6 +354,8 @@ static int fat_stat(struct device_d *dev, const char *filename, struct stat *s)
|
||||||
FILINFO finfo;
|
FILINFO finfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
memset(&finfo, 0, sizeof(FILINFO));
|
||||||
|
|
||||||
ret = f_stat(&priv->fat, filename, &finfo);
|
ret = f_stat(&priv->fat, filename, &finfo);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
7
fs/fs.c
7
fs/fs.c
|
@ -743,6 +743,7 @@ int mount(const char *device, const char *fsname, const char *_path)
|
||||||
struct mtab_entry *entry;
|
struct mtab_entry *entry;
|
||||||
struct fs_device_d *fsdev;
|
struct fs_device_d *fsdev;
|
||||||
struct device_d *dev, *parent_device = NULL;
|
struct device_d *dev, *parent_device = NULL;
|
||||||
|
struct cdev *cdev = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
char *path = normalise_path(_path);
|
char *path = normalise_path(_path);
|
||||||
|
|
||||||
|
@ -808,6 +809,12 @@ int mount(const char *device, const char *fsname, const char *_path)
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strncmp(device, "/dev/", 5)) {
|
||||||
|
cdev = cdev_by_name(device + 5);
|
||||||
|
if(cdev)
|
||||||
|
parent_device = cdev->dev;
|
||||||
|
}
|
||||||
|
|
||||||
if (parent_device)
|
if (parent_device)
|
||||||
dev_add_child(parent_device, &fsdev->dev);
|
dev_add_child(parent_device, &fsdev->dev);
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ int tstc(void);
|
||||||
/* stdout */
|
/* stdout */
|
||||||
void console_putc(unsigned int ch, const char c);
|
void console_putc(unsigned int ch, const char c);
|
||||||
int getc(void);
|
int getc(void);
|
||||||
void console_puts(unsigned int ch, const char *s);
|
int console_puts(unsigned int ch, const char *s);
|
||||||
void console_flush(void);
|
void console_flush(void);
|
||||||
|
|
||||||
static inline void puts(const char *s)
|
static inline int puts(const char *s)
|
||||||
{
|
{
|
||||||
console_puts(CONSOLE_STDOUT, s);
|
return console_puts(CONSOLE_STDOUT, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void putchar(char c)
|
static inline void putchar(char c)
|
||||||
|
@ -54,7 +54,7 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
||||||
#define stderr 2
|
#define stderr 2
|
||||||
#define MAX_FILES 128
|
#define MAX_FILES 128
|
||||||
|
|
||||||
void fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
int fprintf(int file, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3)));
|
||||||
int fputs(int file, const char *s);
|
int fputs(int file, const char *s);
|
||||||
int fputc(int file, const char c);
|
int fputc(int file, const char c);
|
||||||
int ftstc(int file);
|
int ftstc(int file);
|
||||||
|
|
|
@ -46,14 +46,25 @@ static const unsigned char lzop_magic[] = {
|
||||||
|
|
||||||
#define LZO_BLOCK_SIZE (256*1024l)
|
#define LZO_BLOCK_SIZE (256*1024l)
|
||||||
#define HEADER_HAS_FILTER 0x00000800L
|
#define HEADER_HAS_FILTER 0x00000800L
|
||||||
|
#define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4)
|
||||||
|
#define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4)
|
||||||
|
|
||||||
static inline int parse_header(u8 *input, u8 *skip)
|
static inline int parse_header(u8 *input, int *skip, int in_len)
|
||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
u8 *parse = input;
|
u8 *parse = input;
|
||||||
|
u8 *end = input + in_len;
|
||||||
u8 level = 0;
|
u8 level = 0;
|
||||||
u16 version;
|
u16 version;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check that there's enough input to possibly have a valid header.
|
||||||
|
* Then it is possible to parse several fields until the minimum
|
||||||
|
* size may have been used.
|
||||||
|
*/
|
||||||
|
if (in_len < HEADER_SIZE_MIN)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* read magic: 9 first bits */
|
/* read magic: 9 first bits */
|
||||||
for (l = 0; l < 9; l++) {
|
for (l = 0; l < 9; l++) {
|
||||||
if (*parse++ != lzop_magic[l])
|
if (*parse++ != lzop_magic[l])
|
||||||
|
@ -71,6 +82,15 @@ static inline int parse_header(u8 *input, u8 *skip)
|
||||||
else
|
else
|
||||||
parse += 4; /* flags */
|
parse += 4; /* flags */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At least mode, mtime_low, filename length, and checksum must
|
||||||
|
* be left to be parsed. If also mtime_high is present, it's OK
|
||||||
|
* because the next input buffer check is after reading the
|
||||||
|
* filename length.
|
||||||
|
*/
|
||||||
|
if (end - parse < 8 + 1 + 4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* skip mode and mtime_low */
|
/* skip mode and mtime_low */
|
||||||
parse += 8;
|
parse += 8;
|
||||||
if (version >= 0x0940)
|
if (version >= 0x0940)
|
||||||
|
@ -78,108 +98,191 @@ static inline int parse_header(u8 *input, u8 *skip)
|
||||||
|
|
||||||
l = *parse++;
|
l = *parse++;
|
||||||
/* don't care about the file name, and skip checksum */
|
/* don't care about the file name, and skip checksum */
|
||||||
|
if (end - parse < l + 4)
|
||||||
|
return 0;
|
||||||
parse += l + 4;
|
parse += l + 4;
|
||||||
|
|
||||||
*skip = parse - input;
|
*skip = parse - input;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __unlzo(int *dest_len,
|
static inline int __unlzo(u8 *input, int in_len,
|
||||||
int (*fill) (void *, unsigned int),
|
int (*fill) (void *, unsigned int),
|
||||||
int (*flush) (void *, unsigned int))
|
int (*flush) (void *, unsigned int),
|
||||||
|
u8 *output, int *posp,
|
||||||
|
void (*error) (char *x))
|
||||||
{
|
{
|
||||||
u8 skip = 0, r = 0;
|
u8 r = 0;
|
||||||
|
int skip = 0;
|
||||||
u32 src_len, dst_len;
|
u32 src_len, dst_len;
|
||||||
size_t tmp;
|
size_t tmp;
|
||||||
u8 *in_buf, *in_buf_save, *out_buf, *out_buf_save;
|
u8 *in_buf, *in_buf_save, *out_buf;
|
||||||
int obytes_processed = 0;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
out_buf = xmalloc(LZO_BLOCK_SIZE);
|
if (output) {
|
||||||
in_buf = xmalloc(lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
out_buf = output;
|
||||||
|
} else if (!flush) {
|
||||||
|
error("NULL output pointer and no flush function provided");
|
||||||
|
goto exit;
|
||||||
|
} else {
|
||||||
|
out_buf = malloc(LZO_BLOCK_SIZE);
|
||||||
|
if (!out_buf) {
|
||||||
|
error("Could not allocate output buffer");
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input && fill) {
|
||||||
|
error("Both input pointer and fill function provided, don't know what to do");
|
||||||
|
goto exit_1;
|
||||||
|
} else if (input) {
|
||||||
|
in_buf = input;
|
||||||
|
} else if (!fill) {
|
||||||
|
error("NULL input pointer and missing fill function");
|
||||||
|
goto exit_1;
|
||||||
|
} else {
|
||||||
|
in_buf = malloc(lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
||||||
|
if (!in_buf) {
|
||||||
|
error("Could not allocate input buffer");
|
||||||
|
goto exit_1;
|
||||||
|
}
|
||||||
|
}
|
||||||
in_buf_save = in_buf;
|
in_buf_save = in_buf;
|
||||||
out_buf_save = out_buf;
|
|
||||||
|
|
||||||
ret = fill(in_buf, lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
if (posp)
|
||||||
if (ret < 0)
|
*posp = 0;
|
||||||
goto exit_free;
|
|
||||||
|
|
||||||
if (!parse_header(in_buf, &skip))
|
if (fill) {
|
||||||
return -EINVAL;
|
/*
|
||||||
|
* Start from in_buf + HEADER_SIZE_MAX to make it possible
|
||||||
|
* to use memcpy() to copy the unused data to the beginning
|
||||||
|
* of the buffer. This way memmove() isn't needed which
|
||||||
|
* is missing from pre-boot environments of most archs.
|
||||||
|
*/
|
||||||
|
in_buf += HEADER_SIZE_MAX;
|
||||||
|
in_len = fill(in_buf, HEADER_SIZE_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parse_header(in_buf, &skip, in_len)) {
|
||||||
|
error("invalid header");
|
||||||
|
goto exit_2;
|
||||||
|
}
|
||||||
in_buf += skip;
|
in_buf += skip;
|
||||||
|
in_len -= skip;
|
||||||
|
|
||||||
|
if (fill) {
|
||||||
|
/* Move the unused data to the beginning of the buffer. */
|
||||||
|
memcpy(in_buf_save, in_buf, in_len);
|
||||||
|
in_buf = in_buf_save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (posp)
|
||||||
|
*posp = skip;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* read uncompressed block size */
|
/* read uncompressed block size */
|
||||||
|
if (fill && in_len < 4) {
|
||||||
|
skip = fill(in_buf + in_len, 4 - in_len);
|
||||||
|
if (skip > 0)
|
||||||
|
in_len += skip;
|
||||||
|
}
|
||||||
|
if (in_len < 4) {
|
||||||
|
error("file corrupted");
|
||||||
|
goto exit_2;
|
||||||
|
}
|
||||||
dst_len = get_unaligned_be32(in_buf);
|
dst_len = get_unaligned_be32(in_buf);
|
||||||
in_buf += 4;
|
in_buf += 4;
|
||||||
|
in_len -= 4;
|
||||||
|
|
||||||
/* exit if last block */
|
/* exit if last block */
|
||||||
if (dst_len == 0)
|
if (dst_len == 0) {
|
||||||
|
if (posp)
|
||||||
|
*posp += 4;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (dst_len > LZO_BLOCK_SIZE) {
|
if (dst_len > LZO_BLOCK_SIZE) {
|
||||||
printf("dest len longer than block size");
|
error("dest len longer than block size");
|
||||||
goto exit_free;
|
goto exit_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read compressed block size, and skip block checksum info */
|
/* read compressed block size, and skip block checksum info */
|
||||||
|
if (fill && in_len < 8) {
|
||||||
|
skip = fill(in_buf + in_len, 8 - in_len);
|
||||||
|
if (skip > 0)
|
||||||
|
in_len += skip;
|
||||||
|
}
|
||||||
|
if (in_len < 8) {
|
||||||
|
error("file corrupted");
|
||||||
|
goto exit_2;
|
||||||
|
}
|
||||||
src_len = get_unaligned_be32(in_buf);
|
src_len = get_unaligned_be32(in_buf);
|
||||||
in_buf += 8;
|
in_buf += 8;
|
||||||
|
in_len -= 8;
|
||||||
|
|
||||||
if (src_len <= 0 || src_len > dst_len) {
|
if (src_len <= 0 || src_len > dst_len) {
|
||||||
printf("file corrupted");
|
error("file corrupted");
|
||||||
goto exit_free;
|
goto exit_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decompress */
|
/* decompress */
|
||||||
|
if (fill && in_len < src_len) {
|
||||||
|
skip = fill(in_buf + in_len, src_len - in_len);
|
||||||
|
if (skip > 0)
|
||||||
|
in_len += skip;
|
||||||
|
}
|
||||||
|
if (in_len < src_len) {
|
||||||
|
error("file corrupted");
|
||||||
|
goto exit_2;
|
||||||
|
}
|
||||||
tmp = dst_len;
|
tmp = dst_len;
|
||||||
|
|
||||||
/* When the input data is not compressed at all,
|
/* When the input data is not compressed at all,
|
||||||
* lzo1x_decompress_safe will fail, so call memcpy()
|
* lzo1x_decompress_safe will fail, so call memcpy()
|
||||||
* instead */
|
* instead */
|
||||||
if (unlikely(dst_len == src_len)) {
|
if (unlikely(dst_len == src_len))
|
||||||
if (src_len != dst_len) {
|
memcpy(out_buf, in_buf, src_len);
|
||||||
printf("Compressed data violation");
|
else {
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
out_buf = in_buf;
|
|
||||||
} else {
|
|
||||||
r = lzo1x_decompress_safe((u8 *) in_buf, src_len,
|
r = lzo1x_decompress_safe((u8 *) in_buf, src_len,
|
||||||
out_buf, &tmp);
|
out_buf, &tmp);
|
||||||
|
|
||||||
if (r != LZO_E_OK || dst_len != tmp) {
|
if (r != LZO_E_OK || dst_len != tmp) {
|
||||||
printf("Compressed data violation");
|
error("Compressed data violation");
|
||||||
goto exit_free;
|
goto exit_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = flush(out_buf, dst_len);
|
if (flush && flush(out_buf, dst_len) != dst_len)
|
||||||
if (ret < 0)
|
goto exit_2;
|
||||||
goto exit_free;
|
if (output)
|
||||||
|
out_buf += dst_len;
|
||||||
out_buf = in_buf + src_len;
|
if (posp)
|
||||||
in_buf = in_buf_save;
|
*posp += src_len + 12;
|
||||||
ret = fill(in_buf, lzo1x_worst_compress(LZO_BLOCK_SIZE));
|
|
||||||
if (ret < 0)
|
|
||||||
goto exit_free;
|
|
||||||
|
|
||||||
if (ret == 0)
|
|
||||||
in_buf = out_buf;
|
|
||||||
|
|
||||||
out_buf = out_buf_save;
|
|
||||||
|
|
||||||
obytes_processed += dst_len;
|
|
||||||
|
|
||||||
|
in_buf += src_len;
|
||||||
|
in_len -= src_len;
|
||||||
|
if (fill) {
|
||||||
|
/*
|
||||||
|
* If there happens to still be unused data left in
|
||||||
|
* in_buf, move it to the beginning of the buffer.
|
||||||
|
* Use a loop to avoid memmove() dependency.
|
||||||
|
*/
|
||||||
|
if (in_len > 0)
|
||||||
|
for (skip = 0; skip < in_len; ++skip)
|
||||||
|
in_buf_save[skip] = in_buf[skip];
|
||||||
|
in_buf = in_buf_save;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_free:
|
ret = 0;
|
||||||
free(in_buf);
|
exit_2:
|
||||||
free(out_buf);
|
if (!input)
|
||||||
|
free(in_buf_save);
|
||||||
*dest_len = obytes_processed;
|
exit_1:
|
||||||
return 0;
|
if (!output)
|
||||||
|
free(out_buf);
|
||||||
|
exit:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int in_fd;
|
static int in_fd;
|
||||||
|
@ -195,9 +298,14 @@ static int unlzo_flush(void *buf, unsigned int len)
|
||||||
return write(out_fd, buf, len);
|
return write(out_fd, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void unlzo_error(char *s)
|
||||||
|
{
|
||||||
|
printf("%s\n", s);
|
||||||
|
}
|
||||||
|
|
||||||
int unlzo(int _in_fd, int _out_fd, int *dest_len)
|
int unlzo(int _in_fd, int _out_fd, int *dest_len)
|
||||||
{
|
{
|
||||||
in_fd = _in_fd;
|
in_fd = _in_fd;
|
||||||
out_fd = _out_fd;
|
out_fd = _out_fd;
|
||||||
return __unlzo(dest_len, unlzo_fill, unlzo_flush);
|
return __unlzo(NULL, 0, unlzo_fill, unlzo_flush, NULL, NULL, unlzo_error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ int read_key(void)
|
||||||
esc[i] = getc();
|
esc[i] = getc();
|
||||||
if (esc[i++] == '~')
|
if (esc[i++] == '~')
|
||||||
break;
|
break;
|
||||||
|
if (i == ARRAY_SIZE(esc))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
esc[i] = 0;
|
esc[i] = 0;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
setupmbr
|
Loading…
Reference in New Issue