summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/.gitignore1
-rw-r--r--include/command.h5
-rw-r--r--include/digest.h49
-rw-r--r--include/driver.h12
-rw-r--r--include/image.h254
-rw-r--r--include/init.h6
-rw-r--r--include/linux/clkdev.h36
-rw-r--r--include/linux/stringify.h12
-rw-r--r--include/linux/types.h2
-rw-r--r--include/menu.h18
-rw-r--r--include/password.h41
11 files changed, 396 insertions, 40 deletions
diff --git a/include/.gitignore b/include/.gitignore
index bb388cccaa..0e56cf2f8c 100644
--- a/include/.gitignore
+++ b/include/.gitignore
@@ -1,2 +1 @@
config.h
-barebox_default_env.h
diff --git a/include/command.h b/include/command.h
index a612d65e54..4a4d9cf925 100644
--- a/include/command.h
+++ b/include/command.h
@@ -28,6 +28,7 @@
#define __COMMAND_H
#include <linux/list.h>
+#include <linux/stringify.h>
#ifndef NULL
#define NULL 0
@@ -75,10 +76,6 @@ void barebox_cmd_usage(struct command *cmdtp);
#endif /* __ASSEMBLY__ */
-#define __stringify_1(x) #x
-#define __stringify(x) __stringify_1(x)
-
-
#define Struct_Section __attribute__ ((unused,section (".barebox_cmd")))
#define BAREBOX_CMD_START(_name) \
diff --git a/include/digest.h b/include/digest.h
new file mode 100644
index 0000000000..1dcfd9d860
--- /dev/null
+++ b/include/digest.h
@@ -0,0 +1,49 @@
+/*
+ * (C) Copyright 2008-2010 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __DIGEST_H__
+#define __DIGEST_H__
+
+#include <linux/list.h>
+
+struct digest
+{
+ char *name;
+
+ int (*init)(struct digest *d);
+ int (*update)(struct digest *d, const void *data, unsigned long len);
+ int (*final)(struct digest *d, unsigned char *md);
+
+ unsigned int length;
+
+ struct list_head list;
+};
+
+/*
+ * digest functions
+ */
+int digest_register(struct digest *d);
+void digest_unregister(struct digest *d);
+
+struct digest* digest_get_by_name(char* name);
+
+#endif /* __SH_ST_DEVICES_H__ */
diff --git a/include/driver.h b/include/driver.h
index ee0749d48b..b9edca0e7f 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -25,7 +25,8 @@
#include <linux/list.h>
-#define MAX_DRIVER_NAME 32
+#define MAX_DRIVER_NAME 32
+#define FORMAT_DRIVER_MANE_ID "%s%d"
#include <param.h>
@@ -176,9 +177,11 @@ int get_free_deviceid(const char *name_template);
char *deviceid_from_spec_str(const char *str, char **endp);
+extern const char *dev_id(const struct device_d *dev);
+
static inline const char *dev_name(const struct device_d *dev)
{
- return dev->name;
+ return dev_id(dev);
}
/* linear list over all available devices
@@ -239,11 +242,10 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f)
}
/* debugging and troubleshooting/diagnostic helpers. */
-extern const char *dev_id(const struct device_d *dev);
#define dev_printf(dev, format, arg...) \
- printf("%s@%s: " format , dev_name(dev) , \
- dev_id(dev) , ## arg)
+ printf("%s@%s: " format , (dev)->name , \
+ dev_name(dev) , ## arg)
#define dev_emerg(dev, format, arg...) \
dev_printf((dev) , format , ## arg)
diff --git a/include/image.h b/include/image.h
index 13d0303160..2c5956d600 100644
--- a/include/image.h
+++ b/include/image.h
@@ -32,6 +32,11 @@
#define __IMAGE_H__
#include <linux/types.h>
+#ifdef __BAREBOX__
+#include <asm/byteorder.h>
+#include <stdio.h>
+#include <string.h>
+#endif
/*
* Operating System Codes
@@ -61,45 +66,48 @@
/*
* CPU Architecture Codes (supported by Linux)
*/
-#define IH_CPU_INVALID 0 /* Invalid CPU */
-#define IH_CPU_ALPHA 1 /* Alpha */
-#define IH_CPU_ARM 2 /* ARM */
-#define IH_CPU_I386 3 /* Intel x86 */
-#define IH_CPU_IA64 4 /* IA64 */
-#define IH_CPU_MIPS 5 /* MIPS */
-#define IH_CPU_MIPS64 6 /* MIPS 64 Bit */
-#define IH_CPU_PPC 7 /* PowerPC */
-#define IH_CPU_S390 8 /* IBM S390 */
-#define IH_CPU_SH 9 /* SuperH */
-#define IH_CPU_SPARC 10 /* Sparc */
-#define IH_CPU_SPARC64 11 /* Sparc 64 Bit */
-#define IH_CPU_M68K 12 /* M68K */
-#define IH_CPU_NIOS 13 /* Nios-32 */
-#define IH_CPU_MICROBLAZE 14 /* MicroBlaze */
-#define IH_CPU_NIOS2 15 /* Nios-II */
-#define IH_CPU_BLACKFIN 16 /* Blackfin */
-#define IH_CPU_AVR32 17 /* AVR32 */
+#define IH_ARCH_INVALID 0 /* Invalid CPU */
+#define IH_ARCH_ALPHA 1 /* Alpha */
+#define IH_ARCH_ARM 2 /* ARM */
+#define IH_ARCH_I386 3 /* Intel x86 */
+#define IH_ARCH_IA64 4 /* IA64 */
+#define IH_ARCH_MIPS 5 /* MIPS */
+#define IH_ARCH_MIPS64 6 /* MIPS 64 Bit */
+#define IH_ARCH_PPC 7 /* PowerPC */
+#define IH_ARCH_S390 8 /* IBM S390 */
+#define IH_ARCH_SH 9 /* SuperH */
+#define IH_ARCH_SPARC 10 /* Sparc */
+#define IH_ARCH_SPARC64 11 /* Sparc 64 Bit */
+#define IH_ARCH_M68K 12 /* M68K */
+#define IH_ARCH_NIOS 13 /* Nios-32 */
+#define IH_ARCH_MICROBLAZE 14 /* MicroBlaze */
+#define IH_ARCH_NIOS2 15 /* Nios-II */
+#define IH_ARCH_BLACKFIN 16 /* Blackfin */
+#define IH_ARCH_AVR32 17 /* AVR32 */
+#define IH_ARCH_LINUX 18 /* Linux */
#if defined(__PPC__)
-#define IH_CPU IH_CPU_PPC
+#define IH_ARCH IH_ARCH_PPC
#elif defined(__ARM__)
-#define IH_CPU IH_CPU_ARM
+#define IH_ARCH IH_ARCH_ARM
#elif defined(__I386__) || defined(__x86_64__)
-#define IH_CPU IH_CPU_I386
+#define IH_ARCH IH_ARCH_I386
#elif defined(__mips__)
-#define IH_CPU IH_CPU_MIPS
+#define IH_ARCH IH_ARCH_MIPS
#elif defined(__nios__)
-#define IH_CPU IH_CPU_NIOS
-#elif defined(__M68K__)
-#define IH_CPU IH_CPU_M68K
+#define IH_ARCH IH_ARCH_NIOS
+#elif defined(__m68k__)
+#define IH_ARCH IH_ARCH_M68K
#elif defined(__microblaze__)
-#define IH_CPU IH_CPU_MICROBLAZE
+#define IH_ARCH IH_ARCH_MICROBLAZE
#elif defined(__nios2__)
-#define IH_CPU IH_CPU_NIOS2
+#define IH_ARCH IH_ARCH_NIOS2
#elif defined(__blackfin__)
-#define IH_CPU IH_CPU_BLACKFIN
+#define IH_ARCH IH_ARCH_BLACKFIN
#elif defined(__avr32__)
-#define IH_CPU IH_CPU_AVR32
+#define IH_ARCH IH_ARCH_AVR32
+#elif defined(CONFIG_LINUX)
+#define IH_ARCH IH_ARCH_LINUX
#endif
/*
@@ -187,6 +195,194 @@ struct image_handle {
int flags;
};
+#if defined(CONFIG_CMD_BOOTM_SHOW_TYPE) || !defined(__BAREBOX__)
+const char *image_get_os_name(uint8_t os);
+const char *image_get_arch_name(uint8_t arch);
+const char *image_get_type_name(uint8_t type);
+const char *image_get_comp_name(uint8_t comp);
+#else
+static inline const char *image_get_os_name(uint8_t os)
+{
+ return NULL;
+}
+
+static inline const char *image_get_arch_name(uint8_t arch)
+{
+ return NULL;
+}
+
+static inline const char *image_get_type_name(uint8_t type)
+{
+ return NULL;
+}
+
+static inline const char *image_get_comp_name(uint8_t comp)
+{
+ return NULL;
+}
+#endif
+
+#define uimage_to_cpu(x) be32_to_cpu(x)
+#define cpu_to_uimage(x) cpu_to_be32(x)
+
+static inline uint32_t image_get_header_size(void)
+{
+ return sizeof(image_header_t);
+}
+
+#define image_get_hdr_u32(x) \
+static inline uint32_t image_get_##x(const image_header_t *hdr) \
+{ \
+ return uimage_to_cpu(hdr->ih_##x); \
+}
+
+image_get_hdr_u32(magic); /* image_get_magic */
+image_get_hdr_u32(hcrc); /* image_get_hcrc */
+image_get_hdr_u32(time); /* image_get_time */
+image_get_hdr_u32(size); /* image_get_size */
+image_get_hdr_u32(load); /* image_get_load */
+image_get_hdr_u32(ep); /* image_get_ep */
+image_get_hdr_u32(dcrc); /* image_get_dcrc */
+
+#define image_get_hdr_u8(x) \
+static inline uint8_t image_get_##x(const image_header_t *hdr) \
+{ \
+ return hdr->ih_##x; \
+}
+image_get_hdr_u8(os); /* image_get_os */
+image_get_hdr_u8(arch); /* image_get_arch */
+image_get_hdr_u8(type); /* image_get_type */
+image_get_hdr_u8(comp); /* image_get_comp */
+
+static inline char *image_get_name(const image_header_t *hdr)
+{
+ return (char*)hdr->ih_name;
+}
+
+static inline uint32_t image_get_data_size(const image_header_t *hdr)
+{
+ return image_get_size(hdr);
+}
+
+/**
+ * image_get_data - get image payload start address
+ * @hdr: image header
+ *
+ * image_get_data() returns address of the image payload. For single
+ * component images it is image data start. For multi component
+ * images it points to the null terminated table of sub-images sizes.
+ *
+ * returns:
+ * image payload data start address
+ */
+static inline ulong image_get_data(const image_header_t *hdr)
+{
+ return ((ulong)hdr + image_get_header_size());
+}
+
+static inline uint32_t image_get_image_size(const image_header_t *hdr)
+{
+ return (image_get_size(hdr) + image_get_header_size());
+}
+
+static inline ulong image_get_image_end(const image_header_t *hdr)
+{
+ return ((ulong)hdr + image_get_image_size(hdr));
+}
+
+#define image_set_hdr_u32(x) \
+static inline void image_set_##x(image_header_t *hdr, uint32_t val) \
+{ \
+ hdr->ih_##x = cpu_to_uimage(val); \
+}
+
+image_set_hdr_u32(magic); /* image_set_magic */
+image_set_hdr_u32(hcrc); /* image_set_hcrc */
+image_set_hdr_u32(time); /* image_set_time */
+image_set_hdr_u32(size); /* image_set_size */
+image_set_hdr_u32(load); /* image_set_load */
+image_set_hdr_u32(ep); /* image_set_ep */
+image_set_hdr_u32(dcrc); /* image_set_dcrc */
+
+#define image_set_hdr_u8(x) \
+static inline void image_set_##x(image_header_t *hdr, uint8_t val) \
+{ \
+ hdr->ih_##x = val; \
+}
+
+image_set_hdr_u8(os); /* image_set_os */
+image_set_hdr_u8(arch); /* image_set_arch */
+image_set_hdr_u8(type); /* image_set_type */
+image_set_hdr_u8(comp); /* image_set_comp */
+
+static inline void image_set_name(image_header_t *hdr, const char *name)
+{
+ strncpy(image_get_name(hdr), name, IH_NMLEN);
+}
+
+static inline int image_check_magic(const image_header_t *hdr)
+{
+ return (image_get_magic(hdr) == IH_MAGIC);
+}
+static inline int image_check_type(const image_header_t *hdr, uint8_t type)
+{
+ return (image_get_type(hdr) == type);
+}
+static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
+{
+ return (image_get_arch(hdr) == arch);
+}
+static inline int image_check_os(const image_header_t *hdr, uint8_t os)
+{
+ return (image_get_os(hdr) == os);
+}
+
+#ifdef __BAREBOX__
+static inline int image_check_target_arch(const image_header_t *hdr)
+{
+#if defined(__ARM__)
+ if (!image_check_arch(hdr, IH_ARCH_ARM))
+#elif defined(__avr32__)
+ if (!image_check_arch(hdr, IH_ARCH_AVR32))
+#elif defined(__bfin__)
+ if (!image_check_arch(hdr, IH_ARCH_BLACKFIN))
+#elif defined(__I386__)
+ if (!image_check_arch(hdr, IH_ARCH_I386))
+#elif defined(__m68k__)
+ if (!image_check_arch(hdr, IH_ARCH_M68K))
+#elif defined(__microblaze__)
+ if (!image_check_arch(hdr, IH_ARCH_MICROBLAZE))
+#elif defined(__mips__)
+ if (!image_check_arch(hdr, IH_ARCH_MIPS))
+#elif defined(__nios__)
+ if (!image_check_arch(hdr, IH_ARCH_NIOS))
+#elif defined(__nios2__)
+ if (!image_check_arch(hdr, IH_ARCH_NIOS2))
+#elif defined(__PPC__)
+ if (!image_check_arch(hdr, IH_ARCH_PPC))
+#elif defined(__sh__)
+ if (!image_check_arch(hdr, IH_ARCH_SH))
+#elif defined(__sparc__)
+ if (!image_check_arch(hdr, IH_ARCH_SPARC))
+#elif defined(CONFIG_LINUX)
+ if (!image_check_arch(hdr, IH_ARCH_LINUX))
+#else
+# error Unknown CPU type
+#endif
+ return 0;
+
+ return 1;
+}
+#endif
+
+ulong image_multi_count(const image_header_t *hdr);
+void image_multi_getimg(const image_header_t *hdr, ulong idx,
+ ulong *data, ulong *len);
+
+void image_print_size(uint32_t size);
+
+void image_print_contents(const void *ptr);
+
/* commamds/bootm.c */
void print_image_hdr (image_header_t *hdr);
diff --git a/include/init.h b/include/init.h
index 8692b68d07..2f4fac164b 100644
--- a/include/init.h
+++ b/include/init.h
@@ -7,6 +7,10 @@
#define __init
#define __initdata
+/* For assembly routines */
+#define __BARE_INIT .section ".text_bare_init.text","ax"
+
+#ifndef __ASSEMBLY__
typedef int (*initcall_t)(void);
#define __define_initcall(level,fn,id) \
@@ -40,5 +44,7 @@ typedef int (*initcall_t)(void);
*/
#define __bare_init __section(.text_bare_init.text)
+#endif
+
#endif /* _INIT_H */
diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
new file mode 100644
index 0000000000..ae38e1a166
--- /dev/null
+++ b/include/linux/clkdev.h
@@ -0,0 +1,36 @@
+/*
+ * include/linux/clkdev.h
+ *
+ * Copyright (C) 2008 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Helper for the clk API to assist looking up a struct clk.
+ */
+#ifndef __CLKDEV_H
+#define __CLKDEV_H
+
+#include <asm/clkdev.h>
+
+struct clk;
+struct device_d;
+
+struct clk_lookup {
+ struct list_head node;
+ const char *dev_id;
+ const char *con_id;
+ struct clk *clk;
+};
+
+struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
+ const char *dev_fmt, ...);
+
+void clkdev_add(struct clk_lookup *cl);
+void clkdev_drop(struct clk_lookup *cl);
+
+void clkdev_add_table(struct clk_lookup *, size_t);
+int clk_add_alias(const char *, const char *, char *, struct device_d *);
+
+#endif
diff --git a/include/linux/stringify.h b/include/linux/stringify.h
new file mode 100644
index 0000000000..841cec8ed5
--- /dev/null
+++ b/include/linux/stringify.h
@@ -0,0 +1,12 @@
+#ifndef __LINUX_STRINGIFY_H
+#define __LINUX_STRINGIFY_H
+
+/* Indirect stringification. Doing two levels allows the parameter to be a
+ * macro itself. For example, compile with -DFOO=bar, __stringify(FOO)
+ * converts to "bar".
+ */
+
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)
+
+#endif /* !__LINUX_STRINGIFY_H */
diff --git a/include/linux/types.h b/include/linux/types.h
index 96e5708208..2145b6de49 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -6,6 +6,8 @@
#ifndef __KERNEL_STRICT_NAMES
+typedef __u32 __kernel_dev_t;
+
typedef __kernel_fd_set fd_set;
typedef __kernel_dev_t dev_t;
typedef __kernel_ino_t ino_t;
diff --git a/include/menu.h b/include/menu.h
index 22bfc2301f..6e7b555263 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -28,6 +28,11 @@
struct menu;
+typedef enum {
+ MENU_ENTRY_NORMAL = 0,
+ MENU_ENTRY_BOX,
+} menu_entry_type;
+
struct menu_entry {
int num;
char *display;
@@ -35,6 +40,12 @@ struct menu_entry {
void (*free)(struct menu_entry *me);
int non_re_ent;
+ /* MENU_ENTRY_BOX */
+ int box_state;
+ void (*box_action)(struct menu *m, struct menu_entry *me);
+
+ menu_entry_type type;
+
struct list_head list;
};
@@ -42,6 +53,9 @@ struct menu {
char *name;
char *display;
+ int auto_select;
+ char *auto_display;
+
struct list_head list;
struct list_head entries;
@@ -66,7 +80,8 @@ static inline struct menu* menu_alloc(void)
return m;
}
struct menu_entry *menu_add_submenu(struct menu *parent, char *submenu, char *display);
-struct menu_entry *menu_add_command_entry(struct menu *m, char *display, char *command);
+struct menu_entry *menu_add_command_entry(struct menu *m, char *display,
+ char *command, menu_entry_type type);
void menu_free(struct menu *m);
int menu_add(struct menu* m);
void menu_remove(struct menu *m);
@@ -74,6 +89,7 @@ struct menu* menu_get_by_name(char *name);
int menu_show(struct menu *m);
int menu_set_selected_entry(struct menu *m, struct menu_entry* me);
int menu_set_selected(struct menu *m, int num);
+int menu_set_auto_select(struct menu *m, int delay);
struct menu* menu_get_menus(void);
/*
diff --git a/include/password.h b/include/password.h
new file mode 100644
index 0000000000..32301eb482
--- /dev/null
+++ b/include/password.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008-2010 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __PASSWORD_H__
+#define __PASSWORD_H__
+
+#define PASSWD_FILE "/env/etc/passwd"
+#define PASSWD_DIR "/env/etc/"
+
+#define HIDE (0 << 0)
+#define STAR (1 << 1)
+#define CLEAR (1 << 2)
+
+int password(unsigned char *passwd, size_t length, int flags);
+
+int read_passwd(unsigned char *sum, size_t length);
+int write_passwd(unsigned char *sum, size_t length);
+
+int is_passwd_enable(void);
+int passwd_disable(void);
+int check_passwd(unsigned char* passwd, size_t length);
+int set_passwd(unsigned char* passwd, size_t length);
+
+#endif /* __PASSWORD_H__ */