Rafal Jaworowski | 9e1d16c | 2008-02-21 11:56:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007-2008 Semihalf |
| 3 | * |
| 4 | * Written by: Rafal Jaworowski <raj@semihalf.com> |
| 5 | * |
| 6 | * This file is dual licensed; you can use it under the terms of |
| 7 | * either the GPL, or the BSD license, at your option. |
| 8 | * |
| 9 | * I. GPL: |
| 10 | * |
| 11 | * This file is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This file is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | * |
| 26 | * Alternatively, |
| 27 | * |
| 28 | * II. BSD license: |
| 29 | * |
| 30 | * Redistribution and use in source and binary forms, with or without |
| 31 | * modification, are permitted provided that the following conditions |
| 32 | * are met: |
| 33 | * 1. Redistributions of source code must retain the above copyright |
| 34 | * notice, this list of conditions and the following disclaimer. |
| 35 | * 2. Redistributions in binary form must reproduce the above copyright |
| 36 | * notice, this list of conditions and the following disclaimer in the |
| 37 | * documentation and/or other materials provided with the distribution. |
| 38 | * |
| 39 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 40 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 42 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 43 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 44 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 45 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 46 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 47 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 48 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 49 | * SUCH DAMAGE. |
| 50 | */ |
| 51 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 52 | #ifndef _API_PUBLIC_H_ |
| 53 | #define _API_PUBLIC_H_ |
| 54 | |
| 55 | #define API_EINVAL 1 /* invalid argument(s) */ |
| 56 | #define API_ENODEV 2 /* no device */ |
| 57 | #define API_ENOMEM 3 /* no memory */ |
| 58 | #define API_EBUSY 4 /* busy, occupied etc. */ |
| 59 | #define API_EIO 5 /* I/O error */ |
Rafal Jaworowski | 6feb82d | 2009-01-23 13:27:18 +0100 | [diff] [blame] | 60 | #define API_ESYSC 6 /* syscall error */ |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 61 | |
| 62 | typedef int (*scp_t)(int, int *, ...); |
| 63 | |
| 64 | #define API_SIG_VERSION 1 |
| 65 | #define API_SIG_MAGIC "UBootAPI" |
| 66 | #define API_SIG_MAGLEN 8 |
| 67 | |
| 68 | struct api_signature { |
| 69 | char magic[API_SIG_MAGLEN]; /* magic string */ |
| 70 | uint16_t version; /* API version */ |
| 71 | uint32_t checksum; /* checksum of this sig struct */ |
| 72 | scp_t syscall; /* entry point to the API */ |
| 73 | }; |
| 74 | |
| 75 | enum { |
| 76 | API_RSVD = 0, |
| 77 | API_GETC, |
| 78 | API_PUTC, |
| 79 | API_TSTC, |
| 80 | API_PUTS, |
| 81 | API_RESET, |
| 82 | API_GET_SYS_INFO, |
| 83 | API_UDELAY, |
| 84 | API_GET_TIMER, |
| 85 | API_DEV_ENUM, |
| 86 | API_DEV_OPEN, |
| 87 | API_DEV_CLOSE, |
| 88 | API_DEV_READ, |
| 89 | API_DEV_WRITE, |
| 90 | API_ENV_ENUM, |
| 91 | API_ENV_GET, |
| 92 | API_ENV_SET, |
Che-Liang Chiou | 0d46041 | 2011-10-20 23:04:22 +0000 | [diff] [blame] | 93 | API_DISPLAY_GET_INFO, |
| 94 | API_DISPLAY_DRAW_BITMAP, |
| 95 | API_DISPLAY_CLEAR, |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 96 | API_MAXCALL |
| 97 | }; |
| 98 | |
| 99 | #define MR_ATTR_FLASH 0x0001 |
| 100 | #define MR_ATTR_DRAM 0x0002 |
| 101 | #define MR_ATTR_SRAM 0x0003 |
| 102 | |
| 103 | struct mem_region { |
| 104 | unsigned long start; |
| 105 | unsigned long size; |
| 106 | int flags; |
| 107 | }; |
| 108 | |
| 109 | struct sys_info { |
| 110 | unsigned long clk_bus; |
| 111 | unsigned long clk_cpu; |
| 112 | unsigned long bar; |
| 113 | struct mem_region *mr; |
| 114 | int mr_no; /* number of memory regions */ |
| 115 | }; |
| 116 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 117 | #undef CONFIG_SYS_64BIT_LBA |
| 118 | #ifdef CONFIG_SYS_64BIT_LBA |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 119 | typedef u_int64_t lbasize_t; |
| 120 | #else |
| 121 | typedef unsigned long lbasize_t; |
| 122 | #endif |
| 123 | typedef unsigned long lbastart_t; |
| 124 | |
| 125 | #define DEV_TYP_NONE 0x0000 |
| 126 | #define DEV_TYP_NET 0x0001 |
| 127 | |
| 128 | #define DEV_TYP_STOR 0x0002 |
| 129 | #define DT_STOR_IDE 0x0010 |
| 130 | #define DT_STOR_SCSI 0x0020 |
| 131 | #define DT_STOR_USB 0x0040 |
| 132 | #define DT_STOR_MMC 0x0080 |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 133 | #define DT_STOR_SATA 0x0100 |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 134 | |
| 135 | #define DEV_STA_CLOSED 0x0000 /* invalid, closed */ |
| 136 | #define DEV_STA_OPEN 0x0001 /* open i.e. active */ |
| 137 | |
| 138 | struct device_info { |
| 139 | int type; |
| 140 | void *cookie; |
| 141 | |
| 142 | union { |
| 143 | struct { |
| 144 | lbasize_t block_count; /* no of blocks */ |
| 145 | unsigned long block_size; /* size of one block */ |
| 146 | } storage; |
| 147 | |
| 148 | struct { |
| 149 | unsigned char hwaddr[6]; |
| 150 | } net; |
| 151 | } info; |
| 152 | #define di_stor info.storage |
| 153 | #define di_net info.net |
| 154 | |
| 155 | int state; |
| 156 | }; |
| 157 | |
Che-Liang Chiou | 0d46041 | 2011-10-20 23:04:22 +0000 | [diff] [blame] | 158 | #define DISPLAY_TYPE_LCD 0x0001 |
| 159 | #define DISPLAY_TYPE_VIDEO 0x0002 |
| 160 | |
| 161 | struct display_info { |
| 162 | int type; |
| 163 | /* screen size in pixels */ |
| 164 | int pixel_width; |
| 165 | int pixel_height; |
| 166 | /* screen size in rows and columns of text */ |
| 167 | int screen_rows; |
| 168 | int screen_cols; |
| 169 | }; |
| 170 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 171 | #endif /* _API_PUBLIC_H_ */ |