| 1 | /* |
| 2 | * (C) Copyright 2008 Openmoko, Inc. |
| 3 | * Author: Andy Green <andy@openmoko.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of |
| 8 | * the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 18 | * MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #ifndef __QI_H__ |
| 22 | #define __QI_H__ |
| 23 | |
| 24 | #include <stdarg.h> |
| 25 | #include <qi-ctype.h> |
| 26 | #include <asm/byteorder.h> |
| 27 | |
| 28 | #define MALLOC_POOL_EXTENT (100 * 1024) |
| 29 | |
| 30 | #define u32 unsigned int |
| 31 | #define u16 unsigned short |
| 32 | #define u8 unsigned char |
| 33 | typedef unsigned int uint32_t; |
| 34 | typedef unsigned short uint16_t; |
| 35 | typedef unsigned char uint8_t; |
| 36 | |
| 37 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) |
| 38 | |
| 39 | enum filesystem { |
| 40 | FS_RAW, |
| 41 | FS_FAT, |
| 42 | FS_EXT2 |
| 43 | }; |
| 44 | |
| 45 | enum ui_actions { |
| 46 | UI_ACTION_ADD_DEBUG = (1 << 0), |
| 47 | UI_ACTION_SKIPKERNEL = (1 << 1), |
| 48 | }; |
| 49 | |
| 50 | enum ui_indication { |
| 51 | UI_IND_UPDATE_ONLY, |
| 52 | UI_IND_MOUNT_PART, |
| 53 | UI_IND_MOUNT_FAIL, |
| 54 | UI_IND_SKIPPING, |
| 55 | UI_IND_KERNEL_PULL, |
| 56 | UI_IND_KERNEL_PULL_OK, |
| 57 | UI_IND_KERNEL_PULL_FAIL, |
| 58 | UI_IND_INITRAMFS_PULL, |
| 59 | UI_IND_INITRAMFS_PULL_OK, |
| 60 | UI_IND_INITRAMFS_PULL_FAIL, |
| 61 | UI_IND_KERNEL_START, |
| 62 | UI_IND_MEM_TEST |
| 63 | }; |
| 64 | |
| 65 | /* describes a source for getting kernel image */ |
| 66 | |
| 67 | struct kernel_source { |
| 68 | const char *name; /* NULL name means invalid */ |
| 69 | const char *filepath; |
| 70 | const char *initramfs_filepath; |
| 71 | int (*block_init)(void); |
| 72 | int (*block_read)(unsigned char * buf, unsigned long start512, |
| 73 | int blocks512); |
| 74 | int partition_index; /* -1 means no partition table */ |
| 75 | int offset_blocks512_if_no_partition; /* used if partition_index is -1 */ |
| 76 | enum filesystem filesystem; |
| 77 | const char * commandline_append; |
| 78 | }; |
| 79 | |
| 80 | /* describes a board variant, eg, PCB revision */ |
| 81 | |
| 82 | struct board_variant { |
| 83 | const char * name; |
| 84 | int machine_revision; /* passed in revision tag to linux */ |
| 85 | }; |
| 86 | |
| 87 | /* describes a "board", ie, a device like GTA02 including revisions */ |
| 88 | |
| 89 | struct board_api { |
| 90 | const char * name; |
| 91 | int linux_machine_id; |
| 92 | unsigned long linux_mem_start; |
| 93 | unsigned long linux_mem_size; |
| 94 | unsigned long linux_tag_placement; |
| 95 | const char *commandline_board; |
| 96 | const char *commandline_board_debug; |
| 97 | const char *noboot; |
| 98 | const char *append; |
| 99 | |
| 100 | const struct board_variant const * (*get_board_variant)(void); |
| 101 | int (*is_this_board)(void); |
| 102 | void (*early_port_init)(void); |
| 103 | void (*port_init)(void); |
| 104 | void (*post_serial_init)(void); /* print device-specific things */ |
| 105 | char * (*append_device_specific_cmdline)(char *); |
| 106 | void (*putc)(char); |
| 107 | void (*close)(void); |
| 108 | u8 (*get_ui_keys)(void); |
| 109 | u8 (*get_ui_debug)(void); |
| 110 | void (*set_ui_indication)(enum ui_indication); |
| 111 | |
| 112 | struct kernel_source kernel_source[8]; |
| 113 | }; |
| 114 | |
| 115 | /* this is the board we are running on */ |
| 116 | |
| 117 | extern struct board_api const * this_board; |
| 118 | extern struct kernel_source const * this_kernel; |
| 119 | |
| 120 | int printk(const char *fmt, ...); |
| 121 | int vsprintf(char *buf, const char *fmt, va_list args); |
| 122 | int puts(const char *string); |
| 123 | void printhex(unsigned char v); |
| 124 | void print8(unsigned char u); |
| 125 | void print32(unsigned int u); |
| 126 | void printdec(int n); |
| 127 | void hexdump(unsigned char *start, int len); |
| 128 | void udelay(int n); |
| 129 | |
| 130 | /* phase2 only */ |
| 131 | void setnybble(char *p, unsigned char n); |
| 132 | void set8(char *p, unsigned char n); |
| 133 | void set32(char *p, unsigned int u); |
| 134 | |
| 135 | unsigned long crc32(unsigned long crc, const unsigned char *buf, |
| 136 | unsigned int len); |
| 137 | int nand_read_ll(unsigned char *buf, unsigned long start512, int blocks512); |
| 138 | |
| 139 | extern void memory_test(void * start, unsigned int length); |
| 140 | |
| 141 | void set_putc_func(void (*p)(char)); |
| 142 | |
| 143 | #endif |
| 144 | |
| 145 | |