cvmx-sysinfo.h revision 232812
1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights 3 * reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 18 * * Neither the name of Cavium Inc. nor the names of 19 * its contributors may be used to endorse or promote products 20 * derived from this software without specific prior written 21 * permission. 22 23 * This Software, including technical data, may be subject to U.S. export control 24 * laws, including the U.S. Export Administration Act and its associated 25 * regulations, and may be subject to export or import regulations in other 26 * countries. 27 28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 38 ***********************license end**************************************/ 39 40 41/** 42 * @file 43 * 44 * This module provides system/board information obtained by the bootloader. 45 * 46 * <hr>$Revision: 70030 $<hr> 47 * 48 */ 49 50 51#ifndef __CVMX_SYSINFO_H__ 52#define __CVMX_SYSINFO_H__ 53 54#ifndef CVMX_BUILD_FOR_LINUX_KERNEL 55#include "cvmx-app-init.h" 56#endif 57 58#ifdef __cplusplus 59extern "C" { 60#endif 61 62#define OCTEON_SERIAL_LEN 20 63/** 64 * Structure describing application specific information. 65 * __cvmx_app_init() populates this from the cvmx boot descriptor. 66 * This structure is private to simple executive applications, so no 67 * versioning is required. 68 * 69 * This structure must be provided with some fields set in order to 70 * use simple executive functions in other applications (Linux kernel, 71 * u-boot, etc.) The cvmx_sysinfo_minimal_initialize() function is 72 * provided to set the required values in these cases. 73 * 74 */ 75struct cvmx_sysinfo { 76 /* System wide variables */ 77 uint64_t system_dram_size; /**< installed DRAM in system, in bytes */ 78 uint64_t phy_mem_desc_addr; /**< Address of the memory descriptor block */ 79 80 /* Application image specific variables */ 81 uint64_t stack_top; /**< stack top address (virtual) */ 82 uint64_t heap_base; /**< heap base address (virtual) */ 83 uint32_t stack_size; /**< stack size in bytes */ 84 uint32_t heap_size; /**< heap size in bytes */ 85 uint32_t core_mask; /**< coremask defining cores running application */ 86 uint32_t init_core; /**< Deprecated, use cvmx_coremask_first_core() to select init core */ 87 uint64_t exception_base_addr; /**< exception base address, as set by bootloader */ 88 uint32_t cpu_clock_hz; /**< cpu clock speed in hz */ 89 uint32_t dram_data_rate_hz; /**< dram data rate in hz (data rate = 2 * clock rate */ 90 91 uint16_t board_type; 92 uint8_t board_rev_major; 93 uint8_t board_rev_minor; 94 uint8_t mac_addr_base[6]; 95 uint8_t mac_addr_count; 96 char board_serial_number[OCTEON_SERIAL_LEN]; 97 /* 98 * Several boards support compact flash on the Octeon boot 99 * bus. The CF memory spaces may be mapped to different 100 * addresses on different boards. These values will be 0 if 101 * CF is not present. Note that these addresses are physical 102 * addresses, and it is up to the application to use the 103 * proper addressing mode (XKPHYS, KSEG0, etc.) 104 */ 105 uint64_t compact_flash_common_base_addr; 106 uint64_t compact_flash_attribute_base_addr; 107 /* 108 * Base address of the LED display (as on EBT3000 board) This 109 * will be 0 if LED display not present. Note that this 110 * address is a physical address, and it is up to the 111 * application to use the proper addressing mode (XKPHYS, 112 * KSEG0, etc.) 113 */ 114 uint64_t led_display_base_addr; 115 uint32_t dfa_ref_clock_hz; /**< DFA reference clock in hz (if applicable)*/ 116 uint32_t bootloader_config_flags; /**< configuration flags from bootloader */ 117 uint8_t console_uart_num; /** < Uart number used for console */ 118 uint64_t fdt_addr; /** pointer to device tree */ 119}; 120 121#ifndef CVMX_BUILD_FOR_LINUX_KERNEL 122typedef struct cvmx_sysinfo cvmx_sysinfo_t; 123#endif 124 125/** 126 * This function returns the system/board information as obtained 127 * by the bootloader. 128 * 129 * 130 * @return Pointer to the boot information structure 131 * 132 */ 133 134extern struct cvmx_sysinfo *cvmx_sysinfo_get(void); 135 136/** 137 * This function adds the current cpu to sysinfo coremask 138 * 139 */ 140 141void cvmx_sysinfo_add_self_to_core_mask(void); 142 143/** 144 * This function removes the current cpu to sysinfo coremask 145 * 146 */ 147void cvmx_sysinfo_remove_self_from_core_mask(void); 148 149#ifndef CVMX_BUILD_FOR_LINUX_KERNEL 150/** 151 * This function is used in non-simple executive environments (such as Linux kernel, u-boot, etc.) 152 * to configure the minimal fields that are required to use 153 * simple executive files directly. 154 * 155 * Locking (if required) must be handled outside of this 156 * function 157 * 158 * @param phy_mem_desc_addr 159 * Address of the global physical memory descriptor (bootmem 160 * descriptor) 161 * @param board_type Octeon board type enumeration 162 * 163 * @param board_rev_major 164 * Board major revision 165 * @param board_rev_minor 166 * Board minor revision 167 * @param cpu_clock_hz 168 * CPU clock freqency in hertz 169 * 170 * @return 0: Failure 171 * 1: success 172 */ 173extern int cvmx_sysinfo_minimal_initialize(uint64_t phy_mem_desc_addr, uint16_t board_type, uint8_t board_rev_major, 174 uint8_t board_rev_minor, uint32_t cpu_clock_hz); 175#endif 176 177#ifdef CVMX_BUILD_FOR_LINUX_USER 178/** 179 * Initialize the sysinfo structure when running on 180 * Octeon under Linux userspace 181 */ 182extern void cvmx_sysinfo_linux_userspace_initialize(void); 183#endif 184 185#ifdef __cplusplus 186} 187#endif 188 189#endif /* __CVMX_SYSINFO_H__ */ 190