Home | History | Annotate | Line # | Download | only in rpi
vcprop.h revision 1.1
      1 /*	$NetBSD: vcprop.h,v 1.1 2012/10/14 16:16:52 skrll Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Nick Hudson
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Mailbox property interface
     34  */
     35 
     36 #ifndef	_EVBARM_RPI_VCPROP_H_
     37 #define	_EVBARM_RPI_VCPROP_H_
     38 
     39 struct vcprop_tag {
     40 	uint32_t vpt_tag;
     41 #define	VCPROPTAG_NULL			0x00000000
     42 #define	VCPROPTAG_GET_FIRMWAREREV	0x00000001
     43 #define	VCPROPTAG_GET_BOARDMODEL	0x00010001
     44 #define	VCPROPTAG_GET_BOARDREVISION	0x00010002
     45 #define	VCPROPTAG_GET_MACADDRESS	0x00010003
     46 #define	VCPROPTAG_GET_BOARDSERIAL	0x00010004
     47 #define	VCPROPTAG_GET_ARMMEMORY		0x00010005
     48 #define	VCPROPTAG_GET_VCMEMORY		0x00010006
     49 #define	VCPROPTAG_GET_CLOCKS		0x00010007
     50 
     51 #define	VCPROPTAG_GET_CMDLINE		0x00050001
     52 #define	VCPROPTAG_GET_DMACHAN		0x00060001
     53 	uint32_t vpt_len;
     54 	uint32_t vpt_rcode;
     55 #define	VCPROPTAG_REQUEST	(0U << 31)
     56 #define	VCPROPTAG_RESPONSE	(1U << 31)
     57 
     58 };
     59 
     60 #define VCPROPTAG_LEN(x) (sizeof((x)) - sizeof(struct vcprop_tag))
     61 
     62 struct vcprop_memory {
     63 	uint32_t base;
     64 	uint32_t size;
     65 };
     66 
     67 #define	VCPROP_MAXMEMBLOCKS 4
     68 struct vcprop_tag_memory {
     69 	struct vcprop_tag tag;
     70 	struct vcprop_memory mem[VCPROP_MAXMEMBLOCKS];
     71 };
     72 
     73 struct vcprop_tag_fwrev {
     74 	struct vcprop_tag tag;
     75 	uint32_t rev;
     76 };
     77 
     78 struct vcprop_tag_boardmodel {
     79 	struct vcprop_tag tag;
     80 	uint32_t model;
     81 } ;
     82 
     83 struct vcprop_tag_boardrev {
     84 	struct vcprop_tag tag;
     85 	uint32_t rev;
     86 } ;
     87 
     88 struct vcprop_tag_macaddr {
     89 	struct vcprop_tag tag;
     90 	uint64_t addr;
     91 };
     92 
     93 struct vcprop_tag_boardserial {
     94 	struct vcprop_tag tag;
     95 	uint64_t sn;
     96 };
     97 
     98 struct vcprop_clock {
     99 	uint32_t pclk;
    100 	uint32_t cclk;
    101 };
    102 
    103 #define	VCPROP_MAXCLOCKS 16
    104 struct vcprop_tag_clock {
    105 	struct vcprop_tag tag;
    106 	struct vcprop_clock clk[VCPROP_MAXCLOCKS];
    107 };
    108 
    109 #define	VCPROP_MAXCMDLINE 256
    110 struct vcprop_tag_cmdline {
    111 	struct vcprop_tag tag;
    112 	uint8_t cmdline[VCPROP_MAXCMDLINE];
    113 };
    114 
    115 struct vcprop_tag_dmachan {
    116 	struct vcprop_tag tag;
    117 	uint32_t mask;
    118 };
    119 
    120 struct vcprop_buffer_hdr {
    121 	uint32_t vpb_len;
    122 	uint32_t vpb_rcode;
    123 #define	VCPROP_PROCESS_REQUEST 0
    124 #define VCPROP_REQ_SUCCESS	(1U << 31)
    125 #define VCPROP_REQ_EPARSE	(1U << 0)
    126 };
    127 
    128 static inline bool
    129 vcprop_buffer_success_p(struct vcprop_buffer_hdr *vpbh)
    130 {
    131 
    132 	return (vpbh->vpb_rcode & VCPROP_REQ_SUCCESS);
    133 }
    134 
    135 static inline bool
    136 vcprop_tag_success_p(struct vcprop_tag *vpbt)
    137 {
    138 
    139 	return (vpbt->vpt_rcode & VCPROPTAG_RESPONSE);
    140 }
    141 
    142 static inline size_t
    143 vcprop_tag_resplen(struct vcprop_tag *vpbt)
    144 {
    145 
    146 	return (vpbt->vpt_rcode & ~VCPROPTAG_RESPONSE);
    147 }
    148 
    149 #endif	/* _EVBARM_RPI_VCPROP_H_ */
    150