1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef _BOOT_H_ 30 #define _BOOT_H_ 31 32 static inline void DWB(void) /* drain write buffer */ 33 { 34 asm volatile ( 35 "mcr p15, 0, %0, c7, c10, 4\n" : : "r" (0) 36 ); 37 } 38 39 static inline void writel(unsigned val, unsigned addr) 40 { 41 DWB(); 42 (*(volatile unsigned *) (addr)) = (val); 43 DWB(); 44 } 45 46 static inline void writeb(unsigned val, unsigned addr) 47 { 48 DWB(); 49 (*(volatile unsigned char *) (addr)) = (val); 50 DWB(); 51 } 52 53 static inline unsigned readl(unsigned addr) 54 { 55 return (*(volatile unsigned *) (addr)); 56 } 57 58 int dcc_putc(unsigned c); 59 int dcc_getc(); 60 61 void enable_irq(void); 62 63 /* main.c */ 64 enum boot_keys { 65 BOOT_KEY_STOP_BOOT = 1, 66 BOOT_KEY_CONTINUE_BOOT = 2, 67 }; 68 extern void key_changed(unsigned int key, unsigned int is_down) __attribute__ ((weak)); 69 70 /* manage a list of functions to call */ 71 void boot_register_poll_func(void (*func)(void)); 72 void boot_poll(void); 73 74 /* console.c */ 75 void dcc_init(); 76 77 void dprintf(const char *fmt, ...); 78 void dprintf_set_putc(void (*func)(unsigned)); 79 void dprintf_set_flush(void (*func)(void)); 80 81 /* gpio */ 82 void gpio_output_enable(unsigned n, unsigned out); 83 void gpio_write(unsigned n, unsigned on); 84 int gpio_read(unsigned n); 85 86 /* misc.c */ 87 void *alloc(unsigned sz); /* alloc 32byte aligned memory */ 88 void *alloc_page_aligned(unsigned sz); 89 90 void *memcpy(void *dst, const void *src, unsigned len); 91 void *memset(void *dst, unsigned val, unsigned len); 92 char *strcpy(char *dst, const char *src); 93 int strcmp(const char *s1, const char *s2); 94 int memcmp(const void *a, const void *b, unsigned len); 95 char *strstr(const char *s1, const char *s2); 96 int strlen(const char *s); 97 98 /* clock */ 99 unsigned cycles_per_second(void); 100 void print_cpu_speed(void); 101 void arm11_clock_init(void); 102 void mdelay(unsigned msecs); 103 void udelay(unsigned usecs); 104 105 /* LCD */ 106 void console_init(void); 107 void console_set_colors(unsigned bg, unsigned fg); 108 void console_clear(void); 109 void console_putc(unsigned n); 110 void console_flush(void); 111 112 void cprintf(const char *fmt, ...); 113 114 void mddi_init(void); 115 void mddi_start_update(void); 116 int mddi_update_done(void); 117 void *mddi_framebuffer(void); 118 void mddi_remote_write(unsigned val, unsigned reg); 119 extern unsigned fb_width; 120 extern unsigned fb_height; 121 122 /* provided by board files */ 123 void set_led(int on); 124 125 /* provided by jtag.c */ 126 void jtag_okay(const char *msg); 127 void jtag_fail(const char *msg); 128 void jtag_dputc(unsigned ch); 129 void jtag_cmd_loop(void (*do_cmd)(const char *, unsigned, unsigned, unsigned)); 130 131 typedef void (*irq_handler)(unsigned n); 132 133 134 #define DIGEST_SIZE 20 135 #define SIGNATURE_SIZE 256 136 137 void compute_digest(void *data, unsigned len, void *digest_out); 138 int is_signature_okay(void *digest, void *signature, void *pubkey); 139 140 #if 0 141 #define __attr_used __attribute__((used)) 142 #define __attr_init __attribute__((__section__(".init.func.0"))) 143 #define boot_init_hook(func) \ 144 static int (*__boot_init_hook__)(void) __attr_used __attr_init = func 145 #endif 146 147 #endif 148