Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/nds32/include/asm/setup.h |
| 3 | * |
| 4 | * Copyright (C) 1997-1999 Russell King |
| 5 | * Copyright (C) 2008 Andes Technology Corporation |
| 6 | * Copyright (C) 2013 Ken Kuo (ken_kuo@andestech.com) |
| 7 | * Copyright (C) 2017 Rick Chen (rick@andestech.com) |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0 |
| 10 | * |
| 11 | * Structure passed to kernel to tell it about the |
| 12 | * hardware it's running on. See Documentation/arm/Setup |
| 13 | * for more info. |
| 14 | */ |
| 15 | #ifndef __RISCV_SETUP_H |
| 16 | #define __RISCV_SETUP_H |
| 17 | |
| 18 | #define COMMAND_LINE_SIZE 256 |
| 19 | |
| 20 | /* The list ends with an ATAG_NONE node. */ |
| 21 | #define ATAG_NONE 0x00000000 |
| 22 | |
| 23 | struct tag_header { |
| 24 | u32 size; |
| 25 | u32 tag; |
| 26 | }; |
| 27 | |
| 28 | /* The list must start with an ATAG_CORE node */ |
| 29 | #define ATAG_CORE 0x54410001 |
| 30 | |
| 31 | struct tag_core { |
| 32 | u32 flags; /* bit 0 = read-only */ |
| 33 | u32 pagesize; |
| 34 | u32 rootdev; |
| 35 | }; |
| 36 | |
| 37 | /* it is allowed to have multiple ATAG_MEM nodes */ |
| 38 | #define ATAG_MEM 0x54410002 |
| 39 | |
| 40 | struct tag_mem32 { |
| 41 | u32 size; |
| 42 | u32 start; /* physical start address */ |
| 43 | }; |
| 44 | |
| 45 | /* VGA text type displays */ |
| 46 | #define ATAG_VIDEOTEXT 0x54410003 |
| 47 | |
| 48 | struct tag_videotext { |
| 49 | u8 x; |
| 50 | u8 y; |
| 51 | u16 video_page; |
| 52 | u8 video_mode; |
| 53 | u8 video_cols; |
| 54 | u16 video_ega_bx; |
| 55 | u8 video_lines; |
| 56 | u8 video_isvga; |
| 57 | u16 video_points; |
| 58 | }; |
| 59 | |
| 60 | /* describes how the ramdisk will be used in kernel */ |
| 61 | #define ATAG_RAMDISK 0x54410004 |
| 62 | |
| 63 | struct tag_ramdisk { |
| 64 | u32 flags; /* bit 0 = load, bit 1 = prompt */ |
| 65 | u32 size; /* decompressed ramdisk size in _kilo_ bytes */ |
| 66 | u32 start; /* starting block of floppy-based RAM disk image */ |
| 67 | }; |
| 68 | |
| 69 | /* |
| 70 | * this one accidentally used virtual addresses - as such, |
| 71 | * it's deprecated. |
| 72 | * describes where the compressed ramdisk image lives (virtual address) |
| 73 | */ |
| 74 | #define ATAG_INITRD 0x54410005 |
| 75 | |
| 76 | /* describes where the compressed ramdisk image lives (physical address) */ |
| 77 | #define ATAG_INITRD2 0x54420005 |
| 78 | |
| 79 | struct tag_initrd { |
| 80 | u32 start; /* physical start address */ |
| 81 | u32 size; /* size of compressed ramdisk image in bytes */ |
| 82 | }; |
| 83 | |
| 84 | /* board serial number. "64 bits should be enough for everybody" */ |
| 85 | #define ATAG_SERIAL 0x54410006 |
| 86 | |
| 87 | struct tag_serialnr { |
| 88 | u32 low; |
| 89 | u32 high; |
| 90 | }; |
| 91 | |
| 92 | /* board revision */ |
| 93 | #define ATAG_REVISION 0x54410007 |
| 94 | |
| 95 | struct tag_revision { |
| 96 | u32 rev; |
| 97 | }; |
| 98 | |
| 99 | /* initial values for vesafb-type framebuffers. see struct screen_info |
| 100 | * in include/linux/tty.h |
| 101 | */ |
| 102 | #define ATAG_VIDEOLFB 0x54410008 |
| 103 | |
| 104 | struct tag_videolfb { |
| 105 | u16 lfb_width; |
| 106 | u16 lfb_height; |
| 107 | u16 lfb_depth; |
| 108 | u16 lfb_linelength; |
| 109 | u32 lfb_base; |
| 110 | u32 lfb_size; |
| 111 | u8 red_size; |
| 112 | u8 red_pos; |
| 113 | u8 green_size; |
| 114 | u8 green_pos; |
| 115 | u8 blue_size; |
| 116 | u8 blue_pos; |
| 117 | u8 rsvd_size; |
| 118 | u8 rsvd_pos; |
| 119 | }; |
| 120 | |
| 121 | /* command line: \0 terminated string */ |
| 122 | #define ATAG_CMDLINE 0x54410009 |
| 123 | |
| 124 | struct tag_cmdline { |
| 125 | char cmdline[COMMAND_LINE_SIZE]; |
| 126 | }; |
| 127 | |
| 128 | struct tag { |
| 129 | struct tag_header hdr; |
| 130 | union { |
| 131 | struct tag_core core; |
| 132 | struct tag_mem32 mem; |
| 133 | struct tag_videotext videotext; |
| 134 | struct tag_ramdisk ramdisk; |
| 135 | struct tag_initrd initrd; |
| 136 | struct tag_serialnr serialnr; |
| 137 | struct tag_revision revision; |
| 138 | struct tag_videolfb videolfb; |
| 139 | struct tag_cmdline cmdline; |
| 140 | } u; |
| 141 | }; |
| 142 | |
| 143 | struct tagtable { |
| 144 | u32 tag; |
| 145 | int (*parse)(const struct tag *); |
| 146 | }; |
| 147 | |
Rick Chen | 5febadd | 2018-02-12 11:07:58 +0800 | [diff] [blame] | 148 | #define tag_member_present(_tag, member) \ |
| 149 | typeof(_tag) (tag) = (_tag); \ |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 150 | ((unsigned long)(&((struct tag *)0L)->member + 1) \ |
| 151 | <= (tag)->hdr.size * 4) |
| 152 | |
Rick Chen | 5febadd | 2018-02-12 11:07:58 +0800 | [diff] [blame] | 153 | #define tag_next(_t) \ |
| 154 | typeof(_t) (t) = (_t); \ |
| 155 | ((struct tag *)((u32 *)(t) + (t)->hdr.size)) |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 156 | #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) |
| 157 | |
Rick Chen | 5febadd | 2018-02-12 11:07:58 +0800 | [diff] [blame] | 158 | #define for_each_tag(_t, base) \ |
| 159 | typeof(_t) (t) = (_t); \ |
Rick Chen | 76c0a24 | 2017-12-26 13:55:51 +0800 | [diff] [blame] | 160 | for (t = base; t->hdr.size; t = tag_next(t)) |
| 161 | |
| 162 | #ifdef __KERNEL__ |
| 163 | |
| 164 | #define __tag __used __attribute__((__section__(".taglist"))) |
| 165 | #define __tagtable(tag, fn) \ |
| 166 | static struct tagtable __tagtable_##fn __tag = { tag, fn } |
| 167 | |
| 168 | /* |
| 169 | * Memory map description |
| 170 | */ |
| 171 | #define NR_BANKS 8 |
| 172 | |
| 173 | struct meminfo { |
| 174 | int nr_banks; |
| 175 | struct { |
| 176 | unsigned long start; |
| 177 | unsigned long size; |
| 178 | int node; |
| 179 | } bank[NR_BANKS]; |
| 180 | }; |
| 181 | |
| 182 | /* |
| 183 | * Early command line parameters. |
| 184 | */ |
| 185 | struct early_params { |
| 186 | const char *arg; |
| 187 | void (*fn)(char **p); |
| 188 | }; |
| 189 | |
| 190 | #define __early_param(name, fn) \ |
| 191 | static struct early_params __early_##fn __used \ |
| 192 | __attribute__((__section__("__early_param"))) = { name, fn } |
| 193 | |
| 194 | #endif |
| 195 | #endif |