Tom Rini | 8b0c8a1 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */ |
Rafal Jaworowski | 9e1d16c | 2008-02-21 11:56:44 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007-2008 Semihalf |
| 4 | * |
| 5 | * Written by: Rafal Jaworowski <raj@semihalf.com> |
Rafal Jaworowski | 9e1d16c | 2008-02-21 11:56:44 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 8 | #ifndef _API_PUBLIC_H_ |
| 9 | #define _API_PUBLIC_H_ |
| 10 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 11 | #include <linux/types.h> |
| 12 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 13 | #define API_EINVAL 1 /* invalid argument(s) */ |
| 14 | #define API_ENODEV 2 /* no device */ |
| 15 | #define API_ENOMEM 3 /* no memory */ |
| 16 | #define API_EBUSY 4 /* busy, occupied etc. */ |
| 17 | #define API_EIO 5 /* I/O error */ |
Rafal Jaworowski | 6feb82d | 2009-01-23 13:27:18 +0100 | [diff] [blame] | 18 | #define API_ESYSC 6 /* syscall error */ |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 19 | |
| 20 | typedef int (*scp_t)(int, int *, ...); |
| 21 | |
| 22 | #define API_SIG_VERSION 1 |
| 23 | #define API_SIG_MAGIC "UBootAPI" |
| 24 | #define API_SIG_MAGLEN 8 |
| 25 | |
| 26 | struct api_signature { |
| 27 | char magic[API_SIG_MAGLEN]; /* magic string */ |
| 28 | uint16_t version; /* API version */ |
| 29 | uint32_t checksum; /* checksum of this sig struct */ |
| 30 | scp_t syscall; /* entry point to the API */ |
| 31 | }; |
| 32 | |
| 33 | enum { |
| 34 | API_RSVD = 0, |
| 35 | API_GETC, |
| 36 | API_PUTC, |
| 37 | API_TSTC, |
| 38 | API_PUTS, |
| 39 | API_RESET, |
| 40 | API_GET_SYS_INFO, |
| 41 | API_UDELAY, |
| 42 | API_GET_TIMER, |
| 43 | API_DEV_ENUM, |
| 44 | API_DEV_OPEN, |
| 45 | API_DEV_CLOSE, |
| 46 | API_DEV_READ, |
| 47 | API_DEV_WRITE, |
| 48 | API_ENV_ENUM, |
| 49 | API_ENV_GET, |
| 50 | API_ENV_SET, |
Che-Liang Chiou | 0d46041 | 2011-10-20 23:04:22 +0000 | [diff] [blame] | 51 | API_DISPLAY_GET_INFO, |
| 52 | API_DISPLAY_DRAW_BITMAP, |
| 53 | API_DISPLAY_CLEAR, |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 54 | API_MAXCALL |
| 55 | }; |
| 56 | |
| 57 | #define MR_ATTR_FLASH 0x0001 |
| 58 | #define MR_ATTR_DRAM 0x0002 |
| 59 | #define MR_ATTR_SRAM 0x0003 |
| 60 | |
| 61 | struct mem_region { |
| 62 | unsigned long start; |
| 63 | unsigned long size; |
| 64 | int flags; |
| 65 | }; |
| 66 | |
| 67 | struct sys_info { |
| 68 | unsigned long clk_bus; |
| 69 | unsigned long clk_cpu; |
| 70 | unsigned long bar; |
| 71 | struct mem_region *mr; |
| 72 | int mr_no; /* number of memory regions */ |
| 73 | }; |
| 74 | |
Marek BehĂșn | 706fa76 | 2021-03-06 23:43:22 +0100 | [diff] [blame] | 75 | /* |
| 76 | * FIXME: Previously this code was: |
| 77 | * |
| 78 | * #undef CONFIG_SYS_64BIT_LBA |
| 79 | * #ifdef CONFIG_SYS_64BIT_LBA |
| 80 | * typedef u_int64_t lbasize_t; |
| 81 | * #else |
| 82 | * typedef unsigned long lbasize_t; |
| 83 | * #endif |
| 84 | * |
| 85 | * But we cannot just undefine CONFIG_SYS_64BIT_LBA, because then in |
| 86 | * api/api_storage.c the type signature of lbaint_t will be different if |
| 87 | * CONFIG_SYS_64BIT_LBA is enabled for the board, which can result in various |
| 88 | * bugs. |
| 89 | * So simply define lbasize_t as an unsigned long, since this was what was done |
| 90 | * anyway for at least 13 years, but don't undefine CONFIG_SYS_64BIT_LBA. |
| 91 | */ |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 92 | typedef unsigned long lbasize_t; |
Marek BehĂșn | 706fa76 | 2021-03-06 23:43:22 +0100 | [diff] [blame] | 93 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 94 | typedef unsigned long lbastart_t; |
| 95 | |
| 96 | #define DEV_TYP_NONE 0x0000 |
| 97 | #define DEV_TYP_NET 0x0001 |
| 98 | |
| 99 | #define DEV_TYP_STOR 0x0002 |
| 100 | #define DT_STOR_IDE 0x0010 |
| 101 | #define DT_STOR_SCSI 0x0020 |
| 102 | #define DT_STOR_USB 0x0040 |
| 103 | #define DT_STOR_MMC 0x0080 |
Stefan Roese | 3762825 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 104 | #define DT_STOR_SATA 0x0100 |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 105 | |
| 106 | #define DEV_STA_CLOSED 0x0000 /* invalid, closed */ |
| 107 | #define DEV_STA_OPEN 0x0001 /* open i.e. active */ |
| 108 | |
| 109 | struct device_info { |
| 110 | int type; |
| 111 | void *cookie; |
| 112 | |
| 113 | union { |
| 114 | struct { |
| 115 | lbasize_t block_count; /* no of blocks */ |
| 116 | unsigned long block_size; /* size of one block */ |
| 117 | } storage; |
| 118 | |
| 119 | struct { |
| 120 | unsigned char hwaddr[6]; |
| 121 | } net; |
| 122 | } info; |
| 123 | #define di_stor info.storage |
| 124 | #define di_net info.net |
| 125 | |
| 126 | int state; |
| 127 | }; |
| 128 | |
Che-Liang Chiou | 0d46041 | 2011-10-20 23:04:22 +0000 | [diff] [blame] | 129 | #define DISPLAY_TYPE_LCD 0x0001 |
| 130 | #define DISPLAY_TYPE_VIDEO 0x0002 |
| 131 | |
| 132 | struct display_info { |
| 133 | int type; |
| 134 | /* screen size in pixels */ |
| 135 | int pixel_width; |
| 136 | int pixel_height; |
| 137 | /* screen size in rows and columns of text */ |
| 138 | int screen_rows; |
| 139 | int screen_cols; |
| 140 | }; |
| 141 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 142 | #endif /* _API_PUBLIC_H_ */ |