1/*-
2 * Copyright (c) 2012 M. Warner Losh.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#ifndef	__MACHINE_ATAGS_H__
30#define __MACHINE_ATAGS_H__
31
32/*
33 * Linux boot ABI compatable ATAG definitions.  All these structures
34 * assume tight packing, but since they are all uint32_t's, I've not
35 * bothered to do the usual alignment dance.
36 */
37
38#define	LBABI_MAX_COMMAND_LINE  1024
39
40struct arm_lbabi_header
41{
42	uint32_t	size;		/* Size of this node, including header */
43	uint32_t	tag;		/* Node type */
44};
45
46#define	ATAG_NONE       0x00000000	/* End of atags list */
47#define	ATAG_CORE	0x54410001	/* List must start with ATAG_CORE */
48#define	ATAG_MEM	0x54410002	/* Multiple ATAG_MEM nodes possible */
49#define	ATAG_VIDEOTEXT	0x54410003	/* Video parameters */
50#define	ATAG_RAMDISK	0x54410004	/* Describes the ramdisk parameters */
51#define	ATAG_INITRD	0x54410005	/* Deprecated ramdisk -- used va not pa */
52#define	ATAG_INITRD2	0x54420005	/* compressed ramdisk image */
53#define	ATAG_SERIAL	0x54410006	/* 64-bits of serial number */
54#define	ATAG_REVISION	0x54410007	/* Board revision */
55#define	ATAG_VIDEOLFB	0x54410008	/* vesafb framebuffer */
56#define	ATAG_CMDLINE	0x54410009	/* Command line */
57
58/*
59 * ATAG_CORE data
60 */
61struct arm_lbabi_core
62{
63	uint32_t flags;			/* bit 0 == read-only */
64	uint32_t pagesize;
65	uint32_t rootdev;
66};
67
68/*
69 * ATAG_MEM data -- Can be more than one to describe different
70 * banks.
71 */
72struct arm_lbabi_mem32
73{
74	uint32_t size;
75	uint32_t start;			/* start of physical memory */
76};
77
78/*
79 * ATAG_INITRD2 - Compressed ramdisk image details
80 */
81struct arm_lbabi_initrd
82{
83	uint32_t start;			/* pa of start */
84	uint32_t size;			/* How big the ram disk is */
85};
86
87/*
88 * ATAG_SERIAL - serial number
89 */
90struct arm_lbabi_serial_number
91{
92	uint32_t low;
93	uint32_t high;
94};
95
96/*
97 * ATAG_REVISION - board revision
98 */
99struct arm_lbabi_revision
100{
101	uint32_t rev;
102};
103
104/*
105 * ATAG_CMDLINE - Command line from uboot
106 */
107struct arm_lbabi_command_line
108{
109	char command[1];		/* Minimum command length */
110};
111
112struct arm_lbabi_tag
113{
114	struct arm_lbabi_header tag_hdr;
115	union {
116		struct arm_lbabi_core tag_core;
117		struct arm_lbabi_mem32 tag_mem;
118		struct arm_lbabi_initrd tag_initrd;
119		struct arm_lbabi_serial_number tag_sn;
120		struct arm_lbabi_revision tag_rev;
121		struct arm_lbabi_command_line tag_cmd;
122	} u;
123};
124
125#define	ATAG_TAG(a)  (a)->tag_hdr.tag
126#define ATAG_SIZE(a) ((a)->tag_hdr.size * sizeof(uint32_t))
127#define ATAG_NEXT(a) (struct arm_lbabi_tag *)((char *)(a) + ATAG_SIZE(a))
128
129#endif /* __MACHINE_ATAGS_H__ */
130