summaryrefslogtreecommitdiff
path: root/include/boot
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:28:41 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:28:41 -0800
commit076ef94d61f349f7cf0fe776e60456d8f232cca5 (patch)
tree6a7dfaaef61ff7ee33bb2036cd14b08583e70223 /include/boot
parent84fe89dad95fa18a8950d130a2537db834333bb7 (diff)
downloadlegacy-076ef94d61f349f7cf0fe776e60456d8f232cca5.tar.gz
Diffstat (limited to 'include/boot')
-rw-r--r--include/boot/arm.h50
-rw-r--r--include/boot/board.h51
-rw-r--r--include/boot/boot.h147
-rw-r--r--include/boot/bootimg.h97
-rw-r--r--include/boot/flash.h60
-rw-r--r--include/boot/font5x12.h126
-rw-r--r--include/boot/gpio.h36
-rw-r--r--include/boot/gpio_keypad.h47
-rw-r--r--include/boot/tags.h48
-rw-r--r--include/boot/uart.h40
-rw-r--r--include/boot/usb.h89
-rw-r--r--include/boot/usb_descriptors.h163
12 files changed, 954 insertions, 0 deletions
diff --git a/include/boot/arm.h b/include/boot/arm.h
new file mode 100644
index 0000000..13b64f2
--- /dev/null
+++ b/include/boot/arm.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_H
+#define _ARM_H
+
+#define PSR_N 0x80000000
+#define PSR_C 0x40000000
+#define PSR_Z 0x20000000
+#define PSR_V 0x10000000
+
+#define PSR_I 0x00000080
+#define PSR_F 0x00000040
+#define PSR_T 0x00000020
+
+#define PSR_MODE_MASK 0x0000001F
+#define PSR_USR 0x00000010
+#define PSR_FIQ 0x00000011
+#define PSR_IRQ 0x00000012
+#define PSR_SVC 0x00000013
+#define PSR_ABT 0x00000017
+#define PSR_UND 0x0000001B
+#define PSR_SYS 0x0000001F
+
+#endif
diff --git a/include/boot/board.h b/include/boot/board.h
new file mode 100644
index 0000000..19b5c5e
--- /dev/null
+++ b/include/boot/board.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+/* low-level init and partition table setup */
+void board_init(void);
+void board_reboot(void);
+void board_getvar(const char *name, char *value);
+
+/* keypad init */
+void keypad_init(void);
+
+/* return a linux kernel commandline */
+const char *board_cmdline(void);
+unsigned board_machtype(void);
+
+/* lcd panel initialization */
+struct mddi_client_caps;
+
+void panel_poweron(void);
+void panel_init(struct mddi_client_caps *caps);
+void panel_backlight(int on);
+
+#endif
diff --git a/include/boot/boot.h b/include/boot/boot.h
new file mode 100644
index 0000000..d4a4d64
--- /dev/null
+++ b/include/boot/boot.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOOT_H_
+#define _BOOT_H_
+
+static inline void DWB(void) /* drain write buffer */
+{
+ asm volatile (
+ "mcr p15, 0, %0, c7, c10, 4\n" : : "r" (0)
+ );
+}
+
+static inline void writel(unsigned val, unsigned addr)
+{
+ DWB();
+ (*(volatile unsigned *) (addr)) = (val);
+ DWB();
+}
+
+static inline void writeb(unsigned val, unsigned addr)
+{
+ DWB();
+ (*(volatile unsigned char *) (addr)) = (val);
+ DWB();
+}
+
+static inline unsigned readl(unsigned addr)
+{
+ return (*(volatile unsigned *) (addr));
+}
+
+int dcc_putc(unsigned c);
+int dcc_getc();
+
+void enable_irq(void);
+
+/* main.c */
+enum boot_keys {
+ BOOT_KEY_STOP_BOOT = 1,
+ BOOT_KEY_CONTINUE_BOOT = 2,
+};
+extern void key_changed(unsigned int key, unsigned int is_down) __attribute__ ((weak));
+
+/* manage a list of functions to call */
+void boot_register_poll_func(void (*func)(void));
+void boot_poll(void);
+
+/* console.c */
+void dcc_init();
+
+void dprintf(const char *fmt, ...);
+void dprintf_set_putc(void (*func)(unsigned));
+void dprintf_set_flush(void (*func)(void));
+
+/* gpio */
+void gpio_output_enable(unsigned n, unsigned out);
+void gpio_write(unsigned n, unsigned on);
+int gpio_read(unsigned n);
+
+/* misc.c */
+void *alloc(unsigned sz); /* alloc 32byte aligned memory */
+void *alloc_page_aligned(unsigned sz);
+
+void *memcpy(void *dst, const void *src, unsigned len);
+void *memset(void *dst, unsigned val, unsigned len);
+char *strcpy(char *dst, const char *src);
+int strcmp(const char *s1, const char *s2);
+int memcmp(const void *a, const void *b, unsigned len);
+char *strstr(const char *s1, const char *s2);
+int strlen(const char *s);
+
+/* clock */
+unsigned cycles_per_second(void);
+void print_cpu_speed(void);
+void arm11_clock_init(void);
+void mdelay(unsigned msecs);
+void udelay(unsigned usecs);
+
+/* LCD */
+void console_init(void);
+void console_set_colors(unsigned bg, unsigned fg);
+void console_clear(void);
+void console_putc(unsigned n);
+void console_flush(void);
+
+void cprintf(const char *fmt, ...);
+
+void mddi_init(void);
+void mddi_start_update(void);
+int mddi_update_done(void);
+void *mddi_framebuffer(void);
+void mddi_remote_write(unsigned val, unsigned reg);
+extern unsigned fb_width;
+extern unsigned fb_height;
+
+/* provided by board files */
+void set_led(int on);
+
+/* provided by jtag.c */
+void jtag_okay(const char *msg);
+void jtag_fail(const char *msg);
+void jtag_dputc(unsigned ch);
+void jtag_cmd_loop(void (*do_cmd)(const char *, unsigned, unsigned, unsigned));
+
+typedef void (*irq_handler)(unsigned n);
+
+
+#define DIGEST_SIZE 20
+#define SIGNATURE_SIZE 256
+
+void compute_digest(void *data, unsigned len, void *digest_out);
+int is_signature_okay(void *digest, void *signature, void *pubkey);
+
+#if 0
+#define __attr_used __attribute__((used))
+#define __attr_init __attribute__((__section__(".init.func.0")))
+#define boot_init_hook(func) \
+static int (*__boot_init_hook__)(void) __attr_used __attr_init = func
+#endif
+
+#endif
diff --git a/include/boot/bootimg.h b/include/boot/bootimg.h
new file mode 100644
index 0000000..44fde92
--- /dev/null
+++ b/include/boot/bootimg.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOOT_IMAGE_H_
+#define _BOOT_IMAGE_H_
+
+typedef struct boot_img_hdr boot_img_hdr;
+
+#define BOOT_MAGIC "ANDROID!"
+#define BOOT_MAGIC_SIZE 8
+#define BOOT_NAME_SIZE 16
+#define BOOT_ARGS_SIZE 512
+
+struct boot_img_hdr
+{
+ unsigned char magic[BOOT_MAGIC_SIZE];
+
+ unsigned kernel_size; /* size in bytes */
+ unsigned kernel_addr; /* physical load addr */
+
+ unsigned ramdisk_size; /* size in bytes */
+ unsigned ramdisk_addr; /* physical load addr */
+
+ unsigned second_size; /* size in bytes */
+ unsigned second_addr; /* physical load addr */
+
+ unsigned tags_addr; /* physical addr for kernel tags */
+ unsigned page_size; /* flash page size we assume */
+ unsigned unused[2]; /* future expansion: should be 0 */
+
+ unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
+
+ unsigned char cmdline[BOOT_ARGS_SIZE];
+
+ unsigned id[8]; /* timestamp / checksum / sha1 / etc */
+};
+
+/*
+** +-----------------+
+** | boot header | 1 page
+** +-----------------+
+** | kernel | n pages
+** +-----------------+
+** | ramdisk | m pages
+** +-----------------+
+** | second stage | o pages
+** +-----------------+
+**
+** n = (kernel_size + page_size - 1) / page_size
+** m = (ramdisk_size + page_size - 1) / page_size
+** o = (second_size + page_size - 1) / page_size
+**
+** 0. all entities are page_size aligned in flash
+** 1. kernel and ramdisk are required (size != 0)
+** 2. second is optional (second_size == 0 -> no second)
+** 3. load each element (kernel, ramdisk, second) at
+** the specified physical address (kernel_addr, etc)
+** 4. prepare tags at tag_addr. kernel_args[] is
+** appended to the kernel commandline in the tags.
+** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
+** 6. if second_size != 0: jump to second_addr
+** else: jump to kernel_addr
+*/
+
+boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
+ void *ramdisk, unsigned ramdisk_size,
+ void *second, unsigned second_size,
+ unsigned page_size,
+ unsigned *bootimg_size);
+
+void bootimg_set_cmdline(boot_img_hdr *hdr, const char *cmdline);
+#endif
diff --git a/include/boot/flash.h b/include/boot/flash.h
new file mode 100644
index 0000000..c746415
--- /dev/null
+++ b/include/boot/flash.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _INCLUDE_BOOT_FLASH_H_
+#define _INCLUDE_BOOT_FLASH_H_
+
+typedef struct flash_ops flash_ops;
+typedef struct ptentry ptentry;
+
+/* flash partitions are defined in terms of blocks
+** (flash erase units)
+*/
+struct ptentry
+{
+ char name[16];
+ unsigned start;
+ unsigned length;
+ unsigned flags;
+};
+
+/* tools to populate and query the partition table */
+void flash_add_ptn(ptentry *ptn);
+ptentry *flash_find_ptn(const char *name);
+ptentry *flash_get_ptn(unsigned n);
+unsigned flash_get_ptn_count(void);
+void flash_dump_ptn(void);
+
+int flash_init(void);
+int flash_erase(ptentry *ptn);
+int flash_read_ext(ptentry *ptn, unsigned extra_per_page, unsigned offset,
+ void *data, unsigned bytes);
+#define flash_read(ptn, offset, data, bytes) flash_read_ext(ptn, 0, offset, data, bytes)
+int flash_write(ptentry *ptn, unsigned extra_per_page,
+ const void *data, unsigned bytes);
+#endif
diff --git a/include/boot/font5x12.h b/include/boot/font5x12.h
new file mode 100644
index 0000000..e033bf6
--- /dev/null
+++ b/include/boot/font5x12.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+unsigned font5x12[] = {
+ 0x00000000, 0x00000000,
+ 0x08421080, 0x00020084,
+ 0x00052940, 0x00000000,
+ 0x15f52800, 0x0000295f,
+ 0x1c52f880, 0x00023e94,
+ 0x08855640, 0x0004d542,
+ 0x04528800, 0x000b2725,
+ 0x00021080, 0x00000000,
+ 0x04211088, 0x00821042,
+ 0x10841082, 0x00221108,
+ 0x09575480, 0x00000000,
+ 0x3e420000, 0x00000084,
+ 0x00000000, 0x00223000,
+ 0x3e000000, 0x00000000,
+ 0x00000000, 0x00471000,
+ 0x08844200, 0x00008442,
+ 0x2318a880, 0x00022a31,
+ 0x08429880, 0x000f9084,
+ 0x1108c5c0, 0x000f8444,
+ 0x1c4443e0, 0x00074610,
+ 0x14a62100, 0x000423e9,
+ 0x26d087e0, 0x00074610,
+ 0x1e10c5c0, 0x00074631,
+ 0x088443e0, 0x00010844,
+ 0x1d18c5c0, 0x00074631,
+ 0x3d18c5c0, 0x00074610,
+ 0x08e20000, 0x00471000,
+ 0x08e20000, 0x00223000,
+ 0x02222200, 0x00082082,
+ 0x01f00000, 0x000003e0,
+ 0x20820820, 0x00008888,
+ 0x1108c5c0, 0x00020084,
+ 0x2b98c5c0, 0x000f05b5,
+ 0x2318a880, 0x0008c63f,
+ 0x1d2949e0, 0x0007ca52,
+ 0x0210c5c0, 0x00074421,
+ 0x252949e0, 0x0007ca52,
+ 0x1e1087e0, 0x000f8421,
+ 0x1e1087e0, 0x00008421,
+ 0x0210c5c0, 0x00074639,
+ 0x3f18c620, 0x0008c631,
+ 0x084211c0, 0x00071084,
+ 0x10842380, 0x00032508,
+ 0x0654c620, 0x0008c525,
+ 0x02108420, 0x000f8421,
+ 0x2b5dc620, 0x0008c631,
+ 0x2b59ce20, 0x0008c739,
+ 0x2318c5c0, 0x00074631,
+ 0x1f18c5e0, 0x00008421,
+ 0x2318c5c0, 0x01075631,
+ 0x1f18c5e0, 0x0008c525,
+ 0x1c10c5c0, 0x00074610,
+ 0x084213e0, 0x00021084,
+ 0x2318c620, 0x00074631,
+ 0x1518c620, 0x0002114a,
+ 0x2b18c620, 0x000556b5,
+ 0x08a54620, 0x0008c54a,
+ 0x08a54620, 0x00021084,
+ 0x088443e0, 0x000f8442,
+ 0x0421084e, 0x00e10842,
+ 0x08210420, 0x00084108,
+ 0x1084210e, 0x00e42108,
+ 0x0008a880, 0x00000000,
+ 0x00000000, 0x01f00000,
+ 0x00000104, 0x00000000,
+ 0x20e00000, 0x000b663e,
+ 0x22f08420, 0x0007c631,
+ 0x22e00000, 0x00074421,
+ 0x23e84200, 0x000f4631,
+ 0x22e00000, 0x0007443f,
+ 0x1e214980, 0x00010842,
+ 0x22e00000, 0x1d187a31,
+ 0x26d08420, 0x0008c631,
+ 0x08601000, 0x00071084,
+ 0x10c02000, 0x0c94a108,
+ 0x0a908420, 0x0008a4a3,
+ 0x084210c0, 0x00071084,
+ 0x2ab00000, 0x0008d6b5,
+ 0x26d00000, 0x0008c631,
+ 0x22e00000, 0x00074631,
+ 0x22f00000, 0x0210be31,
+ 0x23e00000, 0x21087a31,
+ 0x26d00000, 0x00008421,
+ 0x22e00000, 0x00074506,
+ 0x04f10800, 0x00064842,
+ 0x23100000, 0x000b6631,
+ 0x23100000, 0x00022951,
+ 0x23100000, 0x000556b5,
+ 0x15100000, 0x0008a884,
+ 0x23100000, 0x1d185b31,
+ 0x11f00000, 0x000f8444,
+ 0x06421098, 0x01821084,
+ 0x08421080, 0x00021084,
+ 0x30421083, 0x00321084,
+ 0x0004d640, 0x00000000,
+ 0x00000000, 0x00000000,
+};
diff --git a/include/boot/gpio.h b/include/boot/gpio.h
new file mode 100644
index 0000000..78db64b
--- /dev/null
+++ b/include/boot/gpio.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _GPIO_H_
+#define _GPIO_H_
+
+void gpio_dir(int nr, int out);
+void gpio_set(int nr, int set);
+int gpio_get(int nr);
+
+#endif
diff --git a/include/boot/gpio_keypad.h b/include/boot/gpio_keypad.h
new file mode 100644
index 0000000..11edf45
--- /dev/null
+++ b/include/boot/gpio_keypad.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _GPIO_KEYPAD_H_
+#define _GPIO_KEYPAD_H_
+
+typedef struct {
+ unsigned int *input_gpios;
+ unsigned int *output_gpios;
+ unsigned int ninputs;
+ unsigned int noutputs;
+ unsigned int *key_map;
+ unsigned int settle_time; // micro seconds to wait before reading inputs after driving each output
+ int polarity : 1; // 0: drive active column low, 1: drive active column high
+ int drive_inactive_outputs : 1;
+ unsigned long long state;
+} gpio_keypad_info;
+
+int gpio_keypad_init(gpio_keypad_info *keypad);
+void gpio_keypad_scan_keys(gpio_keypad_info *keypad);
+
+#endif
diff --git a/include/boot/tags.h b/include/boot/tags.h
new file mode 100644
index 0000000..1fc0237
--- /dev/null
+++ b/include/boot/tags.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _INCLUDE_BOOT_TAGS_H_
+#define _INCLUDE_BOOT_TAGS_H_
+
+/* tools to deal with Linux ARM boot tags */
+
+struct tag_handler
+{
+ unsigned type;
+ void (*func)(unsigned type, void *data, unsigned bytes, void *cookie);
+ void *cookie;
+};
+
+void tags_parse(void *tags, struct tag_handler *h, unsigned count);
+
+/* convenience function */
+void tags_import_partitions(void *tags);
+unsigned tags_get_revision(void *tags);
+void tags_get_serialno(void *tags, void *sn); /* sn is 64bits */
+const char *tags_get_cmdline(void *tags);
+#endif
diff --git a/include/boot/uart.h b/include/boot/uart.h
new file mode 100644
index 0000000..90a8a67
--- /dev/null
+++ b/include/boot/uart.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _INCLUDE_BOOT_UART_H_
+#define _INCLUDE_BOOT_UART_H_
+
+void uart_init(unsigned uart_number);
+
+void uart_putc(unsigned);
+int uart_tx_ready(void);
+
+/* returns -1 if no character available, otherwise 0x00-0xff */
+int uart_getc(void);
+
+#endif
diff --git a/include/boot/usb.h b/include/boot/usb.h
new file mode 100644
index 0000000..73637c2
--- /dev/null
+++ b/include/boot/usb.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _USB_COMMON_DEFINES_H
+#define _USB_COMMON_DEFINES_H
+
+#define GET_STATUS 0
+#define CLEAR_FEATURE 1
+#define SET_FEATURE 3
+#define SET_ADDRESS 5
+#define GET_DESCRIPTOR 6
+#define SET_DESCRIPTOR 7
+#define GET_CONFIGURATION 8
+#define SET_CONFIGURATION 9
+#define GET_INTERFACE 10
+#define SET_INTERFACE 11
+#define SYNCH_FRAME 12
+
+#define TYPE_DEVICE 1
+#define TYPE_CONFIGURATION 2
+#define TYPE_STRING 3
+#define TYPE_INTERFACE 4
+#define TYPE_ENDPOINT 5
+
+#define DEVICE_READ 0x80
+#define DEVICE_WRITE 0x00
+#define INTERFACE_READ 0x81
+#define INTERFACE_WRITE 0x01
+#define ENDPOINT_READ 0x82
+#define ENDPOINT_WRITE 0x02
+
+typedef struct
+{
+ unsigned char type;
+ unsigned char request;
+ unsigned short value;
+ unsigned short index;
+ unsigned short length;
+} __attribute__ ((packed)) setup_packet;
+
+
+struct usb_request
+{
+ struct ept_queue_item *item;
+
+ void *buf;
+ unsigned length;
+
+ void (*complete)(struct usb_request *req, unsigned actual, int status);
+ void *context;
+};
+
+struct usb_request *usb_request_alloc();
+struct usb_endpoint *usb_endpoint_alloc(unsigned num, unsigned in, unsigned maxpkt);
+int usb_queue_req(struct usb_endpoint *ept, struct usb_request *req);
+
+void usb_init(void);
+void usb_shutdown(void);
+void usb_poll(void);
+
+/* called to indicate online/offline status */
+void usb_status(unsigned online, unsigned highspeed);
+
+#endif
diff --git a/include/boot/usb_descriptors.h b/include/boot/usb_descriptors.h
new file mode 100644
index 0000000..434fcab
--- /dev/null
+++ b/include/boot/usb_descriptors.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+static unsigned short manufacturer_string[] = {
+ (TYPE_STRING << 8) | (12 * 2),
+ 'G', 'o', 'o', 'g', 'l', 'e', ',', ' ', 'I', 'n', 'c',
+};
+
+static unsigned short product_string[] = {
+ (TYPE_STRING << 8) | (12 * 2),
+ 'A', 'n', 'd', 'r', 'o', 'i', 'd', ' ', '1', '.', '0',
+};
+
+static unsigned short default_string[] = {
+ (TYPE_STRING << 8) | (8 * 2),
+ 'd', 'e', 'f', 'a', 'u', 'l', 't',
+};
+
+static unsigned short language_table[] = {
+ (TYPE_STRING << 8) | 4,
+ 0x0409, // LANGID for US English
+};
+
+static unsigned char device_desc[] = {
+ 18, // length
+ TYPE_DEVICE, // type
+ 0x10, 0x02, // usb spec rev 1.00
+ 0x00, // class
+ 0x00, // subclass
+ 0x00, // protocol
+ 0x40, // max packet size
+ 0xD1, 0x18, // vendor id
+ 0x0D, 0xD0, // product id
+ 0x00, 0x01, // version 1.0
+ 0x01, // manufacturer str idx
+ 0x02, // product str idx
+ 0x00, // serial number index
+ 0x01, // number of configs,
+};
+
+static unsigned char config_desc[] = {
+ 0x09, // length
+ TYPE_CONFIGURATION,
+ 0x20, 0x00, // total length
+ 0x01, // # interfaces
+ 0x01, // config value
+ 0x00, // config string
+ 0x80, // attributes
+ 0x80, // XXX max power (250ma)
+
+ 0x09, // length
+ TYPE_INTERFACE,
+ 0x00, // interface number
+ 0x00, // alt number
+ 0x02, // # endpoints
+ 0xFF,
+ 0x42,
+ 0x03,
+ 0x00, // interface string
+
+ 0x07, // length
+ TYPE_ENDPOINT,
+ 0x81, // in, #1
+ 0x02, // bulk
+ 0x00, 0x02, // max packet 512
+ 0x00, // interval
+
+ 0x07, // length
+ TYPE_ENDPOINT,
+ 0x01, // out, #1
+ 0x02, // bulk
+ 0x00, 0x02, // max packet 512
+ 0x01, // interval
+};
+
+static unsigned char config_desc_fs[] = {
+ 0x09, // length
+ TYPE_CONFIGURATION,
+ 0x20, 0x00, // total length
+ 0x01, // # interfaces
+ 0x01, // config value
+ 0x00, // config string
+ 0x80, // attributes
+ 0x80, // XXX max power (250ma)
+
+ 0x09, // length
+ TYPE_INTERFACE,
+ 0x00, // interface number
+ 0x00, // alt number
+ 0x02, // # endpoints
+ 0xFF,
+ 0x42,
+ 0x03,
+ 0x00, // interface string
+
+ 0x07, // length
+ TYPE_ENDPOINT,
+ 0x81, // in, #1
+ 0x02, // bulk
+ 0x40, 0x00, // max packet 64
+ 0x00, // interval
+
+ 0x07, // length
+ TYPE_ENDPOINT,
+ 0x01, // out, #1
+ 0x02, // bulk
+ 0x40, 0x00, // max packet 64
+ 0x00, // interval
+};
+
+typedef struct
+{
+ void *data;
+ unsigned short length;
+ unsigned short id;
+} dtable;
+
+#define ID(type,num) ((type << 8) | num)
+
+static dtable descr_hs[] = {
+ { device_desc, sizeof(device_desc), ID(TYPE_DEVICE, 0) },
+ { config_desc, sizeof(config_desc), ID(TYPE_CONFIGURATION, 0) },
+ { manufacturer_string, sizeof(manufacturer_string), ID(TYPE_STRING, 1) },
+ { product_string, sizeof(product_string), ID(TYPE_STRING, 2) },
+ { default_string, sizeof(default_string), ID(TYPE_STRING, 4) },
+ { language_table, sizeof(language_table), ID(TYPE_STRING, 0) },
+ { 0, 0, 0 },
+};
+
+static dtable descr_fs[] = {
+ { device_desc, sizeof(device_desc), ID(TYPE_DEVICE, 0) },
+ { config_desc_fs, sizeof(config_desc), ID(TYPE_CONFIGURATION, 0) },
+ { manufacturer_string, sizeof(manufacturer_string), ID(TYPE_STRING, 1) },
+ { product_string, sizeof(product_string), ID(TYPE_STRING, 2) },
+ { default_string, sizeof(default_string), ID(TYPE_STRING, 4) },
+ { language_table, sizeof(language_table), ID(TYPE_STRING, 0) },
+ { 0, 0, 0 },
+};