xref: /openbmc/qemu/hw/xtensa/bootparam.h (revision c719573d)
1 #ifndef HW_XTENSA_BOOTPARAM_H
2 #define HW_XTENSA_BOOTPARAM_H
3 
4 #include "exec/cpu-common.h"
5 
6 #define BP_TAG_COMMAND_LINE     0x1001  /* command line (0-terminated string)*/
7 #define BP_TAG_INITRD           0x1002  /* ramdisk addr and size (bp_meminfo) */
8 #define BP_TAG_MEMORY           0x1003  /* memory addr and size (bp_meminfo) */
9 #define BP_TAG_SERIAL_BAUDRATE  0x1004  /* baud rate of current console. */
10 #define BP_TAG_SERIAL_PORT      0x1005  /* serial device of current console */
11 #define BP_TAG_FDT              0x1006  /* flat device tree addr */
12 
13 #define BP_TAG_FIRST            0x7B0B  /* first tag with a version number */
14 #define BP_TAG_LAST             0x7E0B  /* last tag */
15 
16 typedef struct BpTag {
17     uint16_t tag;
18     uint16_t size;
19 } BpTag;
20 
21 typedef struct BpMemInfo {
22     uint32_t type;
23     uint32_t start;
24     uint32_t end;
25 } BpMemInfo;
26 
27 #define MEMORY_TYPE_CONVENTIONAL        0x1000
28 #define MEMORY_TYPE_NONE                0x2000
29 
30 static inline size_t get_tag_size(size_t data_size)
31 {
32     return data_size + sizeof(BpTag) + 4;
33 }
34 
35 static inline ram_addr_t put_tag(ram_addr_t addr, uint16_t tag,
36         size_t size, const void *data)
37 {
38     BpTag bp_tag = {
39         .tag = tswap16(tag),
40         .size = tswap16((size + 3) & ~3),
41     };
42 
43     cpu_physical_memory_write(addr, &bp_tag, sizeof(bp_tag));
44     addr += sizeof(bp_tag);
45     cpu_physical_memory_write(addr, data, size);
46     addr += (size + 3) & ~3;
47 
48     return addr;
49 }
50 
51 #endif
52