text
stringlengths
12
867k
// // ZSUserHeadBtn.h // HandsUp // // Created by wanghui on 2018/6/22. // Copyright © 2018年 HandsUp.Network. All rights reserved. // #import <UIKit/UIKit.h> @interface ZSUserHeadBtn : UIButton @end
/** * \file * * \brief SAME70-XPLD Board Definition. * * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries. * * \asf_license_start * * \page License * * Subject to your compliance with these terms, you may use Microchip * software and any derivatives exclusively with Microchip products. * It is your responsibility to comply with third party license terms applicable * to your use of third party software (including open source software) that * may accompany Microchip software. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. * * \asf_license_stop * */ /* * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a> */ #ifndef _SAME70_XPLD_H_ #define _SAME70_XPLD_H_ #include "compiler.h" //#include "system_same70.h" void system_board_init(void); /** * \page same70_xplained_pro_opfreq "SAME70-XPLD - Operating frequencies" * This page lists several definition related to the board operating frequency * * \section Definitions * - \ref BOARD_FREQ_* * - \ref BOARD_MCK */ /** Board oscillator settings */ #define BOARD_FREQ_SLCK_XTAL (32768U) #define BOARD_FREQ_SLCK_BYPASS (32768U) #define BOARD_FREQ_MAINCK_XTAL (12000000U) #define BOARD_FREQ_MAINCK_BYPASS (12000000U) /** Master clock frequency */ #define BOARD_MCK CHIP_FREQ_CPU_MAX /** board main clock xtal statup time */ #define BOARD_OSC_STARTUP_US 15625 /*----------------------------------------------------------------------------*/ /** * \page same70_xplained_info "SAME70-XPLD - Board informations" * This page lists several definition related to the board description. * * \section Definitions * - \ref BOARD_NAME */ /** Name of the board */ #define BOARD_NAME "SAME70-XPLD" /** Board definition */ #define same70xpld /** Family definition (already defined) */ #define same70 /** Core definition */ #define cortexm7 /*----------------------------------------------------------------------------*/ #define CONSOLE_UART USART1 #define CONSOLE_UART_ID ID_USART1 /** USART1 pins definitions, PA21,PB4. */ #define USART1_RXD_GPIO PIO_PA21_IDX #define USART1_RXD_FLAGS IOPORT_MODE_MUX_A #define USART1_TXD_GPIO PIO_PB4_IDX #define USART1_TXD_FLAGS IOPORT_MODE_MUX_D /** USART0 pins definitions, PB0,PB1. */ #define USART0_RXD_GPIO PIO_PB0_IDX #define USART0_RXD_FLAGS IOPORT_MODE_MUX_C #define USART0_TXD_GPIO PIO_PB1_IDX #define USART0_TXD_FLAGS IOPORT_MODE_MUX_C #define PIN_USART0_SCK_IDX (PIO_PB13_IDX) #define PIN_USART0_SCK_FLAGS (IOPORT_MODE_MUX_C) /** USART0 pin CTS */ #define PIN_USART0_CTS_IDX (PIO_PB2_IDX) #define PIN_USART0_CTS_FLAGS (IOPORT_MODE_MUX_C) /** USART0 pin RTS */ #define PIN_USART0_RTS_IDX (PIO_PB3_IDX) #define PIN_USART0_RTS_FLAGS (IOPORT_MODE_MUX_C) //! \name LED definitions //@{ #define LED0_GPIO (PIO_PC8_IDX) #define LED0_FLAGS (0) #define LED0_ACTIVE_LEVEL (IOPORT_PIN_LEVEL_LOW) #define LED0_INACTIVE_LEVEL (IOPORT_PIN_LEVEL_HIGH) #define LED_COUNT (1) //@} //! \name SW0 definitions //@{ #define SW0_PIN (PIO_PA11_IDX) #define SW0_ACTIVE (IOPORT_PIN_LEVEL_LOW) #define SW0_INACTIVE (!SW0_ACTIVE) #define SW0_SUPC_INPUT 2 /** * Wrapper macros for SW0, to ensure common naming across all Xplained * boards. */ #define PIN_SW0 {PIO_PA11, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE} #define PIN_SW0_MASK PIO_PA11 #define PIN_SW0_PIO PIOA #define PIN_SW0_ID ID_PIOA #define PIN_SW0_TYPE PIO_INPUT #define PIN_SW0_ATTR (PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE) //@} /** * \name LED #0 definitions * * Wrapper macros for LED0, to ensure common naming across all Xplained * boards. */ //@{ #define LED_0_NAME "LED0 (yellow)" #define LED_0_PIN LED0_GPIO #define LED_0_ACTIVE LED0_ACTIVE_LEVEL #define LED_0_INACTIVE LED0_INACTIVE_LEVEL #define PIN_LED_0 {PIO_PC8, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT} #define PIN_LED_0_MASK PIO_PC8 #define PIN_LED_0_PIO PIOC #define PIN_LED_0_ID ID_PIOC #define PIN_LED_0_TYPE PIO_OUTPUT_1 #define PIN_LED_0_ATTR PIO_DEFAULT //@} /* TC-- Timer Count */ #define PIN_TC0_TIOA0 (PIO_PA0_IDX) #define PIN_TC0_TIOA0_MUX (IOPORT_MODE_MUX_B) #define PIN_TC0_TIOA0_FLAGS (IOPORT_MODE_MUX_B) #define PIN_TC0_TIOA0_PIO PIOA #define PIN_TC0_TIOA0_MASK PIO_PA0 #define PIN_TC0_TIOA0_ID ID_PIOA #define PIN_TC0_TIOA0_TYPE PIO_PERIPH_B #define PIN_TC0_TIOA0_ATTR PIO_DEFAULT #define PIN_TC3_TIOA11 (PIO_PD21_IDX) #define PIN_TC3_TIOA11_MUX (IOPORT_MODE_MUX_C) #define PIN_TC3_TIOA11_FLAGS (IOPORT_MODE_MUX_C) #define PIN_TC3_TIOA11_PIO PIOD #define PIN_TC3_TIOA11_MASK PIO_PD21 #define PIN_TC3_TIOA11_ID ID_PIOD #define PIN_TC3_TIOA11_TYPE PIO_PERIPH_C #define PIN_TC3_TIOA11_ATTR PIO_DEFAULT //! Number of on-board LEDs #define BOARD_NUM_OF_LED 1 /** * Push button #0 definition. Attributes = pull-up + debounce + interrupt on * rising edge. */ #define BUTTON_0_NAME "SW0" #define BUTTON_0_PIN SW0_PIN #define BUTTON_0_ACTIVE SW0_ACTIVE #define BUTTON_0_INACTIVE SW0_INACTIVE #define BUTTON_0_SUPC_INPUT SW0_SUPC_INPUT #define GPIO_PUSH_BUTTON_0 BUTTON_0_PIN #define PUSHBUTTON_1_NAME "SW0" #define PUSHBUTTON_1_WKUP_LINE (2) #define PUSHBUTTON_1_WKUP_FSTT (PMC_FSMR_FSTT2) #define GPIO_PUSH_BUTTON_1 (PIO_PA11_IDX) #define GPIO_PUSH_BUTTON_1_FLAGS (IOPORT_MODE_PULLUP | IOPORT_MODE_DEBOUNCE) #define GPIO_PUSH_BUTTON_1_SENSE (IOPORT_SENSE_RISING) #define PIN_PUSHBUTTON_1 {PIO_PA11, PIOA, ID_PIOA, PIO_INPUT, \ PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE} #define PIN_PUSHBUTTON_1_MASK PIO_PA11 #define PIN_PUSHBUTTON_1_PIO PIOA #define PIN_PUSHBUTTON_1_ID ID_PIOA #define PIN_PUSHBUTTON_1_TYPE PIO_INPUT #define PIN_PUSHBUTTON_1_ATTR (PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE) #define PIN_PUSHBUTTON_1_IRQn PIOA_IRQn /** List of all push button definitions. */ #define PINS_PUSHBUTTONS {PIN_PUSHBUTTON_1} //! \name Extension header #1 pin definitions //@{ #define EXT1_PIN_3 PIO_PC31_IDX #define EXT1_PIN_4 PIO_PA19_IDX #define EXT1_PIN_5 PIO_PB3_IDX #define EXT1_PIN_6 PIO_PB2_IDX #define EXT1_PIN_7 PIO_PA0_IDX #define EXT1_PIN_8 PIO_PC30_IDX #define EXT1_PIN_9 PIO_PD28_IDX #define EXT1_PIN_10 PIO_PC17_IDX #define EXT1_PIN_11 PIO_PA3_IDX #define EXT1_PIN_12 PIO_PA4_IDX #define EXT1_PIN_13 PIO_PB0_IDX #define EXT1_PIN_14 PIO_PB1_IDX #define EXT1_PIN_15 PIO_PD25_IDX #define EXT1_PIN_16 PIO_PD21_IDX #define EXT1_PIN_17 PIO_PD20_IDX #define EXT1_PIN_18 PIO_PD22_IDX //@} //! \name Extension header #1 pin definitions by function //@{ #define EXT1_PIN_ADC_0 EXT1_PIN_3 #define EXT1_PIN_ADC_1 EXT1_PIN_4 #define EXT1_PIN_GPIO_0 EXT1_PIN_5 #define EXT1_PIN_GPIO_1 EXT1_PIN_6 #define EXT1_PIN_PWM_0 EXT1_PIN_7 #define EXT1_PIN_PWM_1 EXT1_PIN_8 #define EXT1_PIN_IRQ EXT1_PIN_9 #define EXT1_PIN_TWI_SDA EXT1_PIN_11 #define EXT1_PIN_TWI_SCL EXT1_PIN_12 #define EXT1_PIN_UART_RX EXT1_PIN_13 #define EXT1_PIN_UART_TX EXT1_PIN_14 #define EXT1_PIN_SPI_SS_1 EXT1_PIN_10 #define EXT1_PIN_SPI_SS_0 EXT1_PIN_15 #define EXT1_PIN_SPI_MOSI EXT1_PIN_16 #define EXT1_PIN_SPI_MISO EXT1_PIN_17 #define EXT1_PIN_SPI_SCK EXT1_PIN_18 //@} //! \name Extension header #2 pin definitions //@{ #define EXT2_PIN_3 PIO_PD30_IDX #define EXT2_PIN_4 PIO_PC13_IDX #define EXT2_PIN_5 PIO_PA6_IDX #define EXT2_PIN_6 PIO_PD11_IDX #define EXT2_PIN_7 PIO_PC19_IDX #define EXT2_PIN_8 PIO_PD26_IDX #define EXT2_PIN_9 PIO_PA2_IDX #define EXT2_PIN_10 PIO_PA24_IDX #define EXT2_PIN_11 PIO_PA3_IDX #define EXT2_PIN_12 PIO_PA4_IDX #define EXT2_PIN_13 PIO_PA21_IDX #define EXT2_PIN_14 PIO_PB4_IDX #define EXT2_PIN_15 PIO_PD27_IDX #define EXT2_PIN_16 PIO_PD21_IDX #define EXT2_PIN_17 PIO_PD20_IDX #define EXT2_PIN_18 PIO_PD22_IDX //@} //! \name Extension header #2 pin definitions by function //@{ #define EXT2_PIN_ADC_0 EXT2_PIN_3 #define EXT2_PIN_ADC_1 EXT2_PIN_4 #define EXT2_PIN_GPIO_0 EXT2_PIN_5 #define EXT2_PIN_GPIO_1 EXT2_PIN_6 #define EXT2_PIN_PWM_0 EXT2_PIN_7 #define EXT2_PIN_PWM_1 EXT2_PIN_8 #define EXT2_PIN_IRQ EXT2_PIN_9 #define EXT2_PIN_TWI_SDA EXT2_PIN_11 #define EXT2_PIN_TWI_SCL EXT2_PIN_12 #define EXT2_PIN_UART_RX EXT2_PIN_13 #define EXT2_PIN_UART_TX EXT2_PIN_14 #define EXT2_PIN_SPI_SS_1 EXT2_PIN_10 #define EXT2_PIN_SPI_SS_0 EXT2_PIN_15 #define EXT2_PIN_SPI_MOSI EXT2_PIN_16 #define EXT2_PIN_SPI_MISO EXT2_PIN_17 #define EXT2_PIN_SPI_SCK EXT2_PIN_18 //@} /** PCK0 pin definition (PA6) */ #define PIN_PCK0 (PIO_PA6_IDX) #define PIN_PCK0_MUX (IOPORT_MODE_MUX_B) #define PIN_PCK0_FLAGS (IOPORT_MODE_MUX_B) #define PIN_PCK0_PORT IOPORT_PIOA #define PIN_PCK0_MASK PIO_PA6B_PCK0 #define PIN_PCK0_PIO PIOA #define PIN_PCK0_ID ID_PIOA #define PIN_PCK0_TYPE PIO_PERIPH_B #define PIN_PCK0_ATTR PIO_DEFAULT /** TWI0 pins definition */ #define TWIHS0_DATA_GPIO PIO_PA3_IDX #define TWIHS0_DATA_FLAGS (IOPORT_MODE_MUX_A) #define TWIHS0_CLK_GPIO PIO_PA4_IDX #define TWIHS0_CLK_FLAGS (IOPORT_MODE_MUX_A) /** SPI0 pins definition */ #define SPI0_MISO_GPIO PIO_PD20_IDX #define SPI0_MISO_FLAGS (IOPORT_MODE_MUX_B) #define SPI0_MOSI_GPIO PIO_PD21_IDX #define SPI0_MOSI_FLAGS (IOPORT_MODE_MUX_B) #define SPI0_NPCS0_GPIO PIO_PB2_IDX #define SPI0_NPCS0_FLAGS (IOPORT_MODE_MUX_D) #define SPI0_NPCS1_GPIO PIO_PD25_IDX #define SPI0_NPCS1_FLAGS (IOPORT_MODE_MUX_B) #define SPI0_NPCS2_GPIO PIO_PD12_IDX #define SPI0_NPCS2_FLAGS (IOPORT_MODE_MUX_C) #define SPI0_NPCS3_GPIO PIO_PD27_IDX #define SPI0_NPCS3_FLAGS (IOPORT_MODE_MUX_B) #define SPI0_SPCK_GPIO PIO_PD22_IDX #define SPI0_SPCK_FLAGS (IOPORT_MODE_MUX_B) /** QSPI pins definition */ #define QSPI_QSCK_GPIO PIO_PA14_IDX #define QSPI_QSCK_FLAGS (IOPORT_MODE_MUX_A) #define QSPI_QCS_GPIO PIO_PA11_IDX #define QSPI_QCS_FLAGS (IOPORT_MODE_MUX_A) #define QSPI_QIO0_GPIO PIO_PA13_IDX #define QSPI_QIO0_FLAGS (IOPORT_MODE_MUX_A) #define QSPI_QIO1_GPIO PIO_PA12_IDX #define QSPI_QIO1_FLAGS (IOPORT_MODE_MUX_A) #define QSPI_QIO2_GPIO PIO_PA17_IDX #define QSPI_QIO2_FLAGS (IOPORT_MODE_MUX_A) #define QSPI_QIO3_GPIO PIO_PD31_IDX #define QSPI_QIO3_FLAGS (IOPORT_MODE_MUX_A) /** AFEC channel for potentiometer */ #define AFEC_CHANNEL_POTENTIOMETER AFEC_CHANNEL_0 #define MCAN_MODULE MCAN1 /*----------------------------------------------------------------------------*/ /** * \page same70_xpld_CAN "SAME70-XPLD - CAN" * This page lists definitions related to CAN0 and CAN1. * * CAN * - \ref PIN_CAN0_TRANSCEIVER_RXEN * - \ref PIN_CAN0_TRANSCEIVER_RS * - \ref PIN_CAN0_TXD * - \ref PIN_CAN0_RXD * - \ref PINS_CAN0 * * - \ref PIN_CAN1_TRANSCEIVER_RXEN * - \ref PIN_CAN1_TRANSCEIVER_RS * - \ref PIN_CAN1_TXD * - \ref PIN_CAN1_RXD * - \ref PINS_CAN1 */ /** CAN0 transceiver PIN RS. */ #define PIN_CAN0_TR_RS_IDX PIO_PE0_IDX #define PIN_CAN0_TR_RS_FLAGS IOPORT_DIR_OUTPUT /** CAN0 transceiver PIN EN. */ #define PIN_CAN0_TR_EN_IDX PIO_PE1_IDX #define PIN_CAN0_TR_EN_FLAGS IOPORT_DIR_OUTPUT /** CAN0 PIN RX. */ #define PIN_CAN0_RX_IDX PIO_PB3_IDX #define PIN_CAN0_RX_FLAGS IOPORT_MODE_MUX_A /** CAN0 PIN TX. */ #define PIN_CAN0_TX_IDX PIO_PB2_IDX #define PIN_CAN0_TX_FLAGS IOPORT_MODE_MUX_A /** CAN1 transceiver PIN RS. */ #define PIN_CAN1_TR_RS_IDX PIO_PE2_IDX #define PIN_CAN1_TR_RS_FLAGS IOPORT_DIR_OUTPUT /** CAN1 transceiver PIN EN. */ #define PIN_CAN1_TR_EN_IDX PIO_PE3_IDX #define PIN_CAN1_TR_EN_FLAGS IOPORT_DIR_OUTPUT /** CAN1 PIN RX. */ #define PIN_CAN1_RX_IDX PIO_PC12_IDX #define PIN_CAN1_RX_FLAGS IOPORT_MODE_MUX_C /** CAN1 PIN TX. */ #define PIN_CAN1_TX_IDX PIO_PC14_IDX #define PIN_CAN1_TX_FLAGS IOPORT_MODE_MUX_C /** PWM LED0 pin definitions. */ #define PIN_PWM_LED0_GPIO PIO_PA23_IDX #define PIN_PWM_LED0_FLAGS (IOPORT_MODE_MUX_B) #define PIN_PWM_LED0_CHANNEL PWM_CHANNEL_0 /** PWM LED1 pin definitions. */ #define PIN_PWM_LED1_GPIO PIO_PA24_IDX #define PIN_PWM_LED1_FLAGS (IOPORT_MODE_MUX_B) #define PIN_PWM_LED1_CHANNEL PWM_CHANNEL_1 /*----------------------------------------------------------------------------*/ /** GMAC HW configurations */ #define BOARD_GMAC_PHY_ADDR 0 #define PIN_GMAC_RESET_MASK PIO_PC10 #define PIN_GMAC_RESET_PIO PIOC #define PIN_GMAC_INT_MASK PIO_PA14 #define PIN_GMAC_INT_PIO PIOA #define PIN_GMAC_PERIPH PIO_PERIPH_A #define PIN_GMAC_PIO PIOD #define PIN_GMAC_MASK (PIO_PD0A_GTXCK | PIO_PD1A_GTXEN | PIO_PD2A_GTX0 | \ PIO_PD3A_GTX1 | PIO_PD4A_GRXDV | PIO_PD5A_GRX0 | \ PIO_PD6A_GRX1 | PIO_PD7A_GRXER | PIO_PD8A_GMDC | \ PIO_PD9A_GMDIO) /** Board configuration of the AT24MAC EEPROM */ #define BOARD_AT24MAC_TWIHS TWIHS0 //#define BOARD_AT24MAC_ADDRESS (0xBE >> 1) #define BOARD_AT24MAC_TWIHS_CLK (400000UL) #define BOARD_AT24MAC_PAGE_SIZE 16 #define BOARD_AT24MAC_TWIHS_INSTANCE TWIHS0 #define BOARD_AT24MAC_ADDRESS (0xAE >> 1) #define BOARD_CLK_TWIHS_EEPROM PIO_PA4 /** HSMCI pins definition. */ /*! Number of slot connected on HSMCI interface */ #define SD_MMC_HSMCI_MEM_CNT 1 #define SD_MMC_HSMCI_SLOT_0_SIZE 4 /** HSMCI MCCDA pin definition. */ #define PIN_HSMCI_MCCDA_GPIO (PIO_PA28_IDX) #define PIN_HSMCI_MCCDA_FLAGS (IOPORT_MODE_MUX_C) /** HSMCI MCCK pin definition. */ #define PIN_HSMCI_MCCK_GPIO (PIO_PA25_IDX) #define PIN_HSMCI_MCCK_FLAGS (IOPORT_MODE_MUX_D) /** HSMCI MCDA0 pin definition. */ #define PIN_HSMCI_MCDA0_GPIO (PIO_PA30_IDX) #define PIN_HSMCI_MCDA0_FLAGS (IOPORT_MODE_MUX_C) /** HSMCI MCDA1 pin definition. */ #define PIN_HSMCI_MCDA1_GPIO (PIO_PA31_IDX) #define PIN_HSMCI_MCDA1_FLAGS (IOPORT_MODE_MUX_C) /** HSMCI MCDA2 pin definition. */ #define PIN_HSMCI_MCDA2_GPIO (PIO_PA26_IDX) #define PIN_HSMCI_MCDA2_FLAGS (IOPORT_MODE_MUX_C) /** HSMCI MCDA3 pin definition. */ #define PIN_HSMCI_MCDA3_GPIO (PIO_PA27_IDX) #define PIN_HSMCI_MCDA3_FLAGS (IOPORT_MODE_MUX_C) /** SD/MMC card detect pin definition. */ #define PIN_HSMCI_CD {PIO_PC16, PIOD, ID_PIOD, PIO_INPUT, PIO_PULLUP} #define SD_MMC_0_CD_GPIO (PIO_PC16_IDX) #define SD_MMC_0_CD_PIO_ID ID_PIOD #define SD_MMC_0_CD_FLAGS (IOPORT_MODE_PULLUP) #define SD_MMC_0_CD_DETECT_VALUE 0 /** EBI pins configuration for LCD */ /** LCD reset pin */ #define PIN_EBI_RESET_MASK PIO_PC13 #define PIN_EBI_RESET_PIO PIOC #define PIN_EBI_RESET_TYPE PIO_OUTPUT_1 #define PIN_EBI_RESET_ATTRI PIO_DEFAULT /** LCD command/data select pin */ #define PIN_EBI_CDS_MASK PIO_PC30 #define PIN_EBI_CDS_PIO PIOC #define PIN_EBI_CDS_TYPE PIO_OUTPUT_1 #define PIN_EBI_CDS_ATTRI PIO_DEFAULT /** LCD data pin */ #define PIN_EBI_DATAL_MASK 0xFF #define PIN_EBI_DATAL_PIO PIOC #define PIN_EBI_DATAL_TYPE PIO_PERIPH_A #define PIN_EBI_DATAL_ATTRI PIO_PULLUP #define PIN_EBI_DATAH_0_MASK 0x3F #define PIN_EBI_DATAH_0_PIO PIOE #define PIN_EBI_DATAH_0_TYPE PIO_PERIPH_A #define PIN_EBI_DATAH_0_ATTRI PIO_PULLUP #define PIN_EBI_DATAH_1_MASK (PIO_PA15A_D14|PIO_PA16A_D15) #define PIN_EBI_DATAH_1_PIO PIOA #define PIN_EBI_DATAH_1_TYPE PIO_PERIPH_A #define PIN_EBI_DATAH_1_ATTRI PIO_PULLUP /** LCD WE pin */ #define PIN_EBI_NWE_MASK PIO_PC8A_NWE #define PIN_EBI_NWE_PIO PIOC #define PIN_EBI_NWE_TYPE PIO_PERIPH_A #define PIN_EBI_NWE_ATTRI PIO_PULLUP /** LCD RD pin */ #define PIN_EBI_NRD_MASK PIO_PC11A_NRD #define PIN_EBI_NRD_PIO PIOC #define PIN_EBI_NRD_TYPE PIO_PERIPH_A #define PIN_EBI_NRD_ATTRI PIO_PULLUP /** LCD CS pin (NCS3) */ #define PIN_EBI_CS_MASK PIO_PD19A_NCS3 #define PIN_EBI_CS_PIO PIOD #define PIN_EBI_CS_TYPE PIO_PERIPH_A #define PIN_EBI_CS_ATTRI PIO_PULLUP /** Back-light pin definition. */ #define PIN_EBI_BACKLIGHT_MASK PIO_PC9B_TIOB7 #define PIN_EBI_BACKLIGHT_PIO PIOC #define PIN_EBI_BACKLIGHT_TYPE PIO_PERIPH_B #define PIN_EBI_BACKLIGHT_ATTRI PIO_DEFAULT /*! \name GPIO Connections of VBUS monitoring */ //! @{ #define USB_VBUS_FLAGS (PIO_INPUT | PIO_PULLUP) #define USB_VBUS_PIN PIO_PC9_IDX /* As IO pin input */ #define USB_VBUS_PIN_IRQn ( PIOC_IRQn) #define USB_VBUS_PIO_ID ID_PIOC #define USB_VBUS_PIO_MASK PIO_PC9 //! @} /*! \name GPIO Connections of ID detecting */ //! @{ #define USB_ID_FLAGS (PIO_INPUT | PIO_PULLUP) #define USB_ID_PIN PIO_PC16_IDX /* As IO pin input */ #define USB_ID_PIN_IRQn (PIOC_IRQn) #define USB_ID_PIO_ID ID_PIOC #define USB_ID_PIO_MASK PIO_PC16 //! @} /** WM8904 Slave address */ #define WM8904_SLAVE_ADDRESS (0x34 >> 1) /** TWI interface for WM8904 */ #define WM8904_TWIHS TWIHS0 /** WM8904 pins definition */ #define WM8904_TK_PIO PIO_PB1_IDX #define WM8904_TK_FLAGS PIO_PERIPH_D #define WM8904_TF_PIO PIO_PB0_IDX #define WM8904_TF_FLAGS PIO_PERIPH_D #define WM8904_TD_PIO PIO_PD26_IDX #define WM8904_TD_FLAGS PIO_PERIPH_B #define WM8904_RK_PIO PIO_PA22_IDX #define WM8904_RK_FLAGS PIO_PERIPH_A #define WM8904_RF_PIO PIO_PD24_IDX #define WM8904_RF_FLAGS PIO_PERIPH_B #define WM8904_RD_PIO PIO_PA10_IDX #define WM8904_RD_FLAGS PIO_PERIPH_C #define WM8904_PCK2_PIO PIO_PA18_IDX #define WM8904_PCK2_FLAGS PIO_PERIPH_B /** Board SDRAM size for MT48LC16M16A2 */ #define BOARD_SDRAM_SIZE (2 * 1024 * 1024) /** Address for transferring command bytes to the SDRAM. */ #define BOARD_SDRAM_ADDR 0x70000000 /** SDRAM pins definitions */ #define SDRAM_BA0_PIO PIO_PA20_IDX #define SDRAM_SDCK_PIO PIO_PD23_IDX #define SDRAM_SDCKE_PIO PIO_PD14_IDX #define SDRAM_SDCS_PIO PIO_PC15_IDX #define SDRAM_RAS_PIO PIO_PD16_IDX #define SDRAM_CAS_PIO PIO_PD17_IDX #define SDRAM_SDWE_PIO PIO_PD29_IDX #define SDRAM_NBS0_PIO PIO_PC18_IDX #define SDRAM_NBS1_PIO PIO_PD15_IDX #define SDRAM_A2_PIO PIO_PC20_IDX #define SDRAM_A3_PIO PIO_PC21_IDX #define SDRAM_A4_PIO PIO_PC22_IDX #define SDRAM_A5_PIO PIO_PC23_IDX #define SDRAM_A6_PIO PIO_PC24_IDX #define SDRAM_A7_PIO PIO_PC25_IDX #define SDRAM_A8_PIO PIO_PC26_IDX #define SDRAM_A9_PIO PIO_PC27_IDX #define SDRAM_A10_PIO PIO_PC28_IDX #define SDRAM_A11_PIO PIO_PC29_IDX #define SDRAM_SDA10_PIO PIO_PD13_IDX #define SDRAM_D0_PIO PIO_PC0_IDX #define SDRAM_D1_PIO PIO_PC1_IDX #define SDRAM_D2_PIO PIO_PC2_IDX #define SDRAM_D3_PIO PIO_PC3_IDX #define SDRAM_D4_PIO PIO_PC4_IDX #define SDRAM_D5_PIO PIO_PC5_IDX #define SDRAM_D6_PIO PIO_PC6_IDX #define SDRAM_D7_PIO PIO_PC7_IDX #define SDRAM_D8_PIO PIO_PE0_IDX #define SDRAM_D9_PIO PIO_PE1_IDX #define SDRAM_D10_PIO PIO_PE2_IDX #define SDRAM_D11_PIO PIO_PE3_IDX #define SDRAM_D12_PIO PIO_PE4_IDX #define SDRAM_D13_PIO PIO_PE5_IDX #define SDRAM_D14_PIO PIO_PA15_IDX #define SDRAM_D15_PIO PIO_PA16_IDX #define SDRAM_BA0_FLAGS PIO_PERIPH_C #define SDRAM_SDCK_FLAGS PIO_PERIPH_C #define SDRAM_SDCKE_FLAGS PIO_PERIPH_C #define SDRAM_SDCS_FLAGS PIO_PERIPH_A #define SDRAM_RAS_FLAGS PIO_PERIPH_C #define SDRAM_CAS_FLAGS PIO_PERIPH_C #define SDRAM_SDWE_FLAGS PIO_PERIPH_C #define SDRAM_NBS0_FLAGS PIO_PERIPH_A #define SDRAM_NBS1_FLAGS PIO_PERIPH_C #define SDRAM_A_FLAGS PIO_PERIPH_A #define SDRAM_SDA10_FLAGS PIO_PERIPH_C #define SDRAM_D_FLAGS PIO_PERIPH_A /** LCD SPI configuration */ #define BOARD_ILI9488_SPI SPI0 #define BOARD_ILI9488_SPI_IRQN SPI0_IRQn #define BOARD_ILI9488_SPI_NPCS 3 /** LCD SPI pins definition */ #define LCD_SPI_MISO_PIO PIO_PD20_IDX #define LCD_SPI_MISO_FLAGS (PIO_PERIPH_B | PIO_DEFAULT) #define LCD_SPI_MOSI_PIO PIO_PD21_IDX #define LCD_SPI_MOSI_FLAGS (PIO_PERIPH_B | PIO_DEFAULT) #define LCD_SPI_SPCK_PIO PIO_PD22_IDX #define LCD_SPI_SPCK_FLAGS (PIO_PERIPH_B | PIO_DEFAULT) #define LCD_SPI_NPCS_PIO PIO_PD27_IDX #define LCD_SPI_NPCS_FLAGS (PIO_PERIPH_B | PIO_DEFAULT) #define LCD_SPI_RESET_PIO PIO_PA24_IDX #define LCD_SPI_RESET_FLAGS (PIO_OUTPUT_1 | PIO_DEFAULT) #define LCD_SPI_CDS_PIO PIO_PA6_IDX #define LCD_SPI_CDS_FLAGS (PIO_OUTPUT_1 | PIO_DEFAULT) #define LCD_SPI_BACKLIGHT_PIO PIO_PC19_IDX #define LCD_SPI_BACKLIGHT_FLAGS (PIO_OUTPUT_1 | PIO_DEFAULT) /** TWI interface for maXTouch XPRO */ #define MAXTOUCH_XPRO_TWIHS TWIHS0 #define MAXTOUCH_XPRO_CHG_PIO PIO_PA2_IDX /** BNO055 external interrupt pin definition */ #define PIN_BNO055_EXT_INIERRUPT {PIO_PD28, PIOD, ID_PIOD, PIO_INPUT, \ PIO_DEFAULT | PIO_IT_RISE_EDGE} #define PIN_BNO055_EXT_INIERRUPT_MASK PIO_PD28 #define PIN_BNO055_EXT_INIERRUPT_PIO PIOD #define PIN_BNO055_EXT_INIERRUPT_ID ID_PIOD #define PIN_BNO055_EXT_INIERRUPT_TYPE PIO_INPUT #define PIN_BNO055_EXT_INIERRUPT_ATTR (PIO_DEFAULT | PIO_IT_RISE_EDGE) #define PIN_BNO055_EXT_INIERRUPT_IRQn PIOD_IRQn #define BOARD_BNO055_TWIHS TWIHS0 #define BOARD_BNO055_ID_TWIHS ID_TWIHS0 /** TWIHS ID for simulated EEPROM application to use */ #define BOARD_AT30TSE_ID_TWIHS ID_TWIHS0 /** TWIHS Base for simulated TWI EEPROM application to use */ #define BOARD_AT30TSE_TWIHS TWIHS0 /*----------------------------------------------------------------------------*/ #endif /* _SAME70_XPLD_H_ */
// // Copyright (C) 2012 OpenSim Ltd // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program; if not, see <http://www.gnu.org/licenses/>. // // @author: Zoltan Bojthe // #ifndef __INET_DELAYER_H #define __INET_DELAYER_H #include "inet/common/INETDefs.h" namespace inet { /** * Delayer module. */ class INET_API Delayer : public cSimpleModule { public: Delayer() { delayPar = nullptr; } protected: virtual void initialize() override; virtual void handleMessage(cMessage *msg) override; cPar *delayPar; static simsignal_t rcvdPkSignal; static simsignal_t sentPkSignal; static simsignal_t delaySignal; }; } // namespace inet #endif // ifndef __INET_DELAYER_H
/* * This header is generated by classdump-dyld 1.0 * on Wednesday, March 22, 2017 at 9:02:50 AM Mountain Standard Time * Operating System: Version 10.1 (Build 14U593) * Image Source: /System/Library/Frameworks/UIKit.framework/UIKit * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class UIKBGradient; @protocol UIKBRenderEffect <NSObject,NSCopying> @property (nonatomic,readonly) BOOL isValid; @property (nonatomic,readonly) BOOL renderUnder; @property (nonatomic,readonly) SEL renderSelector; @property (assign,nonatomic) double weight; @property (nonatomic,readonly) BOOL usesRGBColors; @property (nonatomic,readonly) UIKBGradient * gradient; @required -(CGColorRef)CGColor; -(BOOL)isValid; -(UIKBGradient *)gradient; -(double)weight; -(BOOL)usesRGBColors; -(BOOL)renderUnder; -(SEL)renderSelector; -(void)setWeight:(double)arg1; @end
#include "trig.c" //because it's damn ugly #define abs(val) (val ^ (val >> 31)) + ((val >> 31)&1) float sin(int x) {if (x < 0) x = 360 + x;return sintab[x % 360];} float cos(int x) {if (x < 0) x = 360 + x;return costab[x % 360];} float tan(int x) {if (x < 0) x = 360 + x;return tantab[x % 360];} // sqrt via newton's approximation float sqrt(float val) { float ret; __asm__("sqrt.s %[out], %[in]" : [out] "=f" (ret) : [in] "f" (val)); return ret; }
/* * This header is generated by classdump-dyld 1.0 * on Wednesday, March 22, 2017 at 9:09:20 AM Mountain Standard Time * Operating System: Version 10.1 (Build 14U593) * Image Source: /System/Library/PrivateFrameworks/CoreInterest.framework/CoreInterest * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @interface IFSensedScoreEngine : NSObject +(id)defaultEngine; +(id)naive; +(id)sigmoid; +(id)power; @end
// // IMEmojiMessageBody.h // Pods // // Created by 杨磊 on 15/7/14. // // #import "IMMessageBody.h" typedef NS_ENUM(NSInteger, EmojiContentType) { EmojiContent_IMG = 0, EmojiContent_GIF = 1, }; @interface IMEmojiMessageBody : IMMessageBody @property (assign ,nonatomic) EmojiContentType type; @property (copy, nonatomic) NSString *content; @property (copy, nonatomic) NSString *name; @end
/* * Auto generated Run-Time-Environment Component Configuration File * *** Do not modify ! *** * * Project: 'temperature_pca10040' * Target: 'nrf52832_xxaa' */ #ifndef RTE_COMPONENTS_H #define RTE_COMPONENTS_H /* * Define the Device Header File: */ #define CMSIS_device_header "nrf.h" #endif /* RTE_COMPONENTS_H */
/* A portable stdint.h **************************************************************************** * BSD License: **************************************************************************** * * Copyright (c) 2005-2016 Paul Hsieh * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * **************************************************************************** * * Version 0.1.16.0 * * The ANSI C standard committee, for the C99 standard, specified the * inclusion of a new standard include file called stdint.h. This is * a very useful and long desired include file which contains several * very precise definitions for integer scalar types that is critically * important for making several classes of applications portable * including cryptography, hashing, variable length integer libraries * and so on. But for most developers its likely useful just for * programming sanity. * * The problem is that some compiler vendors chose to ignore the C99 * standard and some older compilers have no opportunity to be updated. * Because of this situation, simply including stdint.h in your code * makes it unportable. * * So that's what this file is all about. It's an attempt to build a * single universal include file that works on as many platforms as * possible to deliver what stdint.h is supposed to. Even compilers * that already come with stdint.h can use this file instead without * any loss of functionality. A few things that should be noted about * this file: * * 1) It is not guaranteed to be portable and/or present an identical * interface on all platforms. The extreme variability of the * ANSI C standard makes this an impossibility right from the * very get go. Its really only meant to be useful for the vast * majority of platforms that possess the capability of * implementing usefully and precisely defined, standard sized * integer scalars. Systems which are not intrinsically 2s * complement may produce invalid constants. * * 2) There is an unavoidable use of non-reserved symbols. * * 3) Other standard include files are invoked. * * 4) This file may come in conflict with future platforms that do * include stdint.h. The hope is that one or the other can be * used with no real difference. * * 5) In the current version, if your platform can't represent * int32_t, int16_t and int8_t, it just dumps out with a compiler * error. * * 6) 64 bit integers may or may not be defined. Test for their * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. * Note that this is different from the C99 specification which * requires the existence of 64 bit support in the compiler. If * this is not defined for your platform, yet it is capable of * dealing with 64 bits then it is because this file has not yet * been extended to cover all of your system's capabilities. * * 7) (u)intptr_t may or may not be defined. Test for its presence * with the test: #ifdef PTRDIFF_MAX. If this is not defined * for your platform, then it is because this file has not yet * been extended to cover all of your system's capabilities, not * because its optional. * * 8) The following might not been defined even if your platform is * capable of defining it: * * WCHAR_MIN * WCHAR_MAX * (u)int64_t * PTRDIFF_MIN * PTRDIFF_MAX * (u)intptr_t * * 9) The following have not been defined: * * WINT_MIN * WINT_MAX * * 10) The criteria for defining (u)int_least(*)_t isn't clear, * except for systems which don't have a type that precisely * defined 8, 16, or 32 bit types (which this include file does * not support anyways). Default definitions have been given. * * 11) The criteria for defining (u)int_fast(*)_t isn't something I * would trust to any particular compiler vendor or the ANSI C * committee. It is well known that "compatible systems" are * commonly created that have very different performance * characteristics from the systems they are compatible with, * especially those whose vendors make both the compiler and the * system. Default definitions have been given, but its strongly * recommended that users never use these definitions for any * reason (they do *NOT* deliver any serious guarantee of * improved performance -- not in this file, nor any vendor's * stdint.h). * * 12) The following macros: * * PRINTF_INTMAX_MODIFIER * PRINTF_INT64_MODIFIER * PRINTF_INT32_MODIFIER * PRINTF_INT16_MODIFIER * PRINTF_LEAST64_MODIFIER * PRINTF_LEAST32_MODIFIER * PRINTF_LEAST16_MODIFIER * PRINTF_INTPTR_MODIFIER * * are strings which have been defined as the modifiers required * for the "d", "u" and "x" printf formats to correctly output * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. * PRINTF_INTPTR_MODIFIER is not defined for some systems which * provide their own stdint.h. PRINTF_INT64_MODIFIER is not * defined if INT64_MAX is not defined. These are an extension * beyond what C99 specifies must be in stdint.h. * * In addition, the following macros are defined: * * PRINTF_INTMAX_HEX_WIDTH * PRINTF_INT64_HEX_WIDTH * PRINTF_INT32_HEX_WIDTH * PRINTF_INT16_HEX_WIDTH * PRINTF_INT8_HEX_WIDTH * PRINTF_INTMAX_DEC_WIDTH * PRINTF_INT64_DEC_WIDTH * PRINTF_INT32_DEC_WIDTH * PRINTF_INT16_DEC_WIDTH * PRINTF_UINT8_DEC_WIDTH * PRINTF_UINTMAX_DEC_WIDTH * PRINTF_UINT64_DEC_WIDTH * PRINTF_UINT32_DEC_WIDTH * PRINTF_UINT16_DEC_WIDTH * PRINTF_UINT8_DEC_WIDTH * * Which specifies the maximum number of characters required to * print the number of that type in either hexadecimal or decimal. * These are an extension beyond what C99 specifies must be in * stdint.h. * * Compilers tested (all with 0 warnings at their highest respective * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 * * This file should be considered a work in progress. Suggestions for * improvements, especially those which increase coverage are strongly * encouraged. * * Acknowledgements * * The following people have made significant contributions to the * development and testing of this file: * * Chris Howie * John Steele Scott * Dave Thorup * John Dill * Florian Wobbe * Christopher Sean Morrison * Mikkel Fahnoe Jorgensen * */ #include <stddef.h> #include <limits.h> #include <signal.h> /* * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. */ #if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600 && !defined(NTDDI_VERSION)) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED) #include <stdint.h> #define _PSTDINT_H_INCLUDED # if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__)) # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "l" # endif # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif # else # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # ifndef PRINTF_INT32_MODIFIER # if (UINT_MAX == UINT32_MAX) # define PRINTF_INT32_MODIFIER "" # else # define PRINTF_INT32_MODIFIER "l" # endif # endif # endif # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "h" # endif # ifndef PRINTF_INTMAX_MODIFIER # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER # endif # ifndef PRINTF_INT64_HEX_WIDTH # define PRINTF_INT64_HEX_WIDTH "16" # endif # ifndef PRINTF_UINT64_HEX_WIDTH # define PRINTF_UINT64_HEX_WIDTH "16" # endif # ifndef PRINTF_INT32_HEX_WIDTH # define PRINTF_INT32_HEX_WIDTH "8" # endif # ifndef PRINTF_UINT32_HEX_WIDTH # define PRINTF_UINT32_HEX_WIDTH "8" # endif # ifndef PRINTF_INT16_HEX_WIDTH # define PRINTF_INT16_HEX_WIDTH "4" # endif # ifndef PRINTF_UINT16_HEX_WIDTH # define PRINTF_UINT16_HEX_WIDTH "4" # endif # ifndef PRINTF_INT8_HEX_WIDTH # define PRINTF_INT8_HEX_WIDTH "2" # endif # ifndef PRINTF_UINT8_HEX_WIDTH # define PRINTF_UINT8_HEX_WIDTH "2" # endif # ifndef PRINTF_INT64_DEC_WIDTH # define PRINTF_INT64_DEC_WIDTH "19" # endif # ifndef PRINTF_UINT64_DEC_WIDTH # define PRINTF_UINT64_DEC_WIDTH "20" # endif # ifndef PRINTF_INT32_DEC_WIDTH # define PRINTF_INT32_DEC_WIDTH "10" # endif # ifndef PRINTF_UINT32_DEC_WIDTH # define PRINTF_UINT32_DEC_WIDTH "10" # endif # ifndef PRINTF_INT16_DEC_WIDTH # define PRINTF_INT16_DEC_WIDTH "5" # endif # ifndef PRINTF_UINT16_DEC_WIDTH # define PRINTF_UINT16_DEC_WIDTH "5" # endif # ifndef PRINTF_INT8_DEC_WIDTH # define PRINTF_INT8_DEC_WIDTH "3" # endif # ifndef PRINTF_UINT8_DEC_WIDTH # define PRINTF_UINT8_DEC_WIDTH "3" # endif # ifndef PRINTF_INTMAX_HEX_WIDTH # define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH # endif # ifndef PRINTF_UINTMAX_HEX_WIDTH # define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH # endif # ifndef PRINTF_INTMAX_DEC_WIDTH # define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH # endif # ifndef PRINTF_UINTMAX_DEC_WIDTH # define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH # endif /* * Something really weird is going on with Open Watcom. Just pull some of * these duplicated definitions from Open Watcom's stdint.h file for now. */ # if defined (__WATCOMC__) && __WATCOMC__ >= 1250 # if !defined (INT64_C) # define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) # endif # if !defined (UINT64_C) # define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) # endif # if !defined (INT32_C) # define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) # endif # if !defined (UINT32_C) # define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) # endif # if !defined (INT16_C) # define INT16_C(x) (x) # endif # if !defined (UINT16_C) # define UINT16_C(x) (x) # endif # if !defined (INT8_C) # define INT8_C(x) (x) # endif # if !defined (UINT8_C) # define UINT8_C(x) (x) # endif # if !defined (UINT64_MAX) # define UINT64_MAX 18446744073709551615ULL # endif # if !defined (INT64_MAX) # define INT64_MAX 9223372036854775807LL # endif # if !defined (UINT32_MAX) # define UINT32_MAX 4294967295UL # endif # if !defined (INT32_MAX) # define INT32_MAX 2147483647L # endif # if !defined (INTMAX_MAX) # define INTMAX_MAX INT64_MAX # endif # if !defined (INTMAX_MIN) # define INTMAX_MIN INT64_MIN # endif # endif #endif /* * I have no idea what is the truly correct thing to do on older Solaris. * From some online discussions, this seems to be what is being * recommended. For people who actually are developing on older Solaris, * what I would like to know is, does this define all of the relevant * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is * considered optional. */ #if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED) #include <sys/inttypes.h> #define _PSTDINT_H_INCLUDED #endif #ifndef _PSTDINT_H_INCLUDED #define _PSTDINT_H_INCLUDED #ifndef SIZE_MAX # define SIZE_MAX ((size_t)-1) #endif /* * Deduce the type assignments from limits.h under the assumption that * integer sizes in bits are powers of 2, and follow the ANSI * definitions. */ #ifndef UINT8_MAX # define UINT8_MAX 0xff #endif #if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks) # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) typedef unsigned char uint8_t; # define UINT8_C(v) ((uint8_t) v) # else # error "Platform not supported" # endif #endif #ifndef INT8_MAX # define INT8_MAX 0x7f #endif #ifndef INT8_MIN # define INT8_MIN INT8_C(0x80) #endif #if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks) # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) typedef signed char int8_t; # define INT8_C(v) ((int8_t) v) # else # error "Platform not supported" # endif #endif #ifndef UINT16_MAX # define UINT16_MAX 0xffff #endif #if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks) #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) typedef unsigned int uint16_t; # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "" # endif # define UINT16_C(v) ((uint16_t) (v)) #elif (USHRT_MAX == UINT16_MAX) typedef unsigned short uint16_t; # define UINT16_C(v) ((uint16_t) (v)) # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "h" # endif #else #error "Platform not supported" #endif #endif #ifndef INT16_MAX # define INT16_MAX 0x7fff #endif #ifndef INT16_MIN # define INT16_MIN INT16_C(0x8000) #endif #if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks) #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) typedef signed int int16_t; # define INT16_C(v) ((int16_t) (v)) # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "" # endif #elif (SHRT_MAX == INT16_MAX) typedef signed short int16_t; # define INT16_C(v) ((int16_t) (v)) # ifndef PRINTF_INT16_MODIFIER # define PRINTF_INT16_MODIFIER "h" # endif #else #error "Platform not supported" #endif #endif #ifndef UINT32_MAX # define UINT32_MAX (0xffffffffUL) #endif #if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks) #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) typedef unsigned long uint32_t; # define UINT32_C(v) v ## UL # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "l" # endif #elif (UINT_MAX == UINT32_MAX) typedef unsigned int uint32_t; # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif # define UINT32_C(v) v ## U #elif (USHRT_MAX == UINT32_MAX) typedef unsigned short uint32_t; # define UINT32_C(v) ((unsigned short) (v)) # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif #else #error "Platform not supported" #endif #endif #ifndef INT32_MAX # define INT32_MAX (0x7fffffffL) #endif #ifndef INT32_MIN # define INT32_MIN INT32_C(0x80000000) #endif #if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks) #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) typedef signed long int32_t; # define INT32_C(v) v ## L # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "l" # endif #elif (INT_MAX == INT32_MAX) typedef signed int int32_t; # define INT32_C(v) v # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif #elif (SHRT_MAX == INT32_MAX) typedef signed short int32_t; # define INT32_C(v) ((short) (v)) # ifndef PRINTF_INT32_MODIFIER # define PRINTF_INT32_MODIFIER "" # endif #else #error "Platform not supported" #endif #endif /* * The macro stdint_int64_defined is temporarily used to record * whether or not 64 integer support is available. It must be * defined for any 64 integer extensions for new platforms that are * added. */ #undef stdint_int64_defined #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) # if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) # define stdint_int64_defined typedef long long int64_t; typedef unsigned long long uint64_t; # define UINT64_C(v) v ## ULL # define INT64_C(v) v ## LL # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # endif #endif #if !defined (stdint_int64_defined) # if defined(__GNUC__) && !defined(vxWorks) # define stdint_int64_defined __extension__ typedef long long int64_t; __extension__ typedef unsigned long long uint64_t; # define UINT64_C(v) v ## ULL # define INT64_C(v) v ## LL # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) # define stdint_int64_defined typedef long long int64_t; typedef unsigned long long uint64_t; # define UINT64_C(v) v ## ULL # define INT64_C(v) v ## LL # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "ll" # endif # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) # define stdint_int64_defined typedef __int64 int64_t; typedef unsigned __int64 uint64_t; # define UINT64_C(v) v ## UI64 # define INT64_C(v) v ## I64 # ifndef PRINTF_INT64_MODIFIER # define PRINTF_INT64_MODIFIER "I64" # endif # endif #endif #if !defined (LONG_LONG_MAX) && defined (INT64_C) # define LONG_LONG_MAX INT64_C (9223372036854775807) #endif #ifndef ULONG_LONG_MAX # define ULONG_LONG_MAX UINT64_C (18446744073709551615) #endif #if !defined (INT64_MAX) && defined (INT64_C) # define INT64_MAX INT64_C (9223372036854775807) #endif #if !defined (INT64_MIN) && defined (INT64_C) # define INT64_MIN INT64_C (-9223372036854775808) #endif #if !defined (UINT64_MAX) && defined (INT64_C) # define UINT64_MAX UINT64_C (18446744073709551615) #endif /* * Width of hexadecimal for number field. */ #ifndef PRINTF_INT64_HEX_WIDTH # define PRINTF_INT64_HEX_WIDTH "16" #endif #ifndef PRINTF_INT32_HEX_WIDTH # define PRINTF_INT32_HEX_WIDTH "8" #endif #ifndef PRINTF_INT16_HEX_WIDTH # define PRINTF_INT16_HEX_WIDTH "4" #endif #ifndef PRINTF_INT8_HEX_WIDTH # define PRINTF_INT8_HEX_WIDTH "2" #endif #ifndef PRINTF_INT64_DEC_WIDTH # define PRINTF_INT64_DEC_WIDTH "19" #endif #ifndef PRINTF_INT32_DEC_WIDTH # define PRINTF_INT32_DEC_WIDTH "10" #endif #ifndef PRINTF_INT16_DEC_WIDTH # define PRINTF_INT16_DEC_WIDTH "5" #endif #ifndef PRINTF_INT8_DEC_WIDTH # define PRINTF_INT8_DEC_WIDTH "3" #endif #ifndef PRINTF_UINT64_DEC_WIDTH # define PRINTF_UINT64_DEC_WIDTH "20" #endif #ifndef PRINTF_UINT32_DEC_WIDTH # define PRINTF_UINT32_DEC_WIDTH "10" #endif #ifndef PRINTF_UINT16_DEC_WIDTH # define PRINTF_UINT16_DEC_WIDTH "5" #endif #ifndef PRINTF_UINT8_DEC_WIDTH # define PRINTF_UINT8_DEC_WIDTH "3" #endif /* * Ok, lets not worry about 128 bit integers for now. Moore's law says * we don't need to worry about that until about 2040 at which point * we'll have bigger things to worry about. */ #ifdef stdint_int64_defined typedef int64_t intmax_t; typedef uint64_t uintmax_t; # define INTMAX_MAX INT64_MAX # define INTMAX_MIN INT64_MIN # define UINTMAX_MAX UINT64_MAX # define UINTMAX_C(v) UINT64_C(v) # define INTMAX_C(v) INT64_C(v) # ifndef PRINTF_INTMAX_MODIFIER # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER # endif # ifndef PRINTF_INTMAX_HEX_WIDTH # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH # endif # ifndef PRINTF_INTMAX_DEC_WIDTH # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH # endif #else typedef int32_t intmax_t; typedef uint32_t uintmax_t; # define INTMAX_MAX INT32_MAX # define UINTMAX_MAX UINT32_MAX # define UINTMAX_C(v) UINT32_C(v) # define INTMAX_C(v) INT32_C(v) # ifndef PRINTF_INTMAX_MODIFIER # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER # endif # ifndef PRINTF_INTMAX_HEX_WIDTH # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH # endif # ifndef PRINTF_INTMAX_DEC_WIDTH # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH # endif #endif /* * Because this file currently only supports platforms which have * precise powers of 2 as bit sizes for the default integers, the * least definitions are all trivial. Its possible that a future * version of this file could have different definitions. */ #ifndef stdint_least_defined typedef int8_t int_least8_t; typedef uint8_t uint_least8_t; typedef int16_t int_least16_t; typedef uint16_t uint_least16_t; typedef int32_t int_least32_t; typedef uint32_t uint_least32_t; # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER # define UINT_LEAST8_MAX UINT8_MAX # define INT_LEAST8_MAX INT8_MAX # define UINT_LEAST16_MAX UINT16_MAX # define INT_LEAST16_MAX INT16_MAX # define UINT_LEAST32_MAX UINT32_MAX # define INT_LEAST32_MAX INT32_MAX # define INT_LEAST8_MIN INT8_MIN # define INT_LEAST16_MIN INT16_MIN # define INT_LEAST32_MIN INT32_MIN # ifdef stdint_int64_defined typedef int64_t int_least64_t; typedef uint64_t uint_least64_t; # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER # define UINT_LEAST64_MAX UINT64_MAX # define INT_LEAST64_MAX INT64_MAX # define INT_LEAST64_MIN INT64_MIN # endif #endif #undef stdint_least_defined /* * The ANSI C committee has defined *int*_fast*_t types as well. This, * of course, defies rationality -- you can't know what will be fast * just from the type itself. Even for a given architecture, compatible * implementations might have different performance characteristics. * Developers are warned to stay away from these types when using this * or any other stdint.h. */ typedef int_least8_t int_fast8_t; typedef uint_least8_t uint_fast8_t; typedef int_least16_t int_fast16_t; typedef uint_least16_t uint_fast16_t; typedef int_least32_t int_fast32_t; typedef uint_least32_t uint_fast32_t; #define UINT_FAST8_MAX UINT_LEAST8_MAX #define INT_FAST8_MAX INT_LEAST8_MAX #define UINT_FAST16_MAX UINT_LEAST16_MAX #define INT_FAST16_MAX INT_LEAST16_MAX #define UINT_FAST32_MAX UINT_LEAST32_MAX #define INT_FAST32_MAX INT_LEAST32_MAX #define INT_FAST8_MIN INT_LEAST8_MIN #define INT_FAST16_MIN INT_LEAST16_MIN #define INT_FAST32_MIN INT_LEAST32_MIN #ifdef stdint_int64_defined typedef int_least64_t int_fast64_t; typedef uint_least64_t uint_fast64_t; # define UINT_FAST64_MAX UINT_LEAST64_MAX # define INT_FAST64_MAX INT_LEAST64_MAX # define INT_FAST64_MIN INT_LEAST64_MIN #endif #undef stdint_int64_defined /* * Whatever piecemeal, per compiler thing we can do about the wchar_t * type limits. */ #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks) # include <wchar.h> # ifndef WCHAR_MIN # define WCHAR_MIN 0 # endif # ifndef WCHAR_MAX # define WCHAR_MAX ((wchar_t)-1) # endif #endif /* * Whatever piecemeal, per compiler/platform thing we can do about the * (u)intptr_t types and limits. */ #if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T) # define STDINT_H_UINTPTR_T_DEFINED #endif #ifndef STDINT_H_UINTPTR_T_DEFINED # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__) # define stdint_intptr_bits 64 # elif defined (__WATCOMC__) || defined (__TURBOC__) # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) # define stdint_intptr_bits 16 # else # define stdint_intptr_bits 32 # endif # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__) # define stdint_intptr_bits 32 # elif defined (__INTEL_COMPILER) /* TODO -- what did Intel do about x86-64? */ # else /* #error "This platform might not be supported yet" */ # endif # ifdef stdint_intptr_bits # define stdint_intptr_glue3_i(a,b,c) a##b##c # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) # ifndef PRINTF_INTPTR_MODIFIER # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) # endif # ifndef PTRDIFF_MAX # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) # endif # ifndef PTRDIFF_MIN # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) # endif # ifndef UINTPTR_MAX # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) # endif # ifndef INTPTR_MAX # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) # endif # ifndef INTPTR_MIN # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) # endif # ifndef INTPTR_C # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) # endif # ifndef UINTPTR_C # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) # endif typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; # else /* TODO -- This following is likely wrong for some platforms, and does nothing for the definition of uintptr_t. */ typedef ptrdiff_t intptr_t; # endif # define STDINT_H_UINTPTR_T_DEFINED #endif /* * Assumes sig_atomic_t is signed and we have a 2s complement machine. */ #ifndef SIG_ATOMIC_MAX # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) #endif #endif #if defined (__TEST_PSTDINT_FOR_CORRECTNESS) /* * Please compile with the maximum warning settings to make sure macros are * not defined more than once. */ #include <stdlib.h> #include <stdio.h> #include <string.h> #define glue3_aux(x,y,z) x ## y ## z #define glue3(x,y,z) glue3_aux(x,y,z) #define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0); #define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0); #define DECL(us,bits) glue3(DECL,us,) (bits) #define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits) #define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; } #define X_SIZE_MAX ((size_t)-1) int main () { int err_n = 0; int err_first = 0; DECL(I,8) DECL(U,8) DECL(I,16) DECL(U,16) DECL(I,32) DECL(U,32) #ifdef INT64_MAX DECL(I,64) DECL(U,64) #endif intmax_t imax = INTMAX_C(0); uintmax_t umax = UINTMAX_C(0); char str0[256], str1[256]; sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647)); if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH)); sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295)); if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH)); #ifdef INT64_MAX sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807)); if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1))); sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591)); if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1))); #endif sprintf (str0, "%d %x\n", 0, ~0); sprintf (str1, "%d %x\n", i8, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1)); sprintf (str1, "%u %x\n", u8, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1)); sprintf (str1, "%d %x\n", i16, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1)); sprintf (str1, "%u %x\n", u16, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1)); sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1)); sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1)); #ifdef INT64_MAX sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1)); #endif sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1)); sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1)); TESTUMAX(8); TESTUMAX(16); TESTUMAX(32); #ifdef INT64_MAX TESTUMAX(64); #endif #define STR(v) #v #define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v)); if (err_n) { printf ("pstdint.h is not correct. Please use sizes below to correct it:\n"); } Q(int) Q(unsigned) Q(long int) Q(short int) Q(int8_t) Q(int16_t) Q(int32_t) #ifdef INT64_MAX Q(int64_t) #endif #if UINT_MAX < X_SIZE_MAX printf ("UINT_MAX < X_SIZE_MAX\n"); #else printf ("UINT_MAX >= X_SIZE_MAX\n"); #endif printf ("%" PRINTF_INT64_MODIFIER "u vs %" PRINTF_INT64_MODIFIER "u\n", UINT_MAX, X_SIZE_MAX); return EXIT_SUCCESS; } #endif
/* stb_image_write - v1.15 - public domain - http://nothings.org/stb writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 no warranty implied; use at your own risk Before #including, #define STB_IMAGE_WRITE_IMPLEMENTATION in the file that you want to have the implementation. Will probably not work correctly with strict-aliasing optimizations. ABOUT: This header file is a library for writing images to C stdio or a callback. The PNG output is not optimal; it is 20-50% larger than the file written by a decent optimizing implementation; though providing a custom zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. This library is designed for source code compactness and simplicity, not optimal image file size or run-time performance. BUILDING: You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace malloc,realloc,free. You can #define STBIW_MEMMOVE() to replace memmove() You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function for PNG compression (instead of the builtin one), it must have the following signature: unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); The returned data will be freed with STBIW_FREE() (free() by default), so it must be heap allocated with STBIW_MALLOC() (malloc() by default), UNICODE: If compiling for Windows and you wish to use Unicode filenames, compile with #define STBIW_WINDOWS_UTF8 and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert Windows wchar_t filenames to utf8. USAGE: There are five functions, one for each image file format: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically There are also five equivalent functions that use an arbitrary write function. You are expected to open/close your file-equivalent before and after calling these: int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); where the callback is: void stbi_write_func(void *context, void *data, int size); You can configure it with these global variables: int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode You can define STBI_WRITE_NO_STDIO to disable the file variant of these functions, so the library will not use stdio.h at all. However, this will also disable HDR writing, because it requires stdio for formatted output. Each function returns 0 on failure and non-0 on success. The functions create an image file defined by the parameters. The image is a rectangle of pixels stored from left-to-right, top-to-bottom. Each pixel contains 'comp' channels of data stored interleaved with 8-bits per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. The *data pointer points to the first byte of the top-left-most pixel. For PNG, "stride_in_bytes" is the distance in bytes from the first byte of a row of pixels to the first byte of the next row of pixels. PNG creates output files with the same number of components as the input. The BMP format expands Y to RGB in the file format and does not output alpha. PNG supports writing rectangles of data even when the bytes storing rows of data are not consecutive in memory (e.g. sub-rectangles of a larger image), by supplying the stride between the beginning of adjacent rows. The other formats do not. (Thus you cannot write a native-format BMP through the BMP writer, both because it is in BGR order and because it may have padding at the end of the line.) PNG allows you to set the deflate compression level by setting the global variable 'stbi_write_png_compression_level' (it defaults to 8). HDR expects linear float data. Since the format is always 32-bit rgb(e) data, alpha (if provided) is discarded, and for monochrome data it is replicated across all three channels. TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed data, set the global variable 'stbi_write_tga_with_rle' to 0. JPEG does ignore alpha channels in input data; quality is between 1 and 100. Higher quality looks better but results in a bigger image. JPEG baseline (no JPEG progressive). CREDITS: Sean Barrett - PNG/BMP/TGA Baldur Karlsson - HDR Jean-Sebastien Guay - TGA monochrome Tim Kelsey - misc enhancements Alan Hickman - TGA RLE Emmanuel Julien - initial file IO callback implementation Jon Olick - original jo_jpeg.cpp code Daniel Gibson - integrate JPEG, allow external zlib Aarni Koskela - allow choosing PNG filter bugfixes: github:Chribba Guillaume Chereau github:jry2 github:romigrou Sergio Gonzalez Jonas Karlsson Filip Wasil Thatcher Ulrich github:poppolopoppo Patrick Boettcher github:xeekworx Cap Petschulat Simon Rodriguez Ivan Tikhonov github:ignotion Adam Schackart LICENSE See end of file for license information. */ #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H #include <stdlib.h> // if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' #ifndef STBIWDEF #ifdef STB_IMAGE_WRITE_STATIC #define STBIWDEF static #else #ifdef __cplusplus #define STBIWDEF extern "C" #else #define STBIWDEF extern #endif #endif #endif #ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations extern int stbi_write_tga_with_rle; extern int stbi_write_png_compression_level; extern int stbi_write_force_png_filter; #endif #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); #ifdef STBI_WINDOWS_UTF8 STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif #endif typedef void stbi_write_func(void *context, void *data, int size); STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); #endif//INCLUDE_STB_IMAGE_WRITE_H #ifdef STB_IMAGE_WRITE_IMPLEMENTATION #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #endif #ifndef STBI_WRITE_NO_STDIO #include <stdio.h> #endif // STBI_WRITE_NO_STDIO #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <math.h> #if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) // ok #elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) // ok #else #error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." #endif #ifndef STBIW_MALLOC #define STBIW_MALLOC(sz) malloc(sz) #define STBIW_REALLOC(p,newsz) realloc(p,newsz) #define STBIW_FREE(p) free(p) #endif #ifndef STBIW_REALLOC_SIZED #define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) #endif #ifndef STBIW_MEMMOVE #define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) #endif #ifndef STBIW_ASSERT #include <assert.h> #define STBIW_ASSERT(x) assert(x) #endif #define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) #ifdef STB_IMAGE_WRITE_STATIC static int stbi_write_png_compression_level = 8; static int stbi_write_tga_with_rle = 1; static int stbi_write_force_png_filter = -1; #else int stbi_write_png_compression_level = 8; int stbi_write_tga_with_rle = 1; int stbi_write_force_png_filter = -1; #endif static int stbi__flip_vertically_on_write = 0; STBIWDEF void stbi_flip_vertically_on_write(int flag) { stbi__flip_vertically_on_write = flag; } typedef struct { stbi_write_func *func; void *context; unsigned char buffer[64]; int buf_used; } stbi__write_context; // initialize a callback-based context static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) { s->func = c; s->context = context; } #ifndef STBI_WRITE_NO_STDIO static void stbi__stdio_write(void *context, void *data, int size) { fwrite(data,1,size,(FILE*) context); } #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) #ifdef __cplusplus #define STBIW_EXTERN extern "C" #else #define STBIW_EXTERN extern #endif STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbiw__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } static int stbi__start_write_file(stbi__write_context *s, const char *filename) { FILE *f = stbiw__fopen(filename, "wb"); stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); return f != NULL; } static void stbi__end_write_file(stbi__write_context *s) { fclose((FILE *)s->context); } #endif // !STBI_WRITE_NO_STDIO typedef unsigned int stbiw_uint32; typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { switch (*fmt++) { case ' ': break; case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); s->func(s->context,&x,1); break; } case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = STBIW_UCHAR(x); b[1] = STBIW_UCHAR(x>>8); s->func(s->context,b,2); break; } case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=STBIW_UCHAR(x); b[1]=STBIW_UCHAR(x>>8); b[2]=STBIW_UCHAR(x>>16); b[3]=STBIW_UCHAR(x>>24); s->func(s->context,b,4); break; } default: STBIW_ASSERT(0); return; } } } static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); } static void stbiw__write_flush(stbi__write_context *s) { if (s->buf_used) { s->func(s->context, &s->buffer, s->buf_used); s->buf_used = 0; } } static void stbiw__putc(stbi__write_context *s, unsigned char c) { s->func(s->context, &c, 1); } static void stbiw__write1(stbi__write_context *s, unsigned char a) { if (s->buf_used + 1 > sizeof(s->buffer)) stbiw__write_flush(s); s->buffer[s->buf_used++] = a; } static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) { int n; if (s->buf_used + 3 > sizeof(s->buffer)) stbiw__write_flush(s); n = s->buf_used; s->buf_used = n+3; s->buffer[n+0] = a; s->buffer[n+1] = b; s->buffer[n+2] = c; } static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) { unsigned char bg[3] = { 255, 0, 255}, px[3]; int k; if (write_alpha < 0) stbiw__write1(s, d[comp - 1]); switch (comp) { case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case case 1: if (expand_mono) stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp else stbiw__write1(s, d[0]); // monochrome TGA break; case 4: if (!write_alpha) { // composite against pink background for (k = 0; k < 3; ++k) px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); break; } /* FALLTHROUGH */ case 3: stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); break; } if (write_alpha > 0) stbiw__write1(s, d[comp - 1]); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) { stbiw_uint32 zero = 0; int i,j, j_end; if (y <= 0) return; if (stbi__flip_vertically_on_write) vdir *= -1; if (vdir < 0) { j_end = -1; j = y-1; } else { j_end = y; j = 0; } for (; j != j_end; j += vdir) { for (i=0; i < x; ++i) { unsigned char *d = (unsigned char *) data + (j*x+i)*comp; stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); } stbiw__write_flush(s); s->func(s->context, &zero, scanline_pad); } } static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { if (y < 0 || x < 0) { return 0; } else { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); return 1; } } static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { int pad = (-x*3) & 3; return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, "11 4 22 4" "4 44 22 444444", 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); stbi__end_write_file(&s); return r; } else return 0; } #endif //!STBI_WRITE_NO_STDIO static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) { int has_alpha = (comp == 2 || comp == 4); int colorbytes = has_alpha ? comp-1 : comp; int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 if (y < 0 || x < 0) return 0; if (!stbi_write_tga_with_rle) { return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { int i,j,k; int jend, jdir; stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); if (stbi__flip_vertically_on_write) { j = 0; jend = y; jdir = 1; } else { j = y-1; jend = -1; jdir = -1; } for (; j != jend; j += jdir) { unsigned char *row = (unsigned char *) data + j * x * comp; int len; for (i = 0; i < x; i += len) { unsigned char *begin = row + i * comp; int diff = 1; len = 1; if (i < x - 1) { ++len; diff = memcmp(begin, row + (i + 1) * comp, comp); if (diff) { const unsigned char *prev = begin; for (k = i + 2; k < x && len < 128; ++k) { if (memcmp(prev, row + k * comp, comp)) { prev += comp; ++len; } else { --len; break; } } } else { for (k = i + 2; k < x && len < 128; ++k) { if (!memcmp(begin, row + k * comp, comp)) { ++len; } else { break; } } } } if (diff) { unsigned char header = STBIW_UCHAR(len - 1); stbiw__write1(s, header); for (k = 0; k < len; ++k) { stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); } } else { unsigned char header = STBIW_UCHAR(len - 129); stbiw__write1(s, header); stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); } } } stbiw__write_flush(s); } return 1; } STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // ************************************************************************************************* // Radiance RGBE HDR writer // by Baldur Karlsson #define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { int exponent; float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); if (maxcomp < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; } else { float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; rgbe[0] = (unsigned char)(linear[0] * normalize); rgbe[1] = (unsigned char)(linear[1] * normalize); rgbe[2] = (unsigned char)(linear[2] * normalize); rgbe[3] = (unsigned char)(exponent + 128); } } static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); s->func(s->context, &lengthbyte, 1); s->func(s->context, &databyte, 1); } static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code s->func(s->context, &lengthbyte, 1); s->func(s->context, data, length); } static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; float linear[3]; int x; scanlineheader[2] = (width&0xff00)>>8; scanlineheader[3] = (width&0x00ff); /* skip RLE for images too small or large */ if (width < 8 || width >= 32768) { for (x=0; x < width; x++) { switch (ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); s->func(s->context, rgbe, 4); } } else { int c,r; /* encode into scratch buffer */ for (x=0; x < width; x++) { switch(ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); scratch[x + width*0] = rgbe[0]; scratch[x + width*1] = rgbe[1]; scratch[x + width*2] = rgbe[2]; scratch[x + width*3] = rgbe[3]; } s->func(s->context, scanlineheader, 4); /* RLE each component separately */ for (c=0; c < 4; c++) { unsigned char *comp = &scratch[width*c]; x = 0; while (x < width) { // find first run r = x; while (r+2 < width) { if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) break; ++r; } if (r+2 >= width) r = width; // dump up to first run while (x < r) { int len = r-x; if (len > 128) len = 128; stbiw__write_dump_data(s, len, &comp[x]); x += len; } // if there's a run, output it if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd // find next byte after run while (r < width && comp[r] == comp[x]) ++r; // output run up to r while (x < r) { int len = r-x; if (len > 127) len = 127; stbiw__write_run_data(s, len, comp[x]); x += len; } } } } } } static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) return 0; else { // Each component is stored separately. Allocate scratch space for full output scanline. unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); int i, len; char buffer[128]; char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; s->func(s->context, header, sizeof(header)-1); #ifdef __STDC_WANT_SECURE_LIB__ len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif s->func(s->context, buffer, len); for(i=0; i < y; i++) stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); STBIW_FREE(scratch); return 1; } } STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // STBI_WRITE_NO_STDIO ////////////////////////////////////////////////////////////////////////////// // // PNG writer // #ifndef STBIW_ZLIB_COMPRESS // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() #define stbiw__sbraw(a) ((int *) (void *) (a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] #define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) #define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) #define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) #define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) #define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) #define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *) p)[1] = 0; *arr = (void *) ((int *) p + 2); stbiw__sbm(*arr) = m; } return *arr; } static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); *bitbuffer >>= 8; *bitcount -= 8; } return data; } static int stbiw__zlib_bitrev(int code, int codebits) { int res=0; while (codebits--) { res = (res << 1) | (code & 1); code >>= 1; } return res; } static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) { int i; for (i=0; i < limit && i < 258; ++i) if (a[i] != b[i]) break; return i; } static unsigned int stbiw__zhash(unsigned char *data) { stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) #define stbiw__zlib_add(code,codebits) \ (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) #define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) #define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) #define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) #define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) #define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) #define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) #define stbiw__ZHASH 16384 #endif // STBIW_ZLIB_COMPRESS STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { #ifdef STBIW_ZLIB_COMPRESS // user provided a zlib compress implementation, use that return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); #else // use builtin static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; unsigned int bitbuf=0; int i,j, bitcount=0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**)); if (hash_table == NULL) return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window stbiw__sbpush(out, 0x5e); // FLEVEL = 1 stbiw__zlib_add(1,1); // BFINAL = 1 stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman for (i=0; i < stbiw__ZHASH; ++i) hash_table[i] = NULL; i=0; while (i < data_len-3) { // hash next 3 bytes of data to be compressed int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; unsigned char *bestloc = 0; unsigned char **hlist = hash_table[h]; int n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32768) { // if entry lies within window int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); if (d >= best) { best=d; bestloc=hlist[j]; } } } // when hash table entry is too long, delete half the entries if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); stbiw__sbn(hash_table[h]) = quality; } stbiw__sbpush(hash_table[h],data+i); if (bestloc) { // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); hlist = hash_table[h]; n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32767) { int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); if (e > best) { // if next match is better, bail on current match bestloc = NULL; break; } } } } if (bestloc) { int d = (int) (data+i - bestloc); // distance back STBIW_ASSERT(d <= 32767 && best <= 258); for (j=0; best > lengthc[j+1]-1; ++j); stbiw__zlib_huff(j+257); if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); for (j=0; d > distc[j+1]-1; ++j); stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); i += best; } else { stbiw__zlib_huffb(data[i]); ++i; } } // write out final bytes for (;i < data_len; ++i) stbiw__zlib_huffb(data[i]); stbiw__zlib_huff(256); // end of block // pad with 0 bits to byte boundary while (bitcount) stbiw__zlib_add(0,1); for (i=0; i < stbiw__ZHASH; ++i) (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); { // compute adler32 on input unsigned int s1=1, s2=0; int blocklen = (int) (data_len % 5552); j=0; while (j < data_len) { for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } s1 %= 65521; s2 %= 65521; j += blocklen; blocklen = 5552; } stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s2)); stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s1)); } *out_len = stbiw__sbn(out); // make returned pointer freeable STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); return (unsigned char *) stbiw__sbraw(out); #endif // STBIW_ZLIB_COMPRESS } static unsigned int stbiw__crc32(unsigned char *buffer, int len) { #ifdef STBIW_CRC32 return STBIW_CRC32(buffer, len); #else static unsigned int crc_table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; unsigned int crc = ~0u; int i; for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; #endif } #define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) #define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); #define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) static void stbiw__wpcrc(unsigned char **data, int len) { unsigned int crc = stbiw__crc32(*data - len - 4, len+4); stbiw__wp32(*data, crc); } static unsigned char stbiw__paeth(int a, int b, int c) { int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); if (pb <= pc) return STBIW_UCHAR(b); return STBIW_UCHAR(c); } // @OPTIMIZE: provide an option that always forces left-predict or paeth predict static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) { static int mapping[] = { 0,1,2,3,4 }; static int firstmap[] = { 0,1,0,5,6 }; int *mymap = (y != 0) ? mapping : firstmap; int i; int type = mymap[filter_type]; unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; if (type==0) { memcpy(line_buffer, z, width*n); return; } // first loop isn't optimized since it's just one pixel for (i = 0; i < n; ++i) { switch (type) { case 1: line_buffer[i] = z[i]; break; case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; case 5: line_buffer[i] = z[i]; break; case 6: line_buffer[i] = z[i]; break; } } switch (type) { case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; } } STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) { int force_filter = stbi_write_force_png_filter; int ctype[5] = { -1, 0, 4, 2, 6 }; unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; unsigned char *out,*o, *filt, *zlib; signed char *line_buffer; int j,zlen; if (stride_bytes == 0) stride_bytes = x * n; if (force_filter >= 5) { force_filter = -1; } filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { int filter_type; if (force_filter > -1) { filter_type = force_filter; stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); } else { // Estimate the best filter by running through all of them: int best_filter = 0, best_filter_val = 0x7fffffff, est, i; for (filter_type = 0; filter_type < 5; filter_type++) { stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); // Estimate the entropy of the line using this filter; the less, the better. est = 0; for (i = 0; i < x*n; ++i) { est += abs((signed char) line_buffer[i]); } if (est < best_filter_val) { best_filter_val = est; best_filter = filter_type; } } if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); filter_type = best_filter; } } // when we get here, filter_type contains the filter type, and line_buffer contains the data filt[j*(x*n+1)] = (unsigned char) filter_type; STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); STBIW_FREE(filt); if (!zlib) return 0; // each tag requires 12 bytes of overhead out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); if (!out) return 0; *out_len = 8 + 12+13 + 12+zlen + 12; o=out; STBIW_MEMMOVE(o,sig,8); o+= 8; stbiw__wp32(o, 13); // header length stbiw__wptag(o, "IHDR"); stbiw__wp32(o, x); stbiw__wp32(o, y); *o++ = 8; *o++ = STBIW_UCHAR(ctype[n]); *o++ = 0; *o++ = 0; *o++ = 0; stbiw__wpcrc(&o,13); stbiw__wp32(o, zlen); stbiw__wptag(o, "IDAT"); STBIW_MEMMOVE(o, zlib, zlen); o += zlen; STBIW_FREE(zlib); stbiw__wpcrc(&o, zlen); stbiw__wp32(o,0); stbiw__wptag(o, "IEND"); stbiw__wpcrc(&o,0); STBIW_ASSERT(o == out + *out_len); return out; } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) { FILE *f; int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; f = stbiw__fopen(filename, "wb"); if (!f) { STBIW_FREE(png); return 0; } fwrite(png, 1, len, f); fclose(f); STBIW_FREE(png); return 1; } #endif STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) { int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; func(context, png, len); STBIW_FREE(png); return 1; } /* *************************************************************************** * * JPEG writer * * This is based on Jon Olick's jo_jpeg.cpp: * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html */ static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { int bitBuf = *bitBufP, bitCnt = *bitCntP; bitCnt += bs[1]; bitBuf |= bs[0] << (24 - bitCnt); while(bitCnt >= 8) { unsigned char c = (bitBuf >> 16) & 255; stbiw__putc(s, c); if(c == 255) { stbiw__putc(s, 0); } bitBuf <<= 8; bitCnt -= 8; } *bitBufP = bitBuf; *bitCntP = bitCnt; } static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; float z1, z2, z3, z4, z5, z11, z13; float tmp0 = d0 + d7; float tmp7 = d0 - d7; float tmp1 = d1 + d6; float tmp6 = d1 - d6; float tmp2 = d2 + d5; float tmp5 = d2 - d5; float tmp3 = d3 + d4; float tmp4 = d3 - d4; // Even part float tmp10 = tmp0 + tmp3; // phase 2 float tmp13 = tmp0 - tmp3; float tmp11 = tmp1 + tmp2; float tmp12 = tmp1 - tmp2; d0 = tmp10 + tmp11; // phase 3 d4 = tmp10 - tmp11; z1 = (tmp12 + tmp13) * 0.707106781f; // c4 d2 = tmp13 + z1; // phase 5 d6 = tmp13 - z1; // Odd part tmp10 = tmp4 + tmp5; // phase 2 tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; // The rotator is modified from fig 4-8 to avoid extra negations. z5 = (tmp10 - tmp12) * 0.382683433f; // c6 z2 = tmp10 * 0.541196100f + z5; // c2-c6 z4 = tmp12 * 1.306562965f + z5; // c2+c6 z3 = tmp11 * 0.707106781f; // c4 z11 = tmp7 + z3; // phase 5 z13 = tmp7 - z3; *d5p = z13 + z2; // phase 6 *d3p = z13 - z2; *d1p = z11 + z4; *d7p = z11 - z4; *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; } static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { int tmp1 = val < 0 ? -val : val; val = val < 0 ? val-1 : val; bits[1] = 1; while(tmp1 >>= 1) { ++bits[1]; } bits[0] = val & ((1<<bits[1])-1); } static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, int du_stride, float *fdtbl, int DC, const unsigned short HTDC[256][2], const unsigned short HTAC[256][2]) { const unsigned short EOB[2] = { HTAC[0x00][0], HTAC[0x00][1] }; const unsigned short M16zeroes[2] = { HTAC[0xF0][0], HTAC[0xF0][1] }; int dataOff, i, j, n, diff, end0pos, x, y; int DU[64]; // DCT rows for(dataOff=0, n=du_stride*8; dataOff<n; dataOff+=du_stride) { stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]); } // DCT columns for(dataOff=0; dataOff<8; ++dataOff) { stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4], &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]); } // Quantize/descale/zigzag the coefficients for(y = 0, j=0; y < 8; ++y) { for(x = 0; x < 8; ++x,++j) { float v; i = y*du_stride+x; v = CDU[i]*fdtbl[j]; // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f)); // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway? DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f); } } // Encode DC diff = DU[0] - DC; if (diff == 0) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]); } else { unsigned short bits[2]; stbiw__jpg_calcBits(diff, bits); stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]); stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } // Encode ACs end0pos = 63; for(; (end0pos>0)&&(DU[end0pos]==0); --end0pos) { } // end0pos = first element in reverse order !=0 if(end0pos == 0) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); return DU[0]; } for(i = 1; i <= end0pos; ++i) { int startpos = i; int nrzeroes; unsigned short bits[2]; for (; DU[i]==0 && i<=end0pos; ++i) { } nrzeroes = i-startpos; if ( nrzeroes >= 16 ) { int lng = nrzeroes>>4; int nrmarker; for (nrmarker=1; nrmarker <= lng; ++nrmarker) stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); nrzeroes &= 15; } stbiw__jpg_calcBits(DU[i], bits); stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } if(end0pos != 63) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); } return DU[0]; } static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { // Constants that don't pollute global namespace static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; static const unsigned char std_ac_luminance_values[] = { 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; static const unsigned char std_ac_chrominance_values[] = { 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; // Huffman tables static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; static const unsigned short YAC_HT[256][2] = { {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const unsigned short UVAC_HT[256][2] = { {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; int row, col, i, k, subsample; float fdtbl_Y[64], fdtbl_UV[64]; unsigned char YTable[64], UVTable[64]; if(!data || !width || !height || comp > 4 || comp < 1) { return 0; } quality = quality ? quality : 90; subsample = quality <= 90 ? 1 : 0; quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; quality = quality < 50 ? 5000 / quality : 200 - quality * 2; for(i = 0; i < 64; ++i) { int uvti, yti = (YQT[i]*quality+50)/100; YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); uvti = (UVQT[i]*quality+50)/100; UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); } for(row = 0, k = 0; row < 8; ++row) { for(col = 0; col < 8; ++col, ++k) { fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); } } // Write Headers { static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; s->func(s->context, (void*)head0, sizeof(head0)); s->func(s->context, (void*)YTable, sizeof(YTable)); stbiw__putc(s, 1); s->func(s->context, UVTable, sizeof(UVTable)); s->func(s->context, (void*)head1, sizeof(head1)); s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); stbiw__putc(s, 0x10); // HTYACinfo s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); stbiw__putc(s, 1); // HTUDCinfo s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); stbiw__putc(s, 0x11); // HTUACinfo s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); s->func(s->context, (void*)head2, sizeof(head2)); } // Encode 8x8 macroblocks { static const unsigned short fillBits[] = {0x7F, 7}; int DCY=0, DCU=0, DCV=0; int bitBuf=0, bitCnt=0; // comp == 2 is grey+alpha (alpha is ignored) int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; const unsigned char *dataR = (const unsigned char *)data; const unsigned char *dataG = dataR + ofsG; const unsigned char *dataB = dataR + ofsB; int x, y, pos; if(subsample) { for(y = 0; y < height; y += 16) { for(x = 0; x < width; x += 16) { float Y[256], U[256], V[256]; for(row = y, pos = 0; row < y+16; ++row) { // row >= height => use last input row int clamped_row = (row < height) ? row : height - 1; int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; for(col = x; col < x+16; ++col, ++pos) { // if col >= width => use pixel from last input column int p = base_p + ((col < width) ? col : (width-1))*comp; float r = dataR[p], g = dataG[p], b = dataB[p]; Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; } } DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); // subsample U,V { float subU[64], subV[64]; int yy, xx; for(yy = 0, pos = 0; yy < 8; ++yy) { for(xx = 0; xx < 8; ++xx, ++pos) { int j = yy*32+xx*2; subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f; subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f; } } DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } } } else { for(y = 0; y < height; y += 8) { for(x = 0; x < width; x += 8) { float Y[64], U[64], V[64]; for(row = y, pos = 0; row < y+8; ++row) { // row >= height => use last input row int clamped_row = (row < height) ? row : height - 1; int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; for(col = x; col < x+8; ++col, ++pos) { // if col >= width => use pixel from last input column int p = base_p + ((col < width) ? col : (width-1))*comp; float r = dataR[p], g = dataG[p], b = dataB[p]; Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; } } DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } } // Do the bit alignment of the EOI marker stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); } // EOI stbiw__putc(s, 0xFF); stbiw__putc(s, 0xD9); return 1; } STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); stbi__end_write_file(&s); return r; } else return 0; } #endif #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history 1.14 (2020-02-02) updated JPEG writer to downsample chroma channels 1.13 1.12 1.11 (2019-08-11) 1.10 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 1.09 (2018-02-11) fix typo in zlib quality API, improve STB_I_W_STATIC in C++ 1.08 (2018-01-29) add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter 1.07 (2017-07-24) doc fix 1.06 (2017-07-23) writing JPEG (using Jon Olick's code) 1.05 ??? 1.04 (2017-03-03) monochrome BMP expansion 1.03 ??? 1.02 (2016-04-02) avoid allocating large structures on the stack 1.01 (2016-01-16) STBIW_REALLOC_SIZED: support allocators with no realloc support avoid race-condition in crc initialization minor compile issues 1.00 (2015-09-14) installable file IO function 0.99 (2015-09-13) warning fixes; TGA rle support 0.98 (2015-04-08) added STBIW_MALLOC, STBIW_ASSERT etc 0.97 (2015-01-18) fixed HDR asserts, rewrote HDR rle logic 0.96 (2015-01-17) add HDR output fix monochrome BMP 0.95 (2014-08-17) add monochrome TGA output 0.94 (2014-05-31) rename private functions to avoid conflicts with stb_image.h 0.93 (2014-05-27) warning fixes 0.92 (2010-08-01) casts to unsigned char to fix warnings 0.91 (2010-07-17) first public release 0.90 first internal release */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */
// // RYJViewController.h // RYJToolKit // // Created by developRen on 11/30/2020. // Copyright (c) 2020 developRen. All rights reserved. // @import UIKit; @interface RYJViewController : UIViewController @end
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* vm2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rpoetess <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/05 19:51:16 by rpoetess #+# #+# */ /* Updated: 2020/02/05 19:51:18 by rpoetess ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" #include "vm.h" uint mem_mod(long int pc) { while (pc < 0) pc += MEM_SIZE; return (pc % MEM_SIZE); } void t_vm_init(t_vm *vm, int n_champs, t_args args) { ft_bzero(vm, sizeof(t_vm)); vm->mode = args.mode; vm->v_flag = args.v_flag; vm->n_champs = n_champs; vm->mem = ft_calloc(MEM_SIZE, sizeof(char)); vm->host_endian = endian(); vm->cycles_to_die = CYCLE_TO_DIE; vm->i_before_check = vm->cycles_to_die; t_arrayp_init(&vm->procs); if (vm->mode == MODE_VIS) write_init(); } void t_vm_print(t_vm *vm) { int i; i = -1; while (++i < MEM_SIZE) { if (!(i % OCTETS_PER_LINE)) ft_printf("0x%04x : ", i); put_hex(vm->mem[i], 2); ft_printf(" "); if (!((i + 1) % OCTETS_PER_LINE)) ft_printf("\n"); } } void put_hex(uint v, int digits) { unsigned int a; unsigned int b; if (!digits) return ; a = v / 16; b = v - a * 16; put_hex(a, digits - 1); if (b < 10) ft_putchar('0' + b); else ft_putchar('a' - 10 + b); }
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/kinesisanalytics/KinesisAnalytics_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/kinesisanalytics/model/ApplicationStatus.h> #include <utility> namespace Aws { namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace KinesisAnalytics { namespace Model { /** * <p>Provides application summary information, including the application Amazon * Resource Name (ARN), name, and status.</p><p><h3>See Also:</h3> <a * href="http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ApplicationSummary">AWS * API Reference</a></p> */ class AWS_KINESISANALYTICS_API ApplicationSummary { public: ApplicationSummary(); ApplicationSummary(const Aws::Utils::Json::JsonValue& jsonValue); ApplicationSummary& operator=(const Aws::Utils::Json::JsonValue& jsonValue); Aws::Utils::Json::JsonValue Jsonize() const; /** * <p>Name of the application.</p> */ inline const Aws::String& GetApplicationName() const{ return m_applicationName; } /** * <p>Name of the application.</p> */ inline void SetApplicationName(const Aws::String& value) { m_applicationNameHasBeenSet = true; m_applicationName = value; } /** * <p>Name of the application.</p> */ inline void SetApplicationName(Aws::String&& value) { m_applicationNameHasBeenSet = true; m_applicationName = std::move(value); } /** * <p>Name of the application.</p> */ inline void SetApplicationName(const char* value) { m_applicationNameHasBeenSet = true; m_applicationName.assign(value); } /** * <p>Name of the application.</p> */ inline ApplicationSummary& WithApplicationName(const Aws::String& value) { SetApplicationName(value); return *this;} /** * <p>Name of the application.</p> */ inline ApplicationSummary& WithApplicationName(Aws::String&& value) { SetApplicationName(std::move(value)); return *this;} /** * <p>Name of the application.</p> */ inline ApplicationSummary& WithApplicationName(const char* value) { SetApplicationName(value); return *this;} /** * <p>ARN of the application.</p> */ inline const Aws::String& GetApplicationARN() const{ return m_applicationARN; } /** * <p>ARN of the application.</p> */ inline void SetApplicationARN(const Aws::String& value) { m_applicationARNHasBeenSet = true; m_applicationARN = value; } /** * <p>ARN of the application.</p> */ inline void SetApplicationARN(Aws::String&& value) { m_applicationARNHasBeenSet = true; m_applicationARN = std::move(value); } /** * <p>ARN of the application.</p> */ inline void SetApplicationARN(const char* value) { m_applicationARNHasBeenSet = true; m_applicationARN.assign(value); } /** * <p>ARN of the application.</p> */ inline ApplicationSummary& WithApplicationARN(const Aws::String& value) { SetApplicationARN(value); return *this;} /** * <p>ARN of the application.</p> */ inline ApplicationSummary& WithApplicationARN(Aws::String&& value) { SetApplicationARN(std::move(value)); return *this;} /** * <p>ARN of the application.</p> */ inline ApplicationSummary& WithApplicationARN(const char* value) { SetApplicationARN(value); return *this;} /** * <p>Status of the application.</p> */ inline const ApplicationStatus& GetApplicationStatus() const{ return m_applicationStatus; } /** * <p>Status of the application.</p> */ inline void SetApplicationStatus(const ApplicationStatus& value) { m_applicationStatusHasBeenSet = true; m_applicationStatus = value; } /** * <p>Status of the application.</p> */ inline void SetApplicationStatus(ApplicationStatus&& value) { m_applicationStatusHasBeenSet = true; m_applicationStatus = std::move(value); } /** * <p>Status of the application.</p> */ inline ApplicationSummary& WithApplicationStatus(const ApplicationStatus& value) { SetApplicationStatus(value); return *this;} /** * <p>Status of the application.</p> */ inline ApplicationSummary& WithApplicationStatus(ApplicationStatus&& value) { SetApplicationStatus(std::move(value)); return *this;} private: Aws::String m_applicationName; bool m_applicationNameHasBeenSet; Aws::String m_applicationARN; bool m_applicationARNHasBeenSet; ApplicationStatus m_applicationStatus; bool m_applicationStatusHasBeenSet; }; } // namespace Model } // namespace KinesisAnalytics } // namespace Aws
/* ------------------------------------------------------------------------- // Venus: A High Performance async server framework // // Module: venus/connection/active.h // Creator: Li Jie // Email: cpunion@gmail.com // Date: 2010-5-10 13:55:00 // // $Id: active.h 2754 2010-05-05 10:25:27Z lijie $ // -----------------------------------------------------------------------*/ #ifndef VENUS_CONN_ACTIVE_H #define VENUS_CONN_ACTIVE_H #ifndef VENUS_BASIC_H #include "../Basic.h" #endif #ifndef VENUS_IO_H #include "../Io.h" #endif #ifndef VENUS_MAIL_H #include "../Mail.h" #endif #ifndef STDEXT_HASHMAP_H #include "../../../../stdext/include/stdext/HashMap.h" #endif #include <map> NS_CERL_BEGIN // ------------------------------------------------------------------------- // class ConnectionImpl class ConnectionImpl { private: ConnectionImpl(const ConnectionImpl&); ConnectionImpl& operator=(const ConnectionImpl&); protected: typedef MailReader<SocketFile> Reader; typedef BufferedWriter<SocketFile> Writer; enum { InvalidMailNo = -1 }; enum { MailNoMask = 0x7FFFFFFF }; typedef bool (cerl_callback *GetProc)(Reader& ar, void* param); struct RecvInfo { ScopedAlloc* alloc; GetProc proc; void* param; bool result; Fiber fiber; }; typedef NS_STDEXT::map<cerl::MailNo, RecvInfo> RecvMap; // callback information RecvMap receivers; NInformation const host; SocketFileObject file; SocketFile fileR; SocketFile fileW; Pool& msgBufPool; // wait for receiver fiber FiberMutex mutexR; // make writers queuing FiberMutex mutexW; Writer writer; Reader reader; UINT32 currMailNo; bool autoReconnect; public: ConnectionImpl( SOCKET socket, const NInformation& hostArg, Pool& msgBufPoolArg) : host(hostArg), fileR(file), fileW(file), msgBufPool(msgBufPoolArg), writer(fileW, (char*)msgBufPool.allocate(), msgBufPool.alloc_size()), reader(fileR, (char*)msgBufPool.allocate(), msgBufPool.alloc_size()), currMailNo(0), autoReconnect(true) { Fiber self = getCurrentFiber(); open_handle(self, socket); } ~ConnectionImpl() { msgBufPool.deallocate((void*)writer.get_buffer(), msgBufPool.alloc_size()); msgBufPool.deallocate((void*)reader.get_buffer(), msgBufPool.alloc_size()); if (file.good() && owner()) file.close(); // wait for receiving fiber to quit CERL_VLOG("Connection", ("wait for receiving fiber\n")); Fiber self = getCurrentFiber(); ScopedLock<FiberMutex> guard(self, mutexR); } void set_auto_reconnect(bool b) { autoReconnect = b; } const NInformation& get_host() const { return host; } bool cerl_call good() const { return file.good(); } public: void cerl_call set_timeout(Timeout to) { file.set_read_timeout(to); file.set_write_timeout(to); } Timeout cerl_call get_timeout() const { return file.get_write_timeout(); } private: bool owner() const { return !(NInformation() == host); } HRESULT cerl_call reopen(Fiber self, const NInformation& host) { CERL_ASSERT(!file.good()); if (!owner()) return E_ACCESSDENIED; // wait for receiving fiber to quit CERL_VLOG("Connection", ("wait for receiving fiber\n")); ScopedLock<FiberMutex> guard(self, mutexR); reader.clear(); writer.clear(); SOCKET socket = connectSocket(self, host); // todo: error process on connect failed. return open_handle(self, socket); } HRESULT cerl_call open_handle(Fiber self, SOCKET socket) { HRESULT result = file.open_handle(socket); if (file.good()) { file.set_read_timeout(CERL_INFINITE); file.set_write_timeout(CERL_INFINITE); CerlIoService(self)->startFiber(self, ReceiverMain, this, VENUS_CONNECTION_STACKSIZE); } return result; } template <class ArgsT> bool cerl_call send(Fiber self, MailNo mailno, FID fid, const ArgsT& args) { MailHeader header = { sizeof(MailHeader), 0, VENUS_MAIL_MAGIC_CODE, mailno, fid }; fileW.setFiber(self); NS_STDEXT_IO_BINARY::put_struct(writer, header); return NS_CERL::putMailBody(writer, args) && writer.flush(); } template <class ResultT> struct Traits { static bool cerl_callback getMailBody(Reader& ar, void* param) { return cerl::getMailBody(ar, *(ResultT*)param); } }; public: template <class ArgsT> bool cerl_call cast(FID fid, const ArgsT& args) { CERL_ASSERT(this); Fiber self = cerl::getCurrentFiber(); MailNo const mailno = (++currMailNo & MailNoMask); Timeout timeout = get_timeout(); if (!mutexW.timed_acquire(self, timeout)) { CERL_WARN("Connection", ("WARN: wait to write timeout\n")); return false; } if (!good() && autoReconnect && reopen(self, host) != S_OK) { mutexW.release(); CERL_WARN("Connection", ("WARN: connection lost!\n")); return false; } const bool b = send(self, mailno, fid, args); mutexW.release(); return b; } template <class ResultT, class ArgsT> bool cerl_call call(ScopedAlloc& alloc, ResultT& result, FID fid, const ArgsT& args) { CERL_ASSERT(this); Fiber self = cerl::getCurrentFiber(); MailNo const mailno = (++currMailNo & MailNoMask); CERL_VLOG("Connection", ("INFO: SEND MailNo: %d\n", (int)mailno)); Timeout timeout = get_timeout(); if (!mutexW.timed_acquire(self, timeout)) { CERL_WARN("Connection", ("WARN: wait to write timeout\n")); return false; } if (!good() && autoReconnect && reopen(self, host) != S_OK) { mutexW.release(); CERL_WARN("Connection", ("WARN: connection lost!\n")); return false; } RecvInfo info; info.alloc = &alloc; info.proc = Traits<ResultT>::getMailBody; info.param = &result; info.result = false; info.fiber = self; receivers.insert(std::make_pair(mailno, info)); bool const fOk = send(self, mailno, fid, args); mutexW.release(); if (!fOk) { CERL_WARN("Connection", ("send failed\n")); return false; } bool succ = timed_yield(self, get_timeout()); receivers.erase(mailno); if (!succ) return false; return info.result; } private: void cerl_callback receiver_(Fiber self) { // protect receive fiber ScopedLock<FiberMutex> guard(self, mutexR); SocketFile pfile(file); Reader reader(pfile, (char*)msgBufPool.allocate(), msgBufPool.alloc_size()); MailHeader header; CERL_VLOG("Connection", ("INFO: Connection::receiver - receiver begin loop.\n")); for(;;) { CERL_VLOG("Connection", ("INFO: Connection::receiver - get header.\n")); if (!NS_STDEXT_IO_BINARY::get_struct(reader, header) || VENUS_MAIL_MAGIC_CODE != header.magic || sizeof(MailHeader) != header.cbHeader) { CERL_WARN("Connection", ("WARN: Connection::receiver - read mail failed: mailno: %d.\n", header.mailno)); file.close(); break; } RecvMap::iterator iterReceiver = receivers.find(header.mailno & MailNoMask); if (receivers.end() == iterReceiver) { CERL_WARN("Connection", ("DROP: mail\n")); skipMailBody(reader); continue; } RecvInfo& receiver = iterReceiver->second; reader.setAlloc(receiver.alloc); CERL_VLOG("Connection", ("INFO: Connection::receiver - do unserialization. \n")); if (!(receiver.result = receiver.proc(reader, receiver.param))) { CERL_WARN("Connection", ("WARN: Connection::receiver - read mail failed!\n")); file.close(); break; } receivers.erase(iterReceiver); CERL_VLOG("Connection", ("INFO: Connection::receiver - schedule to curr fiber. \n")); CerlIoService(self)->scheduleFiber(self); switchToFiber(self, receiver.fiber); } CERL_VLOG("Connection", ("INFO: Connection::receiver cleanup ...\n")); RecvMap::iterator iter = receivers.begin(); for (; iter != receivers.end(); ++ iter) { RecvInfo& receiver = iter->second; receiver.result = false; *(Code*)receiver.param = code_socket_error; CerlIoService(self)->scheduleFiber(self); switchToFiber(self, receiver.fiber); } CERL_VLOG("Connection", ("receiving fiber exit\n")); } static void cerl_callback ReceiverMain(LPVOID lpParam) { FiberParam p(lpParam); ((ConnectionImpl*)p.val)->receiver_(p.self); } }; // ------------------------------------------------------------------------- NS_CERL_END #endif
// Copyright (c) 2012-2014 The Ruxcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef RUXCOIN_VERSION_H #define RUXCOIN_VERSION_H /** * network protocol versioning */ static const int PROTOCOL_VERSION = 70014; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; //! In this version, 'getheaders' was introduced. static const int GETHEADERS_VERSION = 31800; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION = GETHEADERS_VERSION; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this static const int CADDR_TIME_VERSION = 31402; //! BIP 0031, pong message, is enabled for all versions AFTER this one static const int BIP0031_VERSION = 60000; //! "mempool" command, enhanced "getdata" behavior starts with this version static const int MEMPOOL_GD_VERSION = 60002; //! "filter*" commands are disabled without NODE_BLOOM after and including this version static const int NO_BLOOM_VERSION = 70011; //! "sendheaders" command and announcing blocks with headers starts with this version static const int SENDHEADERS_VERSION = 70012; //! "feefilter" tells peers to filter invs to you by fee starts with this version static const int FEEFILTER_VERSION = 70013; //! shord-id-based block download starts with this version static const int SHORT_IDS_BLOCKS_VERSION = 70014; #endif // RUXCOIN_VERSION_H
/* * * Copyright (c) 2016 - 2019 * Stony Brook University * Copyright (c) 2015 - 2018 * Los Alamos National Security, LLC. * Copyright (c) 2011 - 2015 * University of Houston System and UT-Battelle, LLC. * Copyright (c) 2009 - 2015 * Silicon Graphics International Corp. SHMEM is copyrighted * by Silicon Graphics International Corp. (SGI) The OpenSHMEM API * (shmem) is released by Open Source Software Solutions, Inc., under an * agreement with Silicon Graphics International Corp. (SGI). * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * o Neither the name of the University of Houston System, * UT-Battelle, LLC. nor the names of its contributors may be used to * endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /* * expected output: * * PE 0: dst = 123, fetched value = 123 * all others: dst = 123 * */ #include <stdio.h> #include <shmem.h> int dst = 123; int main() { int me; shmem_init(); me = shmem_my_pe(); if (me == 0) { const int fetched = shmem_int_atomic_fetch(&dst, 1); printf("%d: dst = %d, fetched value = %d\n", me, dst, fetched); } shmem_barrier_all(); printf("%d: dst = %d\n", me, dst); shmem_finalize(); return 0; }
/* * Copyright (c) 2020 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ /* Forward declaration to avoid unnecessary includes. */ struct lll_adv_sync; /* Enables CTE transmission according to provided configuration */ void lll_df_cte_tx_enable(struct lll_adv_sync *lll_sync, const struct pdu_adv *pdu, uint32_t *cte_len_us); /* Disables CTE transmission */ void lll_df_conf_cte_tx_disable(void); /* Allocate memory for new DF sync configuration. It will always return the same * pointer until buffer is swapped by lll_df_sync_cfg_latest_get operation. */ struct lll_df_sync_cfg *lll_df_sync_cfg_alloc(struct lll_df_sync *df_cfg, uint8_t *idx); /* Returns pointer to last allocated DF sync configuration. If it is called before * lll_df_sync_cfg_alloc it will return pointer to memory that was recently * enqueued. */ static inline struct lll_df_sync_cfg *lll_df_sync_cfg_peek(struct lll_df_sync *df_cfg) { return &df_cfg->cfg[df_cfg->last]; } /* Enqueue new DF sync configuration data. */ static inline void lll_df_sync_cfg_enqueue(struct lll_df_sync *df_cfg, uint8_t idx) { df_cfg->last = idx; } /* Get latest DF sync configuration data. Latest configuration data are the one * that were enqueued by last lll_df_sync_cfg_enqueue call. */ struct lll_df_sync_cfg *lll_df_sync_cfg_latest_get(struct lll_df_sync *df_cfg, uint8_t *is_modified); /* Get current DF sync configuration data. Current configuration data * are the one that are available after last buffer swap done by call * lll_df_sync_cfg_latest_get. */ static inline struct lll_df_sync_cfg *lll_df_sync_cfg_curr_get(struct lll_df_sync *df_cfg) { return &df_cfg->cfg[df_cfg->first]; } /* Return information if DF sync configuration data were modified since last * call to lll_df_sync_cfg_latest_get. */ static inline uint8_t lll_df_sync_cfg_is_modified(struct lll_df_sync *df_cfg) { return df_cfg->first != df_cfg->last; } /* Enables CTE reception according to provided configuration */ void lll_df_conf_cte_rx_enable(uint8_t slot_duration, uint8_t ant_num, uint8_t *ant_ids, uint8_t chan_idx);
// basic_force.c inherit BOOK; void create() { set_name("内功入门", ({ "force book", "book" })); set_weight(600); if (clonep()) set_default_object(__FILE__); else { set("unit", "本"); set("long", "封面上写著「内功入门」\n"); set("value", 200); set("material", "paper"); set("skill", ([ "name": "force", "exp_required": 1000, "jing_cost": 20, "difficulty": 20, "max_skill": 19, ])); } }
/* * (c)2012 Michael Duane Rice All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. Redistributions in binary * form must reproduce the above copyright notice, this list of conditions * and the following disclaimer in the documentation and/or other materials * provided with the distribution. Neither the name of the copyright holders * nor the names of contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* $Id: sidereal.c 2353 2013-04-19 21:35:53Z swfltek $ */ /* This test allows for 1 second error in calculation of sidereal time 136 years after the epoch. The 'correct' value is 24004.8 seconds. */ #include <time.h> #include <string.h> int main() { time_t t; struct tm calendar; long e; calendar.tm_year = 2136 - 1900; calendar.tm_mon = 0; calendar.tm_mday = 1; calendar.tm_hour = 0; calendar.tm_min = 0; calendar.tm_sec = 0; t = mk_gmtime(&calendar); t = gm_sidereal(&t); e = t - 24005L; e = labs(e); if ( e > 1 ) return (__LINE__); return 0; }
#ifndef zfa2c586730 #define zfa2c586730 #include "kdrive/knx/Config.h" #include "kdrive/knx/telegrams/formatters/Formatter.h" #include <boost/static_assert.hpp> #include <tuple> #include <array> #include <memory> namespace kdrive{namespace knx{template<int z0644e33e40>struct Bits{enum{Value= z0644e33e40*(0x769+138-0x7eb)};};template<int z892c95fbd3>struct Bytes{enum{ Value=z892c95fbd3/(0x17d6+1279-0x1ccd),Offset=z892c95fbd3%(0xec4+5716-0x2510), zf715e08e87=Offset==(0x4ab+7940-0x23af)?true:false,};};template<int index,class Tuple>struct ze973aef068{typedef typename std::tuple_element<index,Tuple>::type z082d8e54fe;enum{Value=z082d8e54fe::z892c95fbd3+ze973aef068<index- (0x19c6+3036-0x25a1),Tuple>::Value};};template<class Tuple>struct ze973aef068< (0x5a3+5272-0x1a3b),Tuple>{typedef typename std::tuple_element< (0x1738+1950-0x1ed6),Tuple>::type z082d8e54fe;enum{Value=z082d8e54fe:: z892c95fbd3};};template<int index,class Tuple>struct z99fe7e8abf{enum{ z892c95fbd3=ze973aef068<index-(0x181+454-0x346),Tuple>::Value,ByteOffset=Bytes< z892c95fbd3>::Value,z6ca52afcb1=Bytes<z892c95fbd3>::Offset};};template<class Tuple>struct z99fe7e8abf<(0x1083+299-0x11ae),Tuple>{enum{z892c95fbd3= (0x52+779-0x35d),ByteOffset=(0xb44+5962-0x228e),z6ca52afcb1=(0x1327+2185-0x1bb0) };};struct z91680f515b zd49fb66547{static unsigned int read(int z202059467a,int z43d31e9636,int z5e1f916d4c,const Buffer&buffer);};struct z91680f515b z3e0ba55e2c{static void write(int z202059467a,int z43d31e9636,int z5e1f916d4c, Buffer&buffer,unsigned int value);};template<int zfdaadc77e5,int T1= (0x1066+4686-0x22b4),int T2=(0xf2a+5888-0x262a),int T3=(0x1ac0+835-0x1e03),int T4=(0x10+5045-0x13c5),int T5=(0xa3f+6072-0x21f7),int z87ec4ad8ee= (0x102a+971-0x13f5),int zc422c570b0=(0x114b+4000-0x20eb),int z01d7d38b56= (0x10e2+5291-0x258d),int z8fbb5cf7c5=(0x1b06+2492-0x24c2)>class zd1e5842927: public AbstractFormatter{private:template<int Bits>struct zee7300c16e{enum{ z892c95fbd3=Bits};};typedef std::tuple<zee7300c16e<zfdaadc77e5>,zee7300c16e<T1>, zee7300c16e<T2>,zee7300c16e<T3>,zee7300c16e<T4>,zee7300c16e<T5>,zee7300c16e< z87ec4ad8ee>,zee7300c16e<zc422c570b0>,zee7300c16e<z01d7d38b56>,zee7300c16e< z8fbb5cf7c5> >TypeList;template<int index>struct Element{typedef typename std:: tuple_element<index,TypeList>::type z082d8e54fe;enum{z892c95fbd3=z082d8e54fe:: z892c95fbd3,z0644e33e40=Bytes<z892c95fbd3>::Value,zf715e08e87=Bytes<z892c95fbd3> ::zf715e08e87,z5039e82d36=z892c95fbd3>(0x10ac+485-0x1291)?true:false,ByteOffset= z99fe7e8abf<index,TypeList>::ByteOffset,z6ca52afcb1=z99fe7e8abf<index,TypeList> ::z6ca52afcb1};};public:typedef zd1e5842927<zfdaadc77e5,T1,T2,T3,T4,T5, z87ec4ad8ee,zc422c570b0,z01d7d38b56,z8fbb5cf7c5>z3f02cdb302;typedef std:: shared_ptr<z3f02cdb302>Ptr;enum{zca14ceedea=std::tuple_size<TypeList>::value, z892c95fbd3=ze973aef068<zca14ceedea-(0x830+3400-0x1577),TypeList>::Value, z0644e33e40=Bytes<z892c95fbd3>::Value,zf715e08e87=Bytes<z892c95fbd3>:: zf715e08e87,z6c5ad13c35=(0x6b2+6194-0x1ec4)};zd1e5842927(){BOOST_STATIC_ASSERT( z892c95fbd3!=(0x1554+2807-0x204b));BOOST_STATIC_ASSERT(z0644e33e40!= (0x1790+1885-0x1eed));BOOST_STATIC_ASSERT(zf715e08e87==true);BOOST_STATIC_ASSERT (sizeof(unsigned int)>=(0x10a5+3190-0x1d17));BOOST_STATIC_ASSERT(zfdaadc77e5<= z6c5ad13c35);BOOST_STATIC_ASSERT(T1<=z6c5ad13c35);BOOST_STATIC_ASSERT(T2<= z6c5ad13c35);BOOST_STATIC_ASSERT(T3<=z6c5ad13c35);BOOST_STATIC_ASSERT(T4<= z6c5ad13c35);BOOST_STATIC_ASSERT(T5<=z6c5ad13c35);BOOST_STATIC_ASSERT( z87ec4ad8ee<=z6c5ad13c35);BOOST_STATIC_ASSERT(zc422c570b0<=z6c5ad13c35); BOOST_STATIC_ASSERT(z01d7d38b56<=z6c5ad13c35);BOOST_STATIC_ASSERT(z8fbb5cf7c5<= z6c5ad13c35);}virtual~zd1e5842927(){}std::size_t size()const override{return z0644e33e40;}bool isValid()const override{return true;}template<int index>void set(unsigned int value){BOOST_STATIC_ASSERT(Element<index>::z5039e82d36); z988e257be4[index]=value;}template<int index>unsigned int get()const{ BOOST_STATIC_ASSERT(Element<index>::z5039e82d36);return z988e257be4[index];} private:typedef std::array<unsigned int,zca14ceedea>Values;template<int index, class Container>struct Reader{inline static void read(Container&container,const Buffer&buffer){Reader<index-(0x295+5311-0x1753),Container>::read(container, buffer);if(Element<index>::z5039e82d36){const int z202059467a=Element<index>:: ByteOffset;const int z43d31e9636=Element<index>::z6ca52afcb1;const int z5e1f916d4c=Element<index>::z892c95fbd3;container[index]=zd49fb66547::read( z202059467a,z43d31e9636,z5e1f916d4c,buffer);}}};template<class Container>struct Reader<(0x3d1+5459-0x1924),Container>{inline static void read(Container& container,const Buffer&buffer){if(Element<(0x20a+8499-0x233d)>::z5039e82d36){ container[(0x17f+6445-0x1aac)]=zd49fb66547::read((0x13b4+2533-0x1d99), (0x217b+1420-0x2707),Element<(0x1510+2835-0x2023)>::z892c95fbd3,buffer);}}}; template<int index,class Container>struct Writer{inline static void write( Container&container,Buffer&buffer){Writer<index-(0xdd3+4822-0x20a8),Container>:: write(container,buffer);if(Element<index>::z5039e82d36){const int z202059467a= Element<index>::ByteOffset;const int z43d31e9636=Element<index>::z6ca52afcb1; const int z5e1f916d4c=Element<index>::z892c95fbd3;const unsigned int value= container[index];z3e0ba55e2c::write(z202059467a,z43d31e9636,z5e1f916d4c,buffer, value);}}};template<class Container>struct Writer<(0x1b+6418-0x192d),Container>{ inline static void write(Container&container,Buffer&buffer){if(Element< (0x1ae5+1593-0x211e)>::z5039e82d36){z3e0ba55e2c::write((0x91c+3843-0x181f), (0x117+5451-0x1662),Element<(0x708+5297-0x1bb9)>::z892c95fbd3,buffer,container[ (0x178+3932-0x10d4)]);}}};std::size_t readImpl(const Buffer&buffer)override{ Reader<zca14ceedea-(0xb14+2568-0x151b),Values>::read(z988e257be4,buffer);return z0644e33e40;}std::size_t writeImpl(Buffer&buffer)override{Writer<zca14ceedea- (0x1463+3321-0x215b),Values>::write(z988e257be4,buffer);return z0644e33e40;} private:Values z988e257be4;};}} #endif
/*-------------------------------------------------------------------------- * * partitionselection.c * Provides utility routines to support partition selection. * * Copyright (c) Pivotal Inc. * *-------------------------------------------------------------------------- */ #include "postgres.h" #include "miscadmin.h" #include "cdb/partitionselection.h" #include "cdb/cdbpartition.h" #include "executor/executor.h" #include "parser/parse_expr.h" #include "utils/memutils.h" /* * During attribute re-mapping for heterogeneous partitions, we use * this struct to identify which varno's attributes will be re-mapped. * Using this struct as a *context* during expression tree walking, we * can skip varattnos that do not belong to a given varno. */ typedef struct AttrMapContext { const AttrNumber *newattno; /* The mapping table to remap the varattno */ Index varno; /* Which rte's varattno to re-map */ } AttrMapContext; static bool change_varattnos_varno_walker(Node *node, const AttrMapContext *attrMapCxt); /* ---------------------------------------------------------------- * eval_propagation_expression * * Evaluate the propagation expression for the given leaf part Oid * and return the result * * ---------------------------------------------------------------- */ static int32 eval_propagation_expression(PartitionSelectorState *node, Oid part_oid) { ExprState *propagationExprState = node->propagationExprState; ExprContext *econtext = node->ps.ps_ExprContext; ResetExprContext(econtext); bool isNull = false; ExprDoneCond isDone = ExprSingleResult; Datum result = ExecEvalExpr(propagationExprState, econtext, &isNull, &isDone); return DatumGetInt32(result); } /* ---------------------------------------------------------------- * construct_partition_constraints_range * * construct a PartitionConstraints node given a PartitionRule for * partition by range * * caller is responsible for free the PartitionConstraints generated * * ---------------------------------------------------------------- */ static PartitionConstraints * construct_part_constraints_range(PartitionRule *rule) { Assert (NULL != rule); PartitionConstraints *constraint = makeNode(PartitionConstraints); Assert (NULL != constraint); constraint->pRule = rule; constraint->defaultPart = rule->parisdefault; if (constraint->defaultPart) { return constraint; } /* retrieve boundary information */ if (NULL == rule->parrangestart && NULL == rule->parrangeend) { /* partition with only the NULL value */ constraint->lowerBound = NULL; constraint->lbInclusive = true; constraint->lbOpen = false; constraint->upperBound = NULL; constraint->upInclusive = true; constraint->upOpen = false; return constraint; } if (NULL == rule->parrangestart) { /* open lower bound */ constraint->lbOpen = true; constraint->lowerBound = NULL; constraint->lbInclusive = false; } else { List *parrangeStart = (List *) rule->parrangestart; Assert (1 == list_length(parrangeStart)); Node *lowerBound = (Node *) linitial(parrangeStart); Assert (IsA(lowerBound, Const)); constraint->lowerBound = (Const *) lowerBound; constraint->lbInclusive = rule->parrangestartincl; constraint->lbOpen = false; } if (NULL == rule->parrangeend) { /* open upper bound */ constraint->upOpen = true; constraint->upperBound = NULL; constraint->upInclusive = false; } else { List *parrangeEnd = (List *) rule->parrangeend; Assert (1 == list_length(parrangeEnd)); Node *upperBound = (Node *) linitial(parrangeEnd); Assert (IsA(upperBound, Const)); constraint->upperBound = (Const *) upperBound; constraint->upInclusive = rule->parrangeendincl; constraint->upOpen = false; } Assert (!constraint->upOpen || !constraint->lbOpen); return constraint; } /* ---------------------------------------------------------------- * construct_partition_constraints_list * * construct a list of PartitionConstraints node given a PartitionRule * for partition by list * * caller is responsible for free the PartitionConstraintss generated * * ---------------------------------------------------------------- */ static List * construct_part_constraints_list(PartitionRule *rule) { List *result = NIL; /* default part */ if (NULL == rule->parlistvalues || rule->parisdefault) { PartitionConstraints *constraint = makeNode(PartitionConstraints); Assert (NULL != constraint); constraint->pRule = rule; constraint->defaultPart = true; result = lappend(result, constraint); return result; } ListCell *lc = NULL; foreach (lc, rule->parlistvalues) { List *values = (List *) lfirst(lc); /* make sure it is single-column partition */ Assert (1 == list_length(values)); Node *value = (Node *) lfirst(list_nth_cell(values, 0)); Assert (IsA(value, Const)); PartitionConstraints *constraint = makeNode(PartitionConstraints); Assert (NULL != constraint); constraint->pRule = rule; constraint->defaultPart = false; constraint->lowerBound = (Const *) value; constraint->lbInclusive = true; constraint->lbOpen = false; constraint->upperBound = (Const *) value; constraint->upInclusive = true; constraint->upOpen = false; result = lappend(result, constraint); } return result; } /* ---------------------------------------------------------------- * construct_partition_constraints * * construct a list of PartitionConstraints node given a PartitionRule * and its partition type * * caller is responsible for free the PartitionConstraintss generated * * ---------------------------------------------------------------- */ static List * construct_part_constraints(PartitionRule *rule, char parkind) { List *result = NIL; switch(parkind) { case 'r': result = lappend(result, construct_part_constraints_range(rule)); break; case 'l': result = construct_part_constraints_list(rule); break; default: elog(ERROR,"unrecognized partitioning kind '%c'", parkind); break; } return result; } /* ---------------------------------------------------------------- * eval_part_qual * * Evaluate a qualification expression that consists of * PartDefaultExpr, PartBoundExpr, PartBoundInclusionExpr, PartBoundOpenExpr * * Return true is passed, otherwise false. * * ---------------------------------------------------------------- */ static bool eval_part_qual(ExprState *exprstate, PartitionSelectorState *node, TupleTableSlot *inputTuple) { /* evaluate generalPredicate */ ExprContext *econtext = node->ps.ps_ExprContext; ResetExprContext(econtext); econtext->ecxt_outertuple = inputTuple; econtext->ecxt_scantuple = inputTuple; List *qualList = list_make1(exprstate); return ExecQual(qualList, econtext, false /* result is not for null */); } /* ---------------------------------------------------------------- * partition_selection * * It finds a child PartitionRule for a given parent partitionNode, which * satisfies with the given partition key value. * * If no such a child partitionRule is found, return NULL. * * Input parameters: * pn: parent PartitionNode * accessMethods: PartitionAccessMethods * root_oid: root table Oid * value: partition key value * exprTypid: type of the expression * * ---------------------------------------------------------------- */ static PartitionRule* partition_selection(PartitionNode *pn, PartitionAccessMethods *accessMethods, Oid root_oid, Datum value, Oid exprTypid, bool isNull) { Assert (NULL != pn); Assert (NULL != accessMethods); Partition *part = pn->part; Assert (1 == part->parnatts); AttrNumber partAttno = part->paratts[0]; Assert (0 < partAttno); Relation rel = relation_open(root_oid, NoLock); TupleDesc tupDesc = RelationGetDescr(rel); Assert(tupDesc->natts >= partAttno); Datum *values = NULL; bool *isnull = NULL; createValueArrays(partAttno, &values, &isnull); isnull[partAttno - 1] = isNull; values[partAttno - 1] = value; PartitionRule *result = get_next_level_matched_partition(pn, values, isnull, tupDesc, accessMethods, exprTypid); freeValueArrays(values, isnull); relation_close(rel, NoLock); return result; } /* ---------------------------------------------------------------- * partition_constraints_range * * Returns a list of PartitionConstraints of all children PartitionRules * with their constraints for a given partition-by-range * PartitionNode * * ---------------------------------------------------------------- */ static List * partition_constraints_range(PartitionNode *pn) { Assert (NULL != pn && 'r' == pn->part->parkind); List *result = NIL; ListCell *lc; foreach (lc, pn->rules) { PartitionRule *rule = (PartitionRule *) lfirst(lc); PartitionConstraints *constraint = construct_part_constraints_range(rule); result = lappend(result, constraint); } return result; } /* ---------------------------------------------------------------- * partition_constraints_list * * Returns a list of PartitionConstraints of all children PartitionRules * with their constraints for a given partition-by-list * PartitionNode * * It generates one PartitionConstraints for each partition value in one * PartitionRule * * ---------------------------------------------------------------- */ static List * partition_constraints_list(PartitionNode *pn) { Assert (NULL != pn && 'l' == pn->part->parkind); List *result = NIL; ListCell *lc = NULL; foreach (lc, pn->rules) { PartitionRule *rule = (PartitionRule *) lfirst(lc); result = list_concat(result, construct_part_constraints_list(rule)); } return result; } /* ---------------------------------------------------------------- * partition_constraints * * Returns a list of PartitionConstraints of all children PartitionRules * with their constraints for a given parent PartitionNode * * ---------------------------------------------------------------- */ static List * partition_constraints(PartitionNode *pn) { Assert (NULL != pn); Partition *part = pn->part; List *result = NIL; switch(part->parkind) { case 'r': result = partition_constraints_range(pn); break; case 'l': result = partition_constraints_list(pn); break; default: elog(ERROR,"unrecognized partitioning kind '%c'", part->parkind); break; } /* add default part if exists */ if (NULL != pn->default_part) { PartitionConstraints *constraint = makeNode(PartitionConstraints); constraint->pRule = pn->default_part; constraint->defaultPart = true; result = lappend(result, constraint); } return result; } /* ---------------------------------------------------------------- * partition_constraints_for_general_predicate * * Return list of PartitionConstraints for the general predicate * of current partition level * * ---------------------------------------------------------------- */ static List * partition_constraints_for_general_predicate(PartitionSelectorState *node, int level, TupleTableSlot *inputTuple, PartitionNode *parentNode) { Assert (NULL != node); Assert (NULL != parentNode); List *partConstraints = partition_constraints(parentNode); List *result = NIL; ListCell *lc = NULL; foreach (lc, partConstraints) { PartitionConstraints *constraints = (PartitionConstraints *) lfirst(lc); /* We need to register it to allLevelParts to evaluate the current predicate */ node->levelPartConstraints[level] = constraints; /* evaluate generalPredicate */ ExprState *exprstate = (ExprState *) lfirst(list_nth_cell(node->levelExprStates, level)); if (eval_part_qual(exprstate, node, inputTuple)) { result = lappend(result, constraints); } } /* reset allLevelPartConstraints */ node->levelPartConstraints[level] = NULL; return result; } /* ---------------------------------------------------------------- * partition_constraints_for_equality_predicate * * Return list of PartitionConstraints for the equality predicate * of current partition level * * ---------------------------------------------------------------- */ static List * partition_constraints_for_equality_predicate(PartitionSelectorState *node, int level, TupleTableSlot *inputTuple, PartitionNode *parentNode) { Assert (NULL != node); Assert (NULL != node->ps.plan); Assert (NULL != parentNode); PartitionSelector *ps = (PartitionSelector *) node->ps.plan; Assert (level < ps->nLevels); /* evaluate equalityPredicate to get partition identifier value */ ExprState *exprState = (ExprState *) lfirst(list_nth_cell(node->levelEqExprStates, level)); ExprContext *econtext = node->ps.ps_ExprContext; ResetExprContext(econtext); econtext->ecxt_outertuple = inputTuple; econtext->ecxt_scantuple = inputTuple; bool isNull = false; ExprDoneCond isDone = ExprSingleResult; Datum value = ExecEvalExpr(exprState, econtext, &isNull, &isDone); /* * Compute the type of the expression result. Sometimes this can be different * than the type of the partition rules (MPP-25707), and we'll need this type * to choose the correct comparator. */ Oid exprTypid = exprType((Node *) exprState->expr); PartitionRule *partRule = partition_selection(parentNode, node->accessMethods, ps->relid, value, exprTypid, isNull); if (NULL != partRule) { return construct_part_constraints(partRule, parentNode->part->parkind); } return NIL; } /* ---------------------------------------------------------------- * processLevel * * find out satisfied PartOids for the given predicates in the * given partition level * * The function is recursively called: * 1. If we are in the intermediate level, we register the * satisfied PartOids and continue with the next level * 2. If we are in the leaf level, we will propagate satisfied * PartOids. * * The return structure contains the leaf part oids and the ids of the scan * operators to which they should be propagated * * Input parameters: * node: PartitionSelectorState * level: the current partition level, starting with 0. * inputTuple: input tuple from outer child for join partition * elimination * * ---------------------------------------------------------------- */ SelectedParts * processLevel(PartitionSelectorState *node, int level, TupleTableSlot *inputTuple) { SelectedParts *selparts = makeNode(SelectedParts); selparts->partOids = NIL; selparts->scanIds = NIL; Assert (NULL != node->ps.plan); PartitionSelector *ps = (PartitionSelector *) node->ps.plan; Assert (level < ps->nLevels); /* get equality and general predicate for the current level */ Expr *equalityPredicate = (Expr *) lfirst(list_nth_cell(ps->levelEqExpressions, level)); Expr *generalPredicate = (Expr *) lfirst(list_nth_cell(ps->levelExpressions, level)); /* get parent PartitionNode if in level 0, it's the root PartitionNode */ PartitionNode *parentNode = node->rootPartitionNode; if (0 != level) { Assert (NULL != node->levelPartConstraints[level - 1]); parentNode = node->levelPartConstraints[level - 1]->pRule->children; } /* list of PartitionConstraints that satisfied the predicates */ List *satisfiedPartConstraints = NULL; /* If equalityPredicate exists */ if (NULL != equalityPredicate) { Assert (NULL == generalPredicate); List *partConstraints = partition_constraints_for_equality_predicate(node, level, inputTuple, parentNode); satisfiedPartConstraints = list_concat(satisfiedPartConstraints, partConstraints); } /* If generalPredicate exists */ else if (NULL != generalPredicate) { List *partConstraints = partition_constraints_for_general_predicate(node, level, inputTuple, parentNode); satisfiedPartConstraints = list_concat(satisfiedPartConstraints, partConstraints); } /* None of the predicate exists */ else { /* * Neither equality predicate nor general predicate * exists. Return all the next level PartitionConstraintss. */ satisfiedPartConstraints = partition_constraints(parentNode); } /* Based on the satisfied PartitionRules, go to next * level or propagate PartOids if we are in the leaf level */ ListCell* lc = NULL; foreach (lc, satisfiedPartConstraints) { PartitionConstraints *partConstraint = (PartitionConstraints *) lfirst(lc); node->levelPartConstraints[level] = partConstraint; bool freeConstraint = true; /* If we already in the leaf level */ if (level == ps->nLevels - 1) { bool shouldPropagate = true; /* if residual predicate exists */ if (NULL != ps->residualPredicate) { /* evaluate residualPredicate */ ExprState *exprstate = node->residualPredicateExprState; shouldPropagate = eval_part_qual(exprstate, node, inputTuple); } if (shouldPropagate) { if (NULL != ps->propagationExpression) { if (!list_member_oid(selparts->partOids, partConstraint->pRule->parchildrelid)) { selparts->partOids = lappend_oid(selparts->partOids, partConstraint->pRule->parchildrelid); int scanId = eval_propagation_expression(node, partConstraint->pRule->parchildrelid); selparts->scanIds = lappend_int(selparts->scanIds, scanId); } } else { /* * We'll need this partConstraint to evaluate the PartOidExpr of the * PartitionSelector operator's target list. Save it in node->acceptedLeafPart. * PartOidExprState.acceptedLeafPart also points to this partConstraint, * so we must save it here (GPSQL-2956). */ *node->acceptedLeafPart = partConstraint; freeConstraint = false; } } } /* Recursively call this function for next level's partition elimination */ else { SelectedParts *selpartsChild = processLevel(node, level+1, inputTuple); selparts->partOids = list_concat(selparts->partOids, selpartsChild->partOids); selparts->scanIds = list_concat(selparts->scanIds, selpartsChild->scanIds); pfree(selpartsChild); } if (freeConstraint) { pfree(partConstraint); } } list_free(satisfiedPartConstraints); /* After finish iteration, reset this level's PartitionConstraints */ node->levelPartConstraints[level] = NULL; return selparts; } /* ---------------------------------------------------------------- * initPartitionSelection * * Initialize partition selection state information * * ---------------------------------------------------------------- */ PartitionSelectorState * initPartitionSelection(bool isRunTime, PartitionSelector *node, EState *estate) { AssertImply (isRunTime, NULL != estate); /* create and initialize PartitionSelectorState structure */ PartitionSelectorState *psstate = makeNode(PartitionSelectorState); psstate->ps.plan = (Plan *) node; psstate->ps.state = estate; psstate->levelPartConstraints = (PartitionConstraints**) palloc0(node->nLevels * sizeof(PartitionConstraints*)); if (isRunTime) { /* ExprContext initialization */ ExecAssignExprContext(estate, &psstate->ps); } else { ExprContext *econtext = makeNode(ExprContext); econtext->ecxt_scantuple = NULL; econtext->ecxt_innertuple = NULL; econtext->ecxt_outertuple = NULL; econtext->ecxt_per_query_memory = 0; econtext->ecxt_per_tuple_memory = AllocSetContextCreate ( NULL /*parent */, "ExprContext", ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE ); econtext->ecxt_param_exec_vals = NULL; econtext->ecxt_param_list_info = NULL; econtext->ecxt_aggvalues = NULL; econtext->ecxt_aggnulls = NULL; econtext->caseValue_datum = (Datum) 0; econtext->caseValue_isNull = true; econtext->domainValue_datum = (Datum) 0; econtext->domainValue_isNull = true; econtext->ecxt_estate = NULL; econtext->ecxt_callbacks = NULL; psstate->ps.ps_ExprContext = econtext; } /* initialize ExprState for evaluating expressions */ ListCell *lc = NULL; foreach (lc, node->levelEqExpressions) { Expr *eqExpr = (Expr *) lfirst(lc); psstate->levelEqExprStates = lappend(psstate->levelEqExprStates, ExecInitExpr(eqExpr, (PlanState *) psstate)); } foreach (lc, node->levelExpressions) { Expr *generalExpr = (Expr *) lfirst(lc); psstate->levelExprStates = lappend(psstate->levelExprStates, ExecInitExpr(generalExpr, (PlanState *) psstate)); } psstate->acceptedLeafPart = (PartitionConstraints **) palloc0(sizeof(void *)); psstate->residualPredicateExprState = ExecInitExpr((Expr *) node->residualPredicate, (PlanState *) psstate); psstate->propagationExprState = ExecInitExpr((Expr *) node->propagationExpression, (PlanState *) psstate); psstate->ps.targetlist = (List *) ExecInitExpr((Expr *) node->plan.targetlist, (PlanState *) psstate); return psstate; } /* ---------------------------------------------------------------- * getPartitionNodeAndAccessMethod * * Retrieve PartitionNode and access method from root table * * ---------------------------------------------------------------- */ void getPartitionNodeAndAccessMethod(Oid rootOid, List *partsMetadata, MemoryContext memoryContext, PartitionNode **partsAndRules, PartitionAccessMethods **accessMethods) { Assert(NULL != partsMetadata); findPartitionMetadataEntry(partsMetadata, rootOid, partsAndRules, accessMethods); Assert(NULL != (*partsAndRules)); Assert(NULL != (*accessMethods)); (*accessMethods)->part_cxt = memoryContext; } /* ---------------------------------------------------------------- * static_part_selection * * Statically select leaf part oids during optimization time * * ---------------------------------------------------------------- */ SelectedParts * static_part_selection(PartitionSelector *ps) { List *partsMetadata = InitializePartsMetadata(ps->relid); PartitionSelectorState *psstate = initPartitionSelection(false /*isRunTime*/, ps, NULL /*estate*/); getPartitionNodeAndAccessMethod ( ps->relid, partsMetadata, NULL, /*memoryContext*/ &psstate->rootPartitionNode, &psstate->accessMethods ); SelectedParts *selparts = processLevel(psstate, 0 /* level */, NULL /*inputSlot*/); /* cleanup */ pfree(psstate->ps.ps_ExprContext); pfree(psstate); list_free_deep(partsMetadata); return selparts; } /* * Generate a map for change_varattnos_of_a_node from old and new TupleDesc's, * matching according to column name. This function returns a NULL pointer (i.e. * null map) if no mapping is necessary (i.e., old and new TupleDesc are already * aligned). * * This function, and change_varattnos_of_a_varno below, used to be in * tablecmds.c, but were removed in upstream commit 188a0a00. But we still need * this for dynamic partition selection in GDPB, so copied them here. */ AttrNumber * varattnos_map(TupleDesc old, TupleDesc new) { AttrNumber *attmap; int i, j; bool mapRequired = false; attmap = (AttrNumber *) palloc0(sizeof(AttrNumber) * old->natts); for (i = 1; i <= old->natts; i++) { if (old->attrs[i - 1]->attisdropped) continue; /* leave the entry as zero */ for (j = 1; j <= new->natts; j++) { if (strcmp(NameStr(old->attrs[i - 1]->attname), NameStr(new->attrs[j - 1]->attname)) == 0) { attmap[i - 1] = j; if (i != j) { mapRequired = true; } break; } } } if (!mapRequired) { pfree(attmap); /* No mapping required, so return NULL */ attmap = NULL; } return attmap; } /* * Replace varattno values in an expression tree according to the given * map array, that is, varattno N is replaced by newattno[N-1]. It is * caller's responsibility to ensure that the array is long enough to * define values for all user varattnos present in the tree. System column * attnos remain unchanged. For historical reason, we only map varattno of the first * range table entry from this method. So, we call the more general * change_varattnos_of_a_varno() with varno set to 1 * * Note that the passed node tree is modified in-place! */ void change_varattnos_of_a_node(Node *node, const AttrNumber *newattno) { /* Only attempt re-mapping if re-mapping is necessary (i.e., non-null newattno map) */ if (newattno) { change_varattnos_of_a_varno(node, newattno, 1 /* varno is hard-coded to 1 (i.e., only first RTE) */); } } /* * Replace varattno values for a given varno RTE index in an expression * tree according to the given map array, that is, varattno N is replaced * by newattno[N-1]. It is caller's responsibility to ensure that the array * is long enough to define values for all user varattnos present in the tree. * System column attnos remain unchanged. * * Note that the passed node tree is modified in-place! */ void change_varattnos_of_a_varno(Node *node, const AttrNumber *newattno, Index varno) { AttrMapContext attrMapCxt; attrMapCxt.newattno = newattno; attrMapCxt.varno = varno; (void) change_varattnos_varno_walker(node, &attrMapCxt); } /* * Remaps the varattno of a varattno in a Var node using an attribute map. */ static bool change_varattnos_varno_walker(Node *node, const AttrMapContext *attrMapCxt) { if (node == NULL) return false; if (IsA(node, Var)) { Var *var = (Var *) node; if (var->varlevelsup == 0 && (var->varno == attrMapCxt->varno) && var->varattno > 0) { /* * ??? the following may be a problem when the node is multiply * referenced though stringToNode() doesn't create such a node * currently. */ Assert(attrMapCxt->newattno[var->varattno - 1] > 0); var->varattno = var->varoattno = attrMapCxt->newattno[var->varattno - 1]; } return false; } return expression_tree_walker(node, change_varattnos_varno_walker, (void *) attrMapCxt); }
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/core/Core_EXPORTS.h> #include <aws/core/http/HttpClient.h> #include <aws/core/http/curl/CurlHandleContainer.h> #include <aws/core/client/ClientConfiguration.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <atomic> namespace Aws { namespace Http { namespace Standard { class StandardHttpResponse; } //Curl implementation of an http client. Right now it is only synchronous. class AWS_CORE_API CurlHttpClient: public HttpClient { public: using Base = HttpClient; //Creates client, initializes curl handle if it hasn't been created already. CurlHttpClient(const Aws::Client::ClientConfiguration& clientConfig); //Makes request and receives response synchronously AWS_DEPRECATED("This funciton in base class has been deprecated") std::shared_ptr<HttpResponse> MakeRequest(HttpRequest& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr, Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const override; //Makes request with shared_ptr typed request and receives response synchronously std::shared_ptr<HttpResponse> MakeRequest(const std::shared_ptr<HttpRequest>& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr, Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const override; static void InitGlobalState(); static void CleanupGlobalState(); private: mutable CurlHandleContainer m_curlHandleContainer; bool m_isUsingProxy; Aws::String m_proxyUserName; Aws::String m_proxyPassword; Aws::String m_proxyScheme; Aws::String m_proxyHost; Aws::String m_proxySSLCertPath; Aws::String m_proxySSLCertType; Aws::String m_proxySSLKeyPath; Aws::String m_proxySSLKeyType; Aws::String m_proxyKeyPasswd; unsigned m_proxyPort; bool m_verifySSL; Aws::String m_caPath; Aws::String m_caFile; bool m_disableExpectHeader; bool m_allowRedirects; static std::atomic<bool> isInit; void MakeRequestInternal(HttpRequest& request, std::shared_ptr<Standard::StandardHttpResponse>& response, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter, Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter) const; }; using PlatformHttpClient = CurlHttpClient; } // namespace Http } // namespace Aws
#include <stdio.h> #include <stdlib.h> #include "char_operations.h" int main() { char(**funcs)(char); funcs = malloc(4 * sizeof(char (*)(char))); if(funcs == NULL) { printf("Failed to allocate memory\n"); return 8; } *(funcs + 0) = lower_to_upper; *(funcs + 1) = upper_to_lower; *(funcs + 2) = space_to_dash; *(funcs + 3) = reverse_letter; int option; char *text = malloc(1001 * sizeof(char)); if (text == NULL) { printf("Failed to allocate memory\n"); free(funcs); return 8; } printf("Podaj text: "); scanf("%1000[^\n]s", text); //Clear buff while(getchar()!='\n'){} printf("Podaj opcje do wyknania: "); if (scanf("%d", &option) != 1) { printf("Incorrect input\n"); free(text); free(funcs); return 1; } if (option < 0 || option > 3) { printf("Incorrect input data\n"); free(text); free(funcs); return 2; } char *newText; switch (option) { case 0: newText = letter_modifier(text, lower_to_upper); break; case 1: newText = letter_modifier(text, upper_to_lower); break; case 2: newText = letter_modifier(text, space_to_dash); break; case 3: newText = letter_modifier(text, reverse_letter); break; default: break; } if (newText == NULL) { printf("Failed to allocate memory\n"); free(text); free(funcs); return 8; } printf("%s", newText); free(text); free(newText); free(funcs); return 0; }
/******************************* LICENSE ******************************* * (C) Copyright 1996-2016 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation nor * does it submit to any jurisdiction. ******************************* LICENSE *******************************/ /*! \fileNetcdfVectorInterpretorAttributes.h \brief Definition of NetcdfVectorInterpretor Attributes class. This file is automatically generated. Do Not Edit! Generated: */ #ifndef NetcdfVectorInterpretorWrapper_H #define NetcdfVectorInterpretorWrapper_H #include "magics.h" #include "ParameterManager.h" #include "Factory.h" #include "NetcdfVectorInterpretor.h" #include "NetcdfInterpretorWrapper.h" namespace magics { class MagRequest; class NetcdfVectorInterpretorWrapper: public NetcdfInterpretorWrapper { public: // -- constructor NetcdfVectorInterpretorWrapper(); NetcdfVectorInterpretorWrapper(NetcdfVectorInterpretor*); // -- destructor virtual ~NetcdfVectorInterpretorWrapper(); virtual void set(const MagRequest&); NetcdfVectorInterpretor* me() { return netcdfvectorinterpretor_; } virtual NetcdfVectorInterpretor* object() { return netcdfvectorinterpretor_; } virtual void object(NetcdfVectorInterpretor* o) { // Remember to delete the previous object netcdfvectorinterpretor_ = o; NetcdfInterpretorWrapper::object(o); } protected: NetcdfVectorInterpretor* netcdfvectorinterpretor_; // -- method virtual void print(ostream&) const; private: string tag_; friend ostream& operator<<(ostream& s,const NetcdfVectorInterpretorWrapper& p) { p.print(s); return s; } }; } // namespace magics #endif
/* * %CopyrightBegin% * * Copyright Ericsson AB 2005-2011. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * %CopyrightEnd% */ /* * Native ethread atomics on PowerPC. * Author: Mikael Pettersson. * * Based on the examples in Appendix E of Motorola's * "Programming Environments Manual For 32-Bit Implementations * of the PowerPC Architecture". */ #ifndef ETHREAD_PPC_ATOMIC_H #define ETHREAD_PPC_ATOMIC_H #define ETHR_HAVE_NATIVE_ATOMIC32 1 #define ETHR_NATIVE_ATOMIC32_IMPL "ethread" typedef struct { volatile ethr_sint32_t counter; } ethr_native_atomic32_t; #if defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_ATOMIC_IMPL__) #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADDR 1 static ETHR_INLINE ethr_sint32_t * ethr_native_atomic32_addr(ethr_native_atomic32_t *var) { return (ethr_sint32_t *) &var->counter; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET 1 static ETHR_INLINE void ethr_native_atomic32_set(ethr_native_atomic32_t *var, ethr_sint32_t i) { var->counter = i; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_read(ethr_native_atomic32_t *var) { return var->counter; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_add_return(ethr_native_atomic32_t *var, ethr_sint32_t incr) { ethr_sint32_t tmp; __asm__ __volatile__( "1:\t" "lwarx %0,0,%1\n\t" "add %0,%2,%0\n\t" "stwcx. %0,0,%1\n\t" "bne- 1b\n\t" : "=&r"(tmp) : "r"(&var->counter), "r"(incr) : "cc", "memory"); return tmp; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_add_return_acqb(ethr_native_atomic32_t *var, ethr_sint32_t incr) { ethr_sint32_t res; res = ethr_native_atomic32_add_return(var, incr); __asm__ __volatile("isync\n\t" : : : "memory"); return res; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_inc_return(ethr_native_atomic32_t *var) { ethr_sint32_t tmp; __asm__ __volatile__( "1:\t" "lwarx %0,0,%1\n\t" "addic %0,%0,1\n\t" /* due to addi's (rA|0) behaviour */ "stwcx. %0,0,%1\n\t" "bne- 1b\n\t" : "=&r"(tmp) : "r"(&var->counter) : "cc", "memory"); return tmp; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_inc_return_acqb(ethr_native_atomic32_t *var) { ethr_sint32_t res; res = ethr_native_atomic32_inc_return(var); __asm__ __volatile("isync\n\t" : : : "memory"); return res; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_dec_return(ethr_native_atomic32_t *var) { ethr_sint32_t tmp; __asm__ __volatile__( "1:\t" "lwarx %0,0,%1\n\t" "addic %0,%0,-1\n\t" "stwcx. %0,0,%1\n\t" "bne- 1b\n\t" : "=&r"(tmp) : "r"(&var->counter) : "cc", "memory"); return tmp; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_dec_return_acqb(ethr_native_atomic32_t *var) { ethr_sint32_t res; res = ethr_native_atomic32_dec_return(var); __asm__ __volatile("isync\n\t" : : : "memory"); return res; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_and_retold(ethr_native_atomic32_t *var, ethr_sint32_t mask) { ethr_sint32_t old, new; __asm__ __volatile__( "1:\t" "lwarx %0,0,%2\n\t" "and %1,%0,%3\n\t" "stwcx. %1,0,%2\n\t" "bne- 1b\n\t" : "=&r"(old), "=&r"(new) : "r"(&var->counter), "r"(mask) : "cc", "memory"); return old; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_and_retold_acqb(ethr_native_atomic32_t *var, ethr_sint32_t mask) { ethr_sint32_t res; res = ethr_native_atomic32_and_retold(var, mask); __asm__ __volatile("isync\n\t" : : : "memory"); return res; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_or_retold(ethr_native_atomic32_t *var, ethr_sint32_t mask) { ethr_sint32_t old, new; __asm__ __volatile__( "1:\t" "lwarx %0,0,%2\n\t" "or %1,%0,%3\n\t" "stwcx. %1,0,%2\n\t" "bne- 1b\n\t" : "=&r"(old), "=&r"(new) : "r"(&var->counter), "r"(mask) : "cc", "memory"); return old; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_or_retold_acqb(ethr_native_atomic32_t *var, ethr_sint32_t mask) { ethr_sint32_t res; res = ethr_native_atomic32_or_retold(var, mask); __asm__ __volatile("isync\n\t" : : : "memory"); return res; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_xchg(ethr_native_atomic32_t *var, ethr_sint32_t val) { ethr_sint32_t tmp; __asm__ __volatile__( "1:\t" "lwarx %0,0,%1\n\t" "stwcx. %2,0,%1\n\t" "bne- 1b\n\t" : "=&r"(tmp) : "r"(&var->counter), "r"(val) : "cc", "memory"); return tmp; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_xchg_acqb(ethr_native_atomic32_t *var, ethr_sint32_t val) { ethr_sint32_t res; res = ethr_native_atomic32_xchg(var, val); __asm__ __volatile("isync\n\t" : : : "memory"); return res; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_cmpxchg(ethr_native_atomic32_t *var, ethr_sint32_t new, ethr_sint32_t expected) { ethr_sint32_t old; __asm__ __volatile__( "1:\t" "lwarx %0,0,%2\n\t" "cmpw 0,%0,%3\n\t" "bne 2f\n\t" "stwcx. %1,0,%2\n\t" "bne- 1b\n\t" "2:" : "=&r"(old) : "r"(new), "r"(&var->counter), "r"(expected) : "cc", "memory"); return old; } #define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_ACQB 1 static ETHR_INLINE ethr_sint32_t ethr_native_atomic32_cmpxchg_acqb(ethr_native_atomic32_t *var, ethr_sint32_t new, ethr_sint32_t expected) { ethr_sint32_t old; __asm__ __volatile__( "1:\t" "lwarx %0,0,%2\n\t" "cmpw 0,%0,%3\n\t" "bne 2f\n\t" "stwcx. %1,0,%2\n\t" "bne- 1b\n\t" "isync\n" "2:" : "=&r"(old) : "r"(new), "r"(&var->counter), "r"(expected) : "cc", "memory"); return old; } #endif /* ETHR_TRY_INLINE_FUNCS */ #endif /* ETHREAD_PPC_ATOMIC_H */
/*****************************************************************************/ /* SOURCE CONTROL VERSIONS */ /*---------------------------------------------------------------------------*/ /* */ /* Version Date Time Author / Comment (optional) */ /* */ /* $Log: rxsearch.h,v $ /* Revision 1.1 2010/07/21 17:14:57 richard_wood /* Initial checkin of V3.0.0 source code and other resources. /* Initial code builds V3.0.0 RC1 /* /* Revision 1.1 2009/06/09 13:21:29 richard_wood /* *** empty log message *** /* /* Revision 1.2 2008/09/19 14:51:49 richard_wood /* Updated for VS 2005 /* /* */ /*****************************************************************************/ /********************************************************************************** Copyright (c) 2003, Albert M. Choy All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Microplanet, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************************/ #pragma once //forward declaration class RegEx; class RxSearch { public: RxSearch(); ~RxSearch(); // returns pointer to result or null LPCTSTR Search (LPCTSTR buffer, // null terminated buffer to search int *resultLen); // length of result // returns 0 for success int Compile(LPCTSTR pattern, // compile pattern for search BOOL fIgnoreCase = TRUE); BOOL HasPattern () { return m_pRegEx ? TRUE : FALSE; } // return 'register' $a thru $z (0-25) LPCTSTR GetAssignment (int n); private: HANDLE m_mutex; RegEx * m_pRegEx; };
#ifndef SLIDER_H #define SLIDER_H #include<QSlider> #include<QMouseEvent> #include<QEvent> #include <QLabel> #include "MyToolTip.h" //滑动条 class CMySlider : public QSlider { Q_OBJECT public: explicit CMySlider(Qt::Orientation orientation, QWidget* parent =0); void mouseMoveEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent * event); void mouseReleaseEvent(QMouseEvent *event); bool event(QEvent *event); bool eventFilter(QObject* target, QEvent * event); //事件过滤 void leaveEvent(QEvent *event); void enterEvent(QEvent *event); signals: void signalPressPosition(qint64 position); void signalMouseMovePosition(qint64 position); public slots: void slotSliderPressed(); void slotSliderReleased(); public: void setToolTipText(const QString toolTip); CMyToolTip* getToolTip(); void setToolTipVisible(bool bIsToolTipVisible); bool getToolTipVisible(); private: bool m_bIsLeftPressDown; bool m_bIsSliderPressed; bool m_bIsDragSlider; qint64 m_pressedPosition; qint64 m_LeftPressPointX; qint64 m_mouseMovePointX; CMyToolTip* m_toolTip; bool m_bIsToolTipVisible; }; #endif // SLIDER_H
#ifndef FS_STREAM_H #define FS_STREAM_H #include <fs/fs.h> /** * \brief Creates a new stream, and returns the file representation * * @param length Length of stream buffer * * @return Pointer to kfile representing the stream */ struct kfile *stream_create(int length); #endif
/* Test for crashing bugs when trying to create too many timers. */ #include <stdio.h> #include <time.h> #include <signal.h> #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> #if _POSIX_THREADS # include <pthread.h> void thread (union sigval arg) { puts ("Timeout"); } int do_test (void) { int i, res; timer_t timerId; struct itimerspec itval; struct sigevent sigev; itval.it_interval.tv_sec = 2; itval.it_interval.tv_nsec = 0; itval.it_value.tv_sec = 2; itval.it_value.tv_nsec = 0; sigev.sigev_notify = SIGEV_THREAD; sigev.sigev_signo = SIGRTMIN; sigev.sigev_notify_function = thread; sigev.sigev_notify_attributes = 0; sigev.sigev_value.sival_ptr = (void *) &timerId; for (i = 0; i < 100; i++) { printf ("cnt = %d\n", i); if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0) { perror ("timer_create"); continue; } res = timer_settime (timerId, 0, &itval, NULL); if (res < 0) perror ("timer_settime"); res = timer_delete (timerId); if (res < 0) perror ("timer_delete"); } return 0; } # define TEST_FUNCTION do_test () #else # define TEST_FUNCTION 0 #endif #include "../test-skeleton.c"
// // HCDOrder.h // 18命令模式 // // Created by yifan on 15/8/15. // Copyright (c) 2015年 黄成都. All rights reserved. // #import <Foundation/Foundation.h> #import "HCDOrder.h" #import "HCDWorker.h" @interface HCDOrder : NSObject @property(nonatomic,copy)NSString *orderString; -(instancetype)initWithOrderString:(NSString *)orderString; //执行命令 -(void)executeOrder; @end
#include "user_interface.h" #include "c_types.h" #include "c_stdio.h" #include "mem.h" #include "osapi.h" #include "user_config.h" #include "platform/config.h" #include "driver/rfm69.h" #include "radiohandler.h" #include "util/cbuff.h" /* RX Buffer Size - 128 == 2+ packets */ #define RFM_RX_BUFFSIZE 128 /* TX Buffer Size - 256 == 4+ packets */ #define RFM_TX_BUFFSIZE 256 static RFM_Handle rfm_handle_base; CBUFFOBJ rxBuffObj; CBUFF rxBuff[RFM_RX_BUFFSIZE]; CBUFFOBJ txBuffObj; CBUFF txBuff[RFM_TX_BUFFSIZE]; bool init_rfm_handler() { int ret = 0; RFM_Handle * rfm_ptr = &rfm_handle_base; cbuffInit(); memset(rfm_ptr, 0, sizeof(rfm_handle_base)); rfm_handle_base.rxBuffNum = cbuffCreate(rxBuff, RFM_RX_BUFFSIZE, &rxBuffObj); rfm_handle_base.txBuffNum = cbuffCreate(txBuff, RFM_TX_BUFFSIZE, &txBuffObj); if (rfm_handle_base.rxBuffNum == 0 || rfm_handle_base.txBuffNum == 0) { NODE_ERR("Error creating rfm cbuff(s)\n"); } else { NODE_DBG("cbuff tx Id=%d, rx = %d\n", rfm_handle_base.txBuffNum, rfm_handle_base.rxBuffNum); } uint8_t thisNodeId, thisNetId; RFM_CONF_T dummy; RFM_CONF_T * rfmConfPtr = &dummy; ret = get_config_ptr((void *)rfmConfPtr, rfm_conf_type); if (ret > 0) { NODE_DBG("Loaded rfm info: Id=%d, netId = %d\n", rfmConfPtr->bridgeId, rfmConfPtr->netId); thisNodeId = rfmConfPtr->bridgeId; thisNetId = rfmConfPtr->netId; } else { thisNodeId = RFM69_NODE_ID; thisNetId = RFM69_NET_ID; NODE_DBG("Error loading rfm.conf\n"); } // rfm_handle_base.msgCb = rfm_callback; rfm_handle_base.nodeId = thisNodeId; rfm_handle_base.msgCb = NULL; rfm_handle_base.state = RFM_IDLE; rfm_handle_base.keepAliveTick = 20; //20 ms default rfm_handle_base.sendTimeout = 1000; //1 sec default rfm_handle_base.options = RFM_OUTPUT_ALL; ret = rfm69_spi_init(); if (ret == RFM_SPI_OK) { NODE_DBG("RFM69 SPI Initialized\n"); ret = rfm69_init(rfm_ptr, thisNodeId, thisNetId); if (ret == RFM_INIT_OK) { NODE_DBG("RFM69 listening on address %d...\n", thisNodeId); radioHandlerInit(rfm_ptr); return true; } } NODE_DBG("Error: RFM init returned %d\n", ret); return false; }
/** * \file * * \brief Instance description for DSU * * Copyright (c) 2013-2014 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * \asf_license_stop * */ #ifndef _SAMD21_DSU_INSTANCE_ #define _SAMD21_DSU_INSTANCE_ /* ========== Register definition for DSU peripheral ========== */ #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) #define REG_DSU_CTRL (0x41002000U) /**< \brief (DSU) Control */ #define REG_DSU_STATUSA (0x41002001U) /**< \brief (DSU) Status A */ #define REG_DSU_STATUSB (0x41002002U) /**< \brief (DSU) Status B */ #define REG_DSU_ADDR (0x41002004U) /**< \brief (DSU) Address */ #define REG_DSU_LENGTH (0x41002008U) /**< \brief (DSU) Length */ #define REG_DSU_DATA (0x4100200CU) /**< \brief (DSU) Data */ #define REG_DSU_DCC0 (0x41002010U) /**< \brief (DSU) Debug Communication Channel 0 */ #define REG_DSU_DCC1 (0x41002014U) /**< \brief (DSU) Debug Communication Channel 1 */ #define REG_DSU_DID (0x41002018U) /**< \brief (DSU) Device Identification */ #define REG_DSU_ENTRY0 (0x41003000U) /**< \brief (DSU) Coresight ROM Table Entry 0 */ #define REG_DSU_ENTRY1 (0x41003004U) /**< \brief (DSU) Coresight ROM Table Entry 1 */ #define REG_DSU_END (0x41003008U) /**< \brief (DSU) Coresight ROM Table End */ #define REG_DSU_MEMTYPE (0x41003FCCU) /**< \brief (DSU) Coresight ROM Table Memory Type */ #define REG_DSU_PID4 (0x41003FD0U) /**< \brief (DSU) Peripheral Identification 4 */ #define REG_DSU_PID0 (0x41003FE0U) /**< \brief (DSU) Peripheral Identification 0 */ #define REG_DSU_PID1 (0x41003FE4U) /**< \brief (DSU) Peripheral Identification 1 */ #define REG_DSU_PID2 (0x41003FE8U) /**< \brief (DSU) Peripheral Identification 2 */ #define REG_DSU_PID3 (0x41003FECU) /**< \brief (DSU) Peripheral Identification 3 */ #define REG_DSU_CID0 (0x41003FF0U) /**< \brief (DSU) Component Identification 0 */ #define REG_DSU_CID1 (0x41003FF4U) /**< \brief (DSU) Component Identification 1 */ #define REG_DSU_CID2 (0x41003FF8U) /**< \brief (DSU) Component Identification 2 */ #define REG_DSU_CID3 (0x41003FFCU) /**< \brief (DSU) Component Identification 3 */ #else #define REG_DSU_CTRL (*(WoReg8 *)0x41002000U) /**< \brief (DSU) Control */ #define REG_DSU_STATUSA (*(RwReg8 *)0x41002001U) /**< \brief (DSU) Status A */ #define REG_DSU_STATUSB (*(RoReg8 *)0x41002002U) /**< \brief (DSU) Status B */ #define REG_DSU_ADDR (*(RwReg *)0x41002004U) /**< \brief (DSU) Address */ #define REG_DSU_LENGTH (*(RwReg *)0x41002008U) /**< \brief (DSU) Length */ #define REG_DSU_DATA (*(RwReg *)0x4100200CU) /**< \brief (DSU) Data */ #define REG_DSU_DCC0 (*(RwReg *)0x41002010U) /**< \brief (DSU) Debug Communication Channel 0 */ #define REG_DSU_DCC1 (*(RwReg *)0x41002014U) /**< \brief (DSU) Debug Communication Channel 1 */ #define REG_DSU_DID (*(RoReg *)0x41002018U) /**< \brief (DSU) Device Identification */ #define REG_DSU_ENTRY0 (*(RoReg *)0x41003000U) /**< \brief (DSU) Coresight ROM Table Entry 0 */ #define REG_DSU_ENTRY1 (*(RoReg *)0x41003004U) /**< \brief (DSU) Coresight ROM Table Entry 1 */ #define REG_DSU_END (*(RoReg *)0x41003008U) /**< \brief (DSU) Coresight ROM Table End */ #define REG_DSU_MEMTYPE (*(RoReg *)0x41003FCCU) /**< \brief (DSU) Coresight ROM Table Memory Type */ #define REG_DSU_PID4 (*(RoReg *)0x41003FD0U) /**< \brief (DSU) Peripheral Identification 4 */ #define REG_DSU_PID0 (*(RoReg *)0x41003FE0U) /**< \brief (DSU) Peripheral Identification 0 */ #define REG_DSU_PID1 (*(RoReg *)0x41003FE4U) /**< \brief (DSU) Peripheral Identification 1 */ #define REG_DSU_PID2 (*(RoReg *)0x41003FE8U) /**< \brief (DSU) Peripheral Identification 2 */ #define REG_DSU_PID3 (*(RoReg *)0x41003FECU) /**< \brief (DSU) Peripheral Identification 3 */ #define REG_DSU_CID0 (*(RoReg *)0x41003FF0U) /**< \brief (DSU) Component Identification 0 */ #define REG_DSU_CID1 (*(RoReg *)0x41003FF4U) /**< \brief (DSU) Component Identification 1 */ #define REG_DSU_CID2 (*(RoReg *)0x41003FF8U) /**< \brief (DSU) Component Identification 2 */ #define REG_DSU_CID3 (*(RoReg *)0x41003FFCU) /**< \brief (DSU) Component Identification 3 */ #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ /* ========== Instance parameters for DSU peripheral ========== */ #define DSU_CLK_HSB_ID 3 #endif /* _SAMD21_DSU_INSTANCE_ */
/** * VampirTrace * http://www.tu-dresden.de/zih/vampirtrace * * Copyright (c) 2005-2008, ZIH, TU Dresden, Federal Republic of Germany * * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing * Centre, Federal Republic of Germany * * See the file COPYING in the package base directory for details **/ #ifndef _VT_COMP_H #define _VT_COMP_H #ifdef __cplusplus # define EXTERN extern "C" #else # define EXTERN extern #endif /* Compiler adapter finalizer */ EXTERN void (*vt_comp_finalize)(void); #endif
// // CompetitionEntity+CoreDataClass.h // localsports // // Created by Antonio Díaz Arroyo on 31/1/18. // Copyright © 2018 cice. All rights reserved. // // #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class ClassificationEntity, MatchEntity; NS_ASSUME_NONNULL_BEGIN @interface CompetitionEntity : NSManagedObject @end NS_ASSUME_NONNULL_END #import "CompetitionEntity+CoreDataProperties.h"
#include "lwip/ip.h" /** * Source based IPv4 routing hook function. This function works only * when destination IP is broadcast IP. */ struct netif * ESP_IRAM_ATTR ip4_route_src(const ip4_addr_t *src, const ip4_addr_t *dest) { struct netif *netif = NULL; /* destination IP is broadcast IP? */ if ((src != NULL) && (dest->addr == IPADDR_BROADCAST)) { /* iterate through netifs */ for (netif = netif_list; netif != NULL; netif = netif->next) { /* is the netif up, does it have a link and a valid address? */ if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) { /* source IP matches? */ if (ip4_addr_cmp(src, netif_ip4_addr(netif))) { /* return netif on which to forward IP packet */ return netif; } } } } return netif; }
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ #define PPAPI_SHARED_IMPL_HOST_RESOURCE_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/shared_impl/ppapi_shared_export.h" namespace ppapi { // For "old" style resources, PP_Resource values differ on the host and plugin // side. Implementations of those should be careful to use HostResource to // prevent confusion. "New" style resources use the same PP_Resource value on // the host and plugin sides, and should not use HostResource. // // Old style resources match these file specs: // Proxy: ppapi/proxy/ppb_*_proxy.* // Host: webkit/plugins/ppapi/* // New style resources match these file specs: // Proxy: ppapi/proxy/*_resource.* // Browser: (content|chrome)/browser/renderer_host/pepper/pepper_*_host.* // Renderer: (content|chrome)/renderer/pepper/pepper_*_host.* // // // Represents a PP_Resource sent over the wire. This just wraps a PP_Resource. // The point is to prevent mistakes where the wrong resource value is sent. // Resource values are remapped in the plugin so that it can talk to multiple // hosts. If all values were PP_Resource, it would be easy to forget to do // this transformation. // // To get the corresponding plugin PP_Resource for a HostResource, use // PluginResourceTracker::PluginResourceForHostResource(). // // All HostResources respresent IDs valid in the host. class PPAPI_SHARED_EXPORT HostResource { public: HostResource(); bool is_null() const { return !host_resource_; } // Some resources are plugin-side only and don't have a corresponding // resource in the host. Yet these resources still need an instance to be // associated with. This function creates a HostResource with the given // instances and a 0 host resource ID for these cases. static HostResource MakeInstanceOnly(PP_Instance instance); // Sets and retrieves the internal PP_Resource which is valid for the host // (a.k.a. renderer, as opposed to the plugin) process. // // DO NOT CALL THESE FUNCTIONS IN THE PLUGIN SIDE OF THE PROXY. The values // will be invalid. See the class comment above. void SetHostResource(PP_Instance instance, PP_Resource resource); PP_Resource host_resource() const { return host_resource_; } PP_Instance instance() const { return instance_; } // This object is used in maps so we need to provide this sorting operator. bool operator<(const HostResource& other) const { if (instance_ != other.instance_) return instance_ < other.instance_; return host_resource_ < other.host_resource_; } private: PP_Instance instance_; PP_Resource host_resource_; }; } // namespace ppapi #endif // PPAPI_SHARED_IMPL_HOST_RESOURCE_H_
/** * @file * @brief * * @author Anton Kozlov * @date 04.06.2014 */ #include <kernel/panic.h> #include <kernel/task/resource.h> #include <kernel/task.h> void task_init(struct task *tsk, int id, struct task *parent, const char *name, struct thread *main_thread, task_priority_t priority) { assert(tsk == task_kernel_task()); assert(id == task_get_id(tsk)); assert(0 == strcmp(name, task_get_name(tsk))); assert(main_thread == task_get_main(tsk)); assert(TASK_PRIORITY_DEFAULT == task_get_priority(tsk)); if (main_thread != NULL) { /* check for thread.NoThreads module */ main_thread->task = tsk; } task_resource_init(tsk); } void task_do_exit(struct task *task, int status) { panic("single task %s called\n", __func__); } void task_start_exit(void) { panic("single task %s called\n", __func__); } void __attribute__((noreturn)) task_finish_exit(void) { panic("single task %s called\n", __func__); }
#include <stdio.h> #include "vicmain_c" #include "gpdsroutines.h" #include "mo_include.h" #define TEST_ARRAY_LENGTH 20 /* MO_TABLE_READ acceptance and unit test Author: Justin McNeill Date: August 1993 */ main44() { AGGREGATE label_ptr; int i,j,k; int status; int label_status; int count; int total_records; int lengths[10]; int item_number[10]; int row_number; char string[120]; char invalid_file_name[80]; char label_file_name[80], table_file_name[80]; char *value; char keywords[TEST_ARRAY_LENGTH][40], object[TEST_ARRAY_LENGTH][20], values[TEST_ARRAY_LENGTH][40]; struct PRODUCTION_TABLE_ENTRY *table_ptr; /* Get production table label and table file names. */ status = zvp("P_LABEL",label_file_name,&count); if ( status != 1 ) { zvmessage("*** Error in ZVP call for P_LABEL"," "); zabend(); } status = zvp("P_TABLE",table_file_name,&count); if ( status != 1 ) { zvmessage("*** Error in ZVP call for P_TABLE"," "); zabend(); } status = zvp("INVALID",invalid_file_name,&count); if ( status != 1 ) { zvmessage("*** Error in ZVP call for INVALID"," "); zabend(); } /* Get production table total number of records. */ label_ptr = gpds_open_file(label_file_name, &status); if ( status < 0 ) { zvmessage("*** Error in GPDS_OPEN_FILE call"," "); zabend(); } value = gpds_get_label_value(label_ptr, "ROOT", moFILE_RECORDS, 1, &status); if ( status < 0 ) { zvmessage("*** Error in GPDS_GET_LABEL_VALUE call"," "); zabend(); } total_records = atoi( value ); gpds_close_file(label_ptr); zvmessage(" "," "); zvmessage("********************************************************"," "); zvmessage(" "," "); zvmessage(" C Test of mo_table_read"," "); zvmessage(" "," "); zvmessage("********************************************************"," "); zvmessage(" "," "); /* Read consecutive rows from production table. */ table_ptr = (struct PRODUCTION_TABLE_ENTRY *)malloc (sizeof(struct PRODUCTION_TABLE_ENTRY)); for ( i=0; i<total_records; i++ ) { row_number = i + 1; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, 0, 0, 0, &status); if ( status < 0 ) { zvmessage("*** Error in MO_TABLE_READ call"," "); sprintf(string,"\tstatus flag is %d",status); zvmessage(string," "); zabend(); } zvmessage(" "," "); zvmessage("********************************************************", " "); sprintf(string,"\nRecord %d of \'%s\':\n", row_number,table_file_name); zvmessage(string," "); sprintf(string,"\tFILE_SPECIFICATION_NAME is \'%s\'", table_ptr->file_specification_name); zvmessage(string," "); sprintf(string,"\t(LINES,LINES_SAMPLES) = (%d,%d)", table_ptr->lines,table_ptr->lines_samples); zvmessage(string," "); sprintf(string,"\t(START_LINE,START_SAMPLE) = (%d,%d)", table_ptr->start_line,table_ptr->start_sample); zvmessage(string," "); sprintf(string,"\tFRAME_ID is \'%s\' and TILE_ID is \'%s\'", table_ptr->frame_id,table_ptr->tile_id); zvmessage(string," "); sprintf(string,"\tMASK_TYPE is \'%s\'",table_ptr->mask_type); zvmessage(string," "); } /* Search table for first row with 'MASK_TYPE' of 'GENERAL'. */ row_number = 1; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, "MASK_TYPE", "GENERAL", 1, &status); if ( status < 0 ) { zvmessage("*** Error in MO_TABLE_READ call"," "); sprintf(string,"\tstatus flag is %d",status); zvmessage(string," "); zabend(); } else { zvmessage(" "," "); zvmessage("********************************************************", " "); sprintf(string,"\nRecord %d of \'%s\':\n", row_number,table_file_name); zvmessage(string," "); sprintf(string,"\tFILE_SPECIFICATION_NAME is \'%s\'", table_ptr->file_specification_name); zvmessage(string," "); sprintf(string,"\t(LINES,LINES_SAMPLES) = (%d,%d)", table_ptr->lines,table_ptr->lines_samples); zvmessage(string," "); sprintf(string,"\t(START_LINE,START_SAMPLE) = (%d,%d)", table_ptr->start_line,table_ptr->start_sample); zvmessage(string," "); sprintf(string,"\tFRAME_ID is \'%s\' and TILE_ID is \'%s\'", table_ptr->frame_id,table_ptr->tile_id); zvmessage(string," "); sprintf(string,"\tMASK_TYPE is \'%s\'",table_ptr->mask_type); zvmessage(string," "); } /* Search table for first row with 'TILE_ID' of '02 of 02'. */ row_number = 1; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, "TILE_ID", "02 OF 02", 1, &status); if ( status < 0 ) { zvmessage("*** Error in MO_TABLE_READ call"," "); sprintf(string,"\tstatus flag is %d",status); zvmessage(string," "); zabend(); } else { zvmessage(" "," "); zvmessage("********************************************************", " "); sprintf(string,"\nRecord %d of \'%s\'\n", row_number,table_file_name); zvmessage(string," "); sprintf(string,"\tFILE_SPECIFICATION_NAME is \'%s\'", table_ptr->file_specification_name); zvmessage(string," "); sprintf(string,"\t(LINES,LINES_SAMPLES) = (%d,%d)", table_ptr->lines,table_ptr->lines_samples); zvmessage(string," "); sprintf(string,"\t(START_LINE,START_SAMPLE) = (%d,%d)", table_ptr->start_line,table_ptr->start_sample); zvmessage(string," "); sprintf(string,"\tFRAME_ID is \'%s\' and TILE_ID is \'%s\'", table_ptr->frame_id,table_ptr->tile_id); zvmessage(string," "); sprintf(string,"\tMASK_TYPE is \'%s\'",table_ptr->mask_type); zvmessage(string," "); } /* Search table for next row with 'TILE_ID' of '02 of 02' and test for case insensitivity. */ row_number++; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, "TILE_iD", "02 oF 02", 1, &status); if ( status < 0 ) { zvmessage("*** Error in MO_TABLE_READ call"," "); sprintf(string,"\tstatus flag is %d",status); zvmessage(string," "); zabend(); } else { zvmessage(" "," "); zvmessage("********************************************************", " "); sprintf(string,"\nRecord %d of \'%s\'\n", row_number,table_file_name); zvmessage(string," "); sprintf(string,"\tFILE_SPECIFICATION_NAME is \'%s\'", table_ptr->file_specification_name); zvmessage(string," "); sprintf(string,"\t(LINES,LINES_SAMPLES) = (%d,%d)", table_ptr->lines,table_ptr->lines_samples); zvmessage(string," "); sprintf(string,"\t(START_LINE,START_SAMPLE) = (%d,%d)", table_ptr->start_line,table_ptr->start_sample); zvmessage(string," "); sprintf(string,"\tFRAME_ID is \'%s\' and TILE_ID is \'%s\'", table_ptr->frame_id,table_ptr->tile_id); zvmessage(string," "); sprintf(string,"\tMASK_TYPE is \'%s\'",table_ptr->mask_type); zvmessage(string," "); } zvmessage(" "," "); zvmessage(" "," "); zvmessage("********************************************************"," "); zvmessage(" "," "); zvmessage("\tTest of error handling of MO table read function"," "); zvmessage(" "," "); zvmessage("********************************************************"," "); zvmessage(" "," "); zvmessage("\tMake call to table read function with "," "); zvmessage("\ta nonexistent label file. Expect -1 status flag"," "); zvmessage("\tindicating an error in opening the file."," "); zvmessage(" "," "); row_number = 1; mo_table_read("NONEXISTENT.LBL",table_file_name,table_ptr, &row_number, "LINES", "002050", 1, &status); if ( status < 0 ) { zvmessage("\t*** Error in MO table read function."," "); sprintf(string,"\t\tstatus flag is %d",status); zvmessage(string," "); } zvmessage("\n********************************************************"," "); zvmessage(" "," "); zvmessage("\tMake call to table read function with "," "); zvmessage("\titem number argument out of range."," "); zvmessage("\tExpect succesful read because there are"," "); zvmessage("\tno keywords with multiple values."," "); zvmessage(" "," "); row_number = 1; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, "LINES", "002050", -2, &status); if ( status < 0 ) { zvmessage("\t*** Error in MO table read function."," "); sprintf(string,"\t\tstatus flag is %d",status); zvmessage(string," "); } else zvmessage("\tSuccessful MO table read "," "); zvmessage("\n********************************************************"," "); zvmessage(" "," "); zvmessage("\tMake call to table read function with "," "); zvmessage("\tinput of invalid record type."," "); zvmessage("\tExpect a -3 status flag value returned."," "); zvmessage(" "," "); row_number = 1; mo_table_read(invalid_file_name,table_file_name,table_ptr, &row_number, "LINES", "002050", 1, &status); if ( status < 0 ) { zvmessage("\t*** Error in MO table read function."," "); sprintf(string,"\t\tstatus flag is %d",status); zvmessage(string," "); } zvmessage("\n********************************************************"," "); zvmessage(" "," "); zvmessage("\tMake call to table read function with "," "); zvmessage("\trow_number argument that is negative."," "); zvmessage("\tExpect a -4 status flag value returned"," "); zvmessage("\tindicating failure in search (EOF reached)."," "); zvmessage(" "," "); row_number = -1; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, "LINES", "002050", 1, &status); if ( status < 0 ) { zvmessage("\t*** Error in MO table read function."," "); sprintf(string,"\t\tstatus flag is %d",status); zvmessage(string," "); } zvmessage("\n********************************************************"," "); zvmessage(" "," "); zvmessage("\tMake call to table read function with "," "); zvmessage("\tkey_value argument that is non-existent.."," "); zvmessage("\tExpect a -5 status flag value returned"," "); zvmessage("\tindicating failure in search (EOF reached)."," "); zvmessage(" "," "); row_number = 1; mo_table_read(label_file_name,table_file_name,table_ptr, &row_number, "LINES", "002340", 1, &status); if ( status < 0 ) { zvmessage("\t*** Error in MO table read function."," "); sprintf(string,"\t\tstatus flag is %d",status); zvmessage(string," "); } zvmessage("\n***************************************************\n"," "); zvmessage("\tEnd of ACCEPTANCE and UNIT test"," "); zvmessage("\n***************************************************\n"," "); }
Copyright 2016 Gregory Bryant Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /***********************************************************************/ #ifndef SCOREPARAMETERS_H #define SCOREPARAMETERS_H #include <QWidget> #include <QMdiSubWindow> namespace Ui { class ScoreParameters; } class ScoreParameters : public QWidget { Q_OBJECT public: explicit ScoreParameters(QWidget *parent = 0); ~ScoreParameters(); QAction *menuAction; QMdiSubWindow *mdiSubWindow; private: Ui::ScoreParameters *ui; public slots: void windowMenuAction(void); }; #endif // SCOREPARAMETERS_H
/// \file ParamGeneration.h /// /// \brief Parameter generation routines for Zerocoin. /// /// \author Ian Miers, Christina Garman and Matthew Green /// \date June 2013 /// /// \copyright Copyright 2013 Ian Miers, Christina Garman and Matthew Green /// \license This project is released under the MIT license. // Copyright (c) 2017 The PIVX developers // Copyright (c) 2017 The Deviant developers #ifndef PARAMGENERATION_H_ #define PARAMGENERATION_H_ #include "Params.h" namespace libzerocoin { void CalculateParams(ZerocoinParams &params, CBigNum N, std::string aux, uint32_t securityLevel); void calculateGroupParamLengths(uint32_t maxPLen, uint32_t securityLevel, uint32_t *pLen, uint32_t *qLen); // Constants #define STRING_COMMIT_GROUP "COIN_COMMITMENT_GROUP" #define STRING_AVC_GROUP "ACCUMULATED_VALUE_COMMITMENT_GROUP" #define STRING_AVC_ORDER "ACCUMULATED_VALUE_COMMITMENT_ORDER" #define STRING_AIC_GROUP "ACCUMULATOR_INTERNAL_COMMITMENT_GROUP" #define STRING_QRNCOMMIT_GROUPG "ACCUMULATOR_QRN_COMMITMENT_GROUPG" #define STRING_QRNCOMMIT_GROUPH "ACCUMULATOR_QRN_COMMITMENT_GROUPH" #define ACCUMULATOR_BASE_CONSTANT 31 #define MAX_PRIMEGEN_ATTEMPTS 10000 #define MAX_ACCUMGEN_ATTEMPTS 10000 #define MAX_GENERATOR_ATTEMPTS 10000 #define NUM_SCHNORRGEN_ATTEMPTS 10000 // Prototypes bool primalityTestByTrialDivision(uint32_t candidate); uint256 calculateSeed(CBigNum modulus, std::string auxString, uint32_t securityLevel, std::string groupName); uint256 calculateGeneratorSeed(uint256 seed, uint256 pSeed, uint256 qSeed, std::string label, uint32_t index, uint32_t count); uint256 calculateHash(uint256 input); IntegerGroupParams deriveIntegerGroupParams(uint256 seed, uint32_t pLen, uint32_t qLen); IntegerGroupParams deriveIntegerGroupFromOrder(CBigNum &groupOrder); void calculateGroupModulusAndOrder(uint256 seed, uint32_t pLen, uint32_t qLen, CBigNum *resultModulus, CBigNum *resultGroupOrder, uint256 *resultPseed, uint256 *resultQseed); CBigNum calculateGroupGenerator(uint256 seed, uint256 pSeed, uint256 qSeed, CBigNum modulus, CBigNum groupOrder, uint32_t index); CBigNum generateRandomPrime(uint32_t primeBitLen, uint256 in_seed, uint256 *out_seed, uint32_t *prime_gen_counter); CBigNum generateIntegerFromSeed(uint32_t numBits, uint256 seed, uint32_t *numIterations); bool primalityTestByTrialDivision(uint32_t candidate); }/* namespace libzerocoin */ #endif /* PARAMGENERATION_H_ */
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_PRERENDER_PRERENDER_HOST_REGISTRY_H_ #define CONTENT_BROWSER_PRERENDER_PRERENDER_HOST_REGISTRY_H_ #include <map> #include "base/callback_forward.h" #include "base/observer_list_types.h" #include "base/types/pass_key.h" #include "content/browser/prerender/prerender_host.h" #include "content/browser/renderer_host/back_forward_cache_impl.h" #include "content/common/content_export.h" #include "third_party/blink/public/common/tokens/tokens.h" #include "third_party/blink/public/mojom/prerender/prerender.mojom.h" #include "url/gurl.h" #include "url/origin.h" namespace content { class FrameTreeNode; class RenderFrameHostImpl; class WebContentsImpl; // Prerender2: // PrerenderHostRegistry creates and retains a prerender host, and reserves it // for NavigationRequest to activate the prerendered page. This is created and // owned by StoragePartitionImpl. // TODO(https://crbug.com/1170619): Tie the registry with WebContentsImpl. // // The APIs of this class are categorized into two: APIs for triggers and APIs // for activators. // // - Triggers (e.g., PrerenderProcessor) can request to create a new prerender // host by CreateAndStartHost() and cancel it by AbandonHost(Async)(). // Triggers cannot cancel the host after it's preserved by an activator. // - Activators (i.e., NavigationRequest) can reserve the prerender host on // activation start by ReserveHostToActivate() and activate it by // ActivateReservedHost(). They can abandon the host by // AbandonPreservedHost(). class CONTENT_EXPORT PrerenderHostRegistry { public: using PassKey = base::PassKey<PrerenderHostRegistry>; PrerenderHostRegistry(); ~PrerenderHostRegistry(); PrerenderHostRegistry(const PrerenderHostRegistry&) = delete; PrerenderHostRegistry& operator=(const PrerenderHostRegistry&) = delete; PrerenderHostRegistry(PrerenderHostRegistry&&) = delete; PrerenderHostRegistry& operator=(PrerenderHostRegistry&&) = delete; class Observer : public base::CheckedObserver { public: // Called once per CreateAndStartHost() call. Does not necessarily // mean a host was created. virtual void OnTrigger(const GURL& url) {} // Called from the registry's destructor. The observer // should drop any reference to the registry. virtual void OnRegistryDestroyed() {} }; void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); // For triggers. // Creates and starts a host. Returns the root frame tree node id of the // prerendered page, which can be used as the id of the host. int CreateAndStartHost(blink::mojom::PrerenderAttributesPtr attributes, RenderFrameHostImpl& initiator_render_frame_host); // For triggers. // Destroys the host registered for `frame_tree_node_id`. // TODO(https://crbug.com/1169594): Distinguish two paths that cancel // prerendering. A prerender can be canceled due to the following reasons: // 1. Initiator was no longer interested. Since one prerender may have several // initiators, PrerenderHostRegistry should not destroy a PrerenderHost // instance if one of the initiators is still alive. // 2. Prerendering page did something undesirable. The same behavior always // happens regardless of which caller calls it. So PrerenderHostRegistry // should destroy the PrerenderHost. void AbandonHost(int frame_tree_node_id); // For triggers. // This is the same with AbandonHost but destroys the prerender host // asynchronously so that the prerendered page itself can cancel prerendering // without concern for self destruction. void AbandonHostAsync(int frame_tree_node_id, PrerenderHost::FinalStatus final_status); // TODO(https://crbug.com/1194865): Remove the following method once the // workaround in the call site is removed. void AbandonAllHostsForWebContents(const WebContentsImpl& web_contents); // For activators. // Reserves the host to activate for a navigation for the given FrameTreeNode. // Returns the root frame tree node id of the prerendered page, which can be // used as the id of the host. Returns RenderFrameHost::kNoFrameTreeNodeId if // it's not found or not ready for activation yet. The caller is responsible // for calling ActivateReservedHost() or AbandonReservedHost() with the id to // release the reserved host. int ReserveHostToActivate(const GURL& navigation_url, FrameTreeNode& frame_tree_node); // For activators. // Activates the host reserved by ReserveHostToActivate(). // - For MPArch, this returns the BackForwardCacheImpl::Entry containing the // page that was activated on success, or nullptr on failure. // - For multiple WebContents, this always returns nullptr. // TODO(crbug.com/1183519): Remove multiple WebContents // implementation after MPArch activation is sufficiently stable. // // `current_render_frame_host` is the RenderFrameHostImpl that will be swapped // out and destroyed by the activation. std::unique_ptr<BackForwardCacheImpl::Entry> ActivateReservedHost( int frame_tree_node_id, RenderFrameHostImpl& current_render_frame_host, NavigationRequest& navigation_request); RenderFrameHostImpl* GetRenderFrameHostForReservedHost( int frame_tree_node_id); // For activators. // Abandons the host reserved by ReserveHostToActivate(). void AbandonReservedHost(int frame_tree_node_id); // Returns the non-reserved host. Returns nullptr if the frame tree node id // doesn't match any host. PrerenderHost* FindHostById(int frame_tree_node_id); // Returns the non-reserved host for `prerendering_url`. Returns nullptr if // the URL doesn't match any non-reserved host. PrerenderHost* FindHostByUrlForTesting(const GURL& prerendering_url); private: std::unique_ptr<PrerenderHost> AbandonHostInternal(int frame_tree_node_id); void NotifyTrigger(const GURL& url); // Hosts that are not reserved for activation yet. // TODO(https://crbug.com/1132746): Expire prerendered contents if they are // not used for a while. std::map<int, std::unique_ptr<PrerenderHost>> prerender_host_by_frame_tree_node_id_; std::map<GURL, int> frame_tree_node_id_by_url_; // Hosts that are reserved for activation. std::map<int, std::unique_ptr<PrerenderHost>> reserved_prerender_host_by_frame_tree_node_id_; base::ObserverList<Observer> observers_; }; } // namespace content #endif // CONTENT_BROWSER_PRERENDER_PRERENDER_HOST_REGISTRY_H_
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <test.h> int main() { char str[] = "foooo-bar-bazz"; char* token = strtok(str, "-"); assert(strlen(token) == 5, "returns the first token"); assert(strncmp(token, "foooo", strlen(token)) == 0, "returns the first token (2)"); int i = 0; int assertions = 0; while (token != NULL) { token = strtok(NULL, "-"); i++; if (i == 1) { assert(strncmp(token, "bar", strlen(token)) == 0, "returns the second token"); assertions++; } else if (i == 2) { assert(strncmp(token, "bazz", strlen(token)) == 0, "returns the third token"); assertions++; } else if (i == 3) { assert(token == NULL, "returns NULL"); assertions++; } } assert(assertions == 3, "found 2 more tokens and then NULL"); return test_summary(); }
// Intel 8250 serial port (UART). #include "types.h" #include "defs.h" #include "param.h" #include "traps.h" #include "spinlock.h" #include "fs.h" #include "file.h" #include "mmu.h" #include "proc.h" #include "x86.h" #define COM1 0x3f8 static int uart; // is there a uart? void uartinit(void) { char *p; // Turn off the FIFO outb(COM1+2, 0); // 9600 baud, 8 data bits, 1 stop bit, parity off. outb(COM1+3, 0x80); // Unlock divisor outb(COM1+0, 115200/9600); outb(COM1+1, 0); outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+4, 0); outb(COM1+1, 0x01); // Enable receive interrupts. // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) return; uart = 1; // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6 is running for 081531246\n"; *p; p++) uartputc(*p); } void uartputc(int c) { int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) microdelay(10); outb(COM1+0, c); } static int uartgetc(void) { if(!uart) return -1; if(!(inb(COM1+5) & 0x01)) return -1; return inb(COM1+0); } void uartintr(void) { consoleintr(uartgetc); }
/* logging.h * * Copyright (C) 2006-2021 wolfSSL Inc. * * This file is part of wolfSSL. * * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ /* submitted by eof */ #ifndef CYASSL_LOGGING_H #define CYASSL_LOGGING_H /* for fips compatibility @wc_fips */ #include <wolfssl/wolfcrypt/logging.h> #define CYASSL_LEAVE WOLFSSL_LEAVE #define CYASSL_ERROR WOLFSSL_ERROR #define CYASSL_ENTER WOLFSSL_ENTER #define CYASSL_MSG WOLFSSL_MSG /* check old macros possibly declared */ #if defined(DEBUG_CYASSL) && !defined(DEBUG_WOLFSSL) #define DEBUG_WOLFSSL #endif #endif /* CYASSL_LOGGING_H */
//===--- Decl.h - Swift Language Declaration ASTs ---------------*- C++ -*-===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // This file defines the Decl class and subclasses. // //===----------------------------------------------------------------------===// #ifndef SWIFT_DECL_H #define SWIFT_DECL_H #include "swift/AST/AccessScope.h" #include "swift/AST/Attr.h" #include "swift/AST/CaptureInfo.h" #include "swift/AST/ClangNode.h" #include "swift/AST/ConcreteDeclRef.h" #include "swift/AST/DefaultArgumentKind.h" #include "swift/AST/DiagnosticConsumer.h" #include "swift/AST/DiagnosticEngine.h" #include "swift/AST/GenericParamKey.h" #include "swift/AST/IfConfigClause.h" #include "swift/AST/LayoutConstraint.h" #include "swift/AST/StorageImpl.h" #include "swift/AST/TypeAlignments.h" #include "swift/AST/TypeWalker.h" #include "swift/AST/Types.h" #include "swift/AST/Witness.h" #include "swift/Basic/ArrayRefView.h" #include "swift/Basic/Compiler.h" #include "swift/Basic/Debug.h" #include "swift/Basic/InlineBitfield.h" #include "swift/Basic/NullablePtr.h" #include "swift/Basic/OptionalEnum.h" #include "swift/Basic/Range.h" #include "swift/Basic/Located.h" #include "llvm/ADT/DenseSet.h" #include "llvm/Support/TrailingObjects.h" #include <type_traits> namespace swift { enum class AccessSemantics : unsigned char; class AccessorDecl; class ApplyExpr; class AvailabilityContext; class GenericEnvironment; class ArchetypeType; class ASTContext; struct ASTNode; class ASTPrinter; class ASTWalker; class ConstructorDecl; class DestructorDecl; class DiagnosticEngine; class DynamicSelfType; class Type; class Expr; class DeclRefExpr; class ForeignErrorConvention; class LiteralExpr; class BraceStmt; class DeclAttributes; class GenericContext; class GenericSignature; class GenericTypeParamDecl; class GenericTypeParamType; class ModuleDecl; class NamedPattern; class EnumCaseDecl; class EnumElementDecl; class ParameterList; class ParameterTypeFlags; class Pattern; struct PrintOptions; struct PropertyWrapperBackingPropertyInfo; struct PropertyWrapperTypeInfo; struct PropertyWrapperMutability; class ProtocolDecl; class ProtocolType; struct RawComment; enum class ResilienceExpansion : unsigned; class TypeAliasDecl; class Stmt; class SubscriptDecl; class UnboundGenericType; class ValueDecl; class VarDecl; class OpaqueReturnTypeRepr; namespace ast_scope { class AbstractPatternEntryScope; class PatternEntryDeclScope; class PatternEntryInitializerScope; } // namespace ast_scope enum class DeclKind : uint8_t { #define DECL(Id, Parent) Id, #define LAST_DECL(Id) Last_Decl = Id, #define DECL_RANGE(Id, FirstId, LastId) \ First_##Id##Decl = FirstId, Last_##Id##Decl = LastId, #include "swift/AST/DeclNodes.def" }; enum : unsigned { NumDeclKindBits = countBitsUsed(static_cast<unsigned>(DeclKind::Last_Decl)) }; /// Fine-grained declaration kind that provides a description of the /// kind of entity a declaration represents, as it would be used in /// diagnostics. /// /// For example, \c FuncDecl is a single declaration class, but it has /// several descriptive entries depending on whether it is an /// operator, global function, local function, method, (observing) /// accessor, etc. enum class DescriptiveDeclKind : uint8_t { Import, Extension, EnumCase, TopLevelCode, IfConfig, PoundDiagnostic, PatternBinding, Var, Param, Let, Property, StaticProperty, ClassProperty, InfixOperator, PrefixOperator, PostfixOperator, PrecedenceGroup, TypeAlias, GenericTypeParam, AssociatedType, Type, Enum, Struct, Class, Protocol, GenericEnum, GenericStruct, GenericClass, GenericType, Subscript, StaticSubscript, ClassSubscript, Constructor, Destructor, LocalFunction, GlobalFunction, OperatorFunction, Method, StaticMethod, ClassMethod, Getter, Setter, Addressor, MutableAddressor, ReadAccessor, ModifyAccessor, WillSet, DidSet, EnumElement, Module, MissingMember, Requirement, OpaqueResultType, OpaqueVarType }; /// Describes which spelling was used in the source for the 'static' or 'class' /// keyword. enum class StaticSpellingKind : uint8_t { None, KeywordStatic, KeywordClass, }; /// Keeps track of whether an enum has cases that have associated values. enum class AssociatedValueCheck { /// We have not yet checked. Unchecked, /// The enum contains no cases or all cases contain no associated values. NoAssociatedValues, /// The enum contains at least one case with associated values. HasAssociatedValues, }; /// Diagnostic printing of \c StaticSpellingKind. llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, StaticSpellingKind SSK); /// Encapsulation of the overload signature of a given declaration, /// which is used to determine uniqueness of a declaration within a /// given context. /// /// Two definitions in the same context may not have the same overload /// signature. struct OverloadSignature { /// The full name of the declaration. DeclName Name; /// The kind of unary operator. UnaryOperatorKind UnaryOperator; /// Whether this is an instance member. unsigned IsInstanceMember : 1; /// Whether this is a variable. unsigned IsVariable : 1; /// Whether this is a function. unsigned IsFunction : 1; /// Whether this is a enum element. unsigned IsEnumElement : 1; /// Whether this is a nominal type. unsigned IsNominal : 1; /// Whether this is a type alias. unsigned IsTypeAlias : 1; /// Whether this signature is part of a protocol extension. unsigned InProtocolExtension : 1; /// Whether this signature is of a member defined in an extension of a generic /// type. unsigned InExtensionOfGenericType : 1; /// Whether this declaration has an opaque return type. unsigned HasOpaqueReturnType : 1; OverloadSignature() : UnaryOperator(UnaryOperatorKind::None), IsInstanceMember(false), IsVariable(false), IsFunction(false), InProtocolExtension(false), InExtensionOfGenericType(false), HasOpaqueReturnType(false) {} }; /// Determine whether two overload signatures conflict. /// /// \param sig1 The overload signature of the first declaration. /// \param sig2 The overload signature of the second declaration. /// \param skipProtocolExtensionCheck If \c true, members of protocol extensions /// will be allowed to conflict with members of protocol declarations. bool conflicting(const OverloadSignature& sig1, const OverloadSignature& sig2, bool skipProtocolExtensionCheck = false); /// Determine whether two overload signatures and overload types conflict. /// /// \param ctx The AST context. /// \param sig1 The overload signature of the first declaration. /// \param sig1Type The overload type of the first declaration. /// \param sig2 The overload signature of the second declaration. /// \param sig2Type The overload type of the second declaration. /// \param wouldConflictInSwift5 If non-null, the referenced boolean will be set /// to \c true iff the function returns \c false for this version of /// Swift, but the given overloads will conflict in Swift 5 mode. /// \param skipProtocolExtensionCheck If \c true, members of protocol extensions /// will be allowed to conflict with members of protocol declarations. bool conflicting(ASTContext &ctx, const OverloadSignature& sig1, CanType sig1Type, const OverloadSignature& sig2, CanType sig2Type, bool *wouldConflictInSwift5 = nullptr, bool skipProtocolExtensionCheck = false); /// The kind of artificial main to generate. enum class ArtificialMainKind : uint8_t { NSApplicationMain, UIApplicationMain, TypeMain, }; /// Decl - Base class for all declarations in Swift. class alignas(1 << DeclAlignInBits) Decl { protected: union { uint64_t OpaqueBits; SWIFT_INLINE_BITFIELD_BASE(Decl, bitmax(NumDeclKindBits,8)+1+1+1+1+1, Kind : bitmax(NumDeclKindBits,8), /// Whether this declaration is invalid. Invalid : 1, /// Whether this declaration was implicitly created, e.g., /// an implicit constructor in a struct. Implicit : 1, /// Whether this declaration was mapped directly from a Clang AST. /// /// Use getClangNode() to retrieve the corresponding Clang AST. FromClang : 1, /// Whether this declaration was added to the surrounding /// DeclContext of an active #if config clause. EscapedFromIfConfig : 1 ); SWIFT_INLINE_BITFIELD_FULL(PatternBindingDecl, Decl, 1+2+16, /// Whether this pattern binding declares static variables. IsStatic : 1, /// Whether 'static' or 'class' was used. StaticSpelling : 2, : NumPadBits, /// The number of pattern binding declarations. NumPatternEntries : 16 ); SWIFT_INLINE_BITFIELD_FULL(EnumCaseDecl, Decl, 32, : NumPadBits, /// The number of tail-allocated element pointers. NumElements : 32 ); SWIFT_INLINE_BITFIELD(ValueDecl, Decl, 1+1+1, AlreadyInLookupTable : 1, /// Whether we have already checked whether this declaration is a /// redeclaration. CheckedRedeclaration : 1, /// Whether the decl can be accessed by swift users; for instance, /// a.storage for lazy var a is a decl that cannot be accessed. IsUserAccessible : 1 ); SWIFT_INLINE_BITFIELD(AbstractStorageDecl, ValueDecl, 1, /// Whether this property is a type property (currently unfortunately /// called 'static'). IsStatic : 1 ); SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 1+1+1+1+1+1+1+1, /// Encodes whether this is a 'let' binding. Introducer : 1, /// Whether this declaration was an element of a capture list. IsCaptureList : 1, /// Whether this declaration captures the 'self' param under the same name. IsSelfParamCapture : 1, /// Whether this vardecl has an initial value bound to it in a way /// that isn't represented in the AST with an initializer in the pattern /// binding. This happens in cases like "for i in ...", switch cases, etc. HasNonPatternBindingInit : 1, /// Whether this is a property used in expressions in the debugger. /// It is up to the debugger to instruct SIL how to access this variable. IsDebuggerVar : 1, /// Whether this is the backing storage for a lazy property. IsLazyStorageProperty : 1, /// Whether this is the backing storage for a property wrapper. IsPropertyWrapperBackingProperty : 1, /// Whether this is a lazily top-level global variable from the main file. IsTopLevelGlobal : 1 ); SWIFT_INLINE_BITFIELD(ParamDecl, VarDecl, 1+2+NumDefaultArgumentKindBits, /// Whether we've computed the specifier yet. SpecifierComputed : 1, /// The specifier associated with this parameter. This determines /// the storage semantics of the value e.g. mutability. Specifier : 2, /// Information about a symbolic default argument, like #file. defaultArgumentKind : NumDefaultArgumentKindBits ); SWIFT_INLINE_BITFIELD(SubscriptDecl, VarDecl, 2, StaticSpelling : 2 ); SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1, /// \see AbstractFunctionDecl::BodyKind BodyKind : 3, /// Import as member status. IAMStatus : 8, /// Whether the function has an implicit 'self' parameter. HasImplicitSelfDecl : 1, /// Whether we are overridden later. Overridden : 1, /// Whether the function body throws. Throws : 1, /// Whether this member was synthesized as part of a derived /// protocol conformance. Synthesized : 1, /// Whether this member's body consists of a single expression. HasSingleExpressionBody : 1 ); SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+1+2+1+1+2+1, /// Whether we've computed the 'static' flag yet. IsStaticComputed : 1, /// Whether this function is a 'static' method. IsStatic : 1, /// Whether 'static' or 'class' was used. StaticSpelling : 2, /// Whether we are statically dispatched even if overridable ForcedStaticDispatch : 1, /// Whether we've computed the 'self' access kind yet. SelfAccessComputed : 1, /// Backing bits for 'self' access kind. SelfAccess : 2, /// Whether this is a top-level function which should be treated /// as if it were in local context for the purposes of capture /// analysis. HasTopLevelLocalContextCaptures : 1 ); SWIFT_INLINE_BITFIELD(AccessorDecl, FuncDecl, 4 + 1 + 1, /// The kind of accessor this is. AccessorKind : 4, /// Whether the accessor is transparent. IsTransparent : 1, /// Whether we have computed the above. IsTransparentComputed : 1); SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 3+1+1, /// The body initialization kind (+1), or zero if not yet computed. /// /// This value is cached but is not serialized, because it is a property /// of the definition of the constructor that is useful only to semantic /// analysis and SIL generation. ComputedBodyInitKind : 3, /// Whether this constructor can fail, by building an Optional type. Failable : 1, /// Whether this initializer is a stub placed into a subclass to /// catch invalid delegations to a designated initializer not /// overridden by the subclass. A stub will always trap at runtime. /// /// Initializer stubs can be invoked from Objective-C or through /// the Objective-C runtime; there is no way to directly express /// an object construction that will invoke a stub. HasStubImplementation : 1 ); SWIFT_INLINE_BITFIELD_EMPTY(TypeDecl, ValueDecl); SWIFT_INLINE_BITFIELD_EMPTY(AbstractTypeParamDecl, TypeDecl); SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, AbstractTypeParamDecl, 16+16, : NumPadBits, Depth : 16, Index : 16 ); SWIFT_INLINE_BITFIELD_EMPTY(GenericTypeDecl, TypeDecl); SWIFT_INLINE_BITFIELD(TypeAliasDecl, GenericTypeDecl, 1+1, /// Whether the typealias forwards perfectly to its underlying type. IsCompatibilityAlias : 1, /// Whether this was a global typealias synthesized by the debugger. IsDebuggerAlias : 1 ); SWIFT_INLINE_BITFIELD(NominalTypeDecl, GenericTypeDecl, 1+1+1, /// Whether we have already added implicitly-defined initializers /// to this declaration. AddedImplicitInitializers : 1, /// Whether there is are lazily-loaded conformances for this nominal type. HasLazyConformances : 1, /// Whether this nominal type is having its semantic members resolved. IsComputingSemanticMembers : 1 ); SWIFT_INLINE_BITFIELD_FULL(ProtocolDecl, NominalTypeDecl, 1+1+1+1+1+1+1+1+1+8+16, /// Whether the \c RequiresClass bit is valid. RequiresClassValid : 1, /// Whether this is a class-bounded protocol. RequiresClass : 1, /// Whether the \c ExistentialConformsToSelf bit is valid. ExistentialConformsToSelfValid : 1, /// Whether the existential of this protocol conforms to itself. ExistentialConformsToSelf : 1, /// Whether the \c ExistentialTypeSupported bit is valid. ExistentialTypeSupportedValid : 1, /// Whether the existential of this protocol can be represented. ExistentialTypeSupported : 1, /// True if the protocol has requirements that cannot be satisfied (e.g. /// because they could not be imported from Objective-C). HasMissingRequirements : 1, /// Whether we've computed the inherited protocols list yet. InheritedProtocolsValid : 1, /// Whether we have a lazy-loaded requirement signature. HasLazyRequirementSignature : 1, : NumPadBits, /// If this is a compiler-known protocol, this will be a KnownProtocolKind /// value, plus one. Otherwise, it will be 0. KnownProtocol : 8, // '8' for speed. This only needs 6. /// The number of requirements in the requirement signature. NumRequirementsInSignature : 16 ); SWIFT_INLINE_BITFIELD(ClassDecl, NominalTypeDecl, 1+1+2+1+1+1+1+1+1, /// Whether this class inherits its superclass's convenience initializers. InheritsSuperclassInits : 1, ComputedInheritsSuperclassInits : 1, /// \see ClassDecl::ForeignKind RawForeignKind : 2, /// \see ClassDecl::getEmittedMembers() HasForcedEmittedMembers : 1, HasMissingDesignatedInitializers : 1, ComputedHasMissingDesignatedInitializers : 1, HasMissingVTableEntries : 1, ComputedHasMissingVTableEntries : 1, /// Whether instances of this class are incompatible /// with weak and unowned references. IsIncompatibleWithWeakReferences : 1 ); SWIFT_INLINE_BITFIELD(StructDecl, NominalTypeDecl, 1+1, /// True if this struct has storage for fields that aren't accessible in /// Swift. HasUnreferenceableStorage : 1, /// True if this struct is imported from C++ and not trivially copyable. IsCxxNotTriviallyCopyable : 1 ); SWIFT_INLINE_BITFIELD(EnumDecl, NominalTypeDecl, 2+1, /// True if the enum has cases and at least one case has associated values. HasAssociatedValues : 2, /// True if the enum has at least one case that has some availability /// attribute. A single bit because it's lazily computed along with the /// HasAssociatedValues bit. HasAnyUnavailableValues : 1 ); SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1+1+1+1+1+1, /// If the module was or is being compiled with `-enable-testing`. TestingEnabled : 1, /// If the module failed to load FailedToLoad : 1, /// Whether the module is resilient. /// /// \sa ResilienceStrategy RawResilienceStrategy : 1, /// Whether all imports have been resolved. Used to detect circular imports. HasResolvedImports : 1, /// If the module was or is being compiled with `-enable-private-imports`. PrivateImportsEnabled : 1, /// If the module is compiled with `-enable-implicit-dynamic`. ImplicitDynamicEnabled : 1, /// Whether the module is a system module. IsSystemModule : 1, /// Whether the module was imported from Clang (or, someday, maybe another /// language). IsNonSwiftModule : 1, /// Whether this module is the main module. IsMainModule : 1 ); SWIFT_INLINE_BITFIELD(PrecedenceGroupDecl, Decl, 1+2, /// Is this an assignment operator? IsAssignment : 1, /// The group's associativity. A value of the Associativity enum. Associativity : 2 ); SWIFT_INLINE_BITFIELD(ImportDecl, Decl, 3+8, ImportKind : 3, /// The number of elements in this path. NumPathElements : 8 ); SWIFT_INLINE_BITFIELD(ExtensionDecl, Decl, 3+1, /// An encoding of the default and maximum access level for this extension. /// /// This is encoded as (1 << (maxAccess-1)) | (1 << (defaultAccess-1)), /// which works because the maximum is always greater than or equal to the /// default, and 'private' is never used. 0 represents an uncomputed value. DefaultAndMaxAccessLevel : 3, /// Whether there is are lazily-loaded conformances for this extension. HasLazyConformances : 1 ); SWIFT_INLINE_BITFIELD(IfConfigDecl, Decl, 1, /// Whether this decl is missing its closing '#endif'. HadMissingEnd : 1 ); SWIFT_INLINE_BITFIELD(PoundDiagnosticDecl, Decl, 1+1, /// `true` if the diagnostic is an error, `false` if it's a warning. IsError : 1, /// Whether this diagnostic has already been emitted. HasBeenEmitted : 1 ); SWIFT_INLINE_BITFIELD(MissingMemberDecl, Decl, 1+2, NumberOfFieldOffsetVectorEntries : 1, NumberOfVTableEntries : 2 ); } Bits; // Storage for the declaration attributes. DeclAttributes Attrs; /// The next declaration in the list of declarations within this /// member context. Decl *NextDecl = nullptr; friend class DeclIterator; friend class IterableDeclContext; friend class MemberLookupTable; private: llvm::PointerUnion<DeclContext *, ASTContext *> Context; Decl(const Decl&) = delete; void operator=(const Decl&) = delete; SourceLoc getLocFromSource() const; struct CachedExternalSourceLocs { SourceLoc Loc; SourceLoc StartLoc; SourceLoc EndLoc; SmallVector<CharSourceRange, 4> DocRanges; }; mutable CachedExternalSourceLocs const *CachedSerializedLocs = nullptr; const CachedExternalSourceLocs *getSerializedLocs() const; protected: Decl(DeclKind kind, llvm::PointerUnion<DeclContext *, ASTContext *> context) : Context(context) { Bits.OpaqueBits = 0; Bits.Decl.Kind = unsigned(kind); Bits.Decl.Invalid = false; Bits.Decl.Implicit = false; Bits.Decl.FromClang = false; Bits.Decl.EscapedFromIfConfig = false; } /// Get the Clang node associated with this declaration. ClangNode getClangNodeImpl() const; /// Set the Clang node associated with this declaration. void setClangNode(ClangNode Node); void updateClangNode(ClangNode node) { assert(hasClangNode()); setClangNode(node); } friend class ClangImporter; DeclContext *getDeclContextForModule() const; public: DeclKind getKind() const { return DeclKind(Bits.Decl.Kind); } /// Retrieve the name of the given declaration kind. /// /// This name should only be used for debugging dumps and other /// developer aids, and should never be part of a diagnostic or exposed /// to the user of the compiler in any way. static StringRef getKindName(DeclKind K); /// Retrieve the descriptive kind for this declaration. DescriptiveDeclKind getDescriptiveKind() const; /// Produce a name for the given descriptive declaration kind, which /// is suitable for use in diagnostics. static StringRef getDescriptiveKindName(DescriptiveDeclKind K); /// Whether swift users should be able to access this decl. For instance, /// var a.storage for lazy var a is an inaccessible decl. An inaccessible decl /// has to be implicit; but an implicit decl does not have to be inaccessible, /// for instance, self. bool isUserAccessible() const; /// Determine if the decl can have a comment. If false, a comment will /// not be serialized. bool canHaveComment() const; LLVM_READONLY DeclContext *getDeclContext() const { if (auto dc = Context.dyn_cast<DeclContext *>()) return dc; return getDeclContextForModule(); } void setDeclContext(DeclContext *DC); /// Retrieve the innermost declaration context corresponding to this /// declaration, which will either be the declaration itself (if it's /// also a declaration context) or its declaration context. DeclContext *getInnermostDeclContext() const; /// Retrieve the module in which this declaration resides. LLVM_READONLY ModuleDecl *getModuleContext() const; /// getASTContext - Return the ASTContext that this decl lives in. LLVM_READONLY ASTContext &getASTContext() const { if (auto dc = Context.dyn_cast<DeclContext *>()) return dc->getASTContext(); return *Context.get<ASTContext *>(); } const DeclAttributes &getAttrs() const { return Attrs; } DeclAttributes &getAttrs() { return Attrs; } /// Returns the introduced OS version in the given platform kind specified /// by @available attribute. /// This function won't consider the parent context to get the information. Optional<llvm::VersionTuple> getIntroducedOSVersion(PlatformKind Kind) const; /// Returns the starting location of the entire declaration. SourceLoc getStartLoc() const { return getSourceRange().Start; } /// Returns the end location of the entire declaration. SourceLoc getEndLoc() const { return getSourceRange().End; } /// Returns the preferred location when referring to declarations /// in diagnostics. SourceLoc getLoc(bool SerializedOK = true) const; /// Returns the source range of the entire declaration. SourceRange getSourceRange() const; /// Returns the source range of the declaration including its attributes. SourceRange getSourceRangeIncludingAttrs() const; SourceLoc TrailingSemiLoc; /// Returns the appropriate kind of entry point to generate for this class, /// based on its attributes. /// /// It is an error to call this on a type that does not have either an /// *ApplicationMain or an main attribute. ArtificialMainKind getArtificialMainKind() const; SWIFT_DEBUG_DUMP; SWIFT_DEBUG_DUMPER(dump(const char *filename)); void dump(raw_ostream &OS, unsigned Indent = 0) const; /// Pretty-print the given declaration. /// /// \param OS Output stream to which the declaration will be printed. void print(raw_ostream &OS) const; void print(raw_ostream &OS, const PrintOptions &Opts) const; /// Pretty-print the given declaration. /// /// \param Printer ASTPrinter object. /// /// \param Opts Options to control how pretty-printing is performed. /// /// \returns true if the declaration was printed or false if the print options /// required the declaration to be skipped from printing. bool print(ASTPrinter &Printer, const PrintOptions &Opts) const; /// Determine whether this declaration should be printed when /// encountered in its declaration context's list of members. bool shouldPrintInContext(const PrintOptions &PO) const; bool walk(ASTWalker &walker); /// Return whether this declaration has been determined invalid. bool isInvalid() const; /// Mark this declaration invalid. void setInvalid(); /// Determine whether this declaration was implicitly generated by the /// compiler (rather than explicitly written in source code). bool isImplicit() const { return Bits.Decl.Implicit; } /// Mark this declaration as implicit. void setImplicit(bool implicit = true) { Bits.Decl.Implicit = implicit; } public: bool escapedFromIfConfig() const { return Bits.Decl.EscapedFromIfConfig; } void setEscapedFromIfConfig(bool Escaped) { Bits.Decl.EscapedFromIfConfig = Escaped; } /// \returns the unparsed comment attached to this declaration. RawComment getRawComment(bool SerializedOK = false) const; Optional<StringRef> getGroupName() const; Optional<StringRef> getSourceFileName() const; Optional<unsigned> getSourceOrder() const; /// \returns the brief comment attached to this declaration. StringRef getBriefComment() const; /// Returns true if there is a Clang AST node associated /// with self. bool hasClangNode() const { return Bits.Decl.FromClang; } /// Retrieve the Clang AST node from which this declaration was /// synthesized, if any. LLVM_READONLY ClangNode getClangNode() const { if (!Bits.Decl.FromClang) return ClangNode(); return getClangNodeImpl(); } /// Retrieve the Clang declaration from which this declaration was /// synthesized, if any. LLVM_READONLY const clang::Decl *getClangDecl() const { if (!Bits.Decl.FromClang) return nullptr; return getClangNodeImpl().getAsDecl(); } /// Retrieve the Clang macro from which this declaration was /// synthesized, if any. LLVM_READONLY const clang::MacroInfo *getClangMacro() { if (!Bits.Decl.FromClang) return nullptr; return getClangNodeImpl().getAsMacro(); } /// Return the GenericContext if the Decl has one. LLVM_READONLY const GenericContext *getAsGenericContext() const; bool hasUnderscoredNaming() const; bool isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic = true) const; /// Check if this is a declaration defined at the top level of the Swift module bool isStdlibDecl() const; AvailabilityContext getAvailabilityForLinkage() const; /// Whether this declaration or one of its outer contexts has the /// @_weakLinked attribute. bool isAlwaysWeakImported() const; /// Whether this declaration is weak-imported from the given module, /// either because of the presence of the @_weakLinked attribute, or /// because of availability. /// /// Note that \p fromModule should either be the "main module" or /// nullptr. (This is because when it is non-null, we query the /// current deployment target, and not the deployment target that /// the module was built with.) /// /// If \p fromModule is the main module, this returns false when the /// declaration is part of the main module, or if the declaration is /// at least as available as the current deployment target. /// /// If \p fromModule is null, we instead return true if the /// declaration is meant to be weak linked with _some_ deployment /// target; that is, the presence of the @_weakLinked attribute or /// any kind of availability is enough, irrespective of the current /// deployment target. bool isWeakImported(ModuleDecl *fromModule) const; /// Returns true if the nature of this declaration allows overrides. /// Note that this does not consider whether it is final or whether /// the class it's on is final. /// /// If this returns true, the decl can be safely casted to ValueDecl. bool isPotentiallyOverridable() const; /// Returns true if this Decl cannot be seen by any other source file bool isPrivateToEnclosingFile() const; /// If an alternative module name is specified for this decl, e.g. using /// @_originalDefinedIn attribute, this function returns this module name. StringRef getAlternateModuleName() const; // Is this Decl an SPI? It can be directly marked with @_spi or is defined in // an @_spi context. bool isSPI() const; // List the SPI groups declared with @_spi or inherited by this decl. // // SPI groups are inherited from the parent contexts only if the local decl // doesn't declare any @_spi. ArrayRef<Identifier> getSPIGroups() const; /// Emit a diagnostic tied to this declaration. template<typename ...ArgTypes> InFlightDiagnostic diagnose( Diag<ArgTypes...> ID, typename detail::PassArgument<ArgTypes>::type... Args) const { return getDiags().diagnose(this, ID, std::move(Args)...); } /// Retrieve the diagnostic engine for diagnostics emission. LLVM_READONLY DiagnosticEngine &getDiags() const; // Make vanilla new/delete illegal for Decls. void *operator new(size_t Bytes) = delete; void operator delete(void *Data) = delete; // Only allow allocation of Decls using the allocator in ASTContext // or by doing a placement new. void *operator new(size_t Bytes, const ASTContext &C, unsigned Alignment = alignof(Decl)); void *operator new(size_t Bytes, void *Mem) { assert(Mem); return Mem; } }; /// Allocates memory for a Decl with the given \p baseSize. If necessary, /// it includes additional space immediately preceding the Decl for a ClangNode. /// \note \p baseSize does not need to include space for a ClangNode if /// requested -- the necessary space will be added automatically. template <typename DeclTy, typename AllocatorTy> void *allocateMemoryForDecl(AllocatorTy &allocator, size_t baseSize, bool includeSpaceForClangNode) { static_assert(alignof(DeclTy) >= sizeof(void *), "A pointer must fit in the alignment of the DeclTy!"); size_t size = baseSize; if (includeSpaceForClangNode) size += alignof(DeclTy); void *mem = allocator.Allocate(size, alignof(DeclTy)); if (includeSpaceForClangNode) mem = reinterpret_cast<char *>(mem) + alignof(DeclTy); return mem; } enum class RequirementReprKind : unsigned { /// A type bound T : P, where T is a type that depends on a generic /// parameter and P is some type that should bound T, either as a concrete /// supertype or a protocol to which T must conform. TypeConstraint, /// A same-type requirement T == U, where T and U are types that shall be /// equivalent. SameType, /// A layout bound T : L, where T is a type that depends on a generic /// parameter and L is some layout specification that should bound T. LayoutConstraint, // Note: there is code that packs this enum in a 2-bit bitfield. Audit users // when adding enumerators. }; /// A single requirement in a 'where' clause, which places additional /// restrictions on the generic parameters or associated types of a generic /// function, type, or protocol. /// /// This always represents a requirement spelled in the source code. It is /// never generated implicitly. /// /// \c GenericParamList assumes these are POD-like. class RequirementRepr { SourceLoc SeparatorLoc; RequirementReprKind Kind : 2; bool Invalid : 1; TypeLoc FirstType; /// The second element represents the right-hand side of the constraint. /// It can be e.g. a type or a layout constraint. union { TypeLoc SecondType; LayoutConstraintLoc SecondLayout; }; /// Set during deserialization; used to print out the requirements accurately /// for the generated interface. StringRef AsWrittenString; RequirementRepr(SourceLoc SeparatorLoc, RequirementReprKind Kind, TypeLoc FirstType, TypeLoc SecondType) : SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false), FirstType(FirstType), SecondType(SecondType) { } RequirementRepr(SourceLoc SeparatorLoc, RequirementReprKind Kind, TypeLoc FirstType, LayoutConstraintLoc SecondLayout) : SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false), FirstType(FirstType), SecondLayout(SecondLayout) { } void printImpl(ASTPrinter &OS, bool AsWritten) const; public: /// Construct a new type-constraint requirement. /// /// \param Subject The type that must conform to the given protocol or /// composition, or be a subclass of the given class type. /// \param ColonLoc The location of the ':', or an invalid location if /// this requirement was implied. /// \param Constraint The protocol or protocol composition to which the /// subject must conform, or superclass from which the subject must inherit. static RequirementRepr getTypeConstraint(TypeLoc Subject, SourceLoc ColonLoc, TypeLoc Constraint) { return { ColonLoc, RequirementReprKind::TypeConstraint, Subject, Constraint }; } /// Construct a new same-type requirement. /// /// \param FirstType The first type. /// \param EqualLoc The location of the '==' in the same-type constraint, or /// an invalid location if this requirement was implied. /// \param SecondType The second type. static RequirementRepr getSameType(TypeLoc FirstType, SourceLoc EqualLoc, TypeLoc SecondType) { return { EqualLoc, RequirementReprKind::SameType, FirstType, SecondType }; } /// Construct a new layout-constraint requirement. /// /// \param Subject The type that must conform to the given layout /// requirement. /// \param ColonLoc The location of the ':', or an invalid location if /// this requirement was implied. /// \param Layout The layout requirement to which the /// subject must conform. static RequirementRepr getLayoutConstraint(TypeLoc Subject, SourceLoc ColonLoc, LayoutConstraintLoc Layout) { return {ColonLoc, RequirementReprKind::LayoutConstraint, Subject, Layout}; } /// Determine the kind of requirement RequirementReprKind getKind() const { return Kind; } /// Determine whether this requirement is invalid. bool isInvalid() const { return Invalid; } /// Mark this requirement invalid. void setInvalid() { Invalid = true; } /// For a type-bound requirement, return the subject of the /// conformance relationship. Type getSubject() const { assert(getKind() == RequirementReprKind::TypeConstraint || getKind() == RequirementReprKind::LayoutConstraint); return FirstType.getType(); } TypeRepr *getSubjectRepr() const { assert(getKind() == RequirementReprKind::TypeConstraint || getKind() == RequirementReprKind::LayoutConstraint); return FirstType.getTypeRepr(); } TypeLoc &getSubjectLoc() { assert(getKind() == RequirementReprKind::TypeConstraint || getKind() == RequirementReprKind::LayoutConstraint); return FirstType; } const TypeLoc &getSubjectLoc() const { assert(getKind() == RequirementReprKind::TypeConstraint || getKind() == RequirementReprKind::LayoutConstraint); return FirstType; } /// For a type-bound requirement, return the protocol or to which /// the subject conforms or superclass it inherits. Type getConstraint() const { assert(getKind() == RequirementReprKind::TypeConstraint); return SecondType.getType(); } TypeRepr *getConstraintRepr() const { assert(getKind() == RequirementReprKind::TypeConstraint); return SecondType.getTypeRepr(); } TypeLoc &getConstraintLoc() { assert(getKind() == RequirementReprKind::TypeConstraint); return SecondType; } const TypeLoc &getConstraintLoc() const { assert(getKind() == RequirementReprKind::TypeConstraint); return SecondType; } LayoutConstraint getLayoutConstraint() const { assert(getKind() == RequirementReprKind::LayoutConstraint); return SecondLayout.getLayoutConstraint(); } LayoutConstraintLoc &getLayoutConstraintLoc() { assert(getKind() == RequirementReprKind::LayoutConstraint); return SecondLayout; } const LayoutConstraintLoc &getLayoutConstraintLoc() const { assert(getKind() == RequirementReprKind::LayoutConstraint); return SecondLayout; } /// Retrieve the first type of a same-type requirement. Type getFirstType() const { assert(getKind() == RequirementReprKind::SameType); return FirstType.getType(); } TypeRepr *getFirstTypeRepr() const { assert(getKind() == RequirementReprKind::SameType); return FirstType.getTypeRepr(); } TypeLoc &getFirstTypeLoc() { assert(getKind() == RequirementReprKind::SameType); return FirstType; } const TypeLoc &getFirstTypeLoc() const { assert(getKind() == RequirementReprKind::SameType); return FirstType; } /// Retrieve the second type of a same-type requirement. Type getSecondType() const { assert(getKind() == RequirementReprKind::SameType); return SecondType.getType(); } TypeRepr *getSecondTypeRepr() const { assert(getKind() == RequirementReprKind::SameType); return SecondType.getTypeRepr(); } TypeLoc &getSecondTypeLoc() { assert(getKind() == RequirementReprKind::SameType); return SecondType; } const TypeLoc &getSecondTypeLoc() const { assert(getKind() == RequirementReprKind::SameType); return SecondType; } /// Retrieve the location of the ':' or '==' in an explicitly-written /// conformance or same-type requirement respectively. SourceLoc getSeparatorLoc() const { return SeparatorLoc; } SourceRange getSourceRange() const { if (getKind() == RequirementReprKind::LayoutConstraint) return SourceRange(FirstType.getSourceRange().Start, SecondLayout.getSourceRange().End); return SourceRange(FirstType.getSourceRange().Start, SecondType.getSourceRange().End); } /// Retrieve the first or subject type representation from the \c repr, /// or \c nullptr if \c repr is null. static TypeRepr *getFirstTypeRepr(const RequirementRepr *repr) { if (!repr) return nullptr; return repr->FirstType.getTypeRepr(); } /// Retrieve the second or constraint type representation from the \c repr, /// or \c nullptr if \c repr is null. static TypeRepr *getSecondTypeRepr(const RequirementRepr *repr) { if (!repr) return nullptr; assert(repr->getKind() == RequirementReprKind::TypeConstraint || repr->getKind() == RequirementReprKind::SameType); return repr->SecondType.getTypeRepr(); } SWIFT_DEBUG_DUMP; void print(raw_ostream &OS) const; void print(ASTPrinter &Printer) const; }; using GenericParamSource = PointerUnion<GenericContext *, GenericParamList *>; /// GenericParamList - A list of generic parameters that is part of a generic /// function or type, along with extra requirements placed on those generic /// parameters and types derived from them. class GenericParamList final : private llvm::TrailingObjects<GenericParamList, GenericTypeParamDecl *> { friend TrailingObjects; SourceRange Brackets; unsigned NumParams; SourceLoc WhereLoc; MutableArrayRef<RequirementRepr> Requirements; GenericParamList *OuterParameters; SourceLoc TrailingWhereLoc; unsigned FirstTrailingWhereArg; GenericParamList(SourceLoc LAngleLoc, ArrayRef<GenericTypeParamDecl *> Params, SourceLoc WhereLoc, MutableArrayRef<RequirementRepr> Requirements, SourceLoc RAngleLoc); // Don't copy. GenericParamList(const GenericParamList &) = delete; GenericParamList &operator=(const GenericParamList &) = delete; public: /// create - Create a new generic parameter list within the given AST context. /// /// \param Context The ASTContext in which the generic parameter list will /// be allocated. /// \param LAngleLoc The location of the opening angle bracket ('<') /// \param Params The list of generic parameters, which will be copied into /// ASTContext-allocated memory. /// \param RAngleLoc The location of the closing angle bracket ('>') static GenericParamList *create(ASTContext &Context, SourceLoc LAngleLoc, ArrayRef<GenericTypeParamDecl *> Params, SourceLoc RAngleLoc); /// create - Create a new generic parameter list and "where" clause within /// the given AST context. /// /// \param Context The ASTContext in which the generic parameter list will /// be allocated. /// \param LAngleLoc The location of the opening angle bracket ('<') /// \param Params The list of generic parameters, which will be copied into /// ASTContext-allocated memory. /// \param WhereLoc The location of the 'where' keyword, if any. /// \param Requirements The list of requirements, which will be copied into /// ASTContext-allocated memory. /// \param RAngleLoc The location of the closing angle bracket ('>') static GenericParamList *create(const ASTContext &Context, SourceLoc LAngleLoc, ArrayRef<GenericTypeParamDecl *> Params, SourceLoc WhereLoc, ArrayRef<RequirementRepr> Requirements, SourceLoc RAngleLoc); MutableArrayRef<GenericTypeParamDecl *> getParams() { return {getTrailingObjects<GenericTypeParamDecl *>(), NumParams}; } ArrayRef<GenericTypeParamDecl *> getParams() const { return {getTrailingObjects<GenericTypeParamDecl *>(), NumParams}; } using iterator = GenericTypeParamDecl **; using const_iterator = const GenericTypeParamDecl * const *; unsigned size() const { return NumParams; } iterator begin() { return getParams().begin(); } iterator end() { return getParams().end(); } const_iterator begin() const { return getParams().begin(); } const_iterator end() const { return getParams().end(); } /// Retrieve the location of the 'where' keyword, or an invalid /// location if 'where' was not present. SourceLoc getWhereLoc() const { return WhereLoc; } /// Retrieve the set of additional requirements placed on these /// generic parameters and types derived from them. /// /// This list may contain both explicitly-written requirements as well as /// implicitly-generated requirements, and may be non-empty even if no /// 'where' keyword is present. MutableArrayRef<RequirementRepr> getRequirements() { return Requirements; } /// Retrieve the set of additional requirements placed on these /// generic parameters and types derived from them. /// /// This list may contain both explicitly-written requirements as well as /// implicitly-generated requirements, and may be non-empty even if no /// 'where' keyword is present. ArrayRef<RequirementRepr> getRequirements() const { return Requirements; } /// Retrieve only those requirements that are written within the brackets, /// which does not include any requirements written in a trailing where /// clause. ArrayRef<RequirementRepr> getNonTrailingRequirements() const { return Requirements.slice(0, FirstTrailingWhereArg); } /// Retrieve only those requirements written in a trailing where /// clause. ArrayRef<RequirementRepr> getTrailingRequirements() const { return Requirements.slice(FirstTrailingWhereArg); } /// Determine whether the generic parameters have a trailing where clause. bool hasTrailingWhereClause() const { return FirstTrailingWhereArg < Requirements.size(); } /// Add a trailing 'where' clause to the list of requirements. /// /// Trailing where clauses are written outside the angle brackets, after the /// main part of a declaration's signature. void addTrailingWhereClause(ASTContext &ctx, SourceLoc trailingWhereLoc, ArrayRef<RequirementRepr> trailingRequirements); /// Retrieve the outer generic parameter list. /// /// This is used for extensions of nested types, and in SIL mode, where a /// single lexical context can have multiple logical generic parameter /// lists. GenericParamList *getOuterParameters() const { return OuterParameters; } /// Set the outer generic parameter list. See \c getOuterParameters /// for more information. void setOuterParameters(GenericParamList *Outer) { OuterParameters = Outer; } SourceLoc getLAngleLoc() const { return Brackets.Start; } SourceLoc getRAngleLoc() const { return Brackets.End; } SourceRange getSourceRange() const { return Brackets; } /// Retrieve the source range covering the where clause. SourceRange getWhereClauseSourceRange() const { if (WhereLoc.isInvalid()) return SourceRange(); auto endLoc = Requirements[FirstTrailingWhereArg-1].getSourceRange().End; return SourceRange(WhereLoc, endLoc); } /// Retrieve the source range covering the trailing where clause. SourceRange getTrailingWhereClauseSourceRange() const { if (!hasTrailingWhereClause()) return SourceRange(); return SourceRange(TrailingWhereLoc, Requirements.back().getSourceRange().End); } /// Configure the depth of the generic parameters in this list. void setDepth(unsigned depth); /// Create a copy of the generic parameter list and all of its generic /// parameter declarations. The copied generic parameters are re-parented /// to the given DeclContext. GenericParamList *clone(DeclContext *dc) const; void print(raw_ostream &OS) const; SWIFT_DEBUG_DUMP; }; /// A trailing where clause. class alignas(RequirementRepr) TrailingWhereClause final : private llvm::TrailingObjects<TrailingWhereClause, RequirementRepr> { friend TrailingObjects; SourceLoc WhereLoc; /// The number of requirements. The actual requirements are tail-allocated. unsigned NumRequirements; TrailingWhereClause(SourceLoc whereLoc, ArrayRef<RequirementRepr> requirements); public: /// Create a new trailing where clause with the given set of requirements. static TrailingWhereClause *create(ASTContext &ctx, SourceLoc whereLoc, ArrayRef<RequirementRepr> requirements); /// Retrieve the location of the 'where' keyword. SourceLoc getWhereLoc() const { return WhereLoc; } /// Retrieve the set of requirements. MutableArrayRef<RequirementRepr> getRequirements() { return {getTrailingObjects<RequirementRepr>(), NumRequirements}; } /// Retrieve the set of requirements. ArrayRef<RequirementRepr> getRequirements() const { return {getTrailingObjects<RequirementRepr>(), NumRequirements}; } /// Compute the source range containing this trailing where clause. SourceRange getSourceRange() const { return SourceRange(WhereLoc, getRequirements().back().getSourceRange().End); } void print(llvm::raw_ostream &OS, bool printWhereKeyword) const; }; // A private class for forcing exact field layout. class alignas(8) _GenericContext { // Not really public. See GenericContext. public: llvm::PointerIntPair<GenericParamList *, 1, bool> GenericParamsAndBit; /// The trailing where clause. /// /// Note that this is not currently serialized, because semantic analysis /// moves the trailing where clause into the generic parameter list. TrailingWhereClause *TrailingWhere = nullptr; /// The generic signature of this declaration. llvm::PointerIntPair<GenericSignature, 1, bool> GenericSigAndBit; }; class GenericContext : private _GenericContext, public DeclContext { friend class GenericParamListRequest; friend class GenericSignatureRequest; protected: GenericContext(DeclContextKind Kind, DeclContext *Parent, GenericParamList *Params); public: /// Retrieve the set of parameters to a generic context, or null if /// this context is not generic. GenericParamList *getGenericParams() const; /// Determine whether this context has generic parameters /// of its own. /// /// \code /// class C<T> { /// func f1() {} // isGeneric == false /// func f2<T>() {} // isGeneric == true /// } /// /// protocol P { // isGeneric == true due to implicit Self param /// func p() // isGeneric == false /// } /// \endcode bool isGeneric() const { return getGenericParams() != nullptr; } bool hasComputedGenericSignature() const; bool isComputingGenericSignature() const; /// Retrieve the trailing where clause for this extension, if any. TrailingWhereClause *getTrailingWhereClause() const { return TrailingWhere; } /// Set the trailing where clause for this extension. void setTrailingWhereClause(TrailingWhereClause *trailingWhereClause) { TrailingWhere = trailingWhereClause; } /// Retrieve the generic signature for this context. GenericSignature getGenericSignature() const; /// Retrieve the generic context for this context. GenericEnvironment *getGenericEnvironment() const; /// Retrieve the innermost generic parameter types. TypeArrayView<GenericTypeParamType> getInnermostGenericParamTypes() const; /// Retrieve the generic requirements. ArrayRef<Requirement> getGenericRequirements() const; /// Set the generic signature of this context. void setGenericSignature(GenericSignature genericSig); /// Retrieve the position of any where clause for this context's /// generic parameters. SourceRange getGenericTrailingWhereClauseSourceRange() const; }; static_assert(sizeof(_GenericContext) + sizeof(DeclContext) == sizeof(GenericContext), "Please add fields to _GenericContext"); /// Describes what kind of name is being imported. /// /// If the enumerators here are changed, make sure to update all diagnostics /// using ImportKind as a select index. enum class ImportKind : uint8_t { Module = 0, Type, Struct, Class, Enum, Protocol, Var, Func }; /// ImportDecl - This represents a single import declaration, e.g.: /// import Swift /// import typealias Swift.Int class ImportDecl final : public Decl, private llvm::TrailingObjects<ImportDecl, Located<Identifier>> { friend TrailingObjects; friend class Decl; public: typedef Located<Identifier> AccessPathElement; private: SourceLoc ImportLoc; SourceLoc KindLoc; /// The resolved module. ModuleDecl *Mod = nullptr; ImportDecl(DeclContext *DC, SourceLoc ImportLoc, ImportKind K, SourceLoc KindLoc, ArrayRef<AccessPathElement> Path); public: static ImportDecl *create(ASTContext &C, DeclContext *DC, SourceLoc ImportLoc, ImportKind Kind, SourceLoc KindLoc, ArrayRef<AccessPathElement> Path, ClangNode ClangN = ClangNode()); /// Returns the import kind that is most appropriate for \p VD. /// /// Note that this will never return \c Type; an imported typealias will use /// the more specific kind from its underlying type. static ImportKind getBestImportKind(const ValueDecl *VD); /// Returns the most appropriate import kind for the given list of decls. /// /// If the list is non-homogeneous, or if there is more than one decl that /// cannot be overloaded, returns None. static Optional<ImportKind> findBestImportKind(ArrayRef<ValueDecl *> Decls); ArrayRef<AccessPathElement> getFullAccessPath() const { return {getTrailingObjects<AccessPathElement>(), static_cast<size_t>(Bits.ImportDecl.NumPathElements)}; } ArrayRef<AccessPathElement> getModulePath() const { auto result = getFullAccessPath(); if (getImportKind() != ImportKind::Module) result = result.slice(0, result.size()-1); return result; } ArrayRef<AccessPathElement> getDeclPath() const { if (getImportKind() == ImportKind::Module) return {}; return getFullAccessPath().back(); } ImportKind getImportKind() const { return static_cast<ImportKind>(Bits.ImportDecl.ImportKind); } bool isExported() const { return getAttrs().hasAttribute<ExportedAttr>(); } ModuleDecl *getModule() const { return Mod; } void setModule(ModuleDecl *M) { Mod = M; } /// For a scoped import such as 'import class Foundation.NSString', retrieve /// the decls it references. Otherwise, returns an empty array. ArrayRef<ValueDecl *> getDecls() const; const clang::Module *getClangModule() const { return getClangNode().getClangModule(); } SourceLoc getStartLoc() const { return ImportLoc; } SourceLoc getLocFromSource() const { return getFullAccessPath().front().Loc; } SourceRange getSourceRange() const { return SourceRange(ImportLoc, getFullAccessPath().back().Loc); } SourceLoc getKindLoc() const { return KindLoc; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::Import; } }; /// ExtensionDecl - This represents a type extension containing methods /// associated with the type. This is not a ValueDecl and has no Type because /// there are no runtime values of the Extension's type. class ExtensionDecl final : public GenericContext, public Decl, public IterableDeclContext { SourceLoc ExtensionLoc; // Location of 'extension' keyword. SourceRange Braces; /// The type being extended. TypeRepr *ExtendedTypeRepr; /// The nominal type being extended. /// /// The bit indicates whether binding has been attempted. The pointer can be /// null if either no binding was attempted or if binding could not find the /// extended nominal. llvm::PointerIntPair<NominalTypeDecl *, 1, bool> ExtendedNominal; MutableArrayRef<TypeLoc> Inherited; /// The next extension in the linked list of extensions. /// /// The bit indicates whether this extension has been resolved to refer to /// a known nominal type. llvm::PointerIntPair<ExtensionDecl *, 1, bool> NextExtension = {nullptr, false}; /// Note that we have added a member into the iterable declaration context. void addedMember(Decl *member); friend class ExtensionIterator; friend class NominalTypeDecl; friend class MemberLookupTable; friend class ConformanceLookupTable; friend class IterableDeclContext; ExtensionDecl(SourceLoc extensionLoc, TypeRepr *extendedType, MutableArrayRef<TypeLoc> inherited, DeclContext *parent, TrailingWhereClause *trailingWhereClause); /// Retrieve the conformance loader (if any), and removing it in the /// same operation. The caller is responsible for loading the /// conformances. std::pair<LazyMemberLoader *, uint64_t> takeConformanceLoader() { if (!Bits.ExtensionDecl.HasLazyConformances) return { nullptr, 0 }; return takeConformanceLoaderSlow(); } /// Slow path for \c takeConformanceLoader(). std::pair<LazyMemberLoader *, uint64_t> takeConformanceLoaderSlow(); friend class ExtendedNominalRequest; friend class Decl; public: using Decl::getASTContext; /// Create a new extension declaration. static ExtensionDecl *create(ASTContext &ctx, SourceLoc extensionLoc, TypeRepr *extendedType, MutableArrayRef<TypeLoc> inherited, DeclContext *parent, TrailingWhereClause *trailingWhereClause, ClangNode clangNode = ClangNode()); SourceLoc getStartLoc() const { return ExtensionLoc; } SourceLoc getLocFromSource() const { return ExtensionLoc; } SourceRange getSourceRange() const { return { ExtensionLoc, Braces.End }; } SourceRange getBraces() const { return Braces; } void setBraces(SourceRange braces) { Braces = braces; } bool hasBeenBound() const { return ExtendedNominal.getInt(); } void setExtendedNominal(NominalTypeDecl *n) { ExtendedNominal.setPointerAndInt(n, true); } /// Retrieve the type being extended. /// /// Only use this entry point when the complete type, as spelled in the source, /// is required. For most clients, \c getExtendedNominal(), which provides /// only the \c NominalTypeDecl, will suffice. Type getExtendedType() const; /// Retrieve the nominal type declaration that is being extended. /// Will trip an assertion if the declaration has not already been computed. /// In order to fail fast when type checking work is attempted /// before extension binding has taken place. NominalTypeDecl *getExtendedNominal() const; /// Compute the nominal type declaration that is being extended. NominalTypeDecl *computeExtendedNominal() const; /// \c hasBeenBound means nothing if this extension can never been bound /// because it is not at the top level. bool canNeverBeBound() const; bool hasValidParent() const; /// Determine whether this extension has already been bound to a nominal /// type declaration. bool alreadyBoundToNominal() const { return NextExtension.getInt(); } /// Retrieve the extended type definition as written in the source, if it exists. TypeRepr *getExtendedTypeRepr() const { return ExtendedTypeRepr; } /// Retrieve the set of protocols that this type inherits (i.e, /// explicitly conforms to). MutableArrayRef<TypeLoc> getInherited() { return Inherited; } ArrayRef<TypeLoc> getInherited() const { return Inherited; } void setInherited(MutableArrayRef<TypeLoc> i) { Inherited = i; } bool hasDefaultAccessLevel() const { return Bits.ExtensionDecl.DefaultAndMaxAccessLevel != 0; } uint8_t getDefaultAndMaxAccessLevelBits() const { return Bits.ExtensionDecl.DefaultAndMaxAccessLevel; } void setDefaultAndMaxAccessLevelBits(AccessLevel defaultAccess, AccessLevel maxAccess) { Bits.ExtensionDecl.DefaultAndMaxAccessLevel = (1 << (static_cast<unsigned>(defaultAccess) - 1)) | (1 << (static_cast<unsigned>(maxAccess) - 1)); } AccessLevel getDefaultAccessLevel() const; AccessLevel getMaxAccessLevel() const; void setDefaultAndMaxAccess(AccessLevel defaultAccess, AccessLevel maxAccess) { assert(!hasDefaultAccessLevel() && "default access level already set"); assert(maxAccess >= defaultAccess); assert(maxAccess != AccessLevel::Private && "private not valid"); assert(defaultAccess != AccessLevel::Private && "private not valid"); setDefaultAndMaxAccessLevelBits(defaultAccess, maxAccess); assert(getDefaultAccessLevel() == defaultAccess && "not enough bits"); assert(getMaxAccessLevel() == maxAccess && "not enough bits"); } void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData); /// Determine whether this is a constrained extension, which adds additional /// requirements beyond those of the nominal type. bool isConstrainedExtension() const; /// Determine whether this extension context is interchangeable with the /// original nominal type context. /// /// False if any of the following properties hold: /// - the extension is defined in a different module from the original /// nominal type decl, /// - the extension is constrained, or /// - the extension is to a protocol. /// FIXME: In a world where protocol extensions are dynamically dispatched, /// "extension is to a protocol" would no longer be a reason to use the /// extension mangling, because an extension method implementation could be /// resiliently moved into the original protocol itself. bool isEquivalentToExtendedContext() const; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Extension; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const IterableDeclContext *C) { return C->getIterableContextKind() == IterableDeclContextKind::ExtensionDecl; } using DeclContext::operator new; }; /// Iterator that walks the extensions of a particular type. class ExtensionIterator { ExtensionDecl *current; public: ExtensionIterator() : current() { } explicit ExtensionIterator(ExtensionDecl *current) : current(current) { } ExtensionDecl *operator*() const { return current; } ExtensionDecl *operator->() const { return current; } ExtensionIterator &operator++() { current = current->NextExtension.getPointer(); return *this; } ExtensionIterator operator++(int) { ExtensionIterator tmp = *this; ++(*this); return tmp; } friend bool operator==(ExtensionIterator x, ExtensionIterator y) { return x.current == y.current; } friend bool operator!=(ExtensionIterator x, ExtensionIterator y) { return x.current != y.current; } }; /// Range that covers a set of extensions. class ExtensionRange { ExtensionIterator first; ExtensionIterator last; public: ExtensionRange(ExtensionIterator first, ExtensionIterator last) : first(first), last(last) { } typedef ExtensionIterator iterator; iterator begin() const { return first; } iterator end() const { return last; } }; /// This represents one entry in a PatternBindingDecl, which are pairs of /// Pattern and Initialization expression. The pattern is always present, but /// the initializer can be null if there is none. class PatternBindingEntry { enum class Flags { Checked = 1 << 0, Removed = 1 << 1, /// Whether the contents of this initializer were subsumed by /// some other initialization, e.g., a lazy property's initializer /// gets subsumed by the getter body. Subsumed = 1 << 2, }; llvm::PointerIntPair<Pattern *, 3, OptionSet<Flags>> PatternAndFlags; struct InitializerAndEqualLoc { // When the initializer is removed we don't actually clear the pointers // because we might need to get initializer's source range. Since the // initializer is ASTContext-allocated it is safe. /// Exactly the expr the programmer wrote Expr *originalInit; /// Might be transformed, e.g. for a property wrapper. In the absence of /// transformation or synthesis, holds the expr as parsed. Expr *initAfterSynthesis; /// The location of the equal '=' token. SourceLoc EqualLoc; }; union { /// The initializer expression and its '=' token loc. InitializerAndEqualLoc InitExpr; /// The text of the initializer expression if deserialized from a module. StringRef InitStringRepresentation; }; enum class PatternFlags { IsText = 1 << 0, IsFullyValidated = 1 << 1, }; /// The initializer context used for this pattern binding entry. llvm::PointerIntPair<DeclContext *, 2, OptionSet<PatternFlags>> InitContextAndFlags; /// Values captured by this initializer. CaptureInfo Captures; friend class Parser; friend class PatternBindingInitializer; friend class PatternBindingDecl; friend class ast_scope::AbstractPatternEntryScope; friend class ast_scope::PatternEntryDeclScope; friend class ast_scope::PatternEntryInitializerScope; private: // FIXME: This API is transitional. Once the callers of // typeCheckPatternBinding are requestified, merge this bit with // Flags::Checked. friend class PatternBindingEntryRequest; bool isFullyValidated() const { return InitContextAndFlags.getInt().contains( PatternFlags::IsFullyValidated); } void setFullyValidated() { InitContextAndFlags.setInt(InitContextAndFlags.getInt() | PatternFlags::IsFullyValidated); } public: /// \p E is the initializer as parsed. PatternBindingEntry(Pattern *P, SourceLoc EqualLoc, Expr *E, DeclContext *InitContext) : PatternAndFlags(P, {}), InitExpr({E, E, EqualLoc}), InitContextAndFlags({InitContext, None}) {} private: Pattern *getPattern() const { return PatternAndFlags.getPointer(); } void setPattern(Pattern *P) { PatternAndFlags.setPointer(P); } /// Whether the given pattern binding entry is initialized. /// /// \param onlyExplicit Only consider explicit initializations (rather /// than implicitly-generated ones). bool isInitialized(bool onlyExplicit = false) const; Expr *getInit() const { if (PatternAndFlags.getInt().contains(Flags::Removed) || InitContextAndFlags.getInt().contains(PatternFlags::IsText)) return nullptr; return InitExpr.initAfterSynthesis; } /// Retrieve the initializer if it should be executed to initialize this /// particular pattern binding. Expr *getExecutableInit() const { return isInitializerSubsumed() ? nullptr : getInit(); } SourceRange getOriginalInitRange() const; void setInit(Expr *E); /// Gets the text of the initializer expression, stripping out inactive /// branches of any #ifs inside the expression. StringRef getInitStringRepresentation(SmallVectorImpl<char> &scratch) const; /// Sets the initializer string representation to the string that was /// deserialized from a partial module. void setInitStringRepresentation(StringRef str) { InitStringRepresentation = str; InitContextAndFlags.setInt(InitContextAndFlags.getInt() | PatternFlags::IsText); } /// Whether this pattern entry can generate a string representation of its /// initializer expression. bool hasInitStringRepresentation() const; /// Retrieve the location of the equal '=' token. SourceLoc getEqualLoc() const { return InitContextAndFlags.getInt().contains(PatternFlags::IsText) ? SourceLoc() : InitExpr.EqualLoc; } /// Set the location of the equal '=' token. void setEqualLoc(SourceLoc equalLoc) { assert(!InitContextAndFlags.getInt().contains(PatternFlags::IsText) && "cannot set equal loc for textual initializer"); InitExpr.EqualLoc = equalLoc; } /// Retrieve the initializer after the =, if any, as it was written in the /// source. Expr *getOriginalInit() const; /// Set the initializer after the = as it was written in the source. void setOriginalInit(Expr *); bool isInitializerChecked() const { return PatternAndFlags.getInt().contains(Flags::Checked); } void setInitializerChecked() { PatternAndFlags.setInt(PatternAndFlags.getInt() | Flags::Checked); } bool isInitializerSubsumed() const { return PatternAndFlags.getInt().contains(Flags::Subsumed); } void setInitializerSubsumed() { PatternAndFlags.setInt(PatternAndFlags.getInt() | Flags::Subsumed); } // Return the first variable initialized by this pattern. VarDecl *getAnchoringVarDecl() const; // Retrieve the declaration context for the initializer. DeclContext *getInitContext() const { return InitContextAndFlags.getPointer(); } /// Override the initializer context. void setInitContext(DeclContext *dc) { InitContextAndFlags.setPointer(dc); } SourceLoc getStartLoc() const; /// Retrieve the end location covered by this pattern binding entry. /// /// \param omitAccessors Whether the computation should omit the accessors /// from the source range. SourceLoc getEndLoc(bool omitAccessors = false) const; /// Retrieve the source range covered by this pattern binding entry. /// /// \param omitAccessors Whether the computation should omit the accessors /// from the source range. SourceRange getSourceRange(bool omitAccessors = false) const; CaptureInfo getCaptureInfo() const { return Captures; } void setCaptureInfo(CaptureInfo captures) { Captures = captures; } unsigned getNumBoundVariables() const; private: SourceLoc getLastAccessorEndLoc() const; }; /// This decl contains a pattern and optional initializer for a set /// of one or more VarDecls declared together. /// /// For example, in /// \code /// var (a, b) = foo(), (c,d) = bar() /// \endcode /// /// this includes two entries in the pattern list. The first contains the /// pattern "(a, b)" and the initializer "foo()". The second contains the /// pattern "(c, d)" and the initializer "bar()". /// class PatternBindingDecl final : public Decl, private llvm::TrailingObjects<PatternBindingDecl, PatternBindingEntry> { friend TrailingObjects; friend class Decl; friend class PatternBindingEntryRequest; SourceLoc StaticLoc; ///< Location of the 'static/class' keyword, if present. SourceLoc VarLoc; ///< Location of the 'var' keyword. friend class Decl; PatternBindingDecl(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc VarLoc, unsigned NumPatternEntries, DeclContext *Parent); SourceLoc getLocFromSource() const { return VarLoc; } public: static PatternBindingDecl *create(ASTContext &Ctx, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc VarLoc, ArrayRef<PatternBindingEntry> PatternList, DeclContext *Parent); static PatternBindingDecl *create(ASTContext &Ctx, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc VarLoc, Pattern *Pat, SourceLoc EqualLoc, Expr *E, DeclContext *Parent); static PatternBindingDecl *createImplicit(ASTContext &Ctx, StaticSpellingKind StaticSpelling, Pattern *Pat, Expr *E, DeclContext *Parent, SourceLoc VarLoc = SourceLoc()); static PatternBindingDecl *createDeserialized( ASTContext &Ctx, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc VarLoc, unsigned NumPatternEntries, DeclContext *Parent); SourceLoc getStartLoc() const { return StaticLoc.isValid() ? StaticLoc : VarLoc; } SourceRange getSourceRange() const; unsigned getNumPatternEntries() const { return Bits.PatternBindingDecl.NumPatternEntries; } ArrayRef<PatternBindingEntry> getPatternList() const { return const_cast<PatternBindingDecl*>(this)->getMutablePatternList(); } void setInitStringRepresentation(unsigned i, StringRef str) { getMutablePatternList()[i].setInitStringRepresentation(str); } /// Whether the given pattern entry is initialized. bool isInitialized(unsigned i) const { return getPatternList()[i].isInitialized(); } Expr *getInit(unsigned i) const { return getPatternList()[i].getInit(); } Expr *getExecutableInit(unsigned i) const { return getPatternList()[i].getExecutableInit(); } Expr *getOriginalInit(unsigned i) const { return getPatternList()[i].getOriginalInit(); } SourceRange getOriginalInitRange(unsigned i) const { return getPatternList()[i].getOriginalInitRange(); } void setInit(unsigned i, Expr *E) { getMutablePatternList()[i].setInit(E); } Pattern *getPattern(unsigned i) const { return getPatternList()[i].getPattern(); } void setPattern(unsigned i, Pattern *Pat, DeclContext *InitContext); DeclContext *getInitContext(unsigned i) const { return getPatternList()[i].getInitContext(); } CaptureInfo getCaptureInfo(unsigned i) const { return getPatternList()[i].getCaptureInfo(); } void setCaptureInfo(unsigned i, CaptureInfo captures) { getMutablePatternList()[i].setCaptureInfo(captures); } /// Given that this PBD is the parent pattern for the specified VarDecl, /// return the entry of the VarDecl in our PatternList. For example, in: /// /// let (a,b) = foo(), (c,d) = bar() /// /// "a" and "b" will have index 0, since they correspond to the first pattern, /// and "c" and "d" will have index 1 since they correspond to the second one. unsigned getPatternEntryIndexForVarDecl(const VarDecl *VD) const; bool isInitializerChecked(unsigned i) const { return getPatternList()[i].isInitializerChecked(); } void setInitializerChecked(unsigned i) { getMutablePatternList()[i].setInitializerChecked(); } bool isInitializerSubsumed(unsigned i) const { return getPatternList()[i].isInitializerSubsumed(); } void setInitializerSubsumed(unsigned i) { getMutablePatternList()[i].setInitializerSubsumed(); } /// Does this binding declare something that requires storage? bool hasStorage() const; /// Determines whether this binding either has an initializer expression, or is /// default initialized, without performing any type checking on it. bool isDefaultInitializable() const { for (unsigned i : range(getNumPatternEntries())) if (!isDefaultInitializable(i)) return false; return true; } /// Can the pattern at index i be default initialized? bool isDefaultInitializable(unsigned i) const; /// Can the property wrapper be used to provide default initialization? bool isDefaultInitializableViaPropertyWrapper(unsigned i) const; /// Does this pattern have a user-provided initializer expression? bool isExplicitlyInitialized(unsigned i) const; /// Whether the pattern entry at the given index can generate a string /// representation of its initializer expression. bool hasInitStringRepresentation(unsigned i) const { return getPatternList()[i].hasInitStringRepresentation(); } SourceLoc getEqualLoc(unsigned i) const; /// When the pattern binding contains only a single variable with no /// destructuring, retrieve that variable. VarDecl *getSingleVar() const; /// Return the first variable initialized by the pattern at the given index. VarDecl *getAnchoringVarDecl(unsigned i) const; bool isStatic() const { return Bits.PatternBindingDecl.IsStatic; } void setStatic(bool s) { Bits.PatternBindingDecl.IsStatic = s; } SourceLoc getStaticLoc() const { return StaticLoc; } /// \returns the way 'static'/'class' was spelled in the source. StaticSpellingKind getStaticSpelling() const { return static_cast<StaticSpellingKind>( Bits.PatternBindingDecl.StaticSpelling); } /// \returns the way 'static'/'class' should be spelled for this declaration. StaticSpellingKind getCorrectStaticSpelling() const; /// Is the pattern binding entry for this variable currently being computed? bool isComputingPatternBindingEntry(const VarDecl *vd) const; /// Gets the text of the initializer expression for the pattern entry at the /// given index, stripping out inactive branches of any #ifs inside the /// expression. StringRef getInitStringRepresentation(unsigned i, SmallVectorImpl<char> &scratch) const { return getPatternList()[i].getInitStringRepresentation(scratch); } static bool classof(const Decl *D) { return D->getKind() == DeclKind::PatternBinding; } private: MutableArrayRef<PatternBindingEntry> getMutablePatternList() { // Pattern entries are tail allocated. return {getTrailingObjects<PatternBindingEntry>(), getNumPatternEntries()}; } }; /// TopLevelCodeDecl - This decl is used as a container for top-level /// expressions and statements in the main module. It is always a direct /// child of a SourceFile. The primary reason for building these is to give /// top-level statements a DeclContext which is distinct from the file itself. /// This, among other things, makes it easier to distinguish between local /// top-level variables (which are not live past the end of the statement) and /// global variables. class TopLevelCodeDecl : public DeclContext, public Decl { BraceStmt *Body; SourceLoc getLocFromSource() const { return getStartLoc(); } friend class Decl; public: TopLevelCodeDecl(DeclContext *Parent, BraceStmt *Body = nullptr) : DeclContext(DeclContextKind::TopLevelCodeDecl, Parent), Decl(DeclKind::TopLevelCode, Parent), Body(Body) {} BraceStmt *getBody() const { return Body; } void setBody(BraceStmt *b) { Body = b; } SourceLoc getStartLoc() const; SourceRange getSourceRange() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::TopLevelCode; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } using DeclContext::operator new; }; /// SerializedTopLevelCodeDeclContext - This represents what was originally a /// TopLevelCodeDecl during serialization. It is preserved only to maintain the /// correct AST structure and remangling after deserialization. class SerializedTopLevelCodeDeclContext : public SerializedLocalDeclContext { public: SerializedTopLevelCodeDeclContext(DeclContext *Parent) : SerializedLocalDeclContext(LocalDeclContextKind::TopLevelCodeDecl, Parent) {} static bool classof(const DeclContext *DC) { if (auto LDC = dyn_cast<SerializedLocalDeclContext>(DC)) return LDC->getLocalDeclContextKind() == LocalDeclContextKind::TopLevelCodeDecl; return false; } }; /// IfConfigDecl - This class represents #if/#else/#endif blocks. /// Active and inactive block members are stored separately, with the intention /// being that active members will be handed back to the enclosing context. class IfConfigDecl : public Decl { /// An array of clauses controlling each of the #if/#elseif/#else conditions. /// The array is ASTContext allocated. ArrayRef<IfConfigClause> Clauses; SourceLoc EndLoc; SourceLoc getLocFromSource() const { return Clauses[0].Loc; } friend class Decl; public: IfConfigDecl(DeclContext *Parent, ArrayRef<IfConfigClause> Clauses, SourceLoc EndLoc, bool HadMissingEnd) : Decl(DeclKind::IfConfig, Parent), Clauses(Clauses), EndLoc(EndLoc) { Bits.IfConfigDecl.HadMissingEnd = HadMissingEnd; } ArrayRef<IfConfigClause> getClauses() const { return Clauses; } /// Return the active clause, or null if there is no active one. const IfConfigClause *getActiveClause() const { for (auto &Clause : Clauses) if (Clause.isActive) return &Clause; return nullptr; } const ArrayRef<ASTNode> getActiveClauseElements() const { if (auto *Clause = getActiveClause()) return Clause->Elements; return {}; } SourceLoc getEndLoc() const { return EndLoc; } bool hadMissingEnd() const { return Bits.IfConfigDecl.HadMissingEnd; } SourceRange getSourceRange() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::IfConfig; } }; class StringLiteralExpr; class PoundDiagnosticDecl : public Decl { SourceLoc StartLoc; SourceLoc EndLoc; StringLiteralExpr *Message; SourceLoc getLocFromSource() const { return StartLoc; } friend class Decl; public: PoundDiagnosticDecl(DeclContext *Parent, bool IsError, SourceLoc StartLoc, SourceLoc EndLoc, StringLiteralExpr *Message) : Decl(DeclKind::PoundDiagnostic, Parent), StartLoc(StartLoc), EndLoc(EndLoc), Message(Message) { Bits.PoundDiagnosticDecl.IsError = IsError; Bits.PoundDiagnosticDecl.HasBeenEmitted = false; } DiagnosticKind getKind() const { return isError() ? DiagnosticKind::Error : DiagnosticKind::Warning; } StringLiteralExpr *getMessage() const { return Message; } bool isError() const { return Bits.PoundDiagnosticDecl.IsError; } bool hasBeenEmitted() const { return Bits.PoundDiagnosticDecl.HasBeenEmitted; } void markEmitted() { Bits.PoundDiagnosticDecl.HasBeenEmitted = true; } SourceLoc getEndLoc() const { return EndLoc; }; SourceRange getSourceRange() const { return SourceRange(StartLoc, EndLoc); } static bool classof(const Decl *D) { return D->getKind() == DeclKind::PoundDiagnostic; } }; class OpaqueTypeDecl; /// ValueDecl - All named decls that are values in the language. These can /// have a type, etc. class ValueDecl : public Decl { DeclName Name; SourceLoc NameLoc; llvm::PointerIntPair<Type, 3, OptionalEnum<AccessLevel>> TypeAndAccess; unsigned LocalDiscriminator = 0; struct { /// Whether the "IsObjC" bit has been computed yet. unsigned isObjCComputed : 1; /// Whether this declaration is exposed to Objective-C. unsigned isObjC : 1; /// Whether the "overridden" declarations have been computed already. unsigned hasOverriddenComputed : 1; /// Whether there are any "overridden" declarations. The actual overridden /// declarations are kept in a side table in the ASTContext. unsigned hasOverridden : 1; /// Whether the "isDynamic" bit has been computed yet. unsigned isDynamicComputed : 1; /// Whether this declaration is 'dynamic', meaning that all uses of /// the declaration will go through an extra level of indirection that /// allows the entity to be replaced at runtime. unsigned isDynamic : 1; /// Whether the "isFinal" bit has been computed yet. unsigned isFinalComputed : 1; /// Whether this declaration is 'final'. A final class can't be subclassed, /// a final class member can't be overriden. unsigned isFinal : 1; /// Whether the "isIUO" bit" has been computed yet. unsigned isIUOComputed : 1; /// Whether this declaration produces an implicitly unwrapped /// optional result. unsigned isIUO : 1; } LazySemanticInfo = { }; friend class DynamicallyReplacedDeclRequest; friend class OverriddenDeclsRequest; friend class IsObjCRequest; friend class IsFinalRequest; friend class IsDynamicRequest; friend class IsImplicitlyUnwrappedOptionalRequest; friend class InterfaceTypeRequest; friend class CheckRedeclarationRequest; friend class Decl; SourceLoc getLocFromSource() const { return NameLoc; } protected: ValueDecl(DeclKind K, llvm::PointerUnion<DeclContext *, ASTContext *> context, DeclName name, SourceLoc NameLoc) : Decl(K, context), Name(name), NameLoc(NameLoc) { Bits.ValueDecl.AlreadyInLookupTable = false; Bits.ValueDecl.CheckedRedeclaration = false; Bits.ValueDecl.IsUserAccessible = true; } // MemberLookupTable borrows a bit from this type friend class MemberLookupTable; bool isAlreadyInLookupTable() { return Bits.ValueDecl.AlreadyInLookupTable; } void setAlreadyInLookupTable(bool value = true) { Bits.ValueDecl.AlreadyInLookupTable = value; } /// Determine whether we have already checked whether this /// declaration is a redeclaration. bool alreadyCheckedRedeclaration() const { return Bits.ValueDecl.CheckedRedeclaration; } /// Set whether we have already checked this declaration as a /// redeclaration. void setCheckedRedeclaration() { Bits.ValueDecl.CheckedRedeclaration = true; } public: /// Return true if this protocol member is a protocol requirement. /// /// Asserts if this is not a member of a protocol. bool isProtocolRequirement() const; void setUserAccessible(bool Accessible) { Bits.ValueDecl.IsUserAccessible = Accessible; } bool isUserAccessible() const { return Bits.ValueDecl.IsUserAccessible; } bool hasName() const { return bool(Name); } bool isOperator() const { return Name.isOperator(); } /// Retrieve the full name of the declaration. DeclName getName() const { return Name; } void setName(DeclName name) { Name = name; } /// Retrieve the base name of the declaration, ignoring any argument /// names. DeclBaseName getBaseName() const { return Name.getBaseName(); } Identifier getBaseIdentifier() const { return Name.getBaseIdentifier(); } /// Generates a DeclNameRef referring to this declaration with as much /// specificity as possible. DeclNameRef createNameRef() const { return DeclNameRef(Name); } /// Retrieve the name to use for this declaration when interoperating /// with the Objective-C runtime. /// /// \returns A "selector" containing the runtime name. For non-method /// entities (classes, protocols, properties), this operation will /// return a zero-parameter selector with the appropriate name in its /// first slot. Optional<ObjCSelector> getObjCRuntimeName( bool skipIsObjCResolution = false) const; /// Determine whether the given declaration can infer @objc, or the /// Objective-C name, if used to satisfy the given requirement. bool canInferObjCFromRequirement(ValueDecl *requirement); SourceLoc getNameLoc() const { return NameLoc; } bool isUsableFromInline() const; /// Returns \c true if this declaration is *not* intended to be used directly /// by application developers despite the visibility. bool shouldHideFromEditor() const; bool hasAccess() const { return TypeAndAccess.getInt().hasValue(); } /// Access control is done by Requests. friend class AccessLevelRequest; /// Returns the access level specified explicitly by the user, or provided by /// default according to language rules. /// /// Most of the time this is not the interesting value to check; access is /// limited by enclosing scopes per SE-0025. Use #getFormalAccessScope to /// check if access control is being used consistently, and to take features /// such as \c \@testable and \c \@usableFromInline into account. /// /// \sa getFormalAccessScope /// \sa hasOpenAccess AccessLevel getFormalAccess() const; /// Determine whether this Decl has either Private or FilePrivate access, /// and its DeclContext does not. bool isOutermostPrivateOrFilePrivateScope() const; /// Returns the outermost DeclContext from which this declaration can be /// accessed, or null if the declaration is public. /// /// This is used when calculating if access control is being used /// consistently. If \p useDC is provided (the location where the value is /// being used), features that affect formal access such as \c \@testable are /// taken into account. /// /// \invariant /// <code>value.isAccessibleFrom( /// value.getFormalAccessScope().getDeclContext())</code> /// /// If \p treatUsableFromInlineAsPublic is true, declarations marked with the /// \c \@usableFromInline attribute are treated as public. This is normally /// false for name lookup and other source language concerns, but true when /// computing the linkage of generated functions. /// /// \sa getFormalAccess /// \sa isAccessibleFrom /// \sa hasOpenAccess AccessScope getFormalAccessScope(const DeclContext *useDC = nullptr, bool treatUsableFromInlineAsPublic = false) const; /// Copy the formal access level and @usableFromInline attribute from /// \p source. /// /// If \p sourceIsParentContext is true, an access level of \c private will /// be copied as \c fileprivate, to ensure that this declaration will be /// available everywhere \p source is. void copyFormalAccessFrom(const ValueDecl *source, bool sourceIsParentContext = false); /// Returns the access level that actually controls how a declaration should /// be emitted and may be used. /// /// This is the access used when making optimization and code generation /// decisions. It should not be used at the AST or semantic level. AccessLevel getEffectiveAccess() const; void setAccess(AccessLevel access) { assert(!hasAccess() && "access already set"); overwriteAccess(access); } /// Overwrite the access of this declaration. /// /// This is needed in the LLDB REPL. void overwriteAccess(AccessLevel access) { TypeAndAccess.setInt(access); } /// Returns true if this declaration is accessible from the given context. /// /// A private declaration is accessible from any DeclContext within the same /// source file. /// /// An internal declaration is accessible from any DeclContext within the same /// module. /// /// A public declaration is accessible everywhere. /// /// If \p DC is null, returns true only if this declaration is public. /// /// If \p forConformance is true, we ignore the visibility of the protocol /// when evaluating protocol extension members. This language rule allows a /// protocol extension of a private protocol to provide default /// implementations for the requirements of a public protocol, even when /// the default implementations are not visible to name lookup. bool isAccessibleFrom(const DeclContext *DC, bool forConformance = false) const; /// Returns whether this declaration should be treated as \c open from /// \p useDC. This is very similar to #getFormalAccess, but takes /// \c \@testable into account. /// /// This is mostly only useful when considering requirements on an override: /// if the base declaration is \c open, the override might have to be too. bool hasOpenAccess(const DeclContext *useDC) const; /// FIXME: This is deprecated. bool isRecursiveValidation() const; /// Retrieve the "interface" type of this value, which uses /// GenericTypeParamType if the declaration is generic. For a generic /// function, this will have a GenericFunctionType with a /// GenericSignature inside the type. Type getInterfaceType() const; bool hasInterfaceType() const; /// Set the interface type for the given value. void setInterfaceType(Type type); /// isInstanceMember - Determine whether this value is an instance member /// of an enum or protocol. bool isInstanceMember() const; /// Retrieve the context discriminator for this local value, which /// is the index of this declaration in the sequence of /// discriminated declarations with the same name in the current /// context. Only local functions and variables with getters and /// setters have discriminators. unsigned getLocalDiscriminator() const; void setLocalDiscriminator(unsigned index); /// Retrieve the declaration that this declaration overrides, if any. ValueDecl *getOverriddenDecl() const; /// Retrieve the declarations that this declaration overrides, if any. llvm::TinyPtrVector<ValueDecl *> getOverriddenDecls() const; /// Set the declaration that this declaration overrides. void setOverriddenDecl(ValueDecl *overridden) { setOverriddenDecls(overridden); } /// Set the declarations that this declaration overrides. void setOverriddenDecls(ArrayRef<ValueDecl *> overridden); /// Whether the overridden declarations have already been computed. bool overriddenDeclsComputed() const; /// Compute the untyped overload signature for this declaration. OverloadSignature getOverloadSignature() const; /// Retrieve the type used to describe this entity for the purposes of /// overload resolution. CanType getOverloadSignatureType() const; /// Returns true if the decl requires Objective-C interop. /// /// This can be true even if there is no 'objc' attribute on the declaration. /// In that case it was inferred by the type checker and set with a call to /// markAsObjC(). bool isObjC() const; /// Note whether this declaration is known to be exposed to Objective-C. void setIsObjC(bool Value); /// Is this declaration 'final'? bool isFinal() const; /// Is this declaration marked with 'dynamic'? bool isDynamic() const; private: bool isObjCDynamic() const { return isObjC() && isDynamic(); } bool isNativeDynamic() const { return !isObjC() && isDynamic(); } bool isObjCDynamicInGenericClass() const; public: /// Should we use Objective-C method dispatch for this decl. bool shouldUseObjCDispatch() const { return isObjCDynamic(); } /// Should we use native dynamic function replacement dispatch for this decl. bool shouldUseNativeDynamicDispatch() const { return isNativeDynamic(); } /// Should we use Objective-C category based function replacement for this /// decl. /// This is all `@objc dynamic` methods except for such methods in native /// generic classes. We can't use a category for generic classes so we use /// native replacement instead (this behavior is only enabled with /// -enable-implicit-dynamic). bool shouldUseObjCMethodReplacement() const; /// Should we use native dynamic function replacement mechanism for this decl. /// This is all native dynamic methods except for `@objc dynamic` methods in /// generic classes (see above). bool shouldUseNativeMethodReplacement() const; /// Is this a native dynamic function replacement based replacement. /// This is all @_dynamicReplacement(for:) of native functions and @objc /// dynamic methods on generic classes (see above). bool isNativeMethodReplacement() const; bool isEffectiveLinkageMoreVisibleThan(ValueDecl *other) const { return (std::min(getEffectiveAccess(), AccessLevel::Public) > std::min(other->getEffectiveAccess(), AccessLevel::Public)); } /// Set whether this type is 'dynamic' or not. void setIsDynamic(bool value); /// Whether the 'dynamic' bit has been computed already. bool isDynamicComputed() const { return LazySemanticInfo.isDynamicComputed; } /// Returns true if this decl can be found by id-style dynamic lookup. bool canBeAccessedByDynamicLookup() const; /// Returns true if this declaration has an implicitly unwrapped optional /// result. The precise meaning depends on the declaration kind: /// - for properties, the value is IUO /// - for subscripts, the element type is IUO /// - for functions, the result type is IUO /// - for constructors, the failability kind is IUO bool isImplicitlyUnwrappedOptional() const; /// Should only be set on imported and deserialized declarations; parsed /// declarations compute this lazily via a request. void setImplicitlyUnwrappedOptional(bool isIUO) { LazySemanticInfo.isIUOComputed = 1; LazySemanticInfo.isIUO = isIUO; } /// Returns the protocol requirements that this decl conforms to. ArrayRef<ValueDecl *> getSatisfiedProtocolRequirements(bool Sorted = false) const; /// Determines the kind of access that should be performed by a /// DeclRefExpr or MemberRefExpr use of this value in the specified /// context. /// /// \param DC The declaration context. /// /// \param isAccessOnSelf Whether this is a member access on the implicit /// 'self' declaration of the declaration context. AccessSemantics getAccessSemanticsFromContext(const DeclContext *DC, bool isAccessOnSelf) const; /// Determines if a reference to this declaration from a nested function /// should be treated like a capture of a local value. bool isLocalCapture() const; /// Print a reference to the given declaration. std::string printRef() const; /// Dump a reference to the given declaration. void dumpRef(raw_ostream &os) const; /// Dump a reference to the given declaration. SWIFT_DEBUG_DUMPER(dumpRef()); /// Returns true if the declaration is a static member of a type. /// /// This is not necessarily the opposite of "isInstanceMember()". Both /// predicates will be false for declarations that either categorically /// can't be "static" or are in a context where "static" doesn't make sense. bool isStatic() const; /// Retrieve the location at which we should insert a new attribute or /// modifier. SourceLoc getAttributeInsertionLoc(bool forModifier) const; static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_ValueDecl && D->getKind() <= DeclKind::Last_ValueDecl; } /// True if this is a C function that was imported as a member of a type in /// Swift. bool isImportAsMember() const; /// Returns true if the declaration's interface type is a function type with a /// curried self parameter. bool hasCurriedSelf() const; /// Returns true if the declaration has a parameter list associated with it. /// /// Note that not all declarations with function interface types have /// parameter lists, for example an enum element without associated values. bool hasParameterList() const; /// Returns the number of curry levels in the declaration's interface type. unsigned getNumCurryLevels() const; /// Get the decl for this value's opaque result type, if it has one. OpaqueTypeDecl *getOpaqueResultTypeDecl() const; /// Get the representative for this value's opaque result type, if it has one. OpaqueReturnTypeRepr *getOpaqueResultTypeRepr() const; /// Retrieve the attribute associating this declaration with a /// function builder, if there is one. CustomAttr *getAttachedFunctionBuilder() const; /// Retrieve the @functionBuilder type attached to this declaration, /// if there is one. Type getFunctionBuilderType() const; /// If this value or its backing storage is annotated /// @_dynamicReplacement(for: ...), compute the original declaration /// that this declaration dynamically replaces. ValueDecl *getDynamicallyReplacedDecl() const; }; /// This is a common base class for declarations which declare a type. class TypeDecl : public ValueDecl { MutableArrayRef<TypeLoc> Inherited; protected: TypeDecl(DeclKind K, llvm::PointerUnion<DeclContext *, ASTContext *> context, Identifier name, SourceLoc NameLoc, MutableArrayRef<TypeLoc> inherited) : ValueDecl(K, context, name, NameLoc), Inherited(inherited) {} public: Identifier getName() const { return getBaseIdentifier(); } /// Returns the string for the base name, or "_" if this is unnamed. StringRef getNameStr() const { return hasName() ? getBaseIdentifier().str() : "_"; } /// The type of this declaration's values. For the type of the /// declaration itself, use getInterfaceType(), which returns a /// metatype. Type getDeclaredInterfaceType() const; /// Retrieve the set of protocols that this type inherits (i.e, /// explicitly conforms to). MutableArrayRef<TypeLoc> getInherited() { return Inherited; } ArrayRef<TypeLoc> getInherited() const { return Inherited; } void setInherited(MutableArrayRef<TypeLoc> i) { Inherited = i; } static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_TypeDecl && D->getKind() <= DeclKind::Last_TypeDecl; } /// Compute an ordering between two type declarations that is ABI-stable. static int compare(const TypeDecl *type1, const TypeDecl *type2); /// Compute an ordering between two type declarations that is ABI-stable. /// This version takes a pointer-to-a-pointer for use with /// llvm::array_pod_sort() and similar. template<typename T> static int compare(T * const* type1, T * const* type2) { return compare(*type1, *type2); } }; /// A type declaration that can have generic parameters attached to it. Because /// it has these generic parameters, it is always a DeclContext. class GenericTypeDecl : public GenericContext, public TypeDecl { public: GenericTypeDecl(DeclKind K, DeclContext *DC, Identifier name, SourceLoc nameLoc, MutableArrayRef<TypeLoc> inherited, GenericParamList *GenericParams); // Resolve ambiguity due to multiple base classes. using TypeDecl::getASTContext; using DeclContext::operator new; using TypeDecl::getDeclaredInterfaceType; static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_GenericTypeDecl && D->getKind() <= DeclKind::Last_GenericTypeDecl; } }; /// OpaqueTypeDecl - This is a declaration of an opaque type. The opaque type /// is formally equivalent to its underlying type, but abstracts it away from /// clients of the opaque type, only exposing the type as something conforming /// to a given set of constraints. /// /// Currently, opaque types do not normally have an explicit spelling in source /// code. One is formed implicitly when a declaration is written with an opaque /// result type, as in: /// /// func foo() -> some SignedInteger { return 1 } /// /// The declared type is a special kind of ArchetypeType representing the /// abstracted underlying type. class OpaqueTypeDecl : public GenericTypeDecl { /// The original declaration that "names" the opaque type. Although a specific /// opaque type cannot be explicitly named, oapque types can propagate /// arbitrarily through expressions, so we need to know *which* opaque type is /// propagated. ValueDecl *NamingDecl; /// The generic signature of the opaque interface to the type. This is the /// outer generic signature with an added generic parameter representing the /// underlying type. GenericSignature OpaqueInterfaceGenericSignature; /// The generic parameter that represents the underlying type. GenericTypeParamType *UnderlyingInterfaceType; /// If known, the underlying type and conformances of the opaque type, /// expressed as a SubstitutionMap for the opaque interface generic signature. /// This maps types in the interface generic signature to the outer generic /// signature of the original declaration. Optional<SubstitutionMap> UnderlyingTypeSubstitutions; mutable Identifier OpaqueReturnTypeIdentifier; public: OpaqueTypeDecl(ValueDecl *NamingDecl, GenericParamList *GenericParams, DeclContext *DC, GenericSignature OpaqueInterfaceGenericSignature, GenericTypeParamType *UnderlyingInterfaceType); ValueDecl *getNamingDecl() const { return NamingDecl; } void setNamingDecl(ValueDecl *D) { assert(!NamingDecl && "already have naming decl"); NamingDecl = D; } /// Is this opaque type the opaque return type of the given function? /// /// This is more complex than just checking `getNamingDecl` because the /// function could also be the getter of a storage declaration. bool isOpaqueReturnTypeOfFunction(const AbstractFunctionDecl *func) const; GenericSignature getOpaqueInterfaceGenericSignature() const { return OpaqueInterfaceGenericSignature; } GenericTypeParamType *getUnderlyingInterfaceType() const { return UnderlyingInterfaceType; } Optional<SubstitutionMap> getUnderlyingTypeSubstitutions() const { return UnderlyingTypeSubstitutions; } void setUnderlyingTypeSubstitutions(SubstitutionMap subs) { assert(!UnderlyingTypeSubstitutions.hasValue() && "resetting underlying type?!"); UnderlyingTypeSubstitutions = subs; } // Opaque type decls are currently always implicit SourceRange getSourceRange() const { return SourceRange(); } // Get the identifier string that can be used to cross-reference unnamed // opaque return types across files. Identifier getOpaqueReturnTypeIdentifier() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::OpaqueType; } static bool classof(const GenericTypeDecl *D) { return D->getKind() == DeclKind::OpaqueType; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } }; /// TypeAliasDecl - This is a declaration of a typealias, for example: /// /// typealias Foo = Int /// /// TypeAliasDecl's always have 'MetatypeType' type. /// class TypeAliasDecl : public GenericTypeDecl { friend class UnderlyingTypeRequest; /// The location of the 'typealias' keyword SourceLoc TypeAliasLoc; /// The location of the equal '=' token SourceLoc EqualLoc; /// The end of the type, valid even when the type cannot be parsed SourceLoc TypeEndLoc; /// The location of the right-hand side of the typealias binding TypeLoc UnderlyingTy; public: TypeAliasDecl(SourceLoc TypeAliasLoc, SourceLoc EqualLoc, Identifier Name, SourceLoc NameLoc, GenericParamList *GenericParams, DeclContext *DC); SourceLoc getStartLoc() const { return TypeAliasLoc; } SourceRange getSourceRange() const; /// Returns the location of the equal '=' token SourceLoc getEqualLoc() const { return EqualLoc; } void setTypeEndLoc(SourceLoc e) { TypeEndLoc = e; } /// Retrieve the TypeRepr corresponding to the parsed underlying type. TypeRepr *getUnderlyingTypeRepr() const { return UnderlyingTy.getTypeRepr(); } void setUnderlyingTypeRepr(TypeRepr *repr) { UnderlyingTy = repr; } /// Retrieve the interface type of the underlying type. Type getUnderlyingType() const; void setUnderlyingType(Type type); /// Returns the interface type of the underlying type if computed, null /// otherwise. Should only be used for dumping. Type getCachedUnderlyingType() const { return UnderlyingTy.getType(); } /// For generic typealiases, return the unbound generic type. UnboundGenericType *getUnboundGenericType() const; /// Retrieve a sugared interface type containing the structure of the interface /// type before any semantic validation has occured. Type getStructuralType() const; bool isCompatibilityAlias() const { return Bits.TypeAliasDecl.IsCompatibilityAlias; } void markAsCompatibilityAlias(bool newValue = true) { Bits.TypeAliasDecl.IsCompatibilityAlias = newValue; } /// Is this a special debugger variable? bool isDebuggerAlias() const { return Bits.TypeAliasDecl.IsDebuggerAlias; } void markAsDebuggerAlias(bool isDebuggerAlias) { Bits.TypeAliasDecl.IsDebuggerAlias = isDebuggerAlias; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::TypeAlias; } static bool classof(const GenericTypeDecl *D) { return D->getKind() == DeclKind::TypeAlias; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } }; /// Abstract class describing generic type parameters and associated types, /// whose common purpose is to anchor the abstract type parameter and specify /// requirements for any corresponding type argument. class AbstractTypeParamDecl : public TypeDecl { protected: AbstractTypeParamDecl(DeclKind kind, DeclContext *dc, Identifier name, SourceLoc NameLoc) : TypeDecl(kind, dc, name, NameLoc, { }) { } public: /// Return the superclass of the generic parameter. Type getSuperclass() const; /// Retrieve the set of protocols to which this abstract type /// parameter conforms. ArrayRef<ProtocolDecl *> getConformingProtocols() const; static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_AbstractTypeParamDecl && D->getKind() <= DeclKind::Last_AbstractTypeParamDecl; } }; /// A declaration of a generic type parameter. /// /// A generic type parameter introduces a new, named type parameter along /// with some set of requirements on any type argument used to realize this /// type parameter. The requirements involve conformances to specific /// protocols or inheritance from a specific class type. /// /// In the following example, 'T' is a generic type parameter with the /// requirement that the type argument conform to the 'Comparable' protocol. /// /// \code /// func min<T : Comparable>(x : T, y : T) -> T { ... } /// \endcode class GenericTypeParamDecl : public AbstractTypeParamDecl { public: static const unsigned InvalidDepth = 0xFFFF; /// Construct a new generic type parameter. /// /// \param dc The DeclContext in which the generic type parameter's owner /// occurs. This should later be overwritten with the actual declaration /// context that owns the type parameter. /// /// \param name The name of the generic parameter. /// \param nameLoc The location of the name. GenericTypeParamDecl(DeclContext *dc, Identifier name, SourceLoc nameLoc, unsigned depth, unsigned index); /// The depth of this generic type parameter, i.e., the number of outer /// levels of generic parameter lists that enclose this type parameter. /// /// \code /// struct X<T> { /// func f<U>() { } /// } /// \endcode /// /// Here 'T' has depth 0 and 'U' has depth 1. Both have index 0. unsigned getDepth() const { return Bits.GenericTypeParamDecl.Depth; } /// Set the depth of this generic type parameter. /// /// \sa getDepth void setDepth(unsigned depth) { Bits.GenericTypeParamDecl.Depth = depth; assert(Bits.GenericTypeParamDecl.Depth == depth && "Truncation"); } /// The index of this generic type parameter within its generic parameter /// list. /// /// \code /// struct X<T, U> { /// func f<V>() { } /// } /// \endcode /// /// Here 'T' and 'U' have indexes 0 and 1, respectively. 'V' has index 0. unsigned getIndex() const { return Bits.GenericTypeParamDecl.Index; } SourceLoc getStartLoc() const { return getNameLoc(); } SourceRange getSourceRange() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::GenericTypeParam; } }; /// A declaration of an associated type. /// /// An associated type introduces a new, named type in a protocol that /// can vary from one conforming type to the next. Associated types have a /// set of requirements to which the type that replaces it much realize, /// described via conformance to specific protocols, or inheritance from a /// specific class type. /// /// In the following example, 'Element' is an associated type with no /// requirements. /// /// \code /// protocol Enumerator { /// typealias Element /// func getNext() -> Element? /// } /// \endcode class AssociatedTypeDecl : public AbstractTypeParamDecl { /// The location of the initial keyword. SourceLoc KeywordLoc; /// The default definition. TypeRepr *DefaultDefinition; /// The where clause attached to the associated type. TrailingWhereClause *TrailingWhere; LazyMemberLoader *Resolver = nullptr; uint64_t ResolverContextData; friend class DefaultDefinitionTypeRequest; public: AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc, Identifier name, SourceLoc nameLoc, TypeRepr *defaultDefinition, TrailingWhereClause *trailingWhere); AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc, Identifier name, SourceLoc nameLoc, TrailingWhereClause *trailingWhere, LazyMemberLoader *definitionResolver, uint64_t resolverData); /// Get the protocol in which this associated type is declared. ProtocolDecl *getProtocol() const { return cast<ProtocolDecl>(getDeclContext()); } /// Check if we have a default definition type. bool hasDefaultDefinitionType() const { // If we have a TypeRepr, return true immediately without kicking off // a request. return DefaultDefinition || getDefaultDefinitionType(); } /// Retrieve the default definition type. Type getDefaultDefinitionType() const; /// Retrieve the default definition as written in the source. TypeRepr *getDefaultDefinitionTypeRepr() const { return DefaultDefinition; } /// Retrieve the trailing where clause for this associated type, if any. TrailingWhereClause *getTrailingWhereClause() const { return TrailingWhere; } /// Set the trailing where clause for this associated type. void setTrailingWhereClause(TrailingWhereClause *trailingWhereClause) { TrailingWhere = trailingWhereClause; } /// Retrieve the associated type "anchor", which is the associated type /// declaration that will be used to describe this associated type in the /// ABI. /// /// The associated type "anchor" is an associated type that does not /// override any other associated type. There may be several such associated /// types; select one deterministically. AssociatedTypeDecl *getAssociatedTypeAnchor() const; /// Retrieve the (first) overridden associated type declaration, if any. AssociatedTypeDecl *getOverriddenDecl() const { return cast_or_null<AssociatedTypeDecl>( AbstractTypeParamDecl::getOverriddenDecl()); } /// Retrieve the set of associated types overridden by this associated /// type. llvm::TinyPtrVector<AssociatedTypeDecl *> getOverriddenDecls() const; SourceLoc getStartLoc() const { return KeywordLoc; } SourceRange getSourceRange() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::AssociatedType; } }; class MemberLookupTable; class ConformanceLookupTable; // Kinds of pointer types. enum PointerTypeKind : unsigned { PTK_UnsafeMutableRawPointer, PTK_UnsafeRawPointer, PTK_UnsafeMutablePointer, PTK_UnsafePointer, PTK_AutoreleasingUnsafeMutablePointer, }; static inline bool isRawPointerKind(PointerTypeKind PTK) { switch (PTK) { case PTK_UnsafeMutableRawPointer: case PTK_UnsafeRawPointer: return true; case PTK_UnsafeMutablePointer: case PTK_UnsafePointer: case PTK_AutoreleasingUnsafeMutablePointer: return false; } llvm_unreachable("Unhandled PointerTypeKind in switch."); } // Kinds of buffer pointer types. enum BufferPointerTypeKind : unsigned { BPTK_UnsafeMutableRawBufferPointer, BPTK_UnsafeRawBufferPointer, BPTK_UnsafeMutableBufferPointer, BPTK_UnsafeBufferPointer, }; enum KeyPathTypeKind : unsigned char { KPTK_AnyKeyPath, KPTK_PartialKeyPath, KPTK_KeyPath, KPTK_WritableKeyPath, KPTK_ReferenceWritableKeyPath }; /// NominalTypeDecl - a declaration of a nominal type, like a struct. class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext { SourceRange Braces; /// The first extension of this type. ExtensionDecl *FirstExtension = nullptr; /// The last extension of this type, used solely for efficient /// insertion of new extensions. ExtensionDecl *LastExtension = nullptr; /// The generation at which we last loaded extensions. unsigned ExtensionGeneration; /// Prepare to traverse the list of extensions. void prepareExtensions(); /// Retrieve the conformance loader (if any), and removing it in the /// same operation. The caller is responsible for loading the /// conformances. std::pair<LazyMemberLoader *, uint64_t> takeConformanceLoader() { if (!Bits.NominalTypeDecl.HasLazyConformances) return { nullptr, 0 }; return takeConformanceLoaderSlow(); } /// Slow path for \c takeConformanceLoader(). std::pair<LazyMemberLoader *, uint64_t> takeConformanceLoaderSlow(); /// A lookup table containing all of the members of this type and /// its extensions. /// /// The table itself is lazily constructed and updated when /// lookupDirect() is called. MemberLookupTable *LookupTable = nullptr; /// Prepare the lookup table to make it ready for lookups. void prepareLookupTable(); /// Note that we have added a member into the iterable declaration context, /// so that it can also be added to the lookup table (if needed). void addedMember(Decl *member); /// Note that we have added an extension into the nominal type, /// so that its members can eventually be added to the lookup table. void addedExtension(ExtensionDecl *ext); /// A lookup table used to find the protocol conformances of /// a given nominal type. mutable ConformanceLookupTable *ConformanceTable = nullptr; /// Prepare the conformance table. void prepareConformanceTable() const; /// Returns the protocol requirements that \c Member conforms to. ArrayRef<ValueDecl *> getSatisfiedProtocolRequirementsForMember(const ValueDecl *Member, bool Sorted) const; friend class ASTContext; friend class MemberLookupTable; friend class ConformanceLookupTable; friend class ExtensionDecl; friend class DeclContext; friend class IterableDeclContext; friend class DirectLookupRequest; friend ArrayRef<ValueDecl *> ValueDecl::getSatisfiedProtocolRequirements(bool Sorted) const; protected: Type DeclaredTy; Type DeclaredInterfaceTy; NominalTypeDecl(DeclKind K, DeclContext *DC, Identifier name, SourceLoc NameLoc, MutableArrayRef<TypeLoc> inherited, GenericParamList *GenericParams) : GenericTypeDecl(K, DC, name, NameLoc, inherited, GenericParams), IterableDeclContext(IterableDeclContextKind::NominalTypeDecl) { Bits.NominalTypeDecl.AddedImplicitInitializers = false; ExtensionGeneration = 0; Bits.NominalTypeDecl.HasLazyConformances = false; Bits.NominalTypeDecl.IsComputingSemanticMembers = false; } friend class ProtocolType; public: using GenericTypeDecl::getASTContext; SourceRange getBraces() const { return Braces; } void setBraces(SourceRange braces) { Braces = braces; } /// Should this declaration behave as if it must be accessed /// resiliently, even when we're building a non-resilient module? /// /// This is used for diagnostics, because we do not want a behavior /// change between builds with resilience enabled and disabled. bool isFormallyResilient() const; /// Do we need to use resilient access patterns outside of this type's /// resilience domain? bool isResilient() const; /// Do we need to use resilient access patterns when accessing this /// type from the given module? bool isResilient(ModuleDecl *M, ResilienceExpansion expansion) const; /// Determine whether we have already attempted to add any /// implicitly-defined initializers to this declaration. bool addedImplicitInitializers() const { return Bits.NominalTypeDecl.AddedImplicitInitializers; } /// Note that we have attempted to add implicit initializers. void setAddedImplicitInitializers() { Bits.NominalTypeDecl.AddedImplicitInitializers = true; } /// getDeclaredType - Retrieve the type declared by this entity, without /// any generic parameters bound if this is a generic type. Type getDeclaredType() const; /// getDeclaredInterfaceType - Retrieve the type declared by this entity, with /// generic parameters bound if this is a generic type. Type getDeclaredInterfaceType() const; /// Add a new extension to this nominal type. void addExtension(ExtensionDecl *extension); /// Retrieve the set of extensions of this type. ExtensionRange getExtensions(); /// Special-behaviour flags passed to lookupDirect() enum class LookupDirectFlags { /// Whether to include @_implements members. /// Used by conformance-checking to find special @_implements members. IncludeAttrImplements = 1 << 0, /// Whether to avoid loading lazy members from any new extensions that would otherwise be found /// by deserialization. /// /// Used by the module loader to break recursion and as an optimization e.g. when it is known that a /// particular member declaration will never appear in an extension. IgnoreNewExtensions = 1 << 1, }; /// Find all of the declarations with the given name within this nominal type /// and its extensions. /// /// This routine does not look into superclasses, nor does it consider /// protocols to which the nominal type conforms. Furthermore, the resulting /// set of declarations has not been filtered for visibility, nor have /// overridden declarations been removed. TinyPtrVector<ValueDecl *> lookupDirect(DeclName name, OptionSet<LookupDirectFlags> flags = OptionSet<LookupDirectFlags>()); /// Collect the set of protocols to which this type should implicitly /// conform, such as AnyObject (for classes). void getImplicitProtocols(SmallVectorImpl<ProtocolDecl *> &protocols); /// Look for conformances of this nominal type to the given /// protocol. /// /// \param module The module from which we initiate the search. /// FIXME: This is currently unused. /// /// \param protocol The protocol whose conformance is requested. /// \param conformances Will be populated with the set of protocol /// conformances found for this protocol. /// /// \returns true if any conformances were found. bool lookupConformance( ModuleDecl *module, ProtocolDecl *protocol, SmallVectorImpl<ProtocolConformance *> &conformances) const; /// Retrieve all of the protocols that this nominal type conforms to. SmallVector<ProtocolDecl *, 2> getAllProtocols() const; /// Retrieve all of the protocol conformances for this nominal type. SmallVector<ProtocolConformance *, 2> getAllConformances( bool sorted = false) const; /// Register an externally-created protocol conformance in the /// conformance lookup table. /// /// This is used by deserialization of module files to report /// conformances. void registerProtocolConformance(ProtocolConformance *conformance); void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData); /// Is this the decl for Optional<T>? bool isOptionalDecl() const; /// Is this a key path type? Optional<KeyPathTypeKind> getKeyPathTypeKind() const; /// Retrieve information about this type as a property wrapper. PropertyWrapperTypeInfo getPropertyWrapperTypeInfo() const; /// Return a collection of the stored member variables of this type. ArrayRef<VarDecl *> getStoredProperties() const; /// Return a collection of the stored member variables of this type, along /// with placeholders for unimportable stored properties. ArrayRef<Decl *> getStoredPropertiesAndMissingMemberPlaceholders() const; /// Return the range of semantics attributes attached to this NominalTypeDecl. auto getSemanticsAttrs() const -> decltype(getAttrs().getSemanticsAttrs()) { return getAttrs().getSemanticsAttrs(); } bool hasSemanticsAttr(StringRef attrValue) const { return getAttrs().hasSemanticsAttr(attrValue); } /// Whether this declaration has a synthesized memberwise initializer. bool hasMemberwiseInitializer() const; /// Retrieves the synthesized memberwise initializer for this declaration, /// or \c nullptr if it does not have one. ConstructorDecl *getMemberwiseInitializer() const; /// Retrieves the effective memberwise initializer for this declaration, or /// \c nullptr if it does not have one. /// /// An effective memberwise initializer is either a synthesized memberwise /// initializer or a user-defined initializer with the same type. /// /// The access level of the memberwise initializer is set to the minimum of: /// - Public, by default. This enables public nominal types to have public /// memberwise initializers. /// - The `public` default is important for synthesized member types, e.g. /// `TangentVector` structs synthesized during `Differentiable` derived /// conformances. Manually extending these types to define a public /// memberwise initializer causes a redeclaration error. /// - The minimum access level of memberwise-initialized properties in the /// nominal type declaration. /// /// Effective memberwise initializers are used only by derived conformances /// for `Self`-returning protocol requirements like `AdditiveArithmetic.+`. /// Such derived conformances require memberwise initialization. ConstructorDecl *getEffectiveMemberwiseInitializer(); /// Whether this declaration has a synthesized zero parameter default /// initializer. bool hasDefaultInitializer() const; bool isTypeErasedGenericClass() const; /// Retrieves the synthesized zero parameter default initializer for this /// declaration, or \c nullptr if it doesn't have one. ConstructorDecl *getDefaultInitializer() const; void synthesizeSemanticMembersIfNeeded(DeclName member); // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_NominalTypeDecl && D->getKind() <= DeclKind::Last_NominalTypeDecl; } static bool classof(const GenericTypeDecl *D) { return D->getKind() >= DeclKind::First_NominalTypeDecl && D->getKind() <= DeclKind::Last_NominalTypeDecl; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const IterableDeclContext *C) { return C->getIterableContextKind() == IterableDeclContextKind::NominalTypeDecl; } static bool classof(const NominalTypeDecl *D) { return true; } static bool classof(const ExtensionDecl *D) { return false; } }; /// This is the declaration of an enum. /// /// For example: /// /// \code /// enum Bool { /// case false /// case true /// } /// /// enum Optional<T> { /// case none /// case some(T) /// } /// \endcode /// /// The type of the decl itself is a MetatypeType; use getDeclaredType() /// to get the declared type ("Bool" or "Optional" in the above example). class EnumDecl final : public NominalTypeDecl { SourceLoc EnumLoc; enum SemanticInfoFlags : uint8_t { // Is the raw type valid? HasComputedRawType = 1 << 0, // Is the complete set of (auto-incremented) raw values available? HasFixedRawValues = 1 << 1, // Is the complete set of raw values type checked? HasFixedRawValuesAndTypes = 1 << 2, }; struct { /// The raw type and a bit to indicate whether the /// raw was computed yet or not. llvm::PointerIntPair<Type, 3, OptionSet<SemanticInfoFlags>> RawTypeAndFlags; bool hasRawType() const { return RawTypeAndFlags.getInt().contains(HasComputedRawType); } void cacheRawType(Type ty) { auto flags = RawTypeAndFlags.getInt() | HasComputedRawType; RawTypeAndFlags.setPointerAndInt(ty, flags); } bool hasFixedRawValues() const { return RawTypeAndFlags.getInt().contains(HasFixedRawValues); } bool hasCheckedRawValues() const { return RawTypeAndFlags.getInt().contains(HasFixedRawValuesAndTypes); } } LazySemanticInfo; friend class EnumRawValuesRequest; friend class EnumRawTypeRequest; public: EnumDecl(SourceLoc EnumLoc, Identifier Name, SourceLoc NameLoc, MutableArrayRef<TypeLoc> Inherited, GenericParamList *GenericParams, DeclContext *DC); SourceLoc getStartLoc() const { return EnumLoc; } SourceRange getSourceRange() const { return SourceRange(EnumLoc, getBraces().End); } public: /// A range for iterating the elements of an enum. using ElementRange = DowncastFilterRange<EnumElementDecl, DeclRange>; /// A range for iterating the cases of an enum. using CaseRange = DowncastFilterRange<EnumCaseDecl, DeclRange>; /// Return a range that iterates over all the elements of an enum. ElementRange getAllElements() const { return ElementRange(getMembers()); } unsigned getNumElements() const { auto eltRange = getAllElements(); return std::distance(eltRange.begin(), eltRange.end()); } /// If this enum has a unique element, return it. A unique element can /// either hold a value or not, and the existence of one unique element does /// not imply the existence or non-existence of the opposite unique element. EnumElementDecl *getUniqueElement(bool hasValue) const; /// Return a range that iterates over all the cases of an enum. CaseRange getAllCases() const { return CaseRange(getMembers()); } /// Insert all of the 'case' element declarations into a DenseSet. void getAllElements(llvm::DenseSet<EnumElementDecl*> &elements) const { for (auto elt : getAllElements()) elements.insert(elt); } /// Whether this enum has a raw value type that recursively references itself. bool hasCircularRawValue() const; /// Record that this enum has had all of its raw values computed. void setHasFixedRawValues(); // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Enum; } static bool classof(const GenericTypeDecl *D) { return D->getKind() == DeclKind::Enum; } static bool classof(const NominalTypeDecl *D) { return D->getKind() == DeclKind::Enum; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const IterableDeclContext *C) { auto NTD = dyn_cast<NominalTypeDecl>(C); return NTD && classof(NTD); } /// Determine whether this enum declares a raw type in its inheritance clause. bool hasRawType() const { return (bool)getRawType(); } /// Retrieve the declared raw type of the enum from its inheritance clause, /// or null if it has none. Type getRawType() const; /// Set the raw type of the enum from its inheritance clause. void setRawType(Type rawType) { auto flags = LazySemanticInfo.RawTypeAndFlags.getInt(); LazySemanticInfo.RawTypeAndFlags.setPointerAndInt( rawType, flags | HasComputedRawType); } /// True if none of the enum cases have associated values. /// /// Note that this is true for enums with absolutely no cases. bool hasOnlyCasesWithoutAssociatedValues() const; /// True if any of the enum cases have availability annotations. /// /// Note that this is false for enums with absolutely no cases. bool hasPotentiallyUnavailableCaseValue() const; /// True if the enum has cases. bool hasCases() const { return !getAllElements().empty(); } /// True if the enum is marked 'indirect'. bool isIndirect() const { return getAttrs().hasAttribute<IndirectAttr>(); } /// True if the enum can be exhaustively switched within \p useDC. /// /// Note that this property is \e not necessarily true for all children of /// \p useDC. In particular, an inlinable function does not get to switch /// exhaustively over a non-exhaustive enum declared in the same module. /// /// This is the predicate used when deciding if a switch statement needs a /// default case. It should not be used for optimization or code generation. /// /// \sa isEffectivelyExhaustive bool isFormallyExhaustive(const DeclContext *useDC) const; /// True if the enum can be exhaustively switched within a function defined /// within \p M, with \p expansion specifying whether the function is /// inlinable. /// /// This is the predicate used when making optimization and code generation /// decisions. It should not be used at the AST or semantic level. /// /// \sa isFormallyExhaustive bool isEffectivelyExhaustive(ModuleDecl *M, ResilienceExpansion expansion) const; }; /// StructDecl - This is the declaration of a struct, for example: /// /// struct Complex { var R : Double, I : Double } /// /// The type of the decl itself is a MetatypeType; use getDeclaredType() /// to get the declared type ("Complex" in the above example). class StructDecl final : public NominalTypeDecl { SourceLoc StructLoc; public: StructDecl(SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc, MutableArrayRef<TypeLoc> Inherited, GenericParamList *GenericParams, DeclContext *DC); SourceLoc getStartLoc() const { return StructLoc; } SourceRange getSourceRange() const { return SourceRange(StructLoc, getBraces().End); } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Struct; } static bool classof(const GenericTypeDecl *D) { return D->getKind() == DeclKind::Struct; } static bool classof(const NominalTypeDecl *D) { return D->getKind() == DeclKind::Struct; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const IterableDeclContext *C) { auto NTD = dyn_cast<NominalTypeDecl>(C); return NTD && classof(NTD); } /// Does this struct contain unreferenceable storage, such as C fields that /// cannot be represented in Swift? bool hasUnreferenceableStorage() const { return Bits.StructDecl.HasUnreferenceableStorage; } void setHasUnreferenceableStorage(bool v) { Bits.StructDecl.HasUnreferenceableStorage = v; } bool isCxxNotTriviallyCopyable() const { return Bits.StructDecl.IsCxxNotTriviallyCopyable; } void setIsCxxNotTriviallyCopyable(bool v) { Bits.StructDecl.IsCxxNotTriviallyCopyable = v; } }; /// This is the base type for AncestryOptions. Each flag describes possible /// interesting kinds of superclasses that a class may have. enum class AncestryFlags : uint8_t { /// The class or one of its superclasses is @objc. ObjC = (1<<0), /// The class or one of its superclasses is @objcMembers. ObjCMembers = (1<<1), /// The class or one of its superclasses is generic. Generic = (1<<2), /// The class or one of its superclasses is resilient. Resilient = (1<<3), /// The class or one of its superclasses has resilient metadata and is in a /// different resilience domain. ResilientOther = (1<<4), /// The class or one of its superclasses is imported from Clang. ClangImported = (1<<5), /// The class or one of its superclasses requires stored property initializers. RequiresStoredPropertyInits = (1<<6), }; /// Return type of ClassDecl::checkAncestry(). Describes a set of interesting /// kinds of superclasses that a class may have. using AncestryOptions = OptionSet<AncestryFlags>; /// ClassDecl - This is the declaration of a class, for example: /// /// class Complex { var R : Double, I : Double } /// /// The type of the decl itself is a MetatypeType; use getDeclaredType() /// to get the declared type ("Complex" in the above example). class ClassDecl final : public NominalTypeDecl { class ObjCMethodLookupTable; SourceLoc ClassLoc; ObjCMethodLookupTable *ObjCMethodLookup = nullptr; /// Create the Objective-C member lookup table. void createObjCMethodLookup(); struct { /// The superclass decl and a bit to indicate whether the /// superclass was computed yet or not. llvm::PointerIntPair<ClassDecl *, 1, bool> SuperclassDecl; /// The superclass type and a bit to indicate whether the /// superclass was computed yet or not. llvm::PointerIntPair<Type, 1, bool> SuperclassType; } LazySemanticInfo; bool hasForcedEmittedMembers() const { return Bits.ClassDecl.HasForcedEmittedMembers; } void setHasForcedEmittedMembers() { Bits.ClassDecl.HasForcedEmittedMembers = true; } Optional<bool> getCachedInheritsSuperclassInitializers() const { if (Bits.ClassDecl.ComputedInheritsSuperclassInits) return Bits.ClassDecl.InheritsSuperclassInits; return None; } Optional<bool> getCachedHasMissingDesignatedInitializers() const { if (!Bits.ClassDecl.ComputedHasMissingDesignatedInitializers) { // Force loading all the members, which will add this attribute if any of // members are determined to be missing while loading. auto mutableThis = const_cast<ClassDecl *>(this); (void)mutableThis->lookupDirect(DeclBaseName::createConstructor()); } if (Bits.ClassDecl.ComputedHasMissingDesignatedInitializers) return Bits.ClassDecl.HasMissingDesignatedInitializers; return None; } void setHasMissingDesignatedInitializers(bool value) { Bits.ClassDecl.HasMissingDesignatedInitializers = value; Bits.ClassDecl.ComputedHasMissingDesignatedInitializers = true; } /// Marks that this class inherits convenience initializers from its /// superclass. void setInheritsSuperclassInitializers(bool value) { Bits.ClassDecl.InheritsSuperclassInits = value; Bits.ClassDecl.ComputedInheritsSuperclassInits = true; } friend class SuperclassDeclRequest; friend class SuperclassTypeRequest; friend class EmittedMembersRequest; friend class HasMissingDesignatedInitializersRequest; friend class InheritsSuperclassInitializersRequest; public: ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc, MutableArrayRef<TypeLoc> Inherited, GenericParamList *GenericParams, DeclContext *DC); SourceLoc getStartLoc() const { return ClassLoc; } SourceRange getSourceRange() const { return SourceRange(ClassLoc, getBraces().End); } /// Determine whether the member area of this class's metadata (which consists /// of field offsets and vtable entries) is to be considered opaque by clients. /// /// Note that even @_fixed_layout classes have resilient metadata if they are /// in a resilient module. bool hasResilientMetadata() const; /// Determine whether this class has resilient metadata when accessed from the /// given module and resilience expansion. bool hasResilientMetadata(ModuleDecl *M, ResilienceExpansion expansion) const; /// Determine whether this class has a superclass. bool hasSuperclass() const { return (bool)getSuperclassDecl(); } /// Retrieve the superclass of this class, or null if there is no superclass. Type getSuperclass() const; /// Retrieve the ClassDecl for the superclass of this class, or null if there /// is no superclass. ClassDecl *getSuperclassDecl() const; /// Check if this class is a superclass or equal to the given class. bool isSuperclassOf(ClassDecl *other) const; /// Set the superclass of this class. void setSuperclass(Type superclass); /// Whether this class has a circular reference in its inheritance hierarchy. bool hasCircularInheritance() const; /// Walk this class and all of the superclasses of this class, transitively, /// invoking the callback function for each class. /// /// \param fn The callback function that will be invoked for each superclass. /// It can return \c Continue to continue the traversal. Returning /// \c SkipChildren halts the search and returns \c false, while returning /// \c Stop halts the search and returns \c true. /// /// \returns \c true if \c fn returned \c Stop for any class, \c false /// otherwise. bool walkSuperclasses( llvm::function_ref<TypeWalker::Action(ClassDecl *)> fn) const; //// Whether this class requires all of its stored properties to //// have initializers in the class definition. bool requiresStoredPropertyInits() const { return checkAncestry(AncestryFlags::RequiresStoredPropertyInits); } /// \see getForeignClassKind enum class ForeignKind : uint8_t { /// A normal Swift or Objective-C class. Normal = 0, /// An imported Core Foundation type. These are AnyObject-compatible but /// do not have runtime metadata. CFType, /// An imported Objective-C type whose class and metaclass symbols are not /// both available at link-time but can be accessed through the Objective-C /// runtime. RuntimeOnly }; /// Whether this class is "foreign", meaning that it is implemented /// by a runtime that Swift does not have first-class integration /// with. This generally means that: /// - class data is either abstracted or cannot be made to /// fit with Swift's metatype schema, and/or /// - there is no facility for subclassing or adding polymorphic /// methods to the class. /// /// We may find ourselves wanting to break this bit into more /// precise chunks later. ForeignKind getForeignClassKind() const { return static_cast<ForeignKind>(Bits.ClassDecl.RawForeignKind); } void setForeignClassKind(ForeignKind kind) { Bits.ClassDecl.RawForeignKind = static_cast<unsigned>(kind); } /// Returns true if this class is any kind of "foreign class". /// /// \see getForeignClassKind bool isForeign() const { return getForeignClassKind() != ForeignKind::Normal; } /// Returns true if the class has designated initializers that are not listed /// in its members. /// /// This can occur, for example, if the class is an Objective-C class with /// initializers that cannot be represented in Swift. bool hasMissingDesignatedInitializers() const; /// Returns true if the class has missing members that require vtable entries. /// /// In this case, the class cannot be subclassed, because we cannot construct /// the vtable for the subclass. bool hasMissingVTableEntries() const; void setHasMissingVTableEntries(bool newValue = true) { Bits.ClassDecl.ComputedHasMissingVTableEntries = 1; Bits.ClassDecl.HasMissingVTableEntries = newValue; } /// Returns true if this class cannot be used with weak or unowned /// references. /// /// Note that this is true if this class or any of its ancestor classes /// are marked incompatible. bool isIncompatibleWithWeakReferences() const; void setIsIncompatibleWithWeakReferences(bool newValue = true) { Bits.ClassDecl.IsIncompatibleWithWeakReferences = newValue; } /// Find a method of a class that overrides a given method. /// Return nullptr, if no such method exists. AbstractFunctionDecl *findOverridingDecl( const AbstractFunctionDecl *method) const; /// Find a method implementation which will be used when a given method /// is invoked on an instance of this class. This implementation may stem /// either from a class itself or its direct or indirect superclasses. AbstractFunctionDecl *findImplementingMethod( const AbstractFunctionDecl *method) const; /// Retrieve the destructor for this class. DestructorDecl *getDestructor() const; /// Determine whether this class inherits the convenience initializers /// from its superclass. bool inheritsSuperclassInitializers() const; /// Walks the class hierarchy starting from this class, checking various /// conditions. AncestryOptions checkAncestry() const; /// Check if the class has ancestry of the given kind. bool checkAncestry(AncestryFlags flag) const { return checkAncestry().contains(flag); } /// The type of metaclass to use for a class. enum class MetaclassKind : uint8_t { ObjC, SwiftStub, }; /// Determine which sort of metaclass to use for this class MetaclassKind getMetaclassKind() const; /// Retrieve the name to use for this class when interoperating with /// the Objective-C runtime. StringRef getObjCRuntimeName(llvm::SmallVectorImpl<char> &buffer) const; using NominalTypeDecl::lookupDirect; /// Look in this class and its extensions (but not any of its protocols or /// superclasses) for declarations with a given Objective-C selector. /// /// Note that this can find methods, initializers, deinitializers, /// getters, and setters. /// /// \param selector The Objective-C selector of the method we're /// looking for. /// /// \param isInstance Whether we are looking for an instance method /// (vs. a class method). TinyPtrVector<AbstractFunctionDecl *> lookupDirect(ObjCSelector selector, bool isInstance); /// Record the presence of an @objc method with the given selector. void recordObjCMethod(AbstractFunctionDecl *method, ObjCSelector selector); /// Get all the members of this class, synthesizing any implicit members /// that appear in the vtable if needed. DeclRange getEmittedMembers() const; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Class; } static bool classof(const GenericTypeDecl *D) { return D->getKind() == DeclKind::Class; } static bool classof(const NominalTypeDecl *D) { return D->getKind() == DeclKind::Class; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const IterableDeclContext *C) { auto NTD = dyn_cast<NominalTypeDecl>(C); return NTD && classof(NTD); } /// Returns true if the decl uses the Objective-C generics model. /// /// This is true of imported Objective-C classes. bool usesObjCGenericsModel() const { return hasClangNode() && isGenericContext() && isObjC(); } /// True if the class is known to be implemented in Swift. bool hasKnownSwiftImplementation() const { return !hasClangNode(); } }; /// Describes whether a requirement refers to 'Self', for use in the /// is-inheritable and is-available-existential checks. struct SelfReferenceKind { bool result; bool parameter; bool requirement; bool other; /// The type does not refer to 'Self' at all. static SelfReferenceKind None() { return SelfReferenceKind(false, false, false, false); } /// The type refers to 'Self', but only as the result type of a method. static SelfReferenceKind Result() { return SelfReferenceKind(true, false, false, false); } /// The type refers to 'Self', but only as the parameter type of a method. static SelfReferenceKind Parameter() { return SelfReferenceKind(false, true, false, false); } /// The type refers to 'Self' within a same-type requiement. static SelfReferenceKind Requirement() { return SelfReferenceKind(false, false, true, false); } /// The type refers to 'Self' in a position that is invariant. static SelfReferenceKind Other() { return SelfReferenceKind(false, false, false, true); } SelfReferenceKind flip() const { return SelfReferenceKind(parameter, result, requirement, other); } SelfReferenceKind operator|=(SelfReferenceKind kind) { result |= kind.result; requirement |= kind.requirement; parameter |= kind.parameter; other |= kind.other; return *this; } operator bool() const { return result || parameter || requirement || other; } private: SelfReferenceKind(bool result, bool parameter, bool requirement, bool other) : result(result), parameter(parameter), requirement(requirement), other(other) { } }; /// The set of known protocols for which derived conformances are supported. enum class KnownDerivableProtocolKind : uint8_t { RawRepresentable, OptionSet, CaseIterable, Comparable, Equatable, Hashable, BridgedNSError, CodingKey, Encodable, Decodable, AdditiveArithmetic, Differentiable, }; /// ProtocolDecl - A declaration of a protocol, for example: /// /// protocol Drawable { /// func draw() /// } /// /// Every protocol has an implicitly-created 'Self' generic parameter that /// stands for a type that conforms to the protocol. For example, /// /// protocol Cloneable { /// func clone() -> Self /// } /// class ProtocolDecl final : public NominalTypeDecl { SourceLoc ProtocolLoc; ArrayRef<ProtocolDecl *> InheritedProtocols; struct { /// The superclass decl and a bit to indicate whether the /// superclass was computed yet or not. llvm::PointerIntPair<ClassDecl *, 1, bool> SuperclassDecl; /// The superclass type and a bit to indicate whether the /// superclass was computed yet or not. llvm::PointerIntPair<Type, 1, bool> SuperclassType; } LazySemanticInfo; /// The generic signature representing exactly the new requirements introduced /// by this protocol. const Requirement *RequirementSignature = nullptr; /// Returns the cached result of \c requiresClass or \c None if it hasn't yet /// been computed. Optional<bool> getCachedRequiresClass() const { if (Bits.ProtocolDecl.RequiresClassValid) return Bits.ProtocolDecl.RequiresClass; return None; } /// Caches the result of \c requiresClass void setCachedRequiresClass(bool requiresClass) { Bits.ProtocolDecl.RequiresClassValid = true; Bits.ProtocolDecl.RequiresClass = requiresClass; } /// Returns the cached result of \c existentialConformsToSelf or \c None if it /// hasn't yet been computed. Optional<bool> getCachedExistentialConformsToSelf() const { if (Bits.ProtocolDecl.ExistentialConformsToSelfValid) return Bits.ProtocolDecl.ExistentialConformsToSelf; return None; } /// Caches the result of \c existentialConformsToSelf void setCachedExistentialConformsToSelf(bool result) { Bits.ProtocolDecl.ExistentialConformsToSelfValid = true; Bits.ProtocolDecl.ExistentialConformsToSelf = result; } /// Returns the cached result of \c existentialTypeSupported or \c None if it /// hasn't yet been computed. Optional<bool> getCachedExistentialTypeSupported() { if (Bits.ProtocolDecl.ExistentialTypeSupportedValid) return Bits.ProtocolDecl.ExistentialTypeSupported; return None; } /// Caches the result of \c existentialTypeSupported void setCachedExistentialTypeSupported(bool supported) { Bits.ProtocolDecl.ExistentialTypeSupportedValid = true; Bits.ProtocolDecl.ExistentialTypeSupported = supported; } bool hasLazyRequirementSignature() const { return Bits.ProtocolDecl.HasLazyRequirementSignature; } friend class SuperclassDeclRequest; friend class SuperclassTypeRequest; friend class RequirementSignatureRequest; friend class ProtocolRequiresClassRequest; friend class ExistentialConformsToSelfRequest; friend class ExistentialTypeSupportedRequest; friend class InheritedProtocolsRequest; public: ProtocolDecl(DeclContext *DC, SourceLoc ProtocolLoc, SourceLoc NameLoc, Identifier Name, MutableArrayRef<TypeLoc> Inherited, TrailingWhereClause *TrailingWhere); using Decl::getASTContext; /// Retrieve the set of protocols inherited from this protocol. ArrayRef<ProtocolDecl *> getInheritedProtocols() const; /// Determine whether this protocol has a superclass. bool hasSuperclass() const { return (bool)getSuperclassDecl(); } /// Retrieve the superclass of this protocol, or null if there is no superclass. Type getSuperclass() const; /// Retrieve the ClassDecl for the superclass of this protocol, or null if there /// is no superclass. ClassDecl *getSuperclassDecl() const; /// Set the superclass of this protocol. void setSuperclass(Type superclass); /// Retrieve the set of AssociatedTypeDecl members of this protocol; this /// saves loading the set of members in cases where there's no possibility of /// a protocol having nested types (ObjC protocols). llvm::TinyPtrVector<AssociatedTypeDecl *> getAssociatedTypeMembers() const; /// Returns a protocol requirement with the given name, or nullptr if the /// name has multiple overloads, or no overloads at all. ValueDecl *getSingleRequirement(DeclName name) const; /// Returns an associated type with the given name, or nullptr if one does /// not exist. AssociatedTypeDecl *getAssociatedType(Identifier name) const; /// Walk this protocol and all of the protocols inherited by this protocol, /// transitively, invoking the callback function for each protocol. /// /// \param fn The callback function that will be invoked for each inherited /// protocol. It can return \c Continue to continue the traversal, /// \c SkipChildren to avoid visiting the children of the given protocol /// but continue the search, and \c Stop to halt the search. /// /// \returns \c true if \c fn returned \c Stop for any protocol, \c false /// otherwise. bool walkInheritedProtocols( llvm::function_ref<TypeWalker::Action(ProtocolDecl *)> fn) const; /// Determine whether this protocol inherits from the given ("super") /// protocol. bool inheritsFrom(const ProtocolDecl *Super) const; ProtocolType *getDeclaredType() const { return reinterpret_cast<ProtocolType *>( NominalTypeDecl::getDeclaredType().getPointer()); } SourceLoc getStartLoc() const { return ProtocolLoc; } SourceRange getSourceRange() const { return SourceRange(ProtocolLoc, getBraces().End); } /// True if this protocol can only be conformed to by class types. bool requiresClass() const; /// Determine whether an existential conforming to this protocol can be /// matched with a generic type parameter constrained to this protocol. /// This is only permitted if there is nothing "non-trivial" that we /// can do with the metatype, which means the protocol must not have /// any static methods and must be declared @objc. bool existentialConformsToSelf() const; /// Does this protocol require a self-conformance witness table? bool requiresSelfConformanceWitnessTable() const; /// Find direct Self references within the given requirement. /// /// \param allowCovariantParameters If true, 'Self' is assumed to be /// covariant anywhere; otherwise, only in the return type of the top-level /// function type. /// /// \param skipAssocTypes If true, associated types of 'Self' are ignored; /// otherwise, they count as an 'other' usage of 'Self'. SelfReferenceKind findProtocolSelfReferences(const ValueDecl *decl, bool allowCovariantParameters, bool skipAssocTypes) const; /// Determine whether we are allowed to refer to an existential type /// conforming to this protocol. This is only permitted if the type of /// the member does not contain any associated types, and does not /// contain 'Self' in 'parameter' or 'other' position. bool isAvailableInExistential(const ValueDecl *decl) const; /// Determine whether we are allowed to refer to an existential type /// conforming to this protocol. This is only permitted if the types of /// all the members do not contain any associated types, and do not /// contain 'Self' in 'parameter' or 'other' position. bool existentialTypeSupported() const; private: void computeKnownProtocolKind() const; bool areInheritedProtocolsValid() const { return Bits.ProtocolDecl.InheritedProtocolsValid; } void setInheritedProtocolsValid() { Bits.ProtocolDecl.InheritedProtocolsValid = true; } public: /// If this is known to be a compiler-known protocol, returns the kind. /// Otherwise returns None. Optional<KnownProtocolKind> getKnownProtocolKind() const { if (Bits.ProtocolDecl.KnownProtocol == 0) computeKnownProtocolKind(); if (Bits.ProtocolDecl.KnownProtocol == 1) return None; return static_cast<KnownProtocolKind>(Bits.ProtocolDecl.KnownProtocol - 2); } Optional<KnownDerivableProtocolKind> getKnownDerivableProtocolKind() const; /// Check whether this protocol is of a specific, known protocol kind. bool isSpecificProtocol(KnownProtocolKind kind) const { if (auto knownKind = getKnownProtocolKind()) return *knownKind == kind; return false; } /// Whether this protocol has a circular reference in its list of inherited /// protocols. bool hasCircularInheritedProtocols() const; /// Returns true if the protocol has requirements that are not listed in its /// members. /// /// This can occur, for example, if the protocol is an Objective-C protocol /// with requirements that cannot be represented in Swift. bool hasMissingRequirements() const { (void)getMembers(); return Bits.ProtocolDecl.HasMissingRequirements; } void setHasMissingRequirements(bool newValue) { Bits.ProtocolDecl.HasMissingRequirements = newValue; } /// Returns the default type witness for an associated type, or a null /// type if there is no default. Type getDefaultTypeWitness(AssociatedTypeDecl *assocType) const; /// Set the default type witness for an associated type. void setDefaultTypeWitness(AssociatedTypeDecl *assocType, Type witness); /// Returns the default witness for a requirement, or nullptr if there is /// no default. Witness getDefaultWitness(ValueDecl *requirement) const; /// Record the default witness for a requirement. void setDefaultWitness(ValueDecl *requirement, Witness witness); /// Returns the default associated conformance witness for an associated /// type, or \c None if there is no default. ProtocolConformanceRef getDefaultAssociatedConformanceWitness(CanType association, ProtocolDecl *requirement) const; /// Set the default associated conformance witness for the given /// associated conformance. void setDefaultAssociatedConformanceWitness( CanType association, ProtocolDecl *requirement, ProtocolConformanceRef conformance); /// Retrieve the name to use for this protocol when interoperating /// with the Objective-C runtime. StringRef getObjCRuntimeName(llvm::SmallVectorImpl<char> &buffer) const; /// Retrieve the requirements that describe this protocol. /// /// These are the requirements including any inherited protocols /// and conformances for associated types that are introduced in this /// protocol. Requirements implied via any other protocol (e.g., inherited /// protocols of the inherited protocols) are not mentioned. The conformance /// requirements listed here become entries in the witness table. ArrayRef<Requirement> getRequirementSignature() const; /// Is the requirement signature currently being computed? bool isComputingRequirementSignature() const; /// Has the requirement signature been computed yet? bool isRequirementSignatureComputed() const { return RequirementSignature != nullptr; } void setRequirementSignature(ArrayRef<Requirement> requirements); void setLazyRequirementSignature(LazyMemberLoader *lazyLoader, uint64_t requirementSignatureData); private: ArrayRef<Requirement> getCachedRequirementSignature() const; public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Protocol; } static bool classof(const GenericTypeDecl *D) { return D->getKind() == DeclKind::Protocol; } static bool classof(const NominalTypeDecl *D) { return D->getKind() == DeclKind::Protocol; } static bool classof(const DeclContext *C) { if (auto D = C->getAsDecl()) return classof(D); return false; } static bool classof(const IterableDeclContext *C) { auto NTD = dyn_cast<NominalTypeDecl>(C); return NTD && classof(NTD); } }; /// AbstractStorageDecl - This is the common superclass for VarDecl and /// SubscriptDecl, representing potentially settable memory locations. class AbstractStorageDecl : public ValueDecl { friend class SetterAccessLevelRequest; friend class IsGetterMutatingRequest; friend class IsSetterMutatingRequest; friend class OpaqueReadOwnershipRequest; friend class StorageImplInfoRequest; friend class RequiresOpaqueAccessorsRequest; friend class RequiresOpaqueModifyCoroutineRequest; friend class SynthesizeAccessorRequest; public: static const size_t MaxNumAccessors = 255; private: /// A record of the accessors for the declaration. class alignas(1 << 3) AccessorRecord final : private llvm::TrailingObjects<AccessorRecord, AccessorDecl*> { friend TrailingObjects; using AccessorIndex = uint8_t; static const AccessorIndex InvalidIndex = 0; /// The range of the braces around the accessor clause. SourceRange Braces; /// The number of accessors currently stored in this record. AccessorIndex NumAccessors; /// The storage capacity of this record for accessors. Always includes /// enough space for adding opaque accessors to the record, which are the /// only accessors that should ever be added retroactively; hence this /// field is only here for the purposes of safety checks. AccessorIndex AccessorsCapacity; /// Either 0, meaning there is no registered accessor of the given kind, /// or the index+1 of the accessor in the accessors array. AccessorIndex AccessorIndices[NumAccessorKinds]; AccessorRecord(SourceRange braces, ArrayRef<AccessorDecl*> accessors, AccessorIndex accessorsCapacity); public: static AccessorRecord *create(ASTContext &ctx, SourceRange braces, ArrayRef<AccessorDecl*> accessors); SourceRange getBracesRange() const { return Braces; } inline AccessorDecl *getAccessor(AccessorKind kind) const; ArrayRef<AccessorDecl *> getAllAccessors() const { return { getTrailingObjects<AccessorDecl*>(), NumAccessors }; } void addOpaqueAccessor(AccessorDecl *accessor); private: MutableArrayRef<AccessorDecl *> getAccessorsBuffer() { return { getTrailingObjects<AccessorDecl*>(), NumAccessors }; } bool registerAccessor(AccessorDecl *accessor, AccessorIndex index); }; llvm::PointerIntPair<AccessorRecord*, 3, OptionalEnum<AccessLevel>> Accessors; struct { unsigned IsGetterMutatingComputed : 1; unsigned IsGetterMutating : 1; unsigned IsSetterMutatingComputed : 1; unsigned IsSetterMutating : 1; unsigned OpaqueReadOwnershipComputed : 1; unsigned OpaqueReadOwnership : 2; unsigned ImplInfoComputed : 1; unsigned RequiresOpaqueAccessorsComputed : 1; unsigned RequiresOpaqueAccessors : 1; unsigned RequiresOpaqueModifyCoroutineComputed : 1; unsigned RequiresOpaqueModifyCoroutine : 1; } LazySemanticInfo = { }; /// The implementation info for the accessors. StorageImplInfo ImplInfo; /// Add a synthesized accessor. void setSynthesizedAccessor(AccessorKind kind, AccessorDecl *getter); protected: AbstractStorageDecl(DeclKind Kind, bool IsStatic, DeclContext *DC, DeclName Name, SourceLoc NameLoc, StorageIsMutable_t supportsMutation) : ValueDecl(Kind, DC, Name, NameLoc), ImplInfo(StorageImplInfo::getSimpleStored(supportsMutation)) { Bits.AbstractStorageDecl.IsStatic = IsStatic; } public: /// Should this declaration be treated as if annotated with transparent /// attribute. bool isTransparent() const; /// Is this a type ('static') variable? bool isStatic() const { return Bits.AbstractStorageDecl.IsStatic; } void setStatic(bool IsStatic) { Bits.AbstractStorageDecl.IsStatic = IsStatic; } /// \returns the way 'static'/'class' should be spelled for this declaration. StaticSpellingKind getCorrectStaticSpelling() const; /// Return the interface type of the stored value. Type getValueInterfaceType() const; /// Determine how this storage is implemented. StorageImplInfo getImplInfo() const; /// Overwrite the registered implementation-info. This should be /// used carefully. void setImplInfo(StorageImplInfo implInfo) { LazySemanticInfo.ImplInfoComputed = 1; ImplInfo = implInfo; } ReadImplKind getReadImpl() const { return getImplInfo().getReadImpl(); } WriteImplKind getWriteImpl() const { return getImplInfo().getWriteImpl(); } ReadWriteImplKind getReadWriteImpl() const { return getImplInfo().getReadWriteImpl(); } /// Return true if this is a VarDecl that has storage associated with /// it. bool hasStorage() const { return getImplInfo().hasStorage(); } /// Return true if this storage has the basic accessors/capability /// to be mutated. This is generally constant after the accessors are /// installed by the parser/importer/whatever. /// /// Note that this is different from the mutability of the declaration /// in the user language: sometimes we can assign to declarations that /// don't support mutation (e.g. to initialize them), and sometimes we /// can't mutate things that do support mutation (e.g. because their /// setter is private). StorageIsMutable_t supportsMutation() const { return getImplInfo().supportsMutation(); } /// isSettable - Determine whether references to this decl may appear /// on the left-hand side of an assignment or as the operand of a /// `&` or 'inout' operator. bool isSettable(const DeclContext *UseDC, const DeclRefExpr *base = nullptr) const; /// Does this storage declaration have explicitly-defined accessors /// written in the source? bool hasParsedAccessors() const; /// Return the ownership of values opaquely read from this storage. OpaqueReadOwnership getOpaqueReadOwnership() const; void setOpaqueReadOwnership(OpaqueReadOwnership ownership) { LazySemanticInfo.OpaqueReadOwnership = unsigned(ownership); LazySemanticInfo.OpaqueReadOwnershipComputed = true; } /// Return true if reading this storage requires the ability to /// modify the base value. bool isGetterMutating() const; void setIsGetterMutating(bool isMutating) { LazySemanticInfo.IsGetterMutating = isMutating; LazySemanticInfo.IsGetterMutatingComputed = true; } /// Return true if modifying this storage requires the ability to /// modify the base value. bool isSetterMutating() const; void setIsSetterMutating(bool isMutating) { LazySemanticInfo.IsSetterMutating = isMutating; LazySemanticInfo.IsSetterMutatingComputed = true; } AccessorDecl *getAccessor(AccessorKind kind) const { if (auto info = Accessors.getPointer()) return info->getAccessor(kind); return nullptr; } ArrayRef<AccessorDecl*> getAllAccessors() const { if (const auto *info = Accessors.getPointer()) return info->getAllAccessors(); return {}; } /// Return an accessor that this storage is expected to have, synthesizing /// one if necessary. Note that will always synthesize one, even if the /// accessor is not part of the expected opaque set for the storage, so use /// with caution. AccessorDecl *getSynthesizedAccessor(AccessorKind kind) const; /// Return an accessor part of the set of opaque accessors dictated by the /// requirements of the ABI. /// /// This will synthesize the accessor if one is required but not specified /// in source; for example, most of the time a mutable property is required /// to have a 'modify' accessor, but if the property was only written with /// 'get' and 'set' accessors, 'modify' will be synthesized to call 'get' /// followed by 'set'. /// /// If the accessor is not needed for ABI reasons, this returns nullptr. /// To ensure an accessor is always returned, use getSynthesizedAccessor(). AccessorDecl *getOpaqueAccessor(AccessorKind kind) const; /// Collect all opaque accessors. ArrayRef<AccessorDecl*> getOpaqueAccessors(llvm::SmallVectorImpl<AccessorDecl*> &scratch) const; /// Return an accessor that was written in source. Returns null if the /// accessor was not explicitly defined by the user. AccessorDecl *getParsedAccessor(AccessorKind kind) const; /// Visit all parsed accessors. void visitParsedAccessors(llvm::function_ref<void (AccessorDecl*)>) const; /// Visit all opaque accessor kinds. void visitExpectedOpaqueAccessors( llvm::function_ref<void (AccessorKind)>) const; /// Visit all opaque accessors. void visitOpaqueAccessors(llvm::function_ref<void (AccessorDecl*)>) const; /// Visit all eagerly emitted accessors. /// /// This is the union of the parsed and opaque sets. void visitEmittedAccessors(llvm::function_ref<void (AccessorDecl*)>) const; void setAccessors(SourceLoc lbraceLoc, ArrayRef<AccessorDecl*> accessors, SourceLoc rbraceLoc); /// Add a setter to an existing Computed var. /// /// This should only be used by the ClangImporter. void setComputedSetter(AccessorDecl *Set); /// Does this storage require opaque accessors of any kind? bool requiresOpaqueAccessors() const; /// Does this storage require an opaque accessor of the given kind? bool requiresOpaqueAccessor(AccessorKind kind) const; /// Does this storage require a 'get' accessor in its opaque-accessors set? bool requiresOpaqueGetter() const { return getOpaqueReadOwnership() != OpaqueReadOwnership::Borrowed; } /// Does this storage require a 'read' accessor in its opaque-accessors set? bool requiresOpaqueReadCoroutine() const { return getOpaqueReadOwnership() != OpaqueReadOwnership::Owned; } /// Does this storage require a 'set' accessor in its opaque-accessors set? bool requiresOpaqueSetter() const { return supportsMutation(); } /// Does this storage require a 'modify' accessor in its opaque-accessors set? bool requiresOpaqueModifyCoroutine() const; /// Does this storage have any explicit observers (willSet or didSet) attached /// to it? bool hasObservers() const { return getParsedAccessor(AccessorKind::WillSet) || getParsedAccessor(AccessorKind::DidSet); } SourceRange getBracesRange() const { if (auto info = Accessors.getPointer()) return info->getBracesRange(); return SourceRange(); } AccessLevel getSetterFormalAccess() const; AccessScope getSetterFormalAccessScope(const DeclContext *useDC = nullptr, bool treatUsableFromInlineAsPublic = false) const; void setSetterAccess(AccessLevel accessLevel) { assert(!Accessors.getInt().hasValue()); overwriteSetterAccess(accessLevel); } void overwriteSetterAccess(AccessLevel accessLevel); /// Given that this is an Objective-C property or subscript declaration, /// produce its getter selector. ObjCSelector getObjCGetterSelector(Identifier preferredName = Identifier()) const; /// Given that this is an Objective-C property or subscript declaration, /// produce its setter selector. ObjCSelector getObjCSetterSelector(Identifier preferredName = Identifier()) const; AbstractStorageDecl *getOverriddenDecl() const { return cast_or_null<AbstractStorageDecl>(ValueDecl::getOverriddenDecl()); } /// Returns the location of 'override' keyword, if any. SourceLoc getOverrideLoc() const; /// Returns true if this declaration has a setter accessible from the given /// context. /// /// If \p DC is null, returns true only if the setter is public. /// /// See \c isAccessibleFrom for a discussion of the \p forConformance /// parameter. bool isSetterAccessibleFrom(const DeclContext *DC, bool forConformance=false) const; /// Determine how this storage declaration should actually be accessed. AccessStrategy getAccessStrategy(AccessSemantics semantics, AccessKind accessKind, ModuleDecl *module, ResilienceExpansion expansion) const; /// Should this declaration behave as if it must be accessed /// resiliently, even when we're building a non-resilient module? /// /// This is used for diagnostics, because we do not want a behavior /// change between builds with resilience enabled and disabled. bool isFormallyResilient() const; /// Do we need to use resilient access patterns outside of this /// property's resilience domain? bool isResilient() const; /// Do we need to use resilient access patterns when accessing this /// property from the given module? bool isResilient(ModuleDecl *M, ResilienceExpansion expansion) const; /// True if the storage can be referenced by a keypath directly. /// Otherwise, its override must be referenced. bool isValidKeyPathComponent() const; /// True if the storage exports a property descriptor for key paths in /// other modules. bool exportsPropertyDescriptor() const; /// True if any of the accessors to the storage is private or fileprivate. bool hasPrivateAccessor() const; bool hasDidSetOrWillSetDynamicReplacement() const; bool hasAnyNativeDynamicAccessors() const; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_AbstractStorageDecl && D->getKind() <= DeclKind::Last_AbstractStorageDecl; } }; /// Describes which synthesized property for a property with an attached /// wrapper is being referenced. enum class PropertyWrapperSynthesizedPropertyKind { /// The backing storage property, which is a stored property of the /// wrapper type. Backing, /// A storage wrapper (e.g., `$foo`), which is a wrapper over the /// wrapper instance's `projectedValue` property. StorageWrapper, }; /// VarDecl - 'var' and 'let' declarations. class VarDecl : public AbstractStorageDecl { friend class NamingPatternRequest; NamedPattern *NamingPattern = nullptr; public: enum class Introducer : uint8_t { Let = 0, Var = 1 }; protected: PointerUnion<PatternBindingDecl *, Stmt *, VarDecl *> Parent; VarDecl(DeclKind kind, bool isStatic, Introducer introducer, bool isCaptureList, SourceLoc nameLoc, Identifier name, DeclContext *dc, StorageIsMutable_t supportsMutation); public: VarDecl(bool isStatic, Introducer introducer, bool isCaptureList, SourceLoc nameLoc, Identifier name, DeclContext *dc) : VarDecl(DeclKind::Var, isStatic, introducer, isCaptureList, nameLoc, name, dc, StorageIsMutable_t(introducer == Introducer::Var)) {} SourceRange getSourceRange() const; Identifier getName() const { return getBaseIdentifier(); } /// Returns the string for the base name, or "_" if this is unnamed. StringRef getNameStr() const { return hasName() ? getBaseIdentifier().str() : "_"; } /// Get the type of the variable within its context. If the context is generic, /// this will use archetypes. Type getType() const; /// Retrieve the source range of the variable type, or an invalid range if the /// variable's type is not explicitly written in the source. /// /// Only for use in diagnostics. It is not always possible to always /// precisely point to the variable type because of type aliases. SourceRange getTypeSourceRangeForDiagnostics() const; /// Returns whether the var is settable in the specified context: this /// is either because it is a stored var, because it has a custom setter, or /// is a let member in an initializer. /// /// Pass a null context and null base to check if it's always settable. bool isSettable(const DeclContext *UseDC, const DeclRefExpr *base = nullptr) const; /// Return the parent pattern binding that may provide an initializer for this /// VarDecl. This returns null if there is none associated with the VarDecl. PatternBindingDecl *getParentPatternBinding() const { if (!Parent) return nullptr; return Parent.dyn_cast<PatternBindingDecl *>(); } void setParentPatternBinding(PatternBindingDecl *PBD) { assert(PBD); Parent = PBD; } /// Return the Pattern involved in initializing this VarDecl. However, recall /// that the Pattern may be involved in initializing more than just this one /// vardecl. For example, if this is a VarDecl for "x", the pattern may be /// "(x, y)" and the initializer on the PatternBindingDecl may be "(1,2)" or /// "foo()". /// /// If this has no parent pattern binding decl or statement associated, it /// returns null. /// Pattern *getParentPattern() const; /// Returns the parsed type of this variable declaration. For parameters, this /// is the parsed type the user explicitly wrote. For variables, this is the /// type the user wrote in the typed pattern that binds this variable. /// /// Note that there are many cases where the user may elide types. This will /// return null in those cases. TypeRepr *getTypeReprOrParentPatternTypeRepr() const; /// Return the statement that owns the pattern associated with this VarDecl, /// if one exists. /// /// NOTE: After parsing and before type checking, all VarDecls from /// CaseLabelItem's Patterns return their CaseStmt. After type checking, we /// will have constructed the CaseLabelItem VarDecl linked list implying this /// will return nullptr. After type checking, if one wishes to find a parent /// pattern of a VarDecl of a CaseStmt, \see getRecursiveParentPatternStmt /// instead. Stmt *getParentPatternStmt() const { if (!Parent) return nullptr; return Parent.dyn_cast<Stmt *>(); } void setParentPatternStmt(Stmt *s) { assert(s); Parent = s; } /// Look for the parent pattern stmt of this var decl, recursively /// looking through var decl pointers and then through any /// fallthroughts. Stmt *getRecursiveParentPatternStmt() const; /// Returns the var decl that this var decl is an implicit reference to if /// such a var decl exists. VarDecl *getParentVarDecl() const { if (!Parent) return nullptr; return Parent.dyn_cast<VarDecl *>(); } /// Set \p v to be the pattern produced VarDecl that is the parent of this /// var decl. void setParentVarDecl(VarDecl *v) { assert(v && v != this); Parent = v; } NamedPattern *getNamingPattern() const; void setNamingPattern(NamedPattern *Pat); /// If this is a VarDecl that does not belong to a CaseLabelItem's pattern, /// return this. Otherwise, this VarDecl must belong to a CaseStmt's /// CaseLabelItem. In that case, return the first case label item of the first /// case stmt in a sequence of case stmts that fallthrough into each other. /// /// NOTE: During type checking, we emit an error if we have a single case /// label item with a pattern that has multiple var decls of the same /// name. This means that during type checking and before type checking, we /// may have a _malformed_ switch stmt var decl linked list since var decls in /// the same case label item that have the same name will point at the same /// canonical var decl, namely the first var decl with the name in the /// canonical case label item's var decl list. This is ok, since we are going /// to emit the error, but it requires us to be more careful/cautious before /// type checking has been complete when relying on canonical var decls /// matching up. VarDecl *getCanonicalVarDecl() const; /// If this is a case stmt var decl, return the var decl that corresponds to /// this var decl in the first case label item of the case stmt. Returns /// nullptr if this isn't a VarDecl that is part of a case stmt. NullablePtr<VarDecl> getCorrespondingFirstCaseLabelItemVarDecl() const; /// If this is a case stmt var decl, return the case body var decl that this /// var decl maps to. NullablePtr<VarDecl> getCorrespondingCaseBodyVariable() const; /// Return true if this var decl is an implicit var decl belonging to a case /// stmt's body. bool isCaseBodyVariable() const; /// True if the global stored property requires lazy initialization. bool isLazilyInitializedGlobal() const; /// Return the initializer involved in this VarDecl. Recall that the /// initializer may be involved in initializing more than just this one /// vardecl though. For example, if this is a VarDecl for "x", the pattern /// may be "(x, y)" and the initializer on the PatternBindingDecl may be /// "(1,2)" or "foo()". /// /// If this has no parent pattern binding decl associated, or if that pattern /// binding has no initial value, this returns null. /// Expr *getParentInitializer() const { if (auto *PBD = getParentPatternBinding()) { const auto i = PBD->getPatternEntryIndexForVarDecl(this); return PBD->getInit(i); } return nullptr; } /// Whether there exists an initializer for this \c VarDecl. bool isParentInitialized() const { if (auto *PBD = getParentPatternBinding()) { const auto i = PBD->getPatternEntryIndexForVarDecl(this); return PBD->isInitialized(i); } return false; } // Return whether this VarDecl has an initial value, either by checking // if it has an initializer in its parent pattern binding or if it has // the @_hasInitialValue attribute. bool hasInitialValue() const { return getAttrs().hasAttribute<HasInitialValueAttr>() || isParentInitialized(); } VarDecl *getOverriddenDecl() const { return cast_or_null<VarDecl>(AbstractStorageDecl::getOverriddenDecl()); } /// Is this an immutable 'let' property? /// /// If this is a ParamDecl, isLet() is true iff /// getSpecifier() == Specifier::Default. bool isLet() const { return getIntroducer() == Introducer::Let; } Introducer getIntroducer() const { return Introducer(Bits.VarDecl.Introducer); } void setIntroducer(Introducer value) { Bits.VarDecl.Introducer = uint8_t(value); } /// Is this an element in a capture list? bool isCaptureList() const { return Bits.VarDecl.IsCaptureList; } /// Is this a capture of the self param? bool isSelfParamCapture() const { return Bits.VarDecl.IsSelfParamCapture; } void setIsSelfParamCapture(bool IsSelfParamCapture = true) { Bits.VarDecl.IsSelfParamCapture = IsSelfParamCapture; } /// Return true if this vardecl has an initial value bound to it in a way /// that isn't represented in the AST with an initializer in the pattern /// binding. This happens in cases like "for i in ...", switch cases, etc. bool hasNonPatternBindingInit() const { return Bits.VarDecl.HasNonPatternBindingInit; } void setHasNonPatternBindingInit(bool V = true) { Bits.VarDecl.HasNonPatternBindingInit = V; } /// Determines if this var has an initializer expression that should be /// exposed to clients. /// There's a very narrow case when we would: if the decl is an instance /// member with an initializer expression and the parent type is /// @frozen and resides in a resilient module. bool isInitExposedToClients() const; /// Is this a special debugger variable? bool isDebuggerVar() const { return Bits.VarDecl.IsDebuggerVar; } void setDebuggerVar(bool IsDebuggerVar) { Bits.VarDecl.IsDebuggerVar = IsDebuggerVar; } /// Is this the synthesized storage for a 'lazy' property? bool isLazyStorageProperty() const { return Bits.VarDecl.IsLazyStorageProperty; } void setLazyStorageProperty(bool IsLazyStorage) { Bits.VarDecl.IsLazyStorageProperty = IsLazyStorage; } /// True if this is a top-level global variable from the main source file. bool isTopLevelGlobal() const { return Bits.VarDecl.IsTopLevelGlobal; } void setTopLevelGlobal(bool b) { Bits.VarDecl.IsTopLevelGlobal = b; } /// Retrieve the custom attributes that attach property wrappers to this /// property. The returned list contains all of the attached property wrapper /// attributes in source order, which means the outermost wrapper attribute /// is provided first. llvm::TinyPtrVector<CustomAttr *> getAttachedPropertyWrappers() const; /// Whether this property has any attached property wrappers. bool hasAttachedPropertyWrapper() const; /// Whether all of the attached property wrappers have an init(wrappedValue:) /// initializer. bool allAttachedPropertyWrappersHaveWrappedValueInit() const; /// Retrieve the type of the attached property wrapper as a contextual /// type. /// /// \param index Which property wrapper type is being computed, where 0 /// indicates the first (outermost) attached property wrapper. /// /// \returns a NULL type for properties without attached wrappers, /// an error type when the property wrapper type itself is erroneous, /// or the wrapper type itself, which may involve unbound generic /// types. Type getAttachedPropertyWrapperType(unsigned index) const; /// Retrieve information about the attached property wrapper type. /// /// \param i Which attached property wrapper type is being queried, where 0 is the outermost (first) /// attached property wrapper type. PropertyWrapperTypeInfo getAttachedPropertyWrapperTypeInfo(unsigned i) const; /// Retrieve the fully resolved attached property wrapper type. /// /// This type will be the fully-resolved form of /// \c getAttachedPropertyWrapperType(0), which will not contain any /// unbound generic types. It will be the type of the backing property. Type getPropertyWrapperBackingPropertyType() const; /// Retrieve information about the backing properties of the attached /// property wrapper. PropertyWrapperBackingPropertyInfo getPropertyWrapperBackingPropertyInfo() const; /// Retrieve information about the mutability of the composed /// property wrappers. Optional<PropertyWrapperMutability> getPropertyWrapperMutability() const; /// Returns whether this property is the backing storage property or a storage /// wrapper for wrapper instance's projectedValue. If this property is /// neither, then it returns `None`. Optional<PropertyWrapperSynthesizedPropertyKind> getPropertyWrapperSynthesizedPropertyKind() const; /// Retrieve the backing storage property for a property that has an /// attached property wrapper. /// /// The backing storage property will be a stored property of the /// wrapper's type. This will be equivalent to /// \c getAttachedPropertyWrapperType(0) when it is fully-specified; /// if \c getAttachedPropertyWrapperType(0) involves an unbound /// generic type, the backing storage property will be the appropriate /// bound generic version. VarDecl *getPropertyWrapperBackingProperty() const; /// Retreive the storage wrapper for a property that has an attached /// property wrapper. VarDecl *getPropertyWrapperStorageWrapper() const; /// Retrieve the backing storage property for a lazy property. VarDecl *getLazyStorageProperty() const; /// Whether the memberwise initializer parameter for a property with a /// property wrapper type uses the wrapped type. This will occur, for example, /// when there is an explicitly-specified initializer like: /// /// \code /// @Lazy var i = 17 /// \endcode /// /// Or when there is no initializer but each composed property wrapper has /// a suitable `init(wrappedValue:)`. bool isPropertyMemberwiseInitializedWithWrappedType() const; /// Whether the innermost property wrapper's initializer's 'wrappedValue' parameter /// is marked with '@autoclosure' and '@escaping'. bool isInnermostPropertyWrapperInitUsesEscapingAutoClosure() const; /// Return the interface type of the value used for the 'wrappedValue:' /// parameter when initializing a property wrapper. /// /// If the property has an attached property wrapper and the 'wrappedValue:' /// parameter is an autoclosure, return a function type returning the stored /// value. Otherwise, return the interface type of the stored value. Type getPropertyWrapperInitValueInterfaceType() const; /// If this property is the backing storage for a property with an attached /// property wrapper, return the original property. /// /// \param kind If not \c None, only returns the original property when /// \c this property is the specified synthesized property. VarDecl *getOriginalWrappedProperty( Optional<PropertyWrapperSynthesizedPropertyKind> kind = None) const; /// Set the property that wraps to this property as it's backing /// property. void setOriginalWrappedProperty(VarDecl *originalProperty); /// Return the Objective-C runtime name for this property. Identifier getObjCPropertyName() const; /// Retrieve the default Objective-C selector for the getter of a /// property of the given name. static ObjCSelector getDefaultObjCGetterSelector(ASTContext &ctx, Identifier propertyName); /// Retrieve the default Objective-C selector for the setter of a /// property of the given name. static ObjCSelector getDefaultObjCSetterSelector(ASTContext &ctx, Identifier propertyName); /// If this is a simple 'let' constant, emit a note with a fixit indicating /// that it can be rewritten to a 'var'. This is used in situations where the /// compiler detects obvious attempts to mutate a constant. void emitLetToVarNoteIfSimple(DeclContext *UseDC) const; /// Returns true if the name is the self identifier and is implicit. bool isSelfParameter() const; /// Determine whether this property will be part of the implicit memberwise /// initializer. /// /// \param preferDeclaredProperties When encountering a `lazy` property /// or a property that has an attached property wrapper, prefer the /// actual declared property (which may or may not be considered "stored" /// as the moment) to the backing storage property. Otherwise, the stored /// backing property will be treated as the member-initialized property. bool isMemberwiseInitialized(bool preferDeclaredProperties) const; /// Return the range of semantics attributes attached to this VarDecl. auto getSemanticsAttrs() const -> decltype(getAttrs().getAttributes<SemanticsAttr>()) { return getAttrs().getAttributes<SemanticsAttr>(); } /// Returns true if this VarDelc has the string \p attrValue as a semantics /// attribute. bool hasSemanticsAttr(StringRef attrValue) const { return llvm::any_of(getSemanticsAttrs(), [&](const SemanticsAttr *attr) { return attrValue.equals(attr->Value); }); } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Var || D->getKind() == DeclKind::Param; } }; enum class ParamSpecifier : uint8_t { Default = 0, InOut = 1, Shared = 2, Owned = 3, }; /// A function parameter declaration. class ParamDecl : public VarDecl { friend class DefaultArgumentInitContextRequest; friend class DefaultArgumentExprRequest; llvm::PointerIntPair<Identifier, 1, bool> ArgumentNameAndDestructured; SourceLoc ParameterNameLoc; SourceLoc ArgumentNameLoc; SourceLoc SpecifierLoc; TypeRepr *TyRepr = nullptr; struct StoredDefaultArgument { PointerUnion<Expr *, VarDecl *> DefaultArg; /// Stores the context for the default argument as well as a bit to /// indicate whether the default expression has been type-checked. llvm::PointerIntPair<Initializer *, 1, bool> InitContextAndIsTypeChecked; StringRef StringRepresentation; CaptureInfo Captures; }; /// Retrieve the cached initializer context for the parameter's default /// argument without triggering a request. Optional<Initializer *> getCachedDefaultArgumentInitContext() const; enum class Flags : uint8_t { /// Whether or not this parameter is vargs. IsVariadic = 1 << 0, /// Whether or not this parameter is `@autoclosure`. IsAutoClosure = 1 << 1, }; /// The default value, if any, along with flags. llvm::PointerIntPair<StoredDefaultArgument *, 2, OptionSet<Flags>> DefaultValueAndFlags; friend class ParamSpecifierRequest; public: ParamDecl(SourceLoc specifierLoc, SourceLoc argumentNameLoc, Identifier argumentName, SourceLoc parameterNameLoc, Identifier parameterName, DeclContext *dc); /// Create a new ParamDecl identical to the first except without the interface type. static ParamDecl *cloneWithoutType(const ASTContext &Ctx, ParamDecl *PD); /// Retrieve the argument (API) name for this function parameter. Identifier getArgumentName() const { return ArgumentNameAndDestructured.getPointer(); } /// Retrieve the parameter (local) name for this function parameter. Identifier getParameterName() const { return getName(); } /// Retrieve the source location of the argument (API) name. /// /// The resulting source location will be valid if the argument name /// was specified separately from the parameter name. SourceLoc getArgumentNameLoc() const { return ArgumentNameLoc; } SourceLoc getParameterNameLoc() const { return ParameterNameLoc; } SourceLoc getSpecifierLoc() const { return SpecifierLoc; } /// Retrieve the TypeRepr corresponding to the parsed type of the parameter, if it exists. TypeRepr *getTypeRepr() const { return TyRepr; } void setTypeRepr(TypeRepr *repr) { TyRepr = repr; } bool isDestructured() const { return ArgumentNameAndDestructured.getInt(); } void setDestructured(bool repr) { ArgumentNameAndDestructured.setInt(repr); } DefaultArgumentKind getDefaultArgumentKind() const { return static_cast<DefaultArgumentKind>(Bits.ParamDecl.defaultArgumentKind); } bool isDefaultArgument() const { return getDefaultArgumentKind() != DefaultArgumentKind::None; } void setDefaultArgumentKind(DefaultArgumentKind K) { Bits.ParamDecl.defaultArgumentKind = static_cast<unsigned>(K); } /// Whether this parameter has a default argument expression available. /// /// Note that this will return false for deserialized declarations, which only /// have a textual representation of their default expression. bool hasDefaultExpr() const; /// Whether this parameter has a caller-side default argument expression /// such as the magic literal \c #function. bool hasCallerSideDefaultExpr() const; /// Retrieve the fully type-checked default argument expression for this /// parameter, or \c nullptr if there is no default expression. /// /// Note that while this will produce a type-checked expression for /// caller-side default arguments such as \c #function, this is done purely to /// check whether the code is valid. Such default arguments get re-created /// at the call site in order to have the correct context information. Expr *getTypeCheckedDefaultExpr() const; /// Retrieve the potentially un-type-checked default argument expression for /// this parameter, which can be queried for information such as its source /// range and textual representation. Returns \c nullptr if there is no /// default expression. Expr *getStructuralDefaultExpr() const { if (auto stored = DefaultValueAndFlags.getPointer()) return stored->DefaultArg.dyn_cast<Expr *>(); return nullptr; } VarDecl *getStoredProperty() const { if (auto stored = DefaultValueAndFlags.getPointer()) return stored->DefaultArg.dyn_cast<VarDecl *>(); return nullptr; } /// Sets a new default argument expression for this parameter. This should /// only be called internally by ParamDecl and AST walkers. /// /// \param E The new default argument. /// \param isTypeChecked Whether this argument should be used as the /// parameter's fully type-checked default argument. void setDefaultExpr(Expr *E, bool isTypeChecked); void setStoredProperty(VarDecl *var); /// Retrieve the initializer context for the parameter's default argument. Initializer *getDefaultArgumentInitContext() const; void setDefaultArgumentInitContext(Initializer *initContext); CaptureInfo getDefaultArgumentCaptureInfo() const { assert(DefaultValueAndFlags.getPointer()); return DefaultValueAndFlags.getPointer()->Captures; } void setDefaultArgumentCaptureInfo(CaptureInfo captures); /// Extracts the text of the default argument attached to the provided /// ParamDecl, removing all inactive #if clauses and providing only the /// text of active #if clauses. /// /// For example, the default argument: /// ``` /// { /// #if false /// print("false") /// #else /// print("true") /// #endif /// } /// ``` /// will return /// ``` /// { /// print("true") /// } /// ``` /// \sa getDefaultValue StringRef getDefaultValueStringRepresentation( SmallVectorImpl<char> &scratch) const; void setDefaultValueStringRepresentation(StringRef stringRepresentation); /// Whether or not this parameter is varargs. bool isVariadic() const { return DefaultValueAndFlags.getInt().contains(Flags::IsVariadic); } void setVariadic(bool value = true) { auto flags = DefaultValueAndFlags.getInt(); DefaultValueAndFlags.setInt(value ? flags | Flags::IsVariadic : flags - Flags::IsVariadic); } /// Whether or not this parameter is marked with `@autoclosure`. bool isAutoClosure() const { return DefaultValueAndFlags.getInt().contains(Flags::IsAutoClosure); } void setAutoClosure(bool value = true) { auto flags = DefaultValueAndFlags.getInt(); DefaultValueAndFlags.setInt(value ? flags | Flags::IsAutoClosure : flags - Flags::IsAutoClosure); } /// Does this parameter reject temporary pointer conversions? bool isNonEphemeral() const { if (getAttrs().hasAttribute<NonEphemeralAttr>()) return true; // Only pointer parameters can be non-ephemeral. auto ty = getInterfaceType(); if (!ty->lookThroughSingleOptionalType()->getAnyPointerElementType()) return false; // Enum element pointer parameters are always non-ephemeral. auto *parentDecl = getDeclContext()->getAsDecl(); if (parentDecl && isa<EnumElementDecl>(parentDecl)) return true; return false; } /// Attempt to apply an implicit `@_nonEphemeral` attribute to this parameter. void setNonEphemeralIfPossible() { // Don't apply the attribute if this isn't a pointer param. auto type = getInterfaceType(); if (!type->lookThroughSingleOptionalType()->getAnyPointerElementType()) return; if (!getAttrs().hasAttribute<NonEphemeralAttr>()) { auto &ctx = getASTContext(); getAttrs().add(new (ctx) NonEphemeralAttr(/*IsImplicit*/ true)); } } /// Remove the type of this varargs element designator, without the array /// type wrapping it. A parameter like "Int..." will have formal parameter /// type of "[Int]" and this returns "Int". static Type getVarargBaseTy(Type VarArgT); /// Remove the type of this varargs element designator, without the array /// type wrapping it. Type getVarargBaseTy() const { assert(isVariadic()); return getVarargBaseTy(getInterfaceType()); } /// Determine whether this declaration is an anonymous closure parameter. bool isAnonClosureParam() const; using Specifier = ParamSpecifier; Optional<Specifier> getCachedSpecifier() const { if (Bits.ParamDecl.SpecifierComputed) return Specifier(Bits.ParamDecl.Specifier); return None; } /// Return the raw specifier value for this parameter. Specifier getSpecifier() const; void setSpecifier(Specifier Spec); /// Is the type of this parameter 'inout'? bool isInOut() const { return getSpecifier() == Specifier::InOut; } /// Is this an immutable 'shared' property? bool isShared() const { return getSpecifier() == Specifier::Shared; } /// Is this an immutable 'owned' property? bool isOwned() const { return getSpecifier() == Specifier::Owned; } bool isImmutable() const { return isImmutableSpecifier(getSpecifier()); } static bool isImmutableSpecifier(Specifier sp) { switch (sp) { case Specifier::Default: case Specifier::Shared: case Specifier::Owned: return true; case Specifier::InOut: return false; } llvm_unreachable("unhandled specifier"); } ValueOwnership getValueOwnership() const { return getValueOwnershipForSpecifier(getSpecifier()); } static ValueOwnership getValueOwnershipForSpecifier(Specifier specifier) { switch (specifier) { case Specifier::Default: return ValueOwnership::Default; case Specifier::InOut: return ValueOwnership::InOut; case Specifier::Shared: return ValueOwnership::Shared; case Specifier::Owned: return ValueOwnership::Owned; } llvm_unreachable("unhandled specifier"); } static Specifier getParameterSpecifierForValueOwnership(ValueOwnership ownership) { switch (ownership) { case ValueOwnership::Default: return Specifier::Default; case ValueOwnership::Shared: return Specifier::Shared; case ValueOwnership::InOut: return Specifier::InOut; case ValueOwnership::Owned: return Specifier::Owned; } llvm_unreachable("unhandled ownership"); } SourceRange getSourceRange() const; AnyFunctionType::Param toFunctionParam(Type type = Type()) const; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == DeclKind::Param; } }; /// Describes the kind of subscripting used in Objective-C. enum class ObjCSubscriptKind { /// Objective-C indexed subscripting, which is based on an integral /// index. Indexed, /// Objective-C keyed subscripting, which is based on an object /// argument or metatype thereof. Keyed }; /// Declares a subscripting operator for a type. /// /// A subscript declaration is defined as a get/set pair that produces a /// specific type. For example: /// /// \code /// subscript (i : Int) -> String { /// get { /* return ith String */ } /// set { /* set ith string to value */ } /// } /// \endcode /// /// A type with a subscript declaration can be used as the base of a subscript /// expression a[i], where a is of the subscriptable type and i is the type /// of the index. A subscript can have multiple indices: /// /// \code /// struct Matrix { /// subscript (i : Int, j : Int) -> Double { /// get { /* return element at position (i, j) */ } /// set { /* set element at position (i, j) */ } /// } /// } /// \endcode /// /// A given type can have multiple subscript declarations, so long as the /// signatures (indices and element type) are distinct. /// class SubscriptDecl : public GenericContext, public AbstractStorageDecl { SourceLoc StaticLoc; SourceLoc ArrowLoc; SourceLoc EndLoc; ParameterList *Indices; TypeLoc ElementTy; public: SubscriptDecl(DeclName Name, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc SubscriptLoc, ParameterList *Indices, SourceLoc ArrowLoc, TypeLoc ElementTy, DeclContext *Parent, GenericParamList *GenericParams) : GenericContext(DeclContextKind::SubscriptDecl, Parent, GenericParams), AbstractStorageDecl(DeclKind::Subscript, StaticSpelling != StaticSpellingKind::None, Parent, Name, SubscriptLoc, /*will be overwritten*/ StorageIsNotMutable), StaticLoc(StaticLoc), ArrowLoc(ArrowLoc), Indices(nullptr), ElementTy(ElementTy) { Bits.SubscriptDecl.StaticSpelling = static_cast<unsigned>(StaticSpelling); setIndices(Indices); } /// \returns the way 'static'/'class' was spelled in the source. StaticSpellingKind getStaticSpelling() const { return static_cast<StaticSpellingKind>(Bits.SubscriptDecl.StaticSpelling); } SourceLoc getStaticLoc() const { return StaticLoc; } SourceLoc getSubscriptLoc() const { return getNameLoc(); } SourceLoc getStartLoc() const { return getStaticLoc().isValid() ? getStaticLoc() : getSubscriptLoc(); } SourceLoc getEndLoc() const { return EndLoc; } void setEndLoc(SourceLoc sl) { EndLoc = sl; } SourceRange getSourceRange() const; SourceRange getSignatureSourceRange() const; /// Retrieve the indices for this subscript operation. ParameterList *getIndices() { return Indices; } const ParameterList *getIndices() const { return Indices; } void setIndices(ParameterList *p); /// Retrieve the type of the element referenced by a subscript /// operation. Type getElementInterfaceType() const; TypeLoc &getElementTypeLoc() { return ElementTy; } const TypeLoc &getElementTypeLoc() const { return ElementTy; } /// Determine the kind of Objective-C subscripting this declaration /// implies. ObjCSubscriptKind getObjCSubscriptKind() const; SubscriptDecl *getOverriddenDecl() const { return cast_or_null<SubscriptDecl>( AbstractStorageDecl::getOverriddenDecl()); } static bool classof(const Decl *D) { return D->getKind() == DeclKind::Subscript; } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } using DeclContext::operator new; using Decl::getASTContext; }; /// Encodes imported-as-member status for C functions that get imported /// as methods. class ImportAsMemberStatus { friend class AbstractFunctionDecl; // non-0 denotes import-as-member. 1 denotes no self index. n+2 denotes self // index of n uint8_t rawValue; public: ImportAsMemberStatus(uint8_t rawValue = 0) : rawValue(rawValue) {} uint8_t getRawValue() const { return rawValue; } bool isImportAsMember() const { return rawValue != 0; } bool isInstance() const { return rawValue >= 2; } bool isStatic() const { return rawValue == 1; } uint8_t getSelfIndex() const { assert(isInstance() && "not set"); return rawValue - 2; } void setStatic() { assert(!isStatic() && "already set"); rawValue = 1; } void setSelfIndex(uint8_t idx) { assert(!isImportAsMember() && "already set"); assert(idx <= UINT8_MAX-2 && "out of bounds"); rawValue = idx + 2; } }; /// Base class for function-like declarations. class AbstractFunctionDecl : public GenericContext, public ValueDecl { friend class NeedsNewVTableEntryRequest; public: enum class BodyKind { /// The function did not have a body in the source code file. None, /// Function body is delayed, to be parsed later. Unparsed, /// Function body is parsed and available as an AST subtree. Parsed, /// Function body is not available, although it was written in the source. Skipped, /// Function body will be synthesized on demand. Synthesize, /// Function body is present and type-checked. TypeChecked, /// This is a memberwise initializer that will be synthesized by SILGen. MemberwiseInitializer, /// Function body text was deserialized from a .swiftmodule. Deserialized // This enum currently needs to fit in a 3-bit bitfield. }; BodyKind getBodyKind() const { return BodyKind(Bits.AbstractFunctionDecl.BodyKind); } struct BodySynthesizer { std::pair<BraceStmt *, bool> (* Fn)(AbstractFunctionDecl *, void *); void *Context; }; private: ParameterList *Params; private: /// The generation at which we last loaded derivative function configurations. unsigned DerivativeFunctionConfigGeneration = 0; /// Prepare to traverse the list of derivative function configurations. void prepareDerivativeFunctionConfigurations(); /// A uniqued list of derivative function configurations. /// - `@differentiable` and `@derivative` attribute type-checking is /// responsible for populating derivative function configurations specified /// in the current module. /// - Module loading is responsible for populating derivative function /// configurations from imported modules. struct DerivativeFunctionConfigurationList; DerivativeFunctionConfigurationList *DerivativeFunctionConfigs = nullptr; public: /// Get all derivative function configurations. ArrayRef<AutoDiffConfig> getDerivativeFunctionConfigurations(); /// Add the given derivative function configuration. void addDerivativeFunctionConfiguration(AutoDiffConfig config); protected: // If a function has a body at all, we have either a parsed body AST node or // we have saved the end location of the unparsed body. union { /// This enum member is active if getBodyKind() is BodyKind::Parsed or /// BodyKind::TypeChecked. BraceStmt *Body; /// This enum member is active if getBodyKind() is BodyKind::Deserialized. StringRef BodyStringRepresentation; /// This enum member is active if getBodyKind() == BodyKind::Synthesize. BodySynthesizer Synthesizer; /// The location of the function body when the body is delayed or skipped. /// /// This enum member is active if getBodyKind() is BodyKind::Unparsed or /// BodyKind::Skipped. SourceRange BodyRange; }; friend class ParseAbstractFunctionBodyRequest; CaptureInfo Captures; /// Location of the 'throws' token. SourceLoc ThrowsLoc; struct { unsigned NeedsNewVTableEntryComputed : 1; unsigned NeedsNewVTableEntry : 1; } LazySemanticInfo = { }; AbstractFunctionDecl(DeclKind Kind, DeclContext *Parent, DeclName Name, SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc, bool HasImplicitSelfDecl, GenericParamList *GenericParams) : GenericContext(DeclContextKind::AbstractFunctionDecl, Parent, GenericParams), ValueDecl(Kind, Parent, Name, NameLoc), Body(nullptr), ThrowsLoc(ThrowsLoc) { setBodyKind(BodyKind::None); Bits.AbstractFunctionDecl.HasImplicitSelfDecl = HasImplicitSelfDecl; Bits.AbstractFunctionDecl.Overridden = false; Bits.AbstractFunctionDecl.Throws = Throws; Bits.AbstractFunctionDecl.Synthesized = false; Bits.AbstractFunctionDecl.HasSingleExpressionBody = false; } void setBodyKind(BodyKind K) { Bits.AbstractFunctionDecl.BodyKind = unsigned(K); } public: void setHasSingleExpressionBody(bool Has = true) { Bits.AbstractFunctionDecl.HasSingleExpressionBody = Has; } bool hasSingleExpressionBody() const { return Bits.AbstractFunctionDecl.HasSingleExpressionBody; } Expr *getSingleExpressionBody() const; void setSingleExpressionBody(Expr *NewBody); /// Returns the string for the base name, or "_" if this is unnamed. StringRef getNameStr() const { assert(!getName().isSpecial() && "Cannot get string for special names"); return hasName() ? getBaseIdentifier().str() : "_"; } /// Should this declaration be treated as if annotated with transparent /// attribute. bool isTransparent() const; // Expose our import as member status ImportAsMemberStatus getImportAsMemberStatus() const { return ImportAsMemberStatus(Bits.AbstractFunctionDecl.IAMStatus); } bool isImportAsMember() const { return getImportAsMemberStatus().isImportAsMember(); } bool isImportAsInstanceMember() const { return getImportAsMemberStatus().isInstance(); } bool isImportAsStaticMember() const { return getImportAsMemberStatus().isStatic(); } uint8_t getSelfIndex() const { return getImportAsMemberStatus().getSelfIndex(); } void setImportAsStaticMember() { auto newValue = getImportAsMemberStatus(); newValue.setStatic(); Bits.AbstractFunctionDecl.IAMStatus = newValue.getRawValue(); } void setSelfIndex(uint8_t idx) { auto newValue = getImportAsMemberStatus(); newValue.setSelfIndex(idx); Bits.AbstractFunctionDecl.IAMStatus = newValue.getRawValue(); } /// Retrieve the location of the 'throws' keyword, if present. SourceLoc getThrowsLoc() const { return ThrowsLoc; } /// Returns true if the function body throws. bool hasThrows() const { return Bits.AbstractFunctionDecl.Throws; } // FIXME: Hack that provides names with keyword arguments for accessors. DeclName getEffectiveFullName() const; /// Returns true if the function has a body written in the source file. /// /// Note that a true return value does not imply that the body was actually /// parsed. bool hasBody() const { return getBodyKind() != BodyKind::None && getBodyKind() != BodyKind::Skipped; } /// Returns true if the text of this function's body can be retrieved either /// by extracting the text from the source buffer or reading the inlinable /// body from a deserialized swiftmodule. bool hasInlinableBodyText() const; /// Returns the function body, if it was parsed, or nullptr otherwise. /// /// Note that a null return value does not imply that the source code did not /// have a body for this function. /// /// \sa hasBody() BraceStmt *getBody(bool canSynthesize = true) const; void setBody(BraceStmt *S, BodyKind NewBodyKind = BodyKind::Parsed); /// Note that the body was skipped for this function. Function body /// cannot be attached after this call. void setBodySkipped(SourceRange bodyRange) { // FIXME: Remove 'Parsed' from this once we can delay parsing function // bodies. Right now -experimental-skip-non-inlinable-function-bodies // requires being able to change the state from Parsed to Skipped, // because we're still eagerly parsing function bodies. assert(getBodyKind() == BodyKind::None || getBodyKind() == BodyKind::Unparsed || getBodyKind() == BodyKind::Parsed); assert(bodyRange.isValid()); BodyRange = bodyRange; setBodyKind(BodyKind::Skipped); } /// Note that parsing for the body was delayed. void setBodyDelayed(SourceRange bodyRange) { assert(getBodyKind() == BodyKind::None || getBodyKind() == BodyKind::Skipped); assert(bodyRange.isValid()); BodyRange = bodyRange; setBodyKind(BodyKind::Unparsed); } /// Provide the parsed body for the function. void setBodyParsed(BraceStmt *S) { setBody(S, BodyKind::Parsed); } /// Note that parsing for the body was delayed. /// /// The function should return the body statement and a flag indicating /// whether that body is already type-checked. void setBodySynthesizer( std::pair<BraceStmt *, bool> (* fn)(AbstractFunctionDecl *, void *), void *context = nullptr) { assert(getBodyKind() == BodyKind::None); Synthesizer = {fn, context}; setBodyKind(BodyKind::Synthesize); } /// Note that this is a memberwise initializer and thus the body will be /// generated by SILGen. void setIsMemberwiseInitializer() { assert(getBodyKind() == BodyKind::None); assert(isa<ConstructorDecl>(this)); setBodyKind(BodyKind::MemberwiseInitializer); } /// Gets the body of this function, stripping the unused portions of #if /// configs inside the body. If this function was not deserialized from a /// .swiftmodule, this body is reconstructed from the original /// source buffer. StringRef getInlinableBodyText(SmallVectorImpl<char> &scratch) const; void setBodyStringRepresentation(StringRef body) { assert(getBodyKind() == BodyKind::None); setBodyKind(BodyKind::Deserialized); BodyStringRepresentation = body; } bool isBodyTypeChecked() const { return getBodyKind() == BodyKind::TypeChecked; } bool isBodySkipped() const { return getBodyKind() == BodyKind::Skipped; } bool isMemberwiseInitializer() const { return getBodyKind() == BodyKind::MemberwiseInitializer; } /// For a method of a class, checks whether it will require a new entry in the /// vtable. bool needsNewVTableEntry() const; bool isSynthesized() const { return Bits.AbstractFunctionDecl.Synthesized; } void setSynthesized(bool value = true) { Bits.AbstractFunctionDecl.Synthesized = value; } public: /// Retrieve the source range of the function body. SourceRange getBodySourceRange() const; /// Retrieve the source range of the function declaration name + patterns. SourceRange getSignatureSourceRange() const; CaptureInfo getCaptureInfo() const { return Captures; } void setCaptureInfo(CaptureInfo captures) { Captures = captures; } /// Retrieve the Objective-C selector that names this method. ObjCSelector getObjCSelector(DeclName preferredName = DeclName(), bool skipIsObjCResolution = false) const; /// Determine whether the given method would produce an Objective-C /// instance method. bool isObjCInstanceMethod() const; /// Determine whether the name of an argument is an API name by default /// depending on the function context. bool argumentNameIsAPIByDefault() const; /// Retrieve the function's parameter list, not including 'self' if present. ParameterList *getParameters() { return Params; } const ParameterList *getParameters() const { return Params; } void setParameters(ParameterList *Params); bool hasImplicitSelfDecl() const { return Bits.AbstractFunctionDecl.HasImplicitSelfDecl; } ParamDecl **getImplicitSelfDeclStorage(); /// Retrieve the implicit 'self' parameter for methods. Returns nullptr for /// free functions. const ParamDecl *getImplicitSelfDecl(bool createIfNeeded=true) const { return const_cast<AbstractFunctionDecl*>(this) ->getImplicitSelfDecl(createIfNeeded); } ParamDecl *getImplicitSelfDecl(bool createIfNeeded=true); /// Retrieve the declaration that this method overrides, if any. AbstractFunctionDecl *getOverriddenDecl() const { return cast_or_null<AbstractFunctionDecl>(ValueDecl::getOverriddenDecl()); } /// Whether the declaration is later overridden in the module /// /// Overrides are resolved during type checking; only query this field after /// the whole module has been checked bool isOverridden() const { return Bits.AbstractFunctionDecl.Overridden; } /// The declaration has been overridden in the module /// /// Resolved during type checking void setIsOverridden() { Bits.AbstractFunctionDecl.Overridden = true; } /// Set information about the foreign error convention used by this /// declaration. void setForeignErrorConvention(const ForeignErrorConvention &convention); /// Get information about the foreign error convention used by this /// declaration, given that it is @objc and 'throws'. Optional<ForeignErrorConvention> getForeignErrorConvention() const; /// If this is a foreign C function imported as a method, get the index of /// the foreign parameter imported as `self`. If the function is imported /// as a static method, `-1` is returned to represent the `self` parameter /// being dropped altogether. `None` is returned for a normal function /// or method. Optional<int> getForeignFunctionAsMethodSelfParameterIndex() const; static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_AbstractFunctionDecl && D->getKind() <= DeclKind::Last_AbstractFunctionDecl; } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } /// True if the declaration is forced to be statically dispatched. bool hasForcedStaticDispatch() const; /// Get the type of this declaration without the Self clause. /// Asserts if not in type context. Type getMethodInterfaceType() const; /// Tests if this is a function returning a DynamicSelfType, or a /// constructor. bool hasDynamicSelfResult() const; using DeclContext::operator new; using Decl::getASTContext; }; class OperatorDecl; enum class SelfAccessKind : uint8_t { NonMutating, Mutating, Consuming, }; /// Diagnostic printing of \c SelfAccessKind. llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK); /// FuncDecl - 'func' declaration. class FuncDecl : public AbstractFunctionDecl { friend class AbstractFunctionDecl; friend class SelfAccessKindRequest; friend class IsStaticRequest; SourceLoc StaticLoc; // Location of the 'static' token or invalid. SourceLoc FuncLoc; // Location of the 'func' token. TypeLoc FnRetType; protected: FuncDecl(DeclKind Kind, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc FuncLoc, DeclName Name, SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc, bool HasImplicitSelfDecl, GenericParamList *GenericParams, DeclContext *Parent) : AbstractFunctionDecl(Kind, Parent, Name, NameLoc, Throws, ThrowsLoc, HasImplicitSelfDecl, GenericParams), StaticLoc(StaticLoc), FuncLoc(FuncLoc) { assert(!Name.getBaseName().isSpecial()); Bits.FuncDecl.StaticSpelling = static_cast<unsigned>(StaticSpelling); Bits.FuncDecl.ForcedStaticDispatch = false; Bits.FuncDecl.SelfAccess = static_cast<unsigned>(SelfAccessKind::NonMutating); Bits.FuncDecl.SelfAccessComputed = false; Bits.FuncDecl.IsStaticComputed = false; Bits.FuncDecl.IsStatic = false; Bits.FuncDecl.HasTopLevelLocalContextCaptures = false; } private: static FuncDecl *createImpl(ASTContext &Context, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc FuncLoc, DeclName Name, SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc, GenericParamList *GenericParams, DeclContext *Parent, ClangNode ClangN); Optional<SelfAccessKind> getCachedSelfAccessKind() const { if (Bits.FuncDecl.SelfAccessComputed) return static_cast<SelfAccessKind>(Bits.FuncDecl.SelfAccess); return None; } Optional<bool> getCachedIsStatic() const { if (Bits.FuncDecl.IsStaticComputed) return Bits.FuncDecl.IsStatic; return None; } public: /// Factory function only for use by deserialization. static FuncDecl *createDeserialized(ASTContext &Context, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc FuncLoc, DeclName Name, SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc, GenericParamList *GenericParams, DeclContext *Parent); static FuncDecl *create(ASTContext &Context, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling, SourceLoc FuncLoc, DeclName Name, SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc, GenericParamList *GenericParams, ParameterList *ParameterList, TypeLoc FnRetType, DeclContext *Parent, ClangNode ClangN = ClangNode()); bool isStatic() const; /// \returns the way 'static'/'class' was spelled in the source. StaticSpellingKind getStaticSpelling() const { return static_cast<StaticSpellingKind>(Bits.FuncDecl.StaticSpelling); } /// \returns the way 'static'/'class' should be spelled for this declaration. StaticSpellingKind getCorrectStaticSpelling() const; void setStatic(bool IsStatic = true) { Bits.FuncDecl.IsStaticComputed = true; Bits.FuncDecl.IsStatic = IsStatic; } bool isMutating() const { return getSelfAccessKind() == SelfAccessKind::Mutating; } bool isNonMutating() const { return getSelfAccessKind() == SelfAccessKind::NonMutating; } bool isConsuming() const { return getSelfAccessKind() == SelfAccessKind::Consuming; } bool isCallAsFunctionMethod() const; bool isMainTypeMainMethod() const; SelfAccessKind getSelfAccessKind() const; void setSelfAccessKind(SelfAccessKind mod) { Bits.FuncDecl.SelfAccess = static_cast<unsigned>(mod); Bits.FuncDecl.SelfAccessComputed = true; } SourceLoc getStaticLoc() const { return StaticLoc; } SourceLoc getFuncLoc() const { return FuncLoc; } SourceLoc getStartLoc() const { return StaticLoc.isValid() && !isa<AccessorDecl>(this) ? StaticLoc : FuncLoc; } SourceRange getSourceRange() const; TypeLoc &getBodyResultTypeLoc() { return FnRetType; } const TypeLoc &getBodyResultTypeLoc() const { return FnRetType; } /// Retrieve the result interface type of this function. Type getResultInterfaceType() const; /// isUnaryOperator - Determine whether this is a unary operator /// implementation. This check is a syntactic rather than type-based check, /// which looks at the number of parameters specified, in order to allow /// for the definition of unary operators on tuples, as in: /// /// prefix func + (param : (a:Int, b:Int)) /// /// This also allows the unary-operator-ness of a func decl to be determined /// prior to type checking. bool isUnaryOperator() const; /// isBinaryOperator - Determine whether this is a binary operator /// implementation. This check is a syntactic rather than type-based check, /// which looks at the number of parameters specified, in order to allow /// distinguishing a binary operator from a unary operator on tuples, as in: /// /// prefix func + (_:(a:Int, b:Int)) // unary operator +(1,2) /// infix func + (a:Int, b:Int) // binary operator 1 + 2 /// /// This also allows the binary-operator-ness of a func decl to be determined /// prior to type checking. bool isBinaryOperator() const; void getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const { return getCaptureInfo().getLocalCaptures(Result); } ParamDecl **getImplicitSelfDeclStorage(); /// Get the supertype method this method overrides, if any. FuncDecl *getOverriddenDecl() const { return cast_or_null<FuncDecl>(AbstractFunctionDecl::getOverriddenDecl()); } OperatorDecl *getOperatorDecl() const; /// Returns true if the function is forced to be statically dispatched. bool hasForcedStaticDispatch() const { return Bits.FuncDecl.ForcedStaticDispatch; } void setForcedStaticDispatch(bool flag) { Bits.FuncDecl.ForcedStaticDispatch = flag; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::Func || D->getKind() == DeclKind::Accessor; } static bool classof(const AbstractFunctionDecl *D) { return classof(static_cast<const Decl*>(D)); } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } /// True if the function is a defer body. bool isDeferBody() const; /// Perform basic checking to determine whether the @IBAction or /// @IBSegueAction attribute can be applied to this function. bool isPotentialIBActionTarget() const; bool hasTopLevelLocalContextCaptures() const { return Bits.FuncDecl.HasTopLevelLocalContextCaptures; } void setHasTopLevelLocalContextCaptures(bool hasCaptures=true); }; /// This represents an accessor function, such as a getter or setter. class AccessorDecl final : public FuncDecl { /// Location of the accessor keyword, e.g. 'set'. SourceLoc AccessorKeywordLoc; AbstractStorageDecl *Storage; AccessorDecl(SourceLoc declLoc, SourceLoc accessorKeywordLoc, AccessorKind accessorKind, AbstractStorageDecl *storage, SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool throws, SourceLoc throwsLoc, bool hasImplicitSelfDecl, GenericParamList *genericParams, DeclContext *parent) : FuncDecl(DeclKind::Accessor, staticLoc, staticSpelling, /*func loc*/ declLoc, /*name*/ Identifier(), /*name loc*/ declLoc, throws, throwsLoc, hasImplicitSelfDecl, genericParams, parent), AccessorKeywordLoc(accessorKeywordLoc), Storage(storage) { Bits.AccessorDecl.AccessorKind = unsigned(accessorKind); } static AccessorDecl *createImpl(ASTContext &ctx, SourceLoc declLoc, SourceLoc accessorKeywordLoc, AccessorKind accessorKind, AbstractStorageDecl *storage, SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool throws, SourceLoc throwsLoc, GenericParamList *genericParams, DeclContext *parent, ClangNode clangNode); Optional<bool> getCachedIsTransparent() const { if (Bits.AccessorDecl.IsTransparentComputed) return Bits.AccessorDecl.IsTransparent; return None; } friend class IsAccessorTransparentRequest; public: static AccessorDecl *createDeserialized(ASTContext &ctx, SourceLoc declLoc, SourceLoc accessorKeywordLoc, AccessorKind accessorKind, AbstractStorageDecl *storage, SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool throws, SourceLoc throwsLoc, GenericParamList *genericParams, DeclContext *parent); static AccessorDecl *create(ASTContext &ctx, SourceLoc declLoc, SourceLoc accessorKeywordLoc, AccessorKind accessorKind, AbstractStorageDecl *storage, SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool throws, SourceLoc throwsLoc, GenericParamList *genericParams, ParameterList *parameterList, TypeLoc fnRetType, DeclContext *parent, ClangNode clangNode = ClangNode()); SourceLoc getAccessorKeywordLoc() const { return AccessorKeywordLoc; } AbstractStorageDecl *getStorage() const { return Storage; } AccessorKind getAccessorKind() const { return AccessorKind(Bits.AccessorDecl.AccessorKind); } bool isGetter() const { return getAccessorKind() == AccessorKind::Get; } bool isSetter() const { return getAccessorKind() == AccessorKind::Set; } bool isAnyAddressor() const { auto kind = getAccessorKind(); return kind == AccessorKind::Address || kind == AccessorKind::MutableAddress; } /// isGetterOrSetter - Determine whether this is specifically a getter or /// a setter, as opposed to some other kind of accessor. /// /// For example, only getters and setters can be exposed to Objective-C. bool isGetterOrSetter() const { return isGetter() || isSetter(); } bool isObservingAccessor() const { switch (getAccessorKind()) { #define OBSERVING_ACCESSOR(ID, KEYWORD) \ case AccessorKind::ID: return true; #define ACCESSOR(ID) \ case AccessorKind::ID: return false; #include "swift/AST/AccessorKinds.def" } llvm_unreachable("bad accessor kind"); } /// \returns true if this is non-mutating due to applying a 'mutating' /// attribute. For example a "mutating set" accessor. bool isExplicitNonMutating() const; /// Is the accesor one of the kinds that's assumed nonmutating by default? bool isAssumedNonMutating() const; /// Is this accessor one of the kinds that's implicitly a coroutine? bool isCoroutine() const { switch (getAccessorKind()) { #define COROUTINE_ACCESSOR(ID, KEYWORD) \ case AccessorKind::ID: return true; #define ACCESSOR(ID) \ case AccessorKind::ID: return false; #include "swift/AST/AccessorKinds.def" } llvm_unreachable("bad accessor kind"); } bool isImplicitGetter() const { return isGetter() && getAccessorKeywordLoc().isInvalid(); } /// Is this accessor a "simple" didSet? A "simple" didSet does not /// use the implicit oldValue parameter in its body or does not have /// an explicit parameter in its parameter list. bool isSimpleDidSet() const; void setIsTransparent(bool transparent) { Bits.AccessorDecl.IsTransparent = transparent; Bits.AccessorDecl.IsTransparentComputed = 1; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::Accessor; } static bool classof(const AbstractFunctionDecl *D) { return classof(static_cast<const Decl*>(D)); } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } }; inline AccessorDecl * AbstractStorageDecl::AccessorRecord::getAccessor(AccessorKind kind) const { if (auto optIndex = AccessorIndices[unsigned(kind)]) { auto accessor = getAllAccessors()[optIndex - 1]; assert(accessor && accessor->getAccessorKind() == kind); return accessor; } return nullptr; } /// This represents a 'case' declaration in an 'enum', which may declare /// one or more individual comma-separated EnumElementDecls. class EnumCaseDecl final : public Decl, private llvm::TrailingObjects<EnumCaseDecl, EnumElementDecl *> { friend TrailingObjects; friend class Decl; SourceLoc CaseLoc; EnumCaseDecl(SourceLoc CaseLoc, ArrayRef<EnumElementDecl *> Elements, DeclContext *DC) : Decl(DeclKind::EnumCase, DC), CaseLoc(CaseLoc) { Bits.EnumCaseDecl.NumElements = Elements.size(); std::uninitialized_copy(Elements.begin(), Elements.end(), getTrailingObjects<EnumElementDecl *>()); } SourceLoc getLocFromSource() const { return CaseLoc; } public: static EnumCaseDecl *create(SourceLoc CaseLoc, ArrayRef<EnumElementDecl*> Elements, DeclContext *DC); /// Get the list of elements declared in this case. ArrayRef<EnumElementDecl *> getElements() const { return {getTrailingObjects<EnumElementDecl *>(), Bits.EnumCaseDecl.NumElements}; } SourceRange getSourceRange() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::EnumCase; } }; /// This represents a single case of an 'enum' declaration. /// /// For example, the X, Y, and Z in this enum: /// /// \code /// enum V { /// case X(Int), Y(Int) /// case Z /// } /// \endcode /// /// The type of an EnumElementDecl is always the EnumType for the containing /// enum. EnumElementDecls are represented in the AST as members of their /// parent EnumDecl, although syntactically they are subordinate to the /// EnumCaseDecl. class EnumElementDecl : public DeclContext, public ValueDecl { friend class EnumRawValuesRequest; /// This is the type specified with the enum element, for /// example 'Int' in 'case Y(Int)'. This is null if there is no type /// associated with this element, as in 'case Z' or in all elements of enum /// definitions. ParameterList *Params; SourceLoc EqualsLoc; /// The raw value literal for the enum element, or null. LiteralExpr *RawValueExpr; public: EnumElementDecl(SourceLoc IdentifierLoc, DeclName Name, ParameterList *Params, SourceLoc EqualsLoc, LiteralExpr *RawValueExpr, DeclContext *DC); /// Returns the string for the base name, or "_" if this is unnamed. StringRef getNameStr() const { assert(!getName().isSpecial() && "Cannot get string for special names"); return hasName() ? getBaseIdentifier().str() : "_"; } Type getArgumentInterfaceType() const; void setParameterList(ParameterList *params); ParameterList *getParameterList() const { return Params; } /// Retrieves a fully typechecked raw value expression associated /// with this enum element, if it exists. LiteralExpr *getRawValueExpr() const; /// Retrieves a "structurally" checked raw value expression associated /// with this enum element, if it exists. /// /// The structural raw value may or may not have a type set, but it is /// guaranteed to be suitable for retrieving any non-semantic information /// like digit text for an integral raw value or user text for a string raw value. LiteralExpr *getStructuralRawValueExpr() const; /// Reset the raw value expression. void setRawValueExpr(LiteralExpr *e); /// Return the containing EnumDecl. EnumDecl *getParentEnum() const { return cast<EnumDecl>(getDeclContext()); } /// Return the containing EnumCaseDecl. EnumCaseDecl *getParentCase() const; SourceLoc getStartLoc() const { return getNameLoc(); } SourceRange getSourceRange() const; bool hasAssociatedValues() const { return getParameterList() != nullptr; } /// True if the case is marked 'indirect'. bool isIndirect() const { return getAttrs().hasAttribute<IndirectAttr>(); } /// Do not call this! /// It exists to let the AST walkers get the raw value without forcing a request. LiteralExpr *getRawValueUnchecked() const { return RawValueExpr; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::EnumElement; } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } using DeclContext::operator new; using Decl::getASTContext; }; inline SourceRange EnumCaseDecl::getSourceRange() const { auto subRange = getElements().back()->getSourceRange(); if (subRange.isValid()) return {CaseLoc, subRange.End}; return {}; } /// Describes the kind of initializer. enum class CtorInitializerKind { /// A designated initializer is an initializer responsible for initializing /// the stored properties of the current class and chaining to a superclass's /// designated initializer (for non-root classes). /// /// Designated initializers are never inherited. Designated, /// A convenience initializer is an initializer that initializes a complete /// object by delegating to another initializer (eventually reaching a /// designated initializer). /// /// Convenience initializers are inherited into subclasses that override /// all of their superclass's designated initializers. Convenience, /// A convenience factory initializer is a convenience initializer introduced /// by an imported Objective-C factory method. /// /// Convenience factory initializers cannot be expressed directly in /// Swift; rather, they are produced by the Clang importer when importing /// an instancetype factory method from Objective-C. ConvenienceFactory, /// A factory initializer is an initializer that is neither designated nor /// convenience: it can be used to create an object of the given type, but /// cannot be chained to via "super.init" nor is it inherited. /// /// A factory initializer is written with a return type of the class name /// itself. FIXME: However, this is only a presentation form, and at present /// the only factory initializers are produced by importing an Objective-C /// factory method that does not return instancetype. /// /// FIXME: Arguably, structs and enums only have factory initializers, and /// using designated initializers for them is a misnomer. Factory }; /// ConstructorDecl - Declares a constructor for a type. For example: /// /// \code /// struct X { /// var x : Int /// init(i : Int) { /// x = i /// } /// } /// \endcode class ConstructorDecl : public AbstractFunctionDecl { /// The location of the '!' or '?' for a failable initializer. SourceLoc FailabilityLoc; ParamDecl *SelfDecl; /// The interface type of the initializing constructor. Type InitializerInterfaceType; /// The typechecked call to super.init expression, which needs to be /// inserted at the end of the initializer by SILGen. Expr *CallToSuperInit = nullptr; public: ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc, bool Failable, SourceLoc FailabilityLoc, bool Throws, SourceLoc ThrowsLoc, ParameterList *BodyParams, GenericParamList *GenericParams, DeclContext *Parent); SourceLoc getConstructorLoc() const { return getNameLoc(); } SourceLoc getStartLoc() const { return getConstructorLoc(); } SourceRange getSourceRange() const; /// Get the interface type of the constructed object. Type getResultInterfaceType() const; /// Get the interface type of the initializing constructor. Type getInitializerInterfaceType(); /// Get the typechecked call to super.init expression, which needs to be /// inserted at the end of the initializer by SILGen. Expr *getSuperInitCall() { return CallToSuperInit; } void setSuperInitCall(Expr *CallExpr) { CallToSuperInit = CallExpr; } ParamDecl **getImplicitSelfDeclStorage() { return &SelfDecl; } /// Specifies the kind of initialization call performed within the body /// of the constructor, e.g., self.init or super.init. enum class BodyInitKind { /// There are no calls to self.init or super.init. None, /// There is a call to self.init, which delegates to another (peer) /// initializer. Delegating, /// There is a call to super.init, which chains to a superclass initializer. Chained, /// There are no calls to self.init or super.init explicitly in the body of /// the constructor, but a 'super.init' call will be implicitly added /// by semantic analysis. ImplicitChained }; /// Determine whether the body of this constructor contains any delegating /// or superclass initializations (\c self.init or \c super.init, /// respectively) within its body. /// /// \param diags If non-null, this check will ensure that the constructor /// body is consistent in its use of delegation vs. chaining and emit any /// diagnostics through the given diagnostic engine. /// /// \param init If non-null and there is an explicit \c self.init or /// \c super.init within the body, will be set to point at that /// initializer. BodyInitKind getDelegatingOrChainedInitKind(DiagnosticEngine *diags, ApplyExpr **init = nullptr) const; void clearCachedDelegatingOrChainedInitKind() { Bits.ConstructorDecl.ComputedBodyInitKind = 0; } /// Whether this constructor is required. bool isRequired() const { return getAttrs().hasAttribute<RequiredAttr>(); } /// Determine the kind of initializer this is. CtorInitializerKind getInitKind() const; /// Whether this is a designated initializer. bool isDesignatedInit() const { return getInitKind() == CtorInitializerKind::Designated; } /// Whether this is a convenience initializer. bool isConvenienceInit() const { return getInitKind() == CtorInitializerKind::Convenience || getInitKind() == CtorInitializerKind::ConvenienceFactory; } /// Whether this is a factory initializer. bool isFactoryInit() const { switch (getInitKind()) { case CtorInitializerKind::Designated: case CtorInitializerKind::Convenience: return false; case CtorInitializerKind::Factory: case CtorInitializerKind::ConvenienceFactory: return true; } llvm_unreachable("bad CtorInitializerKind"); } /// Determine whether this initializer is inheritable. bool isInheritable() const { switch (getInitKind()) { case CtorInitializerKind::Designated: case CtorInitializerKind::Factory: return false; case CtorInitializerKind::Convenience: case CtorInitializerKind::ConvenienceFactory: return true; } llvm_unreachable("bad CtorInitializerKind"); } /// Determine if this is a failable initializer. bool isFailable() const { return Bits.ConstructorDecl.Failable; } /// Retrieve the location of the '!' or '?' in a failable initializer. SourceLoc getFailabilityLoc() const { return FailabilityLoc; } /// Whether the implementation of this method is a stub that traps at runtime. bool hasStubImplementation() const { return Bits.ConstructorDecl.HasStubImplementation; } /// Set whether the implementation of this method is a stub that /// traps at runtime. void setStubImplementation(bool stub) { Bits.ConstructorDecl.HasStubImplementation = stub; } ConstructorDecl *getOverriddenDecl() const { return cast_or_null<ConstructorDecl>( AbstractFunctionDecl::getOverriddenDecl()); } /// Determine whether this initializer falls into the special case for /// Objective-C initializers with selectors longer than "init", e.g., /// \c initForMemory. /// /// In such cases, one can write the Swift initializer /// with a single parameter of type '()', e.g, /// /// \code /// @objc init(forMemory: ()) /// \endcode bool isObjCZeroParameterWithLongSelector() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::Constructor; } static bool classof(const AbstractFunctionDecl *D) { return classof(static_cast<const Decl*>(D)); } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } }; /// DestructorDecl - Declares a destructor for a type. For example: /// /// \code /// struct X { /// var fd : Int /// deinit { /// close(fd) /// } /// } /// \endcode class DestructorDecl : public AbstractFunctionDecl { ParamDecl *SelfDecl; public: DestructorDecl(SourceLoc DestructorLoc, DeclContext *Parent); ParamDecl **getImplicitSelfDeclStorage() { return &SelfDecl; } SourceLoc getDestructorLoc() const { return getNameLoc(); } SourceLoc getStartLoc() const { return getDestructorLoc(); } SourceRange getSourceRange() const; /// Retrieve the Objective-C selector for destructors. ObjCSelector getObjCSelector() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::Destructor; } static bool classof(const AbstractFunctionDecl *D) { return classof(static_cast<const Decl*>(D)); } static bool classof(const DeclContext *DC) { if (auto D = DC->getAsDecl()) return classof(D); return false; } }; /// Declares a precedence group. For example: /// /// \code /// precedencegroup MultiplicativePrecedence { /// associativity: right /// higherThan: AdditivePrecedence /// } /// \endcode class PrecedenceGroupDecl : public Decl { public: struct Relation { SourceLoc NameLoc; Identifier Name; PrecedenceGroupDecl *Group; }; private: SourceLoc PrecedenceGroupLoc, NameLoc, LBraceLoc, RBraceLoc; SourceLoc AssociativityKeywordLoc, AssociativityValueLoc; SourceLoc AssignmentKeywordLoc, AssignmentValueLoc; SourceLoc HigherThanLoc, LowerThanLoc; Identifier Name; unsigned NumHigherThan, NumLowerThan; // Tail-allocated array of Relations Relation *getHigherThanBuffer() { return reinterpret_cast<Relation*>(this + 1); } const Relation *getHigherThanBuffer() const { return reinterpret_cast<const Relation*>(this + 1); } Relation *getLowerThanBuffer() { return getHigherThanBuffer() + NumHigherThan; } const Relation *getLowerThanBuffer() const { return getHigherThanBuffer() + NumHigherThan; } PrecedenceGroupDecl(DeclContext *DC, SourceLoc precedenceGroupLoc, SourceLoc nameLoc, Identifier name, SourceLoc lbraceLoc, SourceLoc associativityKeywordLoc, SourceLoc associativityValueLoc, Associativity associativity, SourceLoc assignmentKeywordLoc, SourceLoc assignmentValueLoc, bool isAssignment, SourceLoc higherThanLoc, ArrayRef<Relation> higherThan, SourceLoc lowerThanLoc, ArrayRef<Relation> lowerThan, SourceLoc rbraceLoc); friend class Decl; SourceLoc getLocFromSource() const { return NameLoc; } public: static PrecedenceGroupDecl *create(DeclContext *dc, SourceLoc precedenceGroupLoc, SourceLoc nameLoc, Identifier name, SourceLoc lbraceLoc, SourceLoc associativityKeywordLoc, SourceLoc associativityValueLoc, Associativity associativity, SourceLoc assignmentKeywordLoc, SourceLoc assignmentValueLoc, bool isAssignment, SourceLoc higherThanLoc, ArrayRef<Relation> higherThan, SourceLoc lowerThanLoc, ArrayRef<Relation> lowerThan, SourceLoc rbraceLoc); SourceRange getSourceRange() const { return { PrecedenceGroupLoc, RBraceLoc }; } /// Return the location of 'precedencegroup' in: /// precedencegroup MultiplicativePrecedence { ... } SourceLoc getPrecedenceGroupLoc() const { return PrecedenceGroupLoc; } /// Return the location of 'MultiplicativePrecedence' in: /// precedencegroup MultiplicativePrecedence { ... } SourceLoc getNameLoc() const { return NameLoc; } Identifier getName() const { return Name; } // This is needed to allow templated code to work with both ValueDecls and // PrecedenceGroupDecls. DeclBaseName getBaseName() const { return Name; } SourceLoc getLBraceLoc() const { return LBraceLoc; } SourceLoc getRBraceLoc() const { return RBraceLoc; } bool isAssociativityImplicit() const { return AssociativityKeywordLoc.isInvalid(); } /// Return the location of 'associativity' in: /// associativity: left SourceLoc getAssociativityKeywordLoc() const { return AssociativityKeywordLoc; } /// Return the location of 'right' in: /// associativity: right SourceLoc getAssociativityValueLoc() const { return AssociativityValueLoc; } Associativity getAssociativity() const { return Associativity(Bits.PrecedenceGroupDecl.Associativity); } bool isLeftAssociative() const { return getAssociativity() == Associativity::Left; } bool isRightAssociative() const { return getAssociativity() == Associativity::Right; } bool isNonAssociative() const { return getAssociativity() == Associativity::None; } bool isAssignmentImplicit() const { return AssignmentKeywordLoc.isInvalid(); } /// Return the location of 'assignment' in: /// assignment: true SourceLoc getAssignmentKeywordLoc() const { return AssignmentKeywordLoc; } /// Return the location of 'assignment' in: /// assignment: true SourceLoc getAssignmentValueLoc() const { return AssignmentValueLoc; } bool isAssignment() const { return Bits.PrecedenceGroupDecl.IsAssignment; } bool isHigherThanImplicit() const { return HigherThanLoc.isInvalid(); } /// Return the location of 'higherThan' in: /// higherThan: AdditivePrecedence SourceLoc getHigherThanLoc() const { return HigherThanLoc; } ArrayRef<Relation> getHigherThan() const { return { getHigherThanBuffer(), NumHigherThan }; } MutableArrayRef<Relation> getMutableHigherThan() { return { getHigherThanBuffer(), NumHigherThan }; } bool isLowerThanImplicit() const { return LowerThanLoc.isInvalid(); } /// Return the location of 'lowerThan' in: /// lowerThan: MultiplicativePrecedence SourceLoc getLowerThanLoc() const { return LowerThanLoc; } ArrayRef<Relation> getLowerThan() const { return { getLowerThanBuffer(), NumLowerThan }; } MutableArrayRef<Relation> getMutableLowerThan() { return { getLowerThanBuffer(), NumLowerThan }; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::PrecedenceGroup; } }; /// The fixity of an OperatorDecl. enum class OperatorFixity : uint8_t { Infix, Prefix, Postfix }; inline void simple_display(llvm::raw_ostream &out, OperatorFixity fixity) { switch (fixity) { case OperatorFixity::Infix: out << "infix"; return; case OperatorFixity::Prefix: out << "prefix"; return; case OperatorFixity::Postfix: out << "postfix"; return; } llvm_unreachable("Unhandled case in switch"); } /// Abstract base class of operator declarations. class OperatorDecl : public Decl { SourceLoc OperatorLoc, NameLoc; Identifier name; ArrayRef<Located<Identifier>> Identifiers; ArrayRef<NominalTypeDecl *> DesignatedNominalTypes; SourceLoc getLocFromSource() const { return NameLoc; } friend class Decl; public: OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc, Identifier Name, SourceLoc NameLoc, ArrayRef<Located<Identifier>> Identifiers) : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name), Identifiers(Identifiers) {} OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc, Identifier Name, SourceLoc NameLoc, ArrayRef<NominalTypeDecl *> DesignatedNominalTypes) : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name), DesignatedNominalTypes(DesignatedNominalTypes) {} /// Retrieve the operator's fixity, corresponding to the concrete subclass /// of the OperatorDecl. OperatorFixity getFixity() const { switch (getKind()) { #define DECL(Id, Name) case DeclKind::Id: llvm_unreachable("Not an operator!"); #define OPERATOR_DECL(Id, Name) #include "swift/AST/DeclNodes.def" case DeclKind::InfixOperator: return OperatorFixity::Infix; case DeclKind::PrefixOperator: return OperatorFixity::Prefix; case DeclKind::PostfixOperator: return OperatorFixity::Postfix; } llvm_unreachable("inavlid decl kind"); } SourceLoc getOperatorLoc() const { return OperatorLoc; } SourceLoc getNameLoc() const { return NameLoc; } Identifier getName() const { return name; } // This is needed to allow templated code to work with both ValueDecls and // OperatorDecls. DeclBaseName getBaseName() const { return name; } /// Get the list of identifiers after the colon in the operator declaration. /// /// This list includes the names of designated types. For infix operators, the /// first item in the list is a precedence group instead. /// /// \todo These two purposes really ought to be in separate properties and the /// designated type list should be of TypeReprs instead of Identifiers. ArrayRef<Located<Identifier>> getIdentifiers() const { return Identifiers; } ArrayRef<NominalTypeDecl *> getDesignatedNominalTypes() const { return DesignatedNominalTypes; } void setDesignatedNominalTypes(ArrayRef<NominalTypeDecl *> nominalTypes) { DesignatedNominalTypes = nominalTypes; } static bool classof(const Decl *D) { // Workaround: http://llvm.org/PR35906 if (DeclKind::Last_Decl == DeclKind::Last_OperatorDecl) return D->getKind() >= DeclKind::First_OperatorDecl; return D->getKind() >= DeclKind::First_OperatorDecl && D->getKind() <= DeclKind::Last_OperatorDecl; } }; /// Declares the behavior of an infix operator. For example: /// /// \code /// infix operator /+/ : AdditionPrecedence, Numeric /// \endcode class InfixOperatorDecl : public OperatorDecl { SourceLoc ColonLoc; public: InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name, SourceLoc nameLoc, SourceLoc colonLoc, ArrayRef<Located<Identifier>> identifiers) : OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc, identifiers), ColonLoc(colonLoc) {} SourceLoc getEndLoc() const { auto identifiers = getIdentifiers(); if (identifiers.empty()) return getNameLoc(); return identifiers.back().Loc; } SourceRange getSourceRange() const { return { getOperatorLoc(), getEndLoc() }; } SourceLoc getColonLoc() const { return ColonLoc; } PrecedenceGroupDecl *getPrecedenceGroup() const; static bool classof(const Decl *D) { return D->getKind() == DeclKind::InfixOperator; } }; /// Declares the behavior of a prefix operator. For example: /// /// \code /// prefix operator /+/ {} /// \endcode class PrefixOperatorDecl : public OperatorDecl { public: PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name, SourceLoc NameLoc, ArrayRef<Located<Identifier>> Identifiers) : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc, Identifiers) {} PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name, SourceLoc NameLoc, ArrayRef<NominalTypeDecl *> designatedNominalTypes) : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc, designatedNominalTypes) {} SourceRange getSourceRange() const { return { getOperatorLoc(), getNameLoc() }; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::PrefixOperator; } }; /// Declares the behavior of a postfix operator. For example: /// /// \code /// postfix operator /+/ {} /// \endcode class PostfixOperatorDecl : public OperatorDecl { public: PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name, SourceLoc NameLoc, ArrayRef<Located<Identifier>> Identifiers) : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc, Identifiers) {} PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name, SourceLoc NameLoc, ArrayRef<NominalTypeDecl *> designatedNominalTypes) : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc, designatedNominalTypes) {} SourceRange getSourceRange() const { return { getOperatorLoc(), getNameLoc() }; } static bool classof(const Decl *D) { return D->getKind() == DeclKind::PostfixOperator; } }; /// Represents a hole where a declaration should have been. /// /// Among other things, these are used to keep vtable layout consistent. class MissingMemberDecl : public Decl { DeclName Name; MissingMemberDecl(DeclContext *DC, DeclName name, unsigned vtableEntries, unsigned fieldOffsetVectorEntries) : Decl(DeclKind::MissingMember, DC), Name(name) { Bits.MissingMemberDecl.NumberOfVTableEntries = vtableEntries; assert(getNumberOfVTableEntries() == vtableEntries && "not enough bits"); Bits.MissingMemberDecl.NumberOfFieldOffsetVectorEntries = fieldOffsetVectorEntries; assert(getNumberOfFieldOffsetVectorEntries() == fieldOffsetVectorEntries && "not enough bits"); setImplicit(); } friend class Decl; SourceLoc getLocFromSource() const { return SourceLoc(); } public: static MissingMemberDecl * create(ASTContext &ctx, DeclContext *DC, DeclName name, unsigned numVTableEntries, bool hasStorage) { assert(!numVTableEntries || isa<ProtocolDecl>(DC) || isa<ClassDecl>(DC) && "Only classes and protocols have vtable/witness table entries"); assert(!hasStorage || !isa<ProtocolDecl>(DC) && "Protocols cannot have missing stored properties"); return new (ctx) MissingMemberDecl(DC, name, numVTableEntries, hasStorage); } DeclName getName() const { return Name; } unsigned getNumberOfVTableEntries() const { return Bits.MissingMemberDecl.NumberOfVTableEntries; } unsigned getNumberOfFieldOffsetVectorEntries() const { return Bits.MissingMemberDecl.NumberOfFieldOffsetVectorEntries; } SourceRange getSourceRange() const { return SourceRange(); } static bool classof(const Decl *D) { return D->getKind() == DeclKind::MissingMember; } }; inline bool AbstractStorageDecl::isSettable(const DeclContext *UseDC, const DeclRefExpr *base) const { if (auto vd = dyn_cast<VarDecl>(this)) return vd->isSettable(UseDC, base); auto sd = cast<SubscriptDecl>(this); return sd->supportsMutation(); } inline void AbstractStorageDecl::overwriteSetterAccess(AccessLevel accessLevel) { Accessors.setInt(accessLevel); if (auto setter = getAccessor(AccessorKind::Set)) setter->overwriteAccess(accessLevel); if (auto modify = getAccessor(AccessorKind::Modify)) modify->overwriteAccess(accessLevel); if (auto mutableAddressor = getAccessor(AccessorKind::MutableAddress)) mutableAddressor->overwriteAccess(accessLevel); } /// Constructors and destructors always have a 'self' parameter, /// which is stored in an instance member. Functions only have a /// 'self' if they are declared inside of a nominal type or extension, /// in which case we tail-allocate storage for it. inline ParamDecl **AbstractFunctionDecl::getImplicitSelfDeclStorage() { switch (getKind()) { default: llvm_unreachable("Unknown AbstractFunctionDecl!"); case DeclKind::Constructor: return cast<ConstructorDecl>(this)->getImplicitSelfDeclStorage(); case DeclKind::Destructor: return cast<DestructorDecl>(this)->getImplicitSelfDeclStorage(); case DeclKind::Func: case DeclKind::Accessor: return cast<FuncDecl>(this)->getImplicitSelfDeclStorage(); } } inline ParamDecl **FuncDecl::getImplicitSelfDeclStorage() { if (!hasImplicitSelfDecl()) return nullptr; if (!isa<AccessorDecl>(this)) { assert(getKind() == DeclKind::Func && "no new kinds of functions"); return reinterpret_cast<ParamDecl **>(this+1); } return reinterpret_cast<ParamDecl **>(static_cast<AccessorDecl*>(this)+1); } inline DeclIterator &DeclIterator::operator++() { Current = Current->NextDecl; return *this; } inline bool AbstractFunctionDecl::hasForcedStaticDispatch() const { if (auto func = dyn_cast<FuncDecl>(this)) return func->hasForcedStaticDispatch(); return false; } inline bool ValueDecl::isStatic() const { // Currently, only storage and function decls can be static/class. if (auto storage = dyn_cast<AbstractStorageDecl>(this)) return storage->isStatic(); if (auto func = dyn_cast<FuncDecl>(this)) return func->isStatic(); return false; } inline bool ValueDecl::isImportAsMember() const { if (auto func = dyn_cast<AbstractFunctionDecl>(this)) return func->isImportAsMember(); return false; } inline bool ValueDecl::hasCurriedSelf() const { if (auto *afd = dyn_cast<AbstractFunctionDecl>(this)) return afd->hasImplicitSelfDecl(); if (isa<EnumElementDecl>(this)) return true; return false; } inline bool ValueDecl::hasParameterList() const { if (auto *eed = dyn_cast<EnumElementDecl>(this)) return eed->hasAssociatedValues(); return isa<AbstractFunctionDecl>(this) || isa<SubscriptDecl>(this); } inline unsigned ValueDecl::getNumCurryLevels() const { unsigned curryLevels = 0; if (hasParameterList()) curryLevels++; if (hasCurriedSelf()) curryLevels++; return curryLevels; } inline bool Decl::isPotentiallyOverridable() const { if (isa<VarDecl>(this) || isa<SubscriptDecl>(this) || isa<FuncDecl>(this) || isa<DestructorDecl>(this)) { return getDeclContext()->getSelfClassDecl(); } else { return false; } } inline GenericParamKey::GenericParamKey(const GenericTypeParamDecl *d) : Depth(d->getDepth()), Index(d->getIndex()) { } inline const GenericContext *Decl::getAsGenericContext() const { switch (getKind()) { default: return nullptr; #define DECL(Id, Parent) // See previous line #define GENERIC_DECL(Id, Parent) \ case DeclKind::Id: \ return static_cast<const Id##Decl*>(this); #include "swift/AST/DeclNodes.def" } } inline bool DeclContext::classof(const Decl *D) { switch (D->getKind()) { // default: return false; #define DECL(ID, PARENT) // See previous line #define CONTEXT_DECL(ID, PARENT) \ case DeclKind::ID: return true; #include "swift/AST/DeclNodes.def" } } inline DeclContext *DeclContext::castDeclToDeclContext(const Decl *D) { // XXX -- ModuleDecl is not defined in Decl.h, but because DeclContexts // preface decls in memory, any DeclContext type will due. const DeclContext *DC = static_cast<const ExtensionDecl*>(D); switch (D->getKind()) { default: llvm_unreachable("Not a DeclContext"); #define DECL(ID, PARENT) // See previous line #define CONTEXT_DECL(ID, PARENT) \ case DeclKind::ID: #include "swift/AST/DeclNodes.def" return const_cast<DeclContext *>(DC); } } inline EnumElementDecl *EnumDecl::getUniqueElement(bool hasValue) const { EnumElementDecl *result = nullptr; bool found = false; for (auto elt : getAllElements()) { if (elt->hasAssociatedValues() == hasValue) { if (found) return nullptr; found = true; result = elt; } } return result; } /// Retrieve the parameter list for a given declaration, or nullputr if there /// is none. ParameterList *getParameterList(ValueDecl *source); /// Retrieve parameter declaration from the given source at given index, or /// nullptr if the source does not have a parameter list. const ParamDecl *getParameterAt(const ValueDecl *source, unsigned index); void simple_display(llvm::raw_ostream &out, OptionSet<NominalTypeDecl::LookupDirectFlags> options); /// Display Decl subclasses. void simple_display(llvm::raw_ostream &out, const Decl *decl); /// Display ValueDecl subclasses. void simple_display(llvm::raw_ostream &out, const ValueDecl *decl); /// Display ExtensionDecls. inline void simple_display(llvm::raw_ostream &out, const ExtensionDecl *decl) { simple_display(out, static_cast<const Decl *>(decl)); } /// Display NominalTypeDecls. inline void simple_display(llvm::raw_ostream &out, const NominalTypeDecl *decl) { simple_display(out, static_cast<const Decl *>(decl)); } inline void simple_display(llvm::raw_ostream &out, const AssociatedTypeDecl *decl) { simple_display(out, static_cast<const Decl *>(decl)); } /// Display GenericContext. /// /// The template keeps this sorted down in the overload set relative to the /// more concrete overloads with Decl pointers thereby breaking a potential ambiguity. template <typename T> inline typename std::enable_if<std::is_same<T, GenericContext>::value>::type simple_display(llvm::raw_ostream &out, const T *GC) { simple_display(out, GC->getAsDecl()); } /// Display GenericParamList. void simple_display(llvm::raw_ostream &out, const GenericParamList *GPL); /// Extract the source location from the given declaration. SourceLoc extractNearestSourceLoc(const Decl *decl); /// Extract the source location from the given declaration. inline SourceLoc extractNearestSourceLoc(const ExtensionDecl *ext) { return extractNearestSourceLoc(static_cast<const Decl *>(ext)); } /// Extract the source location from the given declaration. inline SourceLoc extractNearestSourceLoc(const GenericTypeDecl *type) { return extractNearestSourceLoc(static_cast<const Decl *>(type)); } /// Extract the source location from the given declaration. inline SourceLoc extractNearestSourceLoc(const NominalTypeDecl *type) { return extractNearestSourceLoc(static_cast<const Decl *>(type)); } /// Extract the source location from the given declaration. inline SourceLoc extractNearestSourceLoc(const AbstractFunctionDecl *func) { return extractNearestSourceLoc(static_cast<const Decl *>(func)); } } // end namespace swift #endif
/* * lber-proto.h * function prototypes for lber library */ #ifdef LDAP_DEBUG extern int lber_debug; #endif #ifndef LDAPFUNCDECL #ifdef _WIN32 #define LDAPFUNCDECL __declspec( dllexport ) #else /* _WIN32 */ #define LDAPFUNCDECL #endif /* _WIN32 */ #endif /* LDAPFUNCDECL */ /* * in bprint.c: */ LDAPFUNCDECL void lber_bprint( char *data, int len ); /* * in decode.c: */ LDAPFUNCDECL unsigned long ber_get_tag( BerElement *ber ); LDAPFUNCDECL unsigned long ber_skip_tag( BerElement *ber, unsigned long *len ); LDAPFUNCDECL unsigned long ber_peek_tag( BerElement *ber, unsigned long *len ); LDAPFUNCDECL unsigned long ber_get_int( BerElement *ber, long *num ); LDAPFUNCDECL unsigned long ber_get_stringb( BerElement *ber, char *buf, unsigned long *len ); LDAPFUNCDECL unsigned long ber_get_stringa( BerElement *ber, char **buf ); LDAPFUNCDECL unsigned long ber_get_stringal( BerElement *ber, struct berval **bv ); LDAPFUNCDECL unsigned long ber_get_bitstringa( BerElement *ber, char **buf, unsigned long *len ); LDAPFUNCDECL unsigned long ber_get_null( BerElement *ber ); LDAPFUNCDECL unsigned long ber_get_boolean( BerElement *ber, int *boolval ); LDAPFUNCDECL unsigned long ber_first_element( BerElement *ber, unsigned long *len, char **last ); LDAPFUNCDECL unsigned long ber_next_element( BerElement *ber, unsigned long *len, char *last ); #if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 ) LDAPFUNCDECL unsigned long ber_scanf( BerElement *ber, char *fmt, ... ); #else LDAPFUNCDECL unsigned long ber_scanf(); #endif LDAPFUNCDECL void ber_bvfree( struct berval *bv ); LDAPFUNCDECL void ber_bvecfree( struct berval **bv ); LDAPFUNCDECL struct berval *ber_bvdup( struct berval *bv ); #ifdef STR_TRANSLATION LDAPFUNCDECL void ber_set_string_translators( BerElement *ber, BERTranslateProc encode_proc, BERTranslateProc decode_proc ); #endif /* STR_TRANSLATION */ /* * in encode.c */ LDAPFUNCDECL int ber_put_enum( BerElement *ber, long num, unsigned long tag ); LDAPFUNCDECL int ber_put_int( BerElement *ber, long num, unsigned long tag ); LDAPFUNCDECL int ber_put_ostring( BerElement *ber, char *str, unsigned long len, unsigned long tag ); LDAPFUNCDECL int ber_put_string( BerElement *ber, char *str, unsigned long tag ); LDAPFUNCDECL int ber_put_bitstring( BerElement *ber, char *str, unsigned long bitlen, unsigned long tag ); LDAPFUNCDECL int ber_put_null( BerElement *ber, unsigned long tag ); LDAPFUNCDECL int ber_put_boolean( BerElement *ber, int boolval, unsigned long tag ); LDAPFUNCDECL int ber_start_seq( BerElement *ber, unsigned long tag ); LDAPFUNCDECL int ber_start_set( BerElement *ber, unsigned long tag ); LDAPFUNCDECL int ber_put_seq( BerElement *ber ); LDAPFUNCDECL int ber_put_set( BerElement *ber ); #if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 ) LDAPFUNCDECL int ber_printf( BerElement *ber, char *fmt, ... ); #else LDAPFUNCDECL int ber_printf(); #endif /* * in io.c: */ LDAPFUNCDECL long ber_read( BerElement *ber, char *buf, unsigned long len ); LDAPFUNCDECL long ber_write( BerElement *ber, char *buf, unsigned long len, int nosos ); LDAPFUNCDECL void ber_free( BerElement *ber, int freebuf ); LDAPFUNCDECL int ber_flush( Sockbuf *sb, BerElement *ber, int freeit ); LDAPFUNCDECL BerElement *ber_alloc( void ); LDAPFUNCDECL BerElement *der_alloc( void ); LDAPFUNCDECL BerElement *ber_alloc_t( int options ); LDAPFUNCDECL BerElement *ber_dup( BerElement *ber ); LDAPFUNCDECL void ber_dump( BerElement *ber, int inout ); LDAPFUNCDECL void ber_sos_dump( Seqorset *sos ); LDAPFUNCDECL unsigned long ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ); LDAPFUNCDECL void ber_init( BerElement *ber, int options ); LDAPFUNCDECL void ber_reset( BerElement *ber, int was_writing ); #ifdef NEEDGETOPT /* * in getopt.c */ int getopt( int nargc, char **nargv, char *ostr ); #endif /* NEEDGETOPT */
/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #undef STARTFILE_SPEC #define STARTFILE_SPEC \ "%{!shared: crt1%O%s} crti%O%s crtbegin%O%s crtlibid%O%s" #define TARGET_OS_CPP_BUILTINS() LINUX_TARGET_OS_CPP_BUILTINS() #define MD_UNWIND_SUPPORT "config/bfin/linux-unwind.h" /* Like the definition in gcc.c, but for purposes of uClinux, every link is static. */ #define MFWRAP_SPEC " %{fmudflap|fmudflapth: \ --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\ --wrap=mmap --wrap=munmap --wrap=alloca\ %{fmudflapth: --wrap=pthread_create\ }} %{fmudflap|fmudflapth: --wrap=main}" #undef TARGET_SUPPORTS_SYNC_CALLS #define TARGET_SUPPORTS_SYNC_CALLS 1
/* $FreeBSD$ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. * Copyright (C) 1994, 1995, 1997 TooLs GmbH. * All rights reserved. * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by TooLs GmbH. * 4. The name of TooLs GmbH may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*- * Written by Paul Popelka (paulp@uts.amdahl.com) * * You can do anything you want with this software, just don't say you wrote * it, and don't remove this notice. * * This software is provided "as is". * * The author supplies this software to be publicly redistributed on the * understanding that the author is not responsible for the correct * functioning of this software in any circumstances and is not liable for * any damages caused by this software. * * October 1992 */ #include <sys/param.h> #include <sys/systm.h> #include <sys/uio.h> #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ #include <sys/kernel.h> #include <sys/stat.h> #include <sys/buf.h> #include <sys/proc.h> #include <sys/priv.h> #include <sys/namei.h> #include <sys/mount.h> #include <sys/unistd.h> #include <sys/vnode.h> #include <sys/malloc.h> #include <sys/dirent.h> #include <sys/signalvar.h> #include <sys/time.h> #include <vm/vm.h> #include <vm/vm_extern.h> #include <vm/vm_zone.h> #include <vm/vnode_pager.h> #include <vm/vm_page2.h> #include <sys/buf2.h> #include <machine/inttypes.h> #include <vfs/msdosfs/bpb.h> #include <vfs/msdosfs/direntry.h> #include <vfs/msdosfs/denode.h> #include <vfs/msdosfs/fat.h> #include <vfs/msdosfs/msdosfsmount.h> /* * Some general notes: * * In the ufs filesystem the inodes, superblocks, and indirect blocks are * read/written using the vnode for the filesystem. Blocks that represent * the contents of a file are read/written using the vnode for the file * (including directories when they are read/written as files). This * presents problems for the dos filesystem because data that should be in * an inode (if dos had them) resides in the directory itself. Since we * must update directory entries without the benefit of having the vnode * for the directory we must use the vnode for the filesystem. This means * that when a directory is actually read/written (via read, write, or * readdir, or seek) we must use the vnode for the filesystem instead of * the vnode for the directory as would happen in ufs. This is to insure we * retrieve the correct block from the buffer cache since the hash value is * based upon the vnode address and the desired block number. */ /* * Create a regular file. On entry the directory to contain the file being * created is locked. We must release before we return. We must also free * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or * only if the SAVESTART bit in cn_flags is clear on success. */ static int msdosfs_create(struct vop_old_create_args *ap) { struct componentname *cnp = ap->a_cnp; struct denode ndirent; struct denode *dep; struct denode *pdep = VTODE(ap->a_dvp); struct timespec ts; int error; mprintf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap); /* * If this is the root directory and there is no space left we * can't do anything. This is because the root directory can not * change size. */ if (pdep->de_StartCluster == MSDOSFSROOT && pdep->de_fndoffset >= pdep->de_FileSize) { error = ENOSPC; goto bad; } /* * Create a directory entry for the file, then call createde() to * have it installed. NOTE: DOS files are always executable. We * use the absence of the owner write bit to make the file * readonly. */ memset(&ndirent, 0, sizeof(ndirent)); error = uniqdosname(pdep, cnp, ndirent.de_Name); if (error) goto bad; ndirent.de_Attributes = (ap->a_vap->va_mode & VWRITE) ? ATTR_ARCHIVE : ATTR_ARCHIVE | ATTR_READONLY; ndirent.de_LowerCase = 0; ndirent.de_StartCluster = 0; ndirent.de_FileSize = 0; ndirent.de_dev = pdep->de_dev; ndirent.de_devvp = pdep->de_devvp; ndirent.de_pmp = pdep->de_pmp; ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE; vfs_timestamp(&ts); DETIMES(&ndirent, &ts, &ts, &ts); error = createde(&ndirent, pdep, &dep, cnp); if (error) goto bad; *ap->a_vpp = DETOV(dep); return (0); bad: return (error); } static int msdosfs_mknod(struct vop_old_mknod_args *ap) { return (EINVAL); } static int msdosfs_open(struct vop_open_args *ap) { return(vop_stdopen(ap)); } static int msdosfs_close(struct vop_close_args *ap) { struct vnode *vp = ap->a_vp; struct denode *dep = VTODE(vp); struct timespec ts; if (VREFCNT(vp) > 1) { vfs_timestamp(&ts); DETIMES(dep, &ts, &ts, &ts); } return (vop_stdclose(ap)); } static int msdosfs_access(struct vop_access_args *ap) { struct denode *dep = VTODE(ap->a_vp); struct msdosfsmount *pmp = dep->de_pmp; mode_t file_mode; file_mode = (S_IXUSR|S_IXGRP|S_IXOTH) | (S_IRUSR|S_IRGRP|S_IROTH) | ((dep->de_Attributes & ATTR_READONLY) ? 0 : (S_IWUSR|S_IWGRP|S_IWOTH)); file_mode &= (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask); return (vop_helper_access(ap, pmp->pm_uid, pmp->pm_gid, file_mode, 0)); } static int msdosfs_getattr(struct vop_getattr_args *ap) { struct denode *dep = VTODE(ap->a_vp); struct msdosfsmount *pmp = dep->de_pmp; struct vattr *vap = ap->a_vap; mode_t mode; struct timespec ts; u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry); uint64_t fileid; vfs_timestamp(&ts); DETIMES(dep, &ts, &ts, &ts); vap->va_fsid = devid_from_dev(dep->de_dev); /* * The following computation of the fileid must be the same as that * used in msdosfs_readdir() to compute d_fileno. If not, pwd * doesn't work. */ if (dep->de_Attributes & ATTR_DIRECTORY) { fileid = (uint64_t)cntobn(pmp, dep->de_StartCluster) * dirsperblk; if (dep->de_StartCluster == MSDOSFSROOT) fileid = 1; } else { fileid = (uint64_t)cntobn(pmp, dep->de_dirclust) * dirsperblk; if (dep->de_dirclust == MSDOSFSROOT) fileid = (uint64_t)roottobn(pmp, 0) * dirsperblk; fileid += (uoff_t)dep->de_diroffset / sizeof(struct direntry); } vap->va_fileid = fileid; if ((dep->de_Attributes & ATTR_READONLY) == 0) mode = S_IRWXU|S_IRWXG|S_IRWXO; else mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; vap->va_mode = mode & (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask); vap->va_uid = pmp->pm_uid; vap->va_gid = pmp->pm_gid; vap->va_nlink = 1; vap->va_rmajor = VNOVAL; vap->va_rminor = VNOVAL; vap->va_size = dep->de_FileSize; fattime2timespec(dep->de_MDate, dep->de_MTime, 0, 0, &vap->va_mtime); if (pmp->pm_flags & MSDOSFSMNT_LONGNAME) { fattime2timespec(dep->de_ADate, 0, 0, 0, &vap->va_atime); fattime2timespec(dep->de_CDate, dep->de_CTime, dep->de_CHun, 0, &vap->va_ctime); } else { vap->va_atime = vap->va_mtime; vap->va_ctime = vap->va_mtime; } vap->va_flags = 0; if ((dep->de_Attributes & ATTR_ARCHIVE) == 0) vap->va_flags |= SF_ARCHIVED; vap->va_gen = 0; vap->va_blocksize = pmp->pm_bpcluster; vap->va_bytes = (dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask; vap->va_type = ap->a_vp->v_type; vap->va_filerev = dep->de_modrev; return (0); } static int msdosfs_setattr(struct vop_setattr_args *ap) { struct vnode *vp = ap->a_vp; struct denode *dep = VTODE(vp); struct msdosfsmount *pmp = dep->de_pmp; struct vattr *vap = ap->a_vap; struct ucred *cred = ap->a_cred; int error = 0; mprintf("msdosfs_setattr(): vp %p, vap %p, cred %p\n", vp, vap, cred); /* * Check for unsettable attributes. */ if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) || (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) || (vap->va_blocksize != VNOVAL) || (vap->va_rmajor != VNOVAL) || (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) { mprintf("msdosfs_setattr(): returning EINVAL\n"); mprintf(" va_type %d, va_nlink %llx, va_fsid %llx, va_fileid %llx\n", vap->va_type, (unsigned long long)vap->va_nlink, (unsigned long long)vap->va_fsid, (unsigned long long)vap->va_fileid); mprintf(" va_blocksize %lx, va_rdev %llx, va_bytes %llx, va_gen %lx\n", vap->va_blocksize, (unsigned long long)0, (unsigned long long)vap->va_bytes, vap->va_gen); mprintf(" va_uid %x, va_gid %x\n", vap->va_uid, vap->va_gid); return (EINVAL); } /* * We don't allow setting attributes on the root directory. * The special case for the root directory is because before * FAT32, the root directory didn't have an entry for itself * (and was otherwise special). With FAT32, the root * directory is not so special, but still doesn't have an * entry for itself. */ if (vp->v_flag & VROOT) return (EINVAL); if (vap->va_flags != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != pmp->pm_uid && (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0))) return (error); /* * We are very inconsistent about handling unsupported * attributes. We ignored the access time and the * read and execute bits. We were strict for the other * attributes. * * Here we are strict, stricter than ufs in not allowing * users to attempt to set SF_SETTABLE bits or anyone to * set unsupported bits. However, we ignore attempts to * set ATTR_ARCHIVE for directories `cp -pr' from a more * sensible file system attempts it a lot. */ if (cred->cr_uid != 0) { if (vap->va_flags & SF_SETTABLE) return EPERM; } if (vap->va_flags & ~SF_ARCHIVED) return EOPNOTSUPP; if (vap->va_flags & SF_ARCHIVED) dep->de_Attributes &= ~ATTR_ARCHIVE; else if (!(dep->de_Attributes & ATTR_DIRECTORY)) dep->de_Attributes |= ATTR_ARCHIVE; dep->de_flag |= DE_MODIFIED; } if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { uid_t uid; gid_t gid; if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); uid = vap->va_uid; if (uid == (uid_t)VNOVAL) uid = pmp->pm_uid; gid = vap->va_gid; if (gid == (gid_t)VNOVAL) gid = pmp->pm_gid; if ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid || (gid != pmp->pm_gid && !groupmember(gid, cred))) && (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0))) return error; if (uid != pmp->pm_uid || gid != pmp->pm_gid) return EINVAL; } if (vap->va_size != VNOVAL) { switch (vp->v_type) { case VDIR: return (EISDIR); case VREG: /* * Truncation is only supported for regular files, * Disallow it if the filesystem is read-only. */ if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); break; default: /* * According to POSIX, the result is unspecified * for file types other than regular files, * directories and shared memory objects. We * don't support any file types except regular * files and directories in this file system, so * this (default) case is unreachable and can do * anything. Keep falling through to detrunc() * for now. */ break; } error = detrunc(dep, vap->va_size, 0); if (error) return error; } if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != pmp->pm_uid && (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || (error = VOP_EACCESS(vp, VWRITE, cred)))) return (error); if (vp->v_type != VDIR) { if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 && vap->va_atime.tv_sec != VNOVAL) { dep->de_flag &= ~DE_ACCESS; timespec2fattime(&vap->va_atime, 0, &dep->de_ADate, NULL, NULL); } if (vap->va_mtime.tv_sec != VNOVAL) { dep->de_flag &= ~DE_UPDATE; timespec2fattime(&vap->va_mtime, 0, &dep->de_MDate, &dep->de_MTime, NULL); } dep->de_Attributes |= ATTR_ARCHIVE; dep->de_flag |= DE_MODIFIED; } } /* * DOS files only have the ability to have their writability * attribute set, so we use the owner write bit to set the readonly * attribute. */ if (vap->va_mode != (mode_t)VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); if (cred->cr_uid != pmp->pm_uid && (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0))) return (error); if (vp->v_type != VDIR) { /* We ignore the read and execute bits. */ if (vap->va_mode & VWRITE) dep->de_Attributes &= ~ATTR_READONLY; else dep->de_Attributes |= ATTR_READONLY; dep->de_Attributes |= ATTR_ARCHIVE; dep->de_flag |= DE_MODIFIED; } } return (deupdat(dep, 0)); } static int msdosfs_read(struct vop_read_args *ap) { int error = 0; int blsize; int isadir; size_t orig_resid; u_int n; u_long diff; u_long on; u_long cn; daddr_t lbn; daddr_t rablock; off_t loffset; int rasize; int seqcount; struct buf *bp; struct vnode *vp = ap->a_vp; struct denode *dep = VTODE(vp); struct msdosfsmount *pmp = dep->de_pmp; struct uio *uio = ap->a_uio; if (uio->uio_offset < 0) return (EINVAL); if ((uoff_t)uio->uio_offset > MSDOSFS_FILESIZE_MAX) return (0); /* * If they didn't ask for any data, then we are done. */ orig_resid = uio->uio_resid; if (orig_resid == 0) return (0); /* * The caller is supposed to ensure that * uio->uio_offset >= 0 and uio->uio_resid >= 0. * We don't need to check for large offsets as in ffs because * dep->de_FileSize <= MSDOSFS_FILESIZE_MAX < OFF_MAX, so large * offsets cannot cause overflow even in theory. */ seqcount = ap->a_ioflag >> IO_SEQSHIFT; isadir = dep->de_Attributes & ATTR_DIRECTORY; do { if (uio->uio_offset >= dep->de_FileSize) break; cn = de_cluster(pmp, uio->uio_offset); loffset = de_cn2doff(pmp, cn); rablock = cn + 1; blsize = pmp->pm_bpcluster; on = uio->uio_offset & pmp->pm_crbomask; /* * If we are operating on a directory file then be sure to * do i/o with the vnode for the filesystem instead of the * vnode for the directory. */ bp = NULL; if (isadir) { /* convert cluster # to block # */ error = pcbmap(dep, cn, &lbn, NULL, &blsize); loffset = de_bn2doff(pmp, lbn); if (error == E2BIG) { error = EINVAL; break; } else if (error) break; error = bread(pmp->pm_devvp, loffset, blsize, &bp); } else if (de_cn2off(pmp, rablock) >= dep->de_FileSize) { error = bread(vp, loffset, blsize, &bp); } else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) { error = cluster_readx(vp, ((dep->de_FileSize + blsize - 1) / blsize) * blsize, loffset, blsize, B_NOTMETA, on + uio->uio_resid, seqcount * MAXBSIZE, &bp); bp->b_flags |= B_CLUSTEROK; } else if (seqcount > 1) { off_t raoffset = de_cn2doff(pmp, rablock); rasize = blsize; error = breadn(vp, loffset, blsize, &raoffset, &rasize, 1, &bp); } else { error = bread(vp, loffset, blsize, &bp); } if (error) { brelse(bp); break; } diff = pmp->pm_bpcluster - on; n = szmin(uio->uio_resid, diff); diff = dep->de_FileSize - uio->uio_offset; if (diff < n) n = diff; diff = blsize - bp->b_resid; if (diff < n) n = diff; error = uiomovebp(bp, bp->b_data + on, (size_t)n, uio); bqrelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); if (!isadir && (error == 0 || uio->uio_resid != orig_resid) && (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) dep->de_flag |= DE_ACCESS; return (error); } /* * Write data to a file or directory. */ static int msdosfs_write(struct vop_write_args *ap) { int n; int croffset; size_t resid; u_long osize; int error = 0; u_long count; int seqcount; daddr_t cn, lastcn; struct buf *bp = NULL; int ioflag = ap->a_ioflag; struct uio *uio = ap->a_uio; struct thread *td = uio->uio_td; struct vnode *vp = ap->a_vp; struct vnode *thisvp; struct denode *dep = VTODE(vp); struct msdosfsmount *pmp = dep->de_pmp; struct proc *p = (td ? td->td_proc : NULL); struct lwp *lp = (td ? td->td_lwp : NULL); mprintf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n", vp, uio, ioflag, ap->a_cred); mprintf("msdosfs_write(): diroff %lu, dirclust %lu, startcluster %lu\n", dep->de_diroffset, dep->de_dirclust, dep->de_StartCluster); switch (vp->v_type) { case VREG: if (ioflag & IO_APPEND) uio->uio_offset = dep->de_FileSize; thisvp = vp; break; case VDIR: return EISDIR; default: panic("msdosfs_write(): bad file type"); } if (uio->uio_offset < 0) return (EFBIG); /* * This is needed (unlike in ffs_write()) because we extend the * file outside of the loop but we don't want to extend the file * for writes of 0 bytes. */ if (uio->uio_resid == 0) return (0); /* * The caller is supposed to ensure that * uio->uio_offset >= 0 and uio->uio_resid >= 0. */ if ((uoff_t)uio->uio_offset + uio->uio_resid > MSDOSFS_FILESIZE_MAX) return (EFBIG); /* * If they've exceeded their filesize limit, tell them about it. */ if (p && ((uoff_t)uio->uio_offset + uio->uio_resid > p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) { lwpsignal(p, lp, SIGXFSZ); return (EFBIG); } /* * If the offset we are starting the write at is beyond the end of * the file, then they've done a seek. Unix filesystems allow * files with holes in them, DOS doesn't so we must fill the hole * with zeroed blocks. */ if (uio->uio_offset > dep->de_FileSize) { error = deextend(dep, uio->uio_offset); if (error) return (error); } /* * Remember some values in case the write fails. */ resid = uio->uio_resid; osize = dep->de_FileSize; /* * If we write beyond the end of the file, extend it to its ultimate * size ahead of the time to hopefully get a contiguous area. */ if (uio->uio_offset + resid > osize) { count = de_clcount(pmp, uio->uio_offset + resid) - de_clcount(pmp, osize); error = extendfile(dep, count, NULL, NULL, 0); if (error && (error != ENOSPC || (ioflag & IO_UNIT))) goto errexit; lastcn = dep->de_fc[FC_LASTFC].fc_frcn; } else lastcn = de_clcount(pmp, osize) - 1; seqcount = ioflag >> IO_SEQSHIFT; do { if (de_cluster(pmp, uio->uio_offset) > lastcn) { error = ENOSPC; break; } croffset = uio->uio_offset & pmp->pm_crbomask; n = (int)szmin(uio->uio_resid, pmp->pm_bpcluster - croffset); if (uio->uio_offset + n > dep->de_FileSize) { dep->de_FileSize = uio->uio_offset + n; /* The object size needs to be set before buffer is allocated */ vnode_pager_setsize(vp, dep->de_FileSize); } /* * If either the whole cluster gets written, or we write * the cluster from its start beyond EOF, then no need to * read data from disk. * * If UIO_NOCOPY is set we have to do a read-before-write * to fill in any missing pieces of the buffer since no * actual overwrite will occur. */ cn = de_cluster(pmp, uio->uio_offset); if ((uio->uio_offset & pmp->pm_crbomask) == 0 && uio->uio_segflg != UIO_NOCOPY && (de_cluster(pmp, uio->uio_offset + uio->uio_resid) > de_cluster(pmp, uio->uio_offset) || uio->uio_offset + uio->uio_resid >= dep->de_FileSize)) { bp = getblk(thisvp, de_cn2doff(pmp, cn), pmp->pm_bpcluster, 0, 0); clrbuf(bp); /* * Do the bmap now, since pcbmap needs buffers * for the FAT table. (see msdosfs_strategy) */ if (bp->b_bio2.bio_offset == NOOFFSET) { daddr_t dblkno; error = pcbmap(dep, de_cluster(pmp, bp->b_loffset), &dblkno, NULL, NULL); if (error || dblkno == (daddr_t)-1) { bp->b_bio2.bio_offset = NOOFFSET; } else { bp->b_bio2.bio_offset = de_bn2doff(pmp, dblkno); } } if (bp->b_bio2.bio_offset == NOOFFSET) { brelse(bp); if (!error) error = EIO; /* XXX */ break; } } else { /* * The block we need to write into exists, so read * it in. */ error = bread(thisvp, de_cn2doff(pmp, cn), pmp->pm_bpcluster, &bp); if (error) { brelse(bp); break; } } /* * Should these vnode_pager_* functions be done on dir * files? */ /* * Copy the data from user space into the buf header. */ error = uiomovebp(bp, bp->b_data + croffset, (size_t)n, uio); if (error) { brelse(bp); break; } /* Prepare for clustered writes in some else clauses. */ if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) bp->b_flags |= B_CLUSTEROK; /* * If IO_SYNC, then each buffer is written synchronously. * Otherwise, if we have a severe page deficiency then * write the buffer asynchronously. Otherwise, if on a * cluster boundary then write the buffer asynchronously, * combining it with contiguous clusters if permitted and * possible, since we don't expect more writes into this * buffer soon. Otherwise, do a delayed write because we * expect more writes into this buffer soon. */ if (ioflag & IO_SYNC) bwrite(bp); else if (vm_paging_severe() || buf_dirty_count_severe()) bawrite(bp); else if (n + croffset == pmp->pm_bpcluster) { if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) cluster_write(bp, dep->de_FileSize, pmp->pm_bpcluster, seqcount); else bawrite(bp); } else bdwrite(bp); dep->de_flag |= DE_UPDATE; } while (error == 0 && uio->uio_resid > 0); /* * If the write failed and they want us to, truncate the file back * to the size it was before the write was attempted. */ errexit: if (error) { if (ioflag & IO_UNIT) { detrunc(dep, osize, ioflag & IO_SYNC); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } else { detrunc(dep, dep->de_FileSize, ioflag & IO_SYNC); if (uio->uio_resid != resid) error = 0; } } else if (ioflag & IO_SYNC) error = deupdat(dep, 1); return (error); } /* * Flush the blocks of a file to disk. */ static int msdosfs_fsync(struct vop_fsync_args *ap) { struct vnode *vp = ap->a_vp; struct vnode *devvp; int allerror, error; /* * Flush all dirty buffers associated with a vnode. */ #ifdef DIAGNOSTIC loop: #endif vfsync(vp, ap->a_waitfor, 0, NULL, NULL); #ifdef DIAGNOSTIC if (ap->a_waitfor == MNT_WAIT && !RB_EMPTY(&vp->v_rbdirty_tree)) { vprint("msdosfs_fsync: dirty", vp); goto loop; } #endif /* * If the syncing request comes from fsync(2), sync the entire * FAT and any other metadata that happens to be on devvp. We * need this mainly for the FAT. We write the FAT sloppily, and * syncing it all now is the best we can easily do to get all * directory entries associated with the file (not just the file) * fully synced. The other metadata includes critical metadata * for all directory entries, but only in the MNT_ASYNC case. We * will soon sync all metadata in the file's directory entry. * Non-critical metadata for associated directory entries only * gets synced accidentally, as in most file systems. */ if (ap->a_waitfor == MNT_WAIT) { devvp = VTODE(ap->a_vp)->de_pmp->pm_devvp; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); allerror = VOP_FSYNC(devvp, MNT_WAIT, 0); vn_unlock(devvp); } else allerror = 0; error = deupdat(VTODE(ap->a_vp), ap->a_waitfor == MNT_WAIT); if (allerror == 0) allerror = error; return (allerror); } static int msdosfs_remove(struct vop_old_remove_args *ap) { struct denode *dep = VTODE(ap->a_vp); struct denode *ddep = VTODE(ap->a_dvp); int error; if (ap->a_vp->v_type == VDIR) error = EPERM; else error = removede(ddep, dep); mprintf("msdosfs_remove(), dep %p, v_refcnt 0x%08x\n", dep, ap->a_vp->v_refcnt); return (error); } /* * DOS filesystems don't know what links are. */ static int msdosfs_link(struct vop_old_link_args *ap) { return (EOPNOTSUPP); } /* * Renames on files require moving the denode to a new hash queue since the * denode's location is used to compute which hash queue to put the file * in. Unless it is a rename in place. For example "mv a b". * * What follows is the basic algorithm: * * if (file move) { * if (dest file exists) { * remove dest file * } * if (dest and src in same directory) { * rewrite name in existing directory slot * } else { * write new entry in dest directory * update offset and dirclust in denode * move denode to new hash chain * clear old directory entry * } * } else { * directory move * if (dest directory exists) { * if (dest is not empty) { * return ENOTEMPTY * } * remove dest directory * } * if (dest and src in same directory) { * rewrite name in existing entry * } else { * be sure dest is not a child of src directory * write entry in dest directory * update "." and ".." in moved directory * clear old directory entry for moved directory * } * } * * On entry: * source's parent directory is unlocked * source file or directory is unlocked * destination's parent directory is locked * destination file or directory is locked if it exists * * On exit: * all denodes should be released */ static int msdosfs_rename(struct vop_old_rename_args *ap) { struct vnode *tdvp = ap->a_tdvp; struct vnode *fvp = ap->a_fvp; struct vnode *fdvp = ap->a_fdvp; struct vnode *tvp = ap->a_tvp; struct componentname *tcnp = ap->a_tcnp; struct componentname *fcnp = ap->a_fcnp; struct denode *ip, *xp, *dp, *zp; u_char toname[12], oldname[11]; u_long from_diroffset, to_diroffset; u_char to_count; int doingdirectory = 0, newparent = 0; int error; u_long cn, pcl; daddr_t bn; struct msdosfsmount *pmp; struct direntry *dotdotp; struct buf *bp = NULL; pmp = VFSTOMSDOSFS(fdvp->v_mount); /* * Check for cross-device rename. */ if (fvp->v_mount != tdvp->v_mount || (tvp && fvp->v_mount != tvp->v_mount)) { error = EXDEV; abortit: if (tdvp == tvp) vrele(tdvp); else vput(tdvp); if (tvp) vput(tvp); vrele(fdvp); vrele(fvp); return (error); } /* * If source and dest are the same, do nothing. */ if (tvp == fvp) { error = 0; goto abortit; } /* * fvp is unlocked, fdvp, tvp, tdvp are locked. Lock fvp and note * that we have to unlock it to use the abortit target. */ error = vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM); if (error) goto abortit; dp = VTODE(fdvp); ip = VTODE(fvp); /* * Be sure we are not renaming ".", "..", or an alias of ".". This * leads to a crippled directory tree. It's pretty tough to do a * "ls" or "pwd" with the "." directory entry missing, and "cd .." * doesn't work if the ".." entry is missing. */ if (ip->de_Attributes & ATTR_DIRECTORY) { /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') || dp == ip || (fcnp->cn_flags & CNP_ISDOTDOT) || (tcnp->cn_flags & CNP_ISDOTDOT) || (ip->de_flag & DE_RENAME)) { vn_unlock(fvp); error = EINVAL; goto abortit; } ip->de_flag |= DE_RENAME; doingdirectory++; } /* * fvp locked, fdvp unlocked, tvp, tdvp locked. DE_RENAME only * set if doingdirectory. We will get fvp unlocked in fairly * short order. dp and xp must be setup and fvp must be unlocked * for the out and bad targets to work properly. */ dp = VTODE(tdvp); xp = tvp ? VTODE(tvp) : NULL; /* * Remember direntry place to use for destination */ to_diroffset = dp->de_fndoffset; to_count = dp->de_fndcnt; /* * If ".." must be changed (ie the directory gets a new * parent) then the source directory must not be in the * directory hierarchy above the target, as this would * orphan everything below the source directory. Also * the user must have write permission in the source so * as to be able to change "..". We must repeat the call * to namei, as the parent directory is unlocked by the * call to doscheckpath(). */ error = VOP_EACCESS(fvp, VWRITE, tcnp->cn_cred); vn_unlock(fvp); if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster) newparent = 1; /* * ok. fvp, fdvp unlocked, tvp, tdvp locked. tvp may be NULL. * DE_RENAME only set if doingdirectory. */ if (doingdirectory && newparent) { if (error) /* write access check above */ goto bad; if (xp != NULL) { vput(tvp); xp = NULL; } /* * checkpath vput's tdvp (VTOI(dp)) on return no matter what, * get an extra ref so we wind up with just an unlocked, ref'd * tdvp. The 'out' target skips tvp and tdvp cleanups (tdvp * isn't locked so we can't use the out target). */ vref(tdvp); error = doscheckpath(ip, dp); tcnp->cn_flags |= CNP_PDIRUNLOCK; if (error) { vrele(tdvp); goto out; } /* * relookup no longer messes with the ref count. tdvp must * be unlocked on entry and on success will be locked on * return. */ error = relookup(tdvp, &tvp, tcnp); if (error) { if (tcnp->cn_flags & CNP_PDIRUNLOCK) vrele(tdvp); else vput(tdvp); goto out; } /* * tvp and tdvp are now locked again. */ dp = VTODE(tdvp); xp = tvp ? VTODE(tvp) : NULL; } /* * tvp and tdvp are now locked again, the 'bad' target can be used * to clean them up again. Delete an existant target and clean * up tvp. Set xp to NULL to indicate that tvp has been cleaned up. */ if (xp != NULL) { /* * Target must be empty if a directory and have no links * to it. Also, ensure source and target are compatible * (both directories, or both not directories). */ if (xp->de_Attributes & ATTR_DIRECTORY) { if (!dosdirempty(xp)) { error = ENOTEMPTY; goto bad; } if (!doingdirectory) { error = ENOTDIR; goto bad; } } else if (doingdirectory) { error = EISDIR; goto bad; } error = removede(dp, xp); if (error) goto bad; vput(tvp); xp = NULL; tvp = NULL; } /* * Convert the filename in tcnp into a dos filename. We copy this * into the denode and directory entry for the destination * file/directory. */ error = uniqdosname(VTODE(tdvp), tcnp, toname); if (error) goto bad; /* * Since from wasn't locked at various places above, we have to do * a relookup here. If the target and source are the same directory * we have to unlock the target directory in order to safely relookup * the source, because relookup expects its directory to be unlocked. * * Note that ap->a_fvp is still valid and ref'd. Any cleanup must * now take that into account. * * The tdvp locking issues make this a real mess. */ fcnp->cn_flags &= ~CNP_MODMASK; fcnp->cn_flags |= CNP_LOCKPARENT; if (newparent == 0) vn_unlock(tdvp); error = relookup(fdvp, &fvp, fcnp); if (error || fvp == NULL) { /* * From name has disappeared. Note: fdvp might == tdvp. * * DE_RENAME is only set if doingdirectory. */ if (doingdirectory) panic("rename: lost dir entry"); if (fcnp->cn_flags & CNP_PDIRUNLOCK) vrele(fdvp); else vput(fdvp); if (newparent == 0) vrele(tdvp); else vput(tdvp); vrele(ap->a_fvp); return(0); } /* * No error occured. tdvp, fdvp and fvp are all locked. If * newparent was 0 be aware that fdvp == tdvp. tvp has been cleaned * up. ap->a_fvp is still refd. */ xp = VTODE(fvp); zp = VTODE(fdvp); from_diroffset = zp->de_fndoffset; /* * Ensure that the directory entry still exists and has not * changed till now. If the source is a file the entry may * have been unlinked or renamed. In either case there is * no further work to be done. If the source is a directory * then it cannot have been rmdir'ed or renamed; this is * prohibited by the DE_RENAME flag. * * DE_RENAME is only set if doingdirectory. */ if (xp != ip) { if (doingdirectory) panic("rename: lost dir entry"); goto done; } else { u_long new_dirclust; u_long new_diroffset; /* * First write a new entry in the destination * directory and mark the entry in the source directory * as deleted. Then move the denode to the correct hash * chain for its new location in the filesystem. And, if * we moved a directory, then update its .. entry to point * to the new parent directory. */ memcpy(oldname, ip->de_Name, 11); memcpy(ip->de_Name, toname, 11); /* update denode */ dp->de_fndoffset = to_diroffset; dp->de_fndcnt = to_count; error = createde(ip, dp, NULL, tcnp); if (error) { memcpy(ip->de_Name, oldname, 11); goto done; } /* * If ip is for a directory, then its name should always * be "." since it is for the directory entry in the * directory itself (msdosfs_lookup() always translates * to the "." entry so as to get a unique denode, except * for the root directory there are different * complications). However, we just corrupted its name * to pass the correct name to createde(). Undo this. */ if ((ip->de_Attributes & ATTR_DIRECTORY) != 0) memcpy(ip->de_Name, oldname, 11); ip->de_refcnt++; zp->de_fndoffset = from_diroffset; error = removede(zp, ip); if (error) { /* XXX should downgrade to ro here, fs is corrupt */ goto done; } if (!doingdirectory) { error = pcbmap(dp, de_cluster(pmp, to_diroffset), NULL, &new_dirclust, NULL); if (error) { /* XXX should downgrade to ro here, fs is corrupt */ goto done; } if (new_dirclust == MSDOSFSROOT) new_diroffset = to_diroffset; else new_diroffset = to_diroffset & pmp->pm_crbomask; msdosfs_reinsert(ip, new_dirclust, new_diroffset); } } /* * If we moved a directory to a new parent directory, then we must * fixup the ".." entry in the moved directory. */ if (doingdirectory && newparent) { cn = ip->de_StartCluster; if (cn == MSDOSFSROOT) { /* this should never happen */ panic("msdosfs_rename(): updating .. in root directory?"); } else { bn = cntobn(pmp, cn); } error = bread(pmp->pm_devvp, de_bn2doff(pmp, bn), pmp->pm_bpcluster, &bp); if (error) { /* XXX should downgrade to ro here, fs is corrupt */ brelse(bp); goto done; } dotdotp = (struct direntry *)bp->b_data + 1; pcl = dp->de_StartCluster; if (FAT32(pmp) && pcl == pmp->pm_rootdirblk) pcl = MSDOSFSROOT; putushort(dotdotp->deStartCluster, pcl); if (FAT32(pmp)) putushort(dotdotp->deHighClust, pcl >> 16); if (DOINGASYNC(fvp)) bdwrite(bp); else if ((error = bwrite(bp)) != 0) { /* XXX should downgrade to ro here, fs is corrupt */ goto done; } } /* * done case fvp, fdvp, tdvp are locked. ap->a_fvp is refd */ done: if (doingdirectory) ip->de_flag &= ~DE_RENAME; /* XXX fvp not locked */ vput(fvp); if (newparent) vput(fdvp); else vrele(fdvp); vput(tdvp); vrele(ap->a_fvp); return (error); /* * 'bad' target: xp governs tvp. tvp and tdvp are locked, fdvp and fvp * are not locked. ip points to fvp's inode which may have DE_RENAME * set. */ bad: if (xp) vput(tvp); vput(tdvp); out: /* * 'out' target: tvp and tdvp have already been cleaned up. */ if (doingdirectory) ip->de_flag &= ~DE_RENAME; vrele(fdvp); vrele(fvp); return (error); } static struct { struct direntry dot; struct direntry dotdot; } dosdirtemplate = { { ". ", /* the . entry */ ATTR_DIRECTORY, /* file attribute */ 0, /* reserved */ 0, { 0, 0 }, { 0, 0 }, /* create time & date */ { 0, 0 }, /* access date */ { 0, 0 }, /* high bits of start cluster */ { 210, 4 }, { 210, 4 }, /* modify time & date */ { 0, 0 }, /* startcluster */ { 0, 0, 0, 0 } /* filesize */ }, { ".. ", /* the .. entry */ ATTR_DIRECTORY, /* file attribute */ 0, /* reserved */ 0, { 0, 0 }, { 0, 0 }, /* create time & date */ { 0, 0 }, /* access date */ { 0, 0 }, /* high bits of start cluster */ { 210, 4 }, { 210, 4 }, /* modify time & date */ { 0, 0 }, /* startcluster */ { 0, 0, 0, 0 } /* filesize */ } }; static int msdosfs_mkdir(struct vop_old_mkdir_args *ap) { struct componentname *cnp = ap->a_cnp; struct denode *dep; struct denode *pdep = VTODE(ap->a_dvp); struct direntry *denp; struct msdosfsmount *pmp = pdep->de_pmp; struct buf *bp; u_long newcluster, pcl; int bn; int error; struct denode ndirent; struct timespec ts; /* * If this is the root directory and there is no space left we * can't do anything. This is because the root directory can not * change size. */ if (pdep->de_StartCluster == MSDOSFSROOT && pdep->de_fndoffset >= pdep->de_FileSize) { error = ENOSPC; goto bad2; } /* * Allocate a cluster to hold the about to be created directory. */ error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL); if (error) goto bad2; memset(&ndirent, 0, sizeof(ndirent)); ndirent.de_pmp = pmp; ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE; vfs_timestamp(&ts); DETIMES(&ndirent, &ts, &ts, &ts); /* * Now fill the cluster with the "." and ".." entries. And write * the cluster to disk. This way it is there for the parent * directory to be pointing at if there were a crash. */ bn = cntobn(pmp, newcluster); /* always succeeds */ bp = getblk(pmp->pm_devvp, de_bn2doff(pmp, bn), pmp->pm_bpcluster, 0, 0); memset(bp->b_data, 0, pmp->pm_bpcluster); memcpy(bp->b_data, &dosdirtemplate, sizeof(dosdirtemplate)); denp = (struct direntry *)bp->b_data; putushort(denp[0].deStartCluster, newcluster); putushort(denp[0].deCDate, ndirent.de_CDate); putushort(denp[0].deCTime, ndirent.de_CTime); denp[0].deCHundredth = ndirent.de_CHun; putushort(denp[0].deADate, ndirent.de_ADate); putushort(denp[0].deMDate, ndirent.de_MDate); putushort(denp[0].deMTime, ndirent.de_MTime); pcl = pdep->de_StartCluster; /* * Although the root directory has a non-magic starting cluster * number for FAT32, chkdsk and fsck_msdosfs still require * references to it in dotdot entries to be magic. */ if (FAT32(pmp) && pcl == pmp->pm_rootdirblk) pcl = MSDOSFSROOT; putushort(denp[1].deStartCluster, pcl); putushort(denp[1].deCDate, ndirent.de_CDate); putushort(denp[1].deCTime, ndirent.de_CTime); denp[1].deCHundredth = ndirent.de_CHun; putushort(denp[1].deADate, ndirent.de_ADate); putushort(denp[1].deMDate, ndirent.de_MDate); putushort(denp[1].deMTime, ndirent.de_MTime); if (FAT32(pmp)) { putushort(denp[0].deHighClust, newcluster >> 16); putushort(denp[1].deHighClust, pcl >> 16); } if (DOINGASYNC(ap->a_dvp)) bdwrite(bp); else if ((error = bwrite(bp)) != 0) goto bad; /* * Now build up a directory entry pointing to the newly allocated * cluster. This will be written to an empty slot in the parent * directory. */ error = uniqdosname(pdep, cnp, ndirent.de_Name); if (error) goto bad; ndirent.de_Attributes = ATTR_DIRECTORY; ndirent.de_LowerCase = 0; ndirent.de_StartCluster = newcluster; ndirent.de_FileSize = 0; ndirent.de_dev = pdep->de_dev; ndirent.de_devvp = pdep->de_devvp; error = createde(&ndirent, pdep, &dep, cnp); if (error) goto bad; *ap->a_vpp = DETOV(dep); return (0); bad: clusterfree(pmp, newcluster); bad2: return (error); } static int msdosfs_rmdir(struct vop_old_rmdir_args *ap) { struct vnode *vp = ap->a_vp; struct vnode *dvp = ap->a_dvp; struct denode *ip, *dp; int error; ip = VTODE(vp); dp = VTODE(dvp); /* * Verify the directory is empty (and valid). * (Rmdir ".." won't be valid since * ".." will contain a reference to * the current directory and thus be * non-empty.) */ error = 0; if (!dosdirempty(ip) || ip->de_flag & DE_RENAME) { error = ENOTEMPTY; goto out; } /* * Delete the entry from the directory. For dos filesystems this * gets rid of the directory entry on disk, the in memory copy * still exists but the de_refcnt is <= 0. This prevents it from * being found by deget(). When the vput() on dep is done we give * up access and eventually msdosfs_reclaim() will be called which * will remove it from the denode cache. */ error = removede(dp, ip); if (error) goto out; /* * Truncate the directory that is being deleted. */ error = detrunc(ip, (u_long)0, IO_SYNC); out: return (error); } /* * DOS filesystems don't know what symlinks are. */ static int msdosfs_symlink(struct vop_old_symlink_args *ap) { return (EOPNOTSUPP); } static int msdosfs_readdir(struct vop_readdir_args *ap) { struct mbnambuf nb; int error = 0; int diff; long n; int blsize; long on; u_long cn; u_long dirsperblk; long bias = 0; daddr_t bn, lbn; struct buf *bp = NULL; struct denode *dep; struct msdosfsmount *pmp; struct direntry *dentp; struct dirent dirbuf; struct uio *uio = ap->a_uio; off_t *cookies = NULL; int ncookies = 0; off_t offset, off; int chksum = -1; error = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM); if (error) return (error); dep = VTODE(ap->a_vp); pmp = dep->de_pmp; mprintf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n", ap->a_vp, uio, ap->a_cred, ap->a_eofflag); /* * msdosfs_readdir() won't operate properly on regular files since * it does i/o only with the filesystem vnode, and hence can * retrieve the wrong block from the buffer cache for a plain file. * So, fail attempts to readdir() on a plain file. */ if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) { error = ENOTDIR; goto done; } /* * To be safe, initialize dirbuf */ memset(dirbuf.d_name, 0, sizeof(dirbuf.d_name)); /* * If the user buffer is smaller than the size of one dos directory * entry or the file offset is not a multiple of the size of a * directory entry, then we fail the read. */ off = offset = uio->uio_offset; if (uio->uio_resid < sizeof(struct direntry) || (offset & (sizeof(struct direntry) - 1))) { error = EINVAL; goto done; } if (ap->a_ncookies) { ncookies = uio->uio_resid / 16 + 1; if (ncookies > 1024) ncookies = 1024; cookies = kmalloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK); *ap->a_cookies = cookies; *ap->a_ncookies = ncookies; } dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry); #define d_fileno d_ino /* * If they are reading from the root directory then, we simulate * the . and .. entries since these don't exist in the root * directory. We also set the offset bias to make up for having to * simulate these entries. By this I mean that at file offset 64 we * read the first entry in the root directory that lives on disk. */ if (dep->de_StartCluster == MSDOSFSROOT || (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)) { #if 0 printf("msdosfs_readdir(): going after . or .. in root dir, offset %d\n", offset); #endif bias = 2 * sizeof(struct direntry); if (offset < bias) { for (n = (int)offset / sizeof(struct direntry); n < 2; n++) { dirbuf.d_fileno = FAT32(pmp) ? (uint64_t)cntobn(pmp, pmp->pm_rootdirblk) * dirsperblk : 1; dirbuf.d_type = DT_DIR; switch (n) { case 0: dirbuf.d_namlen = 1; dirbuf.d_name[0] = '.'; break; case 1: dirbuf.d_namlen = 2; dirbuf.d_name[0] = '.'; dirbuf.d_name[1] = '.'; break; } if (vop_write_dirent(&error, uio, dirbuf.d_fileno, dirbuf.d_type, dirbuf.d_namlen, dirbuf.d_name)) goto out; if (error) goto out; offset += sizeof(struct direntry); off = offset; if (cookies) { *cookies++ = offset; if (--ncookies <= 0) goto out; } } } } mbnambuf_init(&nb); off = offset; while (uio->uio_resid > 0) { lbn = de_cluster(pmp, offset - bias); on = (offset - bias) & pmp->pm_crbomask; n = szmin(pmp->pm_bpcluster - on, uio->uio_resid); diff = dep->de_FileSize - (offset - bias); if (diff <= 0) break; n = min(n, diff); error = pcbmap(dep, lbn, &bn, &cn, &blsize); if (error) break; error = bread(pmp->pm_devvp, de_bn2doff(pmp, bn), blsize, &bp); if (error) { brelse(bp); goto done; } n = min(n, blsize - bp->b_resid); if (n == 0) { brelse(bp); error = EIO; goto done; } /* * Convert from dos directory entries to fs-independent * directory entries. */ for (dentp = (struct direntry *)(bp->b_data + on); (char *)dentp < bp->b_data + on + n; dentp++, offset += sizeof(struct direntry)) { #if 0 printf("rd: dentp %08x prev %08x crnt %08x deName %02x attr %02x\n", dentp, prev, crnt, dentp->deName[0], dentp->deAttributes); #endif /* * If this is an unused entry, we can stop. */ if (dentp->deName[0] == SLOT_EMPTY) { brelse(bp); goto out; } /* * Skip deleted entries. */ if (dentp->deName[0] == SLOT_DELETED) { chksum = -1; mbnambuf_init(&nb); continue; } /* * Handle Win95 long directory entries */ if (dentp->deAttributes == ATTR_WIN95) { if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME) continue; chksum = win2unixfn(&nb, (struct winentry *)dentp, chksum, pmp); continue; } /* * Skip volume labels */ if (dentp->deAttributes & ATTR_VOLUME) { chksum = -1; mbnambuf_init(&nb); continue; } /* * This computation of d_fileno must match * the computation of va_fileid in * msdosfs_getattr. */ if (dentp->deAttributes & ATTR_DIRECTORY) { cn = getushort(dentp->deStartCluster); if (FAT32(pmp)) { cn |= getushort(dentp->deHighClust) << 16; if (cn == MSDOSFSROOT) cn = pmp->pm_rootdirblk; } if (cn == MSDOSFSROOT && !FAT32(pmp)) dirbuf.d_fileno = 1; else dirbuf.d_fileno = cntobn(pmp, cn) * dirsperblk; dirbuf.d_type = DT_DIR; } else { dirbuf.d_fileno = (uoff_t)offset / sizeof(struct direntry); dirbuf.d_type = DT_REG; } if (chksum != winChksum(dentp->deName)) { dirbuf.d_namlen = dos2unixfn(dentp->deName, (u_char *)dirbuf.d_name, dentp->deLowerCase | ((pmp->pm_flags & MSDOSFSMNT_SHORTNAME) ? (LCASE_BASE | LCASE_EXT) : 0), pmp); mbnambuf_init(&nb); } else mbnambuf_flush(&nb, &dirbuf); chksum = -1; if (vop_write_dirent(&error, uio, dirbuf.d_fileno, dirbuf.d_type, dirbuf.d_namlen, dirbuf.d_name)) { brelse(bp); goto out; } if (error) { brelse(bp); goto out; } if (cookies) { *cookies++ = offset + sizeof(struct direntry); if (--ncookies <= 0) { brelse(bp); goto out; } } off = offset + sizeof(struct direntry); } brelse(bp); } out: /* Subtract unused cookies */ if (ap->a_ncookies) *ap->a_ncookies -= ncookies; uio->uio_offset = off; /* * Set the eofflag (NFS uses it) */ if (ap->a_eofflag) { if (dep->de_FileSize - (offset - bias) <= 0) *ap->a_eofflag = 1; else *ap->a_eofflag = 0; } done: vn_unlock(ap->a_vp); return (error); } /*- * a_vp - pointer to the file's vnode * a_runp - where to return the "run past" a_bn. This is the count of logical * blocks whose physical blocks (together with a_bn's physical block) * are contiguous. * a_runb - where to return the "run before" a_bn. */ static int msdosfs_bmap(struct vop_bmap_args *ap) { struct fatcache savefc; struct denode *dep; struct mount *mp; struct msdosfsmount *pmp; struct vnode *vp; daddr_t dbn, runbn; u_long cn; int bnpercn, error, maxio, maxrun, run; vp = ap->a_vp; dep = VTODE(vp); pmp = dep->de_pmp; if (ap->a_doffsetp == NULL) return (0); if (ap->a_runp != NULL) *ap->a_runp = 0; if (ap->a_runb != NULL) *ap->a_runb = 0; KKASSERT(((int)ap->a_loffset & ((1 << pmp->pm_cnshift) - 1)) == 0); error = pcbmap(dep, de_cluster(pmp, ap->a_loffset), &dbn, NULL, NULL); if (error || dbn == (daddr_t)-1) *ap->a_doffsetp = NOOFFSET; else *ap->a_doffsetp = de_bn2doff(pmp, dbn); if (error != 0 || dbn == (daddr_t)-1 || (ap->a_runp == NULL && ap->a_runb == NULL)) return (error); /* * Prepare to back out updates of the fatchain cache after the one * for the first block done by pcbmap() above. Without the backout, * then whenever the caller doesn't do i/o to all of the blocks that * we find, the single useful cache entry would be too far in advance * of the actual i/o to work for the next sequential i/o. Then the * FAT would be searched from the beginning. With the backout, the * FAT is searched starting at most a few blocks early. This wastes * much less time. Time is also wasted finding more blocks than the * caller will do i/o to. This is necessary because the runlength * parameters are output-only. */ savefc = dep->de_fc[FC_LASTMAP]; cn = de_cluster(pmp, ap->a_loffset); mp = vp->v_mount; maxio = mp->mnt_iosize_max / mp->mnt_stat.f_iosize; bnpercn = de_cn2bn(pmp, 1); if (ap->a_runp != NULL) { maxrun = ulmin(maxio - 1, pmp->pm_maxcluster - cn); for (run = 1; run <= maxrun; run++) { if (pcbmap(dep, cn + run, &runbn, NULL, NULL) != 0 || runbn != dbn + run * bnpercn) break; } *ap->a_runp = run - 1; } if (ap->a_runb != NULL) { maxrun = ulmin(maxio - 1, cn); for (run = 1; run < maxrun; run++) { if (pcbmap(dep, cn - run, &runbn, NULL, NULL) != 0 || runbn != dbn - run * bnpercn) break; } *ap->a_runb = run - 1; } dep->de_fc[FC_LASTMAP] = savefc; return (0); } static int msdosfs_strategy(struct vop_strategy_args *ap) { struct bio *bio = ap->a_bio; struct bio *nbio; struct buf *bp = bio->bio_buf; struct vnode *vp = ap->a_vp; struct denode *dep = VTODE(vp); struct msdosfsmount *pmp = dep->de_pmp; int error = 0; daddr_t dblkno; if (vp->v_type == VBLK || vp->v_type == VCHR) panic("msdosfs_strategy: spec"); /* * If we don't already know the filesystem relative block number * then get it using pcbmap(). If pcbmap() returns the block * number as -1 then we've got a hole in the file. DOS filesystems * don't allow files with holes, so we shouldn't ever see this. */ nbio = push_bio(bio); if (nbio->bio_offset == NOOFFSET) { error = pcbmap(dep, de_cluster(pmp, bio->bio_offset), &dblkno, NULL, NULL); if (error) { bp->b_error = error; bp->b_flags |= B_ERROR; /* I/O was never started on nbio, must biodone(bio) */ biodone(bio); return (error); } if (dblkno == (daddr_t)-1) { nbio->bio_offset = NOOFFSET; vfs_bio_clrbuf(bp); } else { nbio->bio_offset = de_bn2doff(pmp, dblkno); } } if (nbio->bio_offset == NOOFFSET) { /* I/O was never started on nbio, must biodone(bio) */ biodone(bio); return (0); } /* * Read/write the block from/to the disk that contains the desired * file block. */ vn_strategy(dep->de_devvp, nbio); return (0); } static int msdosfs_print(struct vop_print_args *ap) { struct denode *dep = VTODE(ap->a_vp); kprintf("tag VT_MSDOSFS, startcluster %lu, dircluster %lu, " "diroffset %lu, dev %d, %d", dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset, major(dep->de_dev), minor(dep->de_dev)); lockmgr_printinfo(&ap->a_vp->v_lock); return (0); } static int msdosfs_pathconf(struct vop_pathconf_args *ap) { struct msdosfsmount *pmp = VTODE(ap->a_vp)->de_pmp; switch (ap->a_name) { case _PC_FILESIZEBITS: *ap->a_retval = FAT12(pmp) ? 32 : 33; return (0); case _PC_LINK_MAX: *ap->a_retval = 1; return (0); case _PC_NAME_MAX: *ap->a_retval = pmp->pm_flags & MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12; return (0); case _PC_CHOWN_RESTRICTED: *ap->a_retval = 1; return (0); case _PC_NO_TRUNC: *ap->a_retval = 0; return (0); default: return (vop_stdpathconf(ap)); } /* NOTREACHED */ } /* Global vfs data structures for msdosfs */ struct vop_ops msdosfs_vnode_vops = { .vop_default = vop_defaultop, .vop_access = msdosfs_access, .vop_bmap = msdosfs_bmap, .vop_getpages = vop_stdgetpages, .vop_putpages = vop_stdputpages, .vop_open = msdosfs_open, .vop_close = msdosfs_close, .vop_old_create = msdosfs_create, .vop_fsync = msdosfs_fsync, .vop_getattr = msdosfs_getattr, .vop_inactive = msdosfs_inactive, .vop_old_link = msdosfs_link, .vop_old_lookup = msdosfs_lookup, .vop_old_mkdir = msdosfs_mkdir, .vop_old_mknod = msdosfs_mknod, .vop_pathconf = msdosfs_pathconf, .vop_print = msdosfs_print, .vop_read = msdosfs_read, .vop_readdir = msdosfs_readdir, .vop_reclaim = msdosfs_reclaim, .vop_old_remove = msdosfs_remove, .vop_old_rename = msdosfs_rename, .vop_old_rmdir = msdosfs_rmdir, .vop_setattr = msdosfs_setattr, .vop_strategy = msdosfs_strategy, .vop_old_symlink = msdosfs_symlink, .vop_write = msdosfs_write, };
/* !!DESCRIPTION!! print character frequencies !!ORIGIN!! LCC 4.1 Testsuite !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ /* cf - print character frequencies */ #include "common.h" #include <stdlib.h> #include <stdio.h> #include <ctype.h> FILE *in; #define INFILE "cf.in" #define GETCHAR() fgetc(in) #ifndef NO_FLOATS float f[0x100]; #else signed f[0x100]; #endif #ifdef NO_OLD_FUNC_DECL int main(int argc,char **argv) #else main(argc, argv) int argc; char *argv[]; #endif { int i, c, nc; #ifndef NO_FLOATS float cutoff, atof(); #else signed cutoff; #endif in = fopen(INFILE, "rb"); if (in == NULL) { return EXIT_FAILURE; } if (argc <= 1) #ifndef NO_FLOATS cutoff = 0.0; #else cutoff = 0; #endif else #ifndef NO_FLOATS cutoff = atof(argv[1])/100; #else cutoff = atoi(argv[1])/100; #endif for (i = 0; i < 0x100; ) { #ifndef NO_FLOATS f[i++] = 0.0; #else f[i++] = 0; #endif } printf("input:\n\n"); nc = 0; while ((c = GETCHAR()) != -1) { /* printf("[%02x]",c); */ printf("%c",c); f[c] += 1; nc++; } printf("\n\ncount: %d\n\n",nc); /* now try to print a report in a way so that the order is somewhat independent from the target character set */ printf("a-z char:freq\n\n"); /* first round ... lowercase characters */ for (i = 0; i < 0x100; ++i) { if ((f[i]) && ((f[i]/nc) >= cutoff)) { if ((i >= 'a') && (i <= 'z')) { printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif f[i]=0; } } } printf("A-Z char:freq\n\n"); /* second round ... uppercase characters */ for (i = 0; i < 0x100; ++i) { if ((f[i]) && ((f[i]/nc) >= cutoff)) { if ((i >= 'A') && (i <= 'Z')) { printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif f[i]=0; } } } printf("0-9 char:freq\n\n"); /* third round ... numbers */ for (i = 0; i < 0x100; ++i) { if ((f[i]) && ((f[i]/nc) >= cutoff)) { if ((i >= '0') && (i <= '9')) { printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif f[i]=0; } } } printf("isprint char:freq\n\n"); /* second last round ... remaining printable characters */ for (i = 0; i < 0x100; ++i) { if ((f[i]) && ((f[i]/nc) >= cutoff)) { if(isprint(i)) { printf("%c", i); #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif f[i]=0; } } } printf("rest char:freq\n\n"); /* last round ... remaining non printable characters */ for (i = 0; i < 0x100; ++i) { if ((f[i]) && ((f[i]/nc) >= cutoff)) { if(i=='\n') { printf("newline"); } else { printf("%03o", i); } #ifndef NO_FLOATS printf(":%.1f\n", 100*f[i]/nc); #else printf(":%d\n", 100*f[i]/nc); #endif } } fclose(in); return 0; }
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE114_Process_Control__w32_char_connect_socket_64b.c Label Definition File: CWE114_Process_Control__w32.label.xml Template File: sources-sink-64b.tmpl.c */ /* * @description * CWE: 114 Process Control * BadSource: connect_socket Read data using a connect socket (client side) * GoodSource: Hard code the full pathname to the library * Sinks: * BadSink : Load a dynamic link library * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files * * */ #include "std_testcase.h" #include <wchar.h> #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else /* NOT _WIN32 */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 #define IP_ADDRESS "127.0.0.1" #ifndef OMITBAD void CWE114_Process_Control__w32_char_connect_socket_64b_badSink(void * dataVoidPtr) { /* cast void pointer to a pointer of the appropriate type */ char * * dataPtr = (char * *)dataVoidPtr; /* dereference dataPtr into data */ char * data = (*dataPtr); { HMODULE hModule; /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to * replace his own file with the intended library */ hModule = LoadLibraryA(data); if (hModule != NULL) { FreeLibrary(hModule); printLine("Library loaded and freed successfully"); } else { printLine("Unable to load library"); } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B uses the GoodSource with the BadSink */ void CWE114_Process_Control__w32_char_connect_socket_64b_goodG2BSink(void * dataVoidPtr) { /* cast void pointer to a pointer of the appropriate type */ char * * dataPtr = (char * *)dataVoidPtr; /* dereference dataPtr into data */ char * data = (*dataPtr); { HMODULE hModule; /* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to * replace his own file with the intended library */ hModule = LoadLibraryA(data); if (hModule != NULL) { FreeLibrary(hModule); printLine("Library loaded and freed successfully"); } else { printLine("Unable to load library"); } } } #endif /* OMITGOOD */
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:52:07 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/MailSupport.framework/MailSupport * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <MailSupport/MailSupport-Structs.h> #import <ProtocolBuffer/PBCodable.h> #import <libobjc.A.dylib/NSCopying.h> @class NSString; @interface AWDMailNetworkDiagnosticsReport : PBCodable <NSCopying> { unsigned long long _numActiveCalls; unsigned long long _numBackgroundWifiClients; unsigned long long _timestamp; NSString* _dataIndicator; int _dataInterface; unsigned _reachabilityFlags; BOOL _cellData; BOOL _dnsEnabled; BOOL _roamingAllowed; BOOL _wifiEnabled; SCD_Struct_AW5 _has; } @property (assign,nonatomic) BOOL hasTimestamp; @property (assign,nonatomic) unsigned long long timestamp; //@synthesize timestamp=_timestamp - In the implementation block @property (assign,nonatomic) BOOL hasReachabilityFlags; @property (assign,nonatomic) unsigned reachabilityFlags; //@synthesize reachabilityFlags=_reachabilityFlags - In the implementation block @property (assign,nonatomic) BOOL hasDnsEnabled; @property (assign,nonatomic) BOOL dnsEnabled; //@synthesize dnsEnabled=_dnsEnabled - In the implementation block @property (assign,nonatomic) BOOL hasWifiEnabled; @property (assign,nonatomic) BOOL wifiEnabled; //@synthesize wifiEnabled=_wifiEnabled - In the implementation block @property (assign,nonatomic) BOOL hasDataInterface; @property (assign,nonatomic) int dataInterface; //@synthesize dataInterface=_dataInterface - In the implementation block @property (assign,nonatomic) BOOL hasCellData; @property (assign,nonatomic) BOOL cellData; //@synthesize cellData=_cellData - In the implementation block @property (nonatomic,readonly) BOOL hasDataIndicator; @property (nonatomic,retain) NSString * dataIndicator; //@synthesize dataIndicator=_dataIndicator - In the implementation block @property (assign,nonatomic) BOOL hasRoamingAllowed; @property (assign,nonatomic) BOOL roamingAllowed; //@synthesize roamingAllowed=_roamingAllowed - In the implementation block @property (assign,nonatomic) BOOL hasNumActiveCalls; @property (assign,nonatomic) unsigned long long numActiveCalls; //@synthesize numActiveCalls=_numActiveCalls - In the implementation block @property (assign,nonatomic) BOOL hasNumBackgroundWifiClients; @property (assign,nonatomic) unsigned long long numBackgroundWifiClients; //@synthesize numBackgroundWifiClients=_numBackgroundWifiClients - In the implementation block -(unsigned)reachabilityFlags; -(void)setHasTimestamp:(BOOL)arg1 ; -(void)setDataIndicator:(NSString *)arg1 ; -(id)copyWithZone:(NSZone*)arg1 ; -(void)writeTo:(id)arg1 ; -(BOOL)readFrom:(id)arg1 ; -(void)setReachabilityFlags:(unsigned)arg1 ; -(unsigned long long)timestamp; -(void)setTimestamp:(unsigned long long)arg1 ; -(void)setCellData:(BOOL)arg1 ; -(void)setDnsEnabled:(BOOL)arg1 ; -(void)setRoamingAllowed:(BOOL)arg1 ; -(void)setNumActiveCalls:(unsigned long long)arg1 ; -(void)setNumBackgroundWifiClients:(unsigned long long)arg1 ; -(void)setWifiEnabled:(BOOL)arg1 ; -(NSString *)dataIndicator; -(void)mergeFrom:(id)arg1 ; -(void)copyTo:(id)arg1 ; -(BOOL)isEqual:(id)arg1 ; -(BOOL)hasTimestamp; -(unsigned long long)hash; -(BOOL)wifiEnabled; -(id)description; -(id)dictionaryRepresentation; -(void)setHasReachabilityFlags:(BOOL)arg1 ; -(BOOL)hasReachabilityFlags; -(void)setHasDnsEnabled:(BOOL)arg1 ; -(BOOL)hasDnsEnabled; -(void)setHasWifiEnabled:(BOOL)arg1 ; -(BOOL)hasWifiEnabled; -(void)setDataInterface:(int)arg1 ; -(void)setHasDataInterface:(BOOL)arg1 ; -(BOOL)hasDataInterface; -(void)setHasCellData:(BOOL)arg1 ; -(BOOL)hasCellData; -(BOOL)hasDataIndicator; -(void)setHasRoamingAllowed:(BOOL)arg1 ; -(BOOL)hasRoamingAllowed; -(void)setHasNumActiveCalls:(BOOL)arg1 ; -(BOOL)hasNumActiveCalls; -(void)setHasNumBackgroundWifiClients:(BOOL)arg1 ; -(BOOL)hasNumBackgroundWifiClients; -(BOOL)dnsEnabled; -(int)dataInterface; -(BOOL)cellData; -(BOOL)roamingAllowed; -(unsigned long long)numActiveCalls; -(unsigned long long)numBackgroundWifiClients; @end
/* poly1305.h * * Copyright (C) 2006-2014 wolfSSL Inc. * * This file is part of CyaSSL. * * CyaSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CyaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_POLY1305 #ifndef CTAO_CRYPT_POLY1305_H #define CTAO_CRYPT_POLY1305_H #include <cyassl/ctaocrypt/types.h> #ifdef __cplusplus extern "C" { #endif /* auto detect between 32bit / 64bit */ #define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__)) #define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64)) #define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && \ ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)))) #if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT) #define POLY130564 #else #define POLY130532 #endif enum { POLY1305 = 7, POLY1305_BLOCK_SIZE = 16, POLY1305_DIGEST_SIZE = 16, POLY1305_PAD_SIZE = 56 }; /* Poly1305 state */ typedef struct Poly1305 { #if defined(POLY130564) word64 r[3]; word64 h[3]; word64 pad[2]; #else word32 r[5]; word32 h[5]; word32 pad[4]; #endif size_t leftover; unsigned char buffer[POLY1305_BLOCK_SIZE]; unsigned char final; } Poly1305; /* does init */ CYASSL_API int Poly1305SetKey(Poly1305* poly1305, const byte* key, word32 kySz); CYASSL_API int Poly1305Update(Poly1305* poly1305, const byte*, word32); CYASSL_API int Poly1305Final(Poly1305* poly1305, byte* tag); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* CTAO_CRYPT_POLY1305_H */ #endif /* HAVE_POLY1305 */
#include <linux/init.h> // init.h 헤더파일 추가 #include <linux/module.h> // module.h 헤더파일 추가 #include <linux/kernel.h> // kernel.h 헤더파일 추가 #include <linux/list.h> // list.h 헤더파일 추가 #include <linux/slab.h> // slab.h 헤더파일 추가 struct birthday { int month; // 월 int day; // 일 int year; // 년 struct list_head list; // *next, *perv 변수를 통해 리스트 노드를 연결할 수 있게 한다. }; static LIST_HEAD(birthday_list); // 생일 정보를 연결리스트에 담을 수 있도록, birthday_list라는 이름으로 연결리스트의 헤드 포인터(시작점)를 초기화한다. int module_birthday_init(void) { struct birthday *person; // birthday 포인터를 담을 수 있도록 선언한 임시변수이다. person = kmalloc(sizeof(*person), GFP_KERNEL); // birthday 포인터의 크기만큼, 커널용 메모리를 할당한다. person->month = 7; person->day = 8; person->year = 1996; INIT_LIST_HEAD(&person->list); // list_head의 각 항목을 초기화 한다. list_add_tail(&person->list, &birthday_list); // 위의 항목을 연결리스트에 추가한다. person = kmalloc(sizeof(*person), GFP_KERNEL); person->month = 12; person->day = 28; person->year = 2000; INIT_LIST_HEAD(&person->list); // list_head의 각 항목을 초기화 한다. list_add_tail(&person->list, &birthday_list); // 위의 항목을 연결리스트에 추가한다. person = kmalloc(sizeof(*person), GFP_KERNEL); person->month = 2; person->day = 1; person->year = 2000; INIT_LIST_HEAD(&person->list); // list_head의 각 항목을 초기화 한다. list_add_tail(&person->list, &birthday_list); // 위의 항목을 연결리스트에 추가한다. person = kmalloc(sizeof(*person), GFP_KERNEL); person->month = 6; person->day = 3; person->year = 1234; INIT_LIST_HEAD(&person->list); // list_head의 각 항목을 초기화 한다. list_add_tail(&person->list, &birthday_list); // 위의 항목을 연결리스트에 추가한다. list_for_each_entry(person, &birthday_list, list) // person 변수가 cursor역할을 하여 순회하라. 순회 대상은 birthday_List이다. list_head는 list라는 변수(멤버)의 이름으로 저장되어있다. { // node를 순차적으로 접근할 수 있도록 하는 매크로이다. printk(KERN_INFO "person %d %d %d\n", person->month, person->day, person->year); // <6> KERN_INFO 레벨에서 생일에 대한 정보 로그 출력 } return 0; // 정상적인 종료를 알림 } void module_birthday_exit(void) { struct birthday *ptr, *next; // 밑의 순회 매크로를 사용하기 위해서 cursor과 임시변수 next를 선언. list_for_each_entry_safe(ptr, next, &birthday_list, list) // prt 변수가 cursor 역할을 하여 순회하라. next를 임시변수로 사용하며, 순회 대상(HEAD)은 birthday_list이다. { // list_head는 list라는 변수(멤버)의 이름으로 저장되어있다. // list_for_each_entry_safe는 list_for_each_entry와 다르게 순회 중간에 node가 삭제되어도 정지하지 않는다. printk(KERN_INFO "Removing %d %d %d\n", ptr->month, ptr->day, ptr->year); // <6> KERN_INFO 레벨에서 삭제할 생일에 대한 정보 로그 출력 list_del(&ptr->list); // ptr포인터에 담긴 엔트리(node)를 삭제한다. kfree(ptr); // 동적할당된 ptr 메모리를 반납한다. } } module_init(module_birthday_init); // 유저레벨에서 insmod를 통해 birthday.ko를 적재할 경우, module_birthday_init 함수가 호출되도록 한다. module_exit(module_birthday_exit); // 유저레벨에서 rmmod를 통해 birthday.ko 모듈을 해제할 경우, module_birthday_exit 함수가 호출되도록 한다. MODULE_LICENSE("GPL"); // birthday.ko 모듈의 라이선스를 GPL(GNU Public License)로 지정하여 오픈 소스임을 명시한다. MODULE_DESCRIPTION("Birthday List"); // 모듈의 설명을 Birthday List로 한다. MODULE_AUTHOR("LANI"); // 모듈 제작자를 LANI로 한다.
/*========================================================================= Program: Visualization Toolkit Module: vtkImageGaussianSource.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /** * @class vtkImageGaussianSource * @brief Create an image with Gaussian pixel values. * * vtkImageGaussianSource just produces images with pixel values determined * by a Gaussian. */ #ifndef vtkImageGaussianSource_h #define vtkImageGaussianSource_h #include "vtkImagingSourcesModule.h" // For export macro #include "vtkImageAlgorithm.h" class VTKIMAGINGSOURCES_EXPORT vtkImageGaussianSource : public vtkImageAlgorithm { public: static vtkImageGaussianSource *New(); vtkTypeMacro(vtkImageGaussianSource,vtkImageAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); /** * Set/Get the extent of the whole output image. */ void SetWholeExtent(int xMinx, int xMax, int yMin, int yMax, int zMin, int zMax); //@{ /** * Set/Get the center of the Gaussian. */ vtkSetVector3Macro(Center, double); vtkGetVector3Macro(Center, double); //@} //@{ /** * Set/Get the Maximum value of the gaussian */ vtkSetMacro(Maximum, double); vtkGetMacro(Maximum, double); //@} //@{ /** * Set/Get the standard deviation of the gaussian */ vtkSetMacro(StandardDeviation, double); vtkGetMacro(StandardDeviation, double); //@} protected: vtkImageGaussianSource(); ~vtkImageGaussianSource() {} double StandardDeviation; int WholeExtent[6]; double Center[3]; double Maximum; virtual int RequestInformation (vtkInformation *, vtkInformationVector**, vtkInformationVector *); virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); private: vtkImageGaussianSource(const vtkImageGaussianSource&) VTK_DELETE_FUNCTION; void operator=(const vtkImageGaussianSource&) VTK_DELETE_FUNCTION; }; #endif
/** @file Copyright (C) 2019, vit9696. All rights reserved. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef OC_CONFIGURATION_LIB_H #define OC_CONFIGURATION_LIB_H #include <Library/DebugLib.h> #include <Library/OcSerializeLib.h> #include <Library/OcBootManagementLib.h> /** ACPI section **/ /// /// ACPI added tables. /// #define OC_ACPI_ADD_ENTRY_FIELDS(_, __) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Path , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_ACPI_ADD_ENTRY) #define OC_ACPI_ADD_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_ACPI_ADD_ENTRY, _, __) OC_DECLARE (OC_ACPI_ADD_ARRAY) /// /// ACPI table deletion. /// #define OC_ACPI_DELETE_ENTRY_FIELDS(_, __) \ _(BOOLEAN , All , , FALSE , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(UINT8 , OemTableId , [8] , {0} , () ) \ _(UINT32 , TableLength , , 0 , () ) \ _(UINT8 , TableSignature , [4] , {0} , () ) OC_DECLARE (OC_ACPI_DELETE_ENTRY) #define OC_ACPI_DELETE_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_ACPI_DELETE_ENTRY, _, __) OC_DECLARE (OC_ACPI_DELETE_ARRAY) /// /// ACPI patches. /// #define OC_ACPI_PATCH_ENTRY_FIELDS(_, __) \ _(UINT32 , Count , , 0 , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_STRING , Base , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(UINT32 , BaseSkip , , 0 , () ) \ _(UINT32 , Limit , , 0 , () ) \ _(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_DATA , ReplaceMask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(UINT8 , OemTableId , [8] , {0} , () ) \ _(UINT32 , TableLength , , 0 , () ) \ _(UINT8 , TableSignature , [4] , {0} , () ) \ _(UINT32 , Skip , , 0 , () ) OC_DECLARE (OC_ACPI_PATCH_ENTRY) #define OC_ACPI_PATCH_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_ACPI_PATCH_ENTRY, _, __) OC_DECLARE (OC_ACPI_PATCH_ARRAY) /// /// ACPI quirks. /// #define OC_ACPI_QUIRKS_FIELDS(_, __) \ _(BOOLEAN , FadtEnableReset , , FALSE , ()) \ _(BOOLEAN , NormalizeHeaders , , FALSE , ()) \ _(BOOLEAN , RebaseRegions , , FALSE , ()) \ _(BOOLEAN , ResetHwSig , , FALSE , ()) \ _(BOOLEAN , ResetLogoStatus , , FALSE , ()) \ _(BOOLEAN , SyncTableIds , , FALSE , ()) OC_DECLARE (OC_ACPI_QUIRKS) #define OC_ACPI_CONFIG_FIELDS(_, __) \ _(OC_ACPI_ADD_ARRAY , Add , , OC_CONSTR2 (OC_ACPI_ADD_ARRAY, _, __) , OC_DESTR (OC_ACPI_ADD_ARRAY)) \ _(OC_ACPI_DELETE_ARRAY , Delete , , OC_CONSTR2 (OC_ACPI_DELETE_ARRAY, _, __) , OC_DESTR (OC_ACPI_DELETE_ARRAY)) \ _(OC_ACPI_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_ACPI_PATCH_ARRAY, _, __) , OC_DESTR (OC_ACPI_PATCH_ARRAY)) \ _(OC_ACPI_QUIRKS , Quirks , , OC_CONSTR2 (OC_ACPI_QUIRKS, _, __) , OC_DESTR (OC_ACPI_QUIRKS)) OC_DECLARE (OC_ACPI_CONFIG) /** Apple bootloader section **/ #define OC_BOOTER_WL_ENTRY_FIELDS(_, __) \ _(UINT64 , Address , , 0 , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_BOOTER_WL_ENTRY) #define OC_BOOTER_WL_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_BOOTER_WL_ENTRY, _, __) OC_DECLARE (OC_BOOTER_WL_ARRAY) /// /// Bootloader patches. /// #define OC_BOOTER_PATCH_ENTRY_FIELDS(_, __) \ _(OC_STRING , Arch , , OC_STRING_CONSTR ("Any", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(UINT32 , Count , , 0 , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_STRING , Identifier , , OC_STRING_CONSTR ("Any", _, __), OC_DESTR (OC_STRING) ) \ _(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_DATA , ReplaceMask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(UINT32 , Limit , , 0 , () ) \ _(UINT32 , Skip , , 0 , () ) OC_DECLARE (OC_BOOTER_PATCH_ENTRY) #define OC_BOOTER_PATCH_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_BOOTER_PATCH_ENTRY, _, __) OC_DECLARE (OC_BOOTER_PATCH_ARRAY) /// /// Apple bootloader quirks. /// #define OC_BOOTER_QUIRKS_FIELDS(_, __) \ _(BOOLEAN , AllowRelocationBlock , , FALSE , ()) \ _(BOOLEAN , AvoidRuntimeDefrag , , FALSE , ()) \ _(BOOLEAN , DevirtualiseMmio , , FALSE , ()) \ _(BOOLEAN , DisableSingleUser , , FALSE , ()) \ _(BOOLEAN , DisableVariableWrite , , FALSE , ()) \ _(BOOLEAN , DiscardHibernateMap , , FALSE , ()) \ _(BOOLEAN , EnableSafeModeSlide , , FALSE , ()) \ _(BOOLEAN , EnableWriteUnprotector , , FALSE , ()) \ _(BOOLEAN , ForceBooterSignature , , FALSE , ()) \ _(BOOLEAN , ForceExitBootServices , , FALSE , ()) \ _(BOOLEAN , ProtectMemoryRegions , , FALSE , ()) \ _(BOOLEAN , ProtectSecureBoot , , FALSE , ()) \ _(BOOLEAN , ProtectUefiServices , , FALSE , ()) \ _(BOOLEAN , ProvideCustomSlide , , FALSE , ()) \ _(UINT8 , ProvideMaxSlide , , 0 , ()) \ _(BOOLEAN , RebuildAppleMemoryMap , , FALSE , ()) \ _(BOOLEAN , SetupVirtualMap , , FALSE , ()) \ _(BOOLEAN , SignalAppleOS , , FALSE , ()) \ _(BOOLEAN , SyncRuntimePermissions , , FALSE , ()) OC_DECLARE (OC_BOOTER_QUIRKS) /// /// Apple bootloader section. /// #define OC_BOOTER_CONFIG_FIELDS(_, __) \ _(OC_BOOTER_WL_ARRAY , MmioWhitelist , , OC_CONSTR2 (OC_BOOTER_WL_ARRAY, _, __) , OC_DESTR (OC_BOOTER_WL_ARRAY)) \ _(OC_BOOTER_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_BOOTER_PATCH_ARRAY, _, __) , OC_DESTR (OC_BOOTER_PATCH_ARRAY)) \ _(OC_BOOTER_QUIRKS , Quirks , , OC_CONSTR2 (OC_BOOTER_QUIRKS, _, __) , OC_DESTR (OC_BOOTER_QUIRKS)) OC_DECLARE (OC_BOOTER_CONFIG) /** DeviceProperties section **/ /// /// Device properties is an associative map of devices with their property key value maps. /// #define OC_DEV_PROP_ADD_MAP_FIELDS(_, __) \ OC_MAP (OC_STRING, OC_ASSOC, _, __) OC_DECLARE (OC_DEV_PROP_ADD_MAP) #define OC_DEV_PROP_DELETE_ENTRY_FIELDS(_, __) \ OC_ARRAY (OC_STRING, _, __) OC_DECLARE (OC_DEV_PROP_DELETE_ENTRY) #define OC_DEV_PROP_DELETE_MAP_FIELDS(_, __) \ OC_MAP (OC_STRING, OC_DEV_PROP_DELETE_ENTRY, _, __) OC_DECLARE (OC_DEV_PROP_DELETE_MAP) #define OC_DEV_PROP_CONFIG_FIELDS(_, __) \ _(OC_DEV_PROP_ADD_MAP , Add , , OC_CONSTR2 (OC_DEV_PROP_ADD_MAP, _, __) , OC_DESTR (OC_DEV_PROP_ADD_MAP)) \ _(OC_DEV_PROP_DELETE_MAP , Delete , , OC_CONSTR2 (OC_DEV_PROP_DELETE_MAP, _, __) , OC_DESTR (OC_DEV_PROP_DELETE_MAP)) OC_DECLARE (OC_DEV_PROP_CONFIG) /** KernelSpace section **/ /// /// KernelSpace kext adds. /// #define OC_KERNEL_ADD_ENTRY_FIELDS(_, __) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Arch , , OC_STRING_CONSTR ("Any", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , MaxKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , MinKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Identifier , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , BundlePath , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , ExecutablePath , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , PlistPath , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(UINT8 * , ImageData , , NULL , OcFreePointer ) \ _(UINT32 , ImageDataSize , , 0 , () ) \ _(CHAR8 * , PlistData , , NULL , OcFreePointer ) \ _(UINT32 , PlistDataSize , , 0 , () ) OC_DECLARE (OC_KERNEL_ADD_ENTRY) #define OC_KERNEL_ADD_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_KERNEL_ADD_ENTRY, _, __) OC_DECLARE (OC_KERNEL_ADD_ARRAY) /// /// KernelSpace kext blocks. /// #define OC_KERNEL_BLOCK_ENTRY_FIELDS(_, __) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Arch , , OC_STRING_CONSTR ("Any", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Identifier , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , MaxKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , MinKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_KERNEL_BLOCK_ENTRY) #define OC_KERNEL_BLOCK_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_KERNEL_BLOCK_ENTRY, _, __) OC_DECLARE (OC_KERNEL_BLOCK_ARRAY) /// /// Kernel emulation preferences. /// #define OC_KERNEL_EMULATE_FIELDS(_,__) \ _(UINT32 , Cpuid1Data , [4] , {0} , () ) \ _(UINT32 , Cpuid1Mask , [4] , {0} , () ) \ _(BOOLEAN , DummyPowerManagement, , FALSE , () ) \ _(OC_STRING , MaxKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , MinKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_KERNEL_EMULATE) /// /// KernelSpace forced loaded kexts. /// #define OC_KERNEL_FORCE_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_KERNEL_ADD_ENTRY, _, __) OC_DECLARE (OC_KERNEL_FORCE_ARRAY) /// /// KernelSpace patches. /// #define OC_KERNEL_PATCH_ENTRY_FIELDS(_, __) \ _(OC_STRING , Arch , , OC_STRING_CONSTR ("Any", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Base , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(UINT32 , Count , , 0 , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_STRING , Identifier , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_STRING , MaxKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , MinKernel , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(OC_DATA , ReplaceMask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \ _(UINT32 , Limit , , 0 , () ) \ _(UINT32 , Skip , , 0 , () ) OC_DECLARE (OC_KERNEL_PATCH_ENTRY) #define OC_KERNEL_PATCH_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_KERNEL_PATCH_ENTRY, _, __) OC_DECLARE (OC_KERNEL_PATCH_ARRAY) /// /// KernelSpace quirks. /// #define OC_KERNEL_QUIRKS_FIELDS(_, __) \ _(INT64 , SetApfsTrimTimeout , , -1 , ()) \ _(BOOLEAN , AppleCpuPmCfgLock , , FALSE , ()) \ _(BOOLEAN , AppleXcpmCfgLock , , FALSE , ()) \ _(BOOLEAN , AppleXcpmExtraMsrs , , FALSE , ()) \ _(BOOLEAN , AppleXcpmForceBoost , , FALSE , ()) \ _(BOOLEAN , CustomSmbiosGuid , , FALSE , ()) \ _(BOOLEAN , DisableIoMapper , , FALSE , ()) \ _(BOOLEAN , DisableLinkeditJettison , , FALSE , ()) \ _(BOOLEAN , DisableRtcChecksum , , FALSE , ()) \ _(BOOLEAN , ExtendBTFeatureFlags , , FALSE , ()) \ _(BOOLEAN , ExternalDiskIcons , , FALSE , ()) \ _(BOOLEAN , ForceSecureBootScheme , , FALSE , ()) \ _(BOOLEAN , IncreasePciBarSize , , FALSE , ()) \ _(BOOLEAN , LapicKernelPanic , , FALSE , ()) \ _(BOOLEAN , LegacyCommpage , , FALSE , ()) \ _(BOOLEAN , PanicNoKextDump , , FALSE , ()) \ _(BOOLEAN , PowerTimeoutKernelPanic , , FALSE , ()) \ _(BOOLEAN , ProvideCurrentCpuInfo , , FALSE , ()) \ _(BOOLEAN , ThirdPartyDrives , , FALSE , ()) \ _(BOOLEAN , XhciPortLimit , , FALSE , ()) OC_DECLARE (OC_KERNEL_QUIRKS) /// /// KernelSpace operation scheme. /// #define OC_KERNEL_SCHEME_FIELDS(_, __) \ _(OC_STRING , KernelArch , , OC_STRING_CONSTR ("Auto", _, __), OC_DESTR (OC_STRING)) \ _(OC_STRING , KernelCache , , OC_STRING_CONSTR ("Auto", _, __), OC_DESTR (OC_STRING)) \ _(BOOLEAN , CustomKernel , , FALSE , ()) \ _(BOOLEAN , FuzzyMatch , , FALSE , ()) OC_DECLARE (OC_KERNEL_SCHEME) #define OC_KERNEL_CONFIG_FIELDS(_, __) \ _(OC_KERNEL_ADD_ARRAY , Add , , OC_CONSTR2 (OC_KERNEL_ADD_ARRAY, _, __) , OC_DESTR (OC_KERNEL_ADD_ARRAY)) \ _(OC_KERNEL_BLOCK_ARRAY , Block , , OC_CONSTR2 (OC_KERNEL_BLOCK_ARRAY, _, __) , OC_DESTR (OC_KERNEL_BLOCK_ARRAY)) \ _(OC_KERNEL_EMULATE , Emulate , , OC_CONSTR2 (OC_KERNEL_EMULATE, _, __) , OC_DESTR (OC_KERNEL_EMULATE)) \ _(OC_KERNEL_FORCE_ARRAY , Force , , OC_CONSTR2 (OC_KERNEL_FORCE_ARRAY, _, __) , OC_DESTR (OC_KERNEL_FORCE_ARRAY)) \ _(OC_KERNEL_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_KERNEL_PATCH_ARRAY, _, __) , OC_DESTR (OC_KERNEL_PATCH_ARRAY)) \ _(OC_KERNEL_QUIRKS , Quirks , , OC_CONSTR2 (OC_KERNEL_QUIRKS, _, __) , OC_DESTR (OC_KERNEL_QUIRKS)) \ _(OC_KERNEL_SCHEME , Scheme , , OC_CONSTR2 (OC_KERNEL_SCHEME, _, __) , OC_DESTR (OC_KERNEL_SCHEME)) OC_DECLARE (OC_KERNEL_CONFIG) /** Misc section **/ #define OC_MISC_BLESS_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_STRING, _, __) OC_DECLARE (OC_MISC_BLESS_ARRAY) #define OC_MISC_BOOT_FIELDS(_, __) \ _(OC_STRING , PickerMode , , OC_STRING_CONSTR ("Builtin", _, __) , OC_DESTR (OC_STRING)) \ _(OC_STRING , HibernateMode , , OC_STRING_CONSTR ("None", _, __) , OC_DESTR (OC_STRING)) \ _(OC_STRING , LauncherOption , , OC_STRING_CONSTR ("Disabled", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , LauncherPath , , OC_STRING_CONSTR ("Default", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT32 , ConsoleAttributes , , 0 , ()) \ _(UINT32 , PickerAttributes , , 0 , ()) \ _(OC_STRING , PickerVariant , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING)) \ _(UINT32 , TakeoffDelay , , 0 , ()) \ _(UINT32 , Timeout , , 0 , ()) \ _(BOOLEAN , PickerAudioAssist , , FALSE , ()) \ _(BOOLEAN , HideAuxiliary , , FALSE , ()) \ _(BOOLEAN , PollAppleHotKeys , , FALSE , ()) \ _(BOOLEAN , ShowPicker , , FALSE , ()) OC_DECLARE (OC_MISC_BOOT) #define OC_MISC_DEBUG_FIELDS(_, __) \ _(UINT64 , DisplayLevel , , 0 , ()) \ _(UINT32 , DisplayDelay , , 0 , ()) \ _(UINT32 , Target , , 0 , ()) \ _(BOOLEAN , AppleDebug , , FALSE , ()) \ _(BOOLEAN , ApplePanic , , FALSE , ()) \ _(BOOLEAN , DisableWatchDog , , FALSE , ()) \ _(BOOLEAN , SerialInit , , FALSE , ()) \ _(BOOLEAN , SysReport , , FALSE , ()) OC_DECLARE (OC_MISC_DEBUG) #define OCS_EXPOSE_BOOT_PATH 1U #define OCS_EXPOSE_VERSION_VAR 2U #define OCS_EXPOSE_VERSION_UI 4U #define OCS_EXPOSE_OEM_INFO 8U #define OCS_EXPOSE_VERSION (OCS_EXPOSE_VERSION_VAR | OCS_EXPOSE_VERSION_UI) #define OCS_EXPOSE_ALL_BITS (\ OCS_EXPOSE_BOOT_PATH | OCS_EXPOSE_VERSION_VAR | \ OCS_EXPOSE_VERSION_UI | OCS_EXPOSE_OEM_INFO) typedef enum { OcsVaultOptional = 0, OcsVaultBasic = 1, OcsVaultSecure = 2, } OCS_VAULT_MODE; #define OC_MISC_SECURITY_FIELDS(_, __) \ _(OC_STRING , Vault , , OC_STRING_CONSTR ("Secure", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , DmgLoading , , OC_STRING_CONSTR ("Signed", _, __), OC_DESTR (OC_STRING) ) \ _(UINT32 , ScanPolicy , , OC_SCAN_DEFAULT_POLICY , ()) \ _(UINT32 , ExposeSensitiveData , , OCS_EXPOSE_VERSION , ()) \ _(BOOLEAN , AllowNvramReset , , FALSE , ()) \ _(BOOLEAN , AllowSetDefault , , FALSE , ()) \ _(BOOLEAN , AllowToggleSip , , FALSE , ()) \ _(BOOLEAN , AuthRestart , , FALSE , ()) \ _(BOOLEAN , BlacklistAppleUpdate , , FALSE , ()) \ _(BOOLEAN , EnablePassword , , FALSE , ()) \ _(UINT8 , PasswordHash , [64] , {0} , ()) \ _(OC_DATA , PasswordSalt , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA)) \ _(OC_STRING , SecureBootModel , , OC_STRING_CONSTR ("Default", _, __), OC_DESTR (OC_STRING) ) \ _(UINT64 , ApECID , , 0 , ()) \ _(UINT64 , HaltLevel , , 0x80000000 , ()) OC_DECLARE (OC_MISC_SECURITY) #define OC_MISC_TOOLS_ENTRY_FIELDS(_, __) \ _(OC_STRING , Arguments , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Flavour , , OC_STRING_CONSTR ("Auto", _, __), OC_DESTR (OC_STRING) ) \ _(BOOLEAN , Auxiliary , , FALSE , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(BOOLEAN , RealPath , , FALSE , () ) \ _(BOOLEAN , TextMode , , FALSE , () ) \ _(OC_STRING , Name , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Path , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_MISC_TOOLS_ENTRY) #define OC_MISC_TOOLS_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_MISC_TOOLS_ENTRY, _, __) OC_DECLARE (OC_MISC_TOOLS_ARRAY) #define OC_MISC_CONFIG_FIELDS(_, __) \ _(OC_MISC_BLESS_ARRAY , BlessOverride , , OC_CONSTR2 (OC_MISC_BLESS_ARRAY, _, __) , OC_DESTR (OC_MISC_BLESS_ARRAY)) \ _(OC_MISC_BOOT , Boot , , OC_CONSTR2 (OC_MISC_BOOT, _, __) , OC_DESTR (OC_MISC_BOOT)) \ _(OC_MISC_DEBUG , Debug , , OC_CONSTR2 (OC_MISC_DEBUG, _, __) , OC_DESTR (OC_MISC_DEBUG)) \ _(OC_MISC_SECURITY , Security , , OC_CONSTR2 (OC_MISC_SECURITY, _, __) , OC_DESTR (OC_MISC_SECURITY)) \ _(OC_MISC_TOOLS_ARRAY , Entries , , OC_CONSTR2 (OC_MISC_TOOLS_ARRAY, _, __) , OC_DESTR (OC_MISC_TOOLS_ARRAY)) \ _(OC_MISC_TOOLS_ARRAY , Tools , , OC_CONSTR2 (OC_MISC_TOOLS_ARRAY, _, __) , OC_DESTR (OC_MISC_TOOLS_ARRAY)) OC_DECLARE (OC_MISC_CONFIG) /** NVRAM section **/ /// /// NVRAM values is an associative map of GUIDS with their property key value maps. /// #define OC_NVRAM_ADD_MAP_FIELDS(_, __) \ OC_MAP (OC_STRING, OC_ASSOC, _, __) OC_DECLARE (OC_NVRAM_ADD_MAP) #define OC_NVRAM_DELETE_ENTRY_FIELDS(_, __) \ OC_ARRAY (OC_STRING, _, __) OC_DECLARE (OC_NVRAM_DELETE_ENTRY) #define OC_NVRAM_DELETE_MAP_FIELDS(_, __) \ OC_MAP (OC_STRING, OC_NVRAM_DELETE_ENTRY, _, __) OC_DECLARE (OC_NVRAM_DELETE_MAP) #define OC_NVRAM_LEGACY_ENTRY_FIELDS(_, __) \ OC_ARRAY (OC_STRING, _, __) OC_DECLARE (OC_NVRAM_LEGACY_ENTRY) #define OC_NVRAM_LEGACY_MAP_FIELDS(_, __) \ OC_MAP (OC_STRING, OC_NVRAM_LEGACY_ENTRY, _, __) OC_DECLARE (OC_NVRAM_LEGACY_MAP) #define OC_NVRAM_CONFIG_FIELDS(_, __) \ _(OC_NVRAM_ADD_MAP , Add , , OC_CONSTR2 (OC_NVRAM_ADD_MAP, _, __) , OC_DESTR (OC_NVRAM_ADD_MAP)) \ _(OC_NVRAM_DELETE_MAP , Delete , , OC_CONSTR2 (OC_NVRAM_DELETE_MAP, _, __) , OC_DESTR (OC_NVRAM_DELETE_MAP)) \ _(OC_NVRAM_LEGACY_MAP , Legacy , , OC_CONSTR2 (OC_NVRAM_LEGACY_MAP, _, __) , OC_DESTR (OC_NVRAM_LEGACY_MAP)) \ _(BOOLEAN , LegacyEnable , , FALSE , () ) \ _(BOOLEAN , LegacyOverwrite , , FALSE , () ) \ _(BOOLEAN , WriteFlash , , FALSE , () ) OC_DECLARE (OC_NVRAM_CONFIG) /** Platform information configuration **/ #define OC_PLATFORM_GENERIC_CONFIG_FIELDS(_, __) \ _(OC_STRING , SystemProductName , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemUuid , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , Mlb , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemMemoryStatus , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT16 , ProcessorType , , 0 , () ) \ _(UINT8 , Rom , [6] , {0} , () ) \ _(BOOLEAN , SpoofVendor , , FALSE , () ) \ _(BOOLEAN , AdviseFeatures , , FALSE , () ) \ _(BOOLEAN , MaxBIOSVersion , , FALSE , () ) OC_DECLARE (OC_PLATFORM_GENERIC_CONFIG) #define OC_PLATFORM_DATA_HUB_CONFIG_FIELDS(_, __) \ _(OC_STRING , PlatformName , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemProductName , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemUuid , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BoardProduct , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT8 , BoardRevision , [1] , {0} , () ) \ _(UINT64 , StartupPowerEvents , , 0 , () ) \ _(UINT64 , InitialTSC , , 0 , () ) \ _(UINT64 , FSBFrequency , , 0 , () ) \ _(UINT64 , ARTFrequency , , 0 , () ) \ _(UINT32 , DevicePathsSupported, , 0 , () ) \ _(UINT8 , SmcRevision , [6] , {0} , () ) \ _(UINT8 , SmcBranch , [8] , {0} , () ) \ _(UINT8 , SmcPlatform , [8] , {0} , () ) OC_DECLARE (OC_PLATFORM_DATA_HUB_CONFIG) #define OC_PLATFORM_MEMORY_DEVICE_ENTRY_FIELDS(_, __) \ _(UINT32 , Size , , 0 , () ) \ _(UINT16 , Speed , , 0 , () ) \ _(OC_STRING , DeviceLocator , , OC_STRING_CONSTR ("Unknown", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , BankLocator , , OC_STRING_CONSTR ("Unknown", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Manufacturer , , OC_STRING_CONSTR ("Unknown", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , SerialNumber , , OC_STRING_CONSTR ("Unknown", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , AssetTag , , OC_STRING_CONSTR ("Unknown", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , PartNumber , , OC_STRING_CONSTR ("Unknown", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_PLATFORM_MEMORY_DEVICE_ENTRY) #define OC_PLATFORM_MEMORY_DEVICES_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_PLATFORM_MEMORY_DEVICE_ENTRY, _, __) OC_DECLARE (OC_PLATFORM_MEMORY_DEVICES_ARRAY) #define OC_PLATFORM_MEMORY_CONFIG_FIELDS(_, __) \ _(UINT8 , FormFactor , , 0x2 , () ) \ _(UINT8 , Type , , 0x2 , () ) \ _(UINT16 , TypeDetail , , 0x4 , () ) \ _(UINT16 , TotalWidth , , 0xFFFF , () ) \ _(UINT16 , DataWidth , , 0xFFFF , () ) \ _(UINT8 , ErrorCorrection, , 0x3 , () ) \ _(UINT64 , MaxCapacity , , 0 , () ) \ _(OC_PLATFORM_MEMORY_DEVICES_ARRAY, Devices , , OC_CONSTR3 (OC_PLATFORM_MEMORY_DEVICES_ARRAY, _, __), OC_DESTR (OC_PLATFORM_MEMORY_DEVICES_ARRAY)) OC_DECLARE (OC_PLATFORM_MEMORY_CONFIG) #define OC_PLATFORM_NVRAM_CONFIG_FIELDS(_, __) \ _(OC_STRING , Bid , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , Mlb , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemUuid , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT8 , Rom , [6] , {0} , () ) \ _(UINT64 , FirmwareFeatures , , 0 , () ) \ _(UINT64 , FirmwareFeaturesMask , , 0 , () ) OC_DECLARE (OC_PLATFORM_NVRAM_CONFIG) #define OC_PLATFORM_SMBIOS_CONFIG_FIELDS(_, __) \ _(OC_STRING , BIOSVendor , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BIOSVersion , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BIOSReleaseDate , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemManufacturer , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemProductName , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemVersion , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemUuid , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemSKUNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , SystemFamily , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BoardManufacturer , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BoardProduct , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BoardVersion , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BoardSerialNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , BoardAssetTag , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT8 , BoardType , , 0 , () ) \ _(OC_STRING , BoardLocationInChassis, , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , ChassisManufacturer , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT8 , ChassisType , , 0 , () ) \ _(OC_STRING , ChassisVersion , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , ChassisSerialNumber , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , ChassisAssetTag , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(UINT32 , PlatformFeature , , 0xFFFFFFFFU , () ) \ _(UINT64 , FirmwareFeatures , , 0 , () ) \ _(UINT64 , FirmwareFeaturesMask , , 0 , () ) \ _(UINT8 , SmcVersion , [16] , {0} , () ) \ _(UINT16 , ProcessorType , , 0 , () ) OC_DECLARE (OC_PLATFORM_SMBIOS_CONFIG) #define OC_PLATFORM_CONFIG_FIELDS(_, __) \ _(BOOLEAN , Automatic , , FALSE , ()) \ _(BOOLEAN , CustomMemory , , FALSE , ()) \ _(BOOLEAN , UpdateDataHub , , FALSE , ()) \ _(BOOLEAN , UpdateNvram , , FALSE , ()) \ _(BOOLEAN , UpdateSmbios , , FALSE , ()) \ _(BOOLEAN , UseRawUuidEncoding , , FALSE , ()) \ _(OC_STRING , UpdateSmbiosMode , , OC_STRING_CONSTR ("Create", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_PLATFORM_GENERIC_CONFIG , Generic , , OC_CONSTR2 (OC_PLATFORM_GENERIC_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_GENERIC_CONFIG)) \ _(OC_PLATFORM_DATA_HUB_CONFIG , DataHub , , OC_CONSTR2 (OC_PLATFORM_DATA_HUB_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_DATA_HUB_CONFIG)) \ _(OC_PLATFORM_MEMORY_CONFIG , Memory , , OC_CONSTR2 (OC_PLATFORM_MEMORY_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_MEMORY_CONFIG)) \ _(OC_PLATFORM_NVRAM_CONFIG , Nvram , , OC_CONSTR2 (OC_PLATFORM_NVRAM_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_NVRAM_CONFIG)) \ _(OC_PLATFORM_SMBIOS_CONFIG , Smbios , , OC_CONSTR2 (OC_PLATFORM_SMBIOS_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_SMBIOS_CONFIG)) OC_DECLARE (OC_PLATFORM_CONFIG) /** Uefi section **/ /// /// Drivers is an ordered array of drivers to load. /// #define OC_UEFI_DRIVER_ENTRY_FIELDS(_, __) \ _(OC_STRING , Arguments , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) \ _(BOOLEAN , Enabled , , FALSE , ()) \ _(OC_STRING , Path , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING) ) OC_DECLARE (OC_UEFI_DRIVER_ENTRY) #define OC_UEFI_DRIVER_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_UEFI_DRIVER_ENTRY, _, __) OC_DECLARE (OC_UEFI_DRIVER_ARRAY) /// /// APFS is a set of options for APFS file system support. /// #define OC_UEFI_APFS_FIELDS(_, __) \ _(UINT64 , MinVersion , , 0 , ()) \ _(UINT32 , MinDate , , 0 , ()) \ _(BOOLEAN , EnableJumpstart , , FALSE , ()) \ _(BOOLEAN , GlobalConnect , , FALSE , ()) \ _(BOOLEAN , HideVerbose , , FALSE , ()) \ _(BOOLEAN , JumpstartHotPlug , , FALSE , ()) OC_DECLARE (OC_UEFI_APFS) /// /// AppleInput is a set of options to configure OpenCore's reverse engingeered then customised implementation of the AppleEvent protocol. /// #define OC_UEFI_APPLEINPUT_FIELDS(_, __) \ _(OC_STRING , AppleEvent , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING) ) \ _(BOOLEAN , CustomDelays , , FALSE , ()) \ _(UINT16 , KeyInitialDelay , , 50 , ()) \ _(UINT16 , KeySubsequentDelay , , 5 , ()) \ _(BOOLEAN , GraphicsInputMirroring, , FALSE , ()) \ _(UINT16 , PointerSpeedDiv , , 1 , ()) \ _(UINT16 , PointerSpeedMul , , 1 , ()) OC_DECLARE (OC_UEFI_APPLEINPUT) /// /// Audio is a set of options for sound configuration. /// #define OC_UEFI_AUDIO_FIELDS(_, __) \ _(OC_STRING , AudioDevice , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING)) \ _(OC_STRING , PlayChime , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING)) \ _(UINT32 , SetupDelay , , 0 , ()) \ _(UINT16 , VolumeAmplifier , , 0 , ()) \ _(BOOLEAN , AudioSupport , , FALSE , ()) \ _(UINT8 , AudioCodec , , 0 , ()) \ _(UINT8 , AudioOut , , 0 , ()) \ _(UINT8 , MinimumVolume , , 0 , ()) \ _(BOOLEAN , ResetTrafficClass , , FALSE , ()) OC_DECLARE (OC_UEFI_AUDIO) /// /// Input is a set of options to support advanced input. /// #define OC_UEFI_INPUT_FIELDS(_, __) \ _(OC_STRING , KeySupportMode , , OC_STRING_CONSTR ("Auto", _, __) , OC_DESTR (OC_STRING)) \ _(OC_STRING , PointerSupportMode , , OC_STRING_CONSTR ("", _, __) , OC_DESTR (OC_STRING)) \ _(UINT32 , TimerResolution , , 0 , ()) \ _(UINT8 , KeyForgetThreshold , , 0 , ()) \ _(BOOLEAN , KeySupport , , FALSE , ()) \ _(BOOLEAN , KeyFiltering , , FALSE , ()) \ _(BOOLEAN , KeySwap , , FALSE , ()) \ _(BOOLEAN , PointerSupport , , FALSE , ()) OC_DECLARE (OC_UEFI_INPUT) /// /// Output is a set of options to support advanced output. /// #define OC_UEFI_OUTPUT_FIELDS(_, __) \ _(OC_STRING , ConsoleMode , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING)) \ _(OC_STRING , Resolution , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING)) \ _(OC_STRING , TextRenderer , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING)) \ _(OC_STRING , GopPassThrough , , OC_STRING_CONSTR ("Disabled", _, __), OC_DESTR (OC_STRING)) \ _(BOOLEAN , IgnoreTextInGraphics , , FALSE , ()) \ _(BOOLEAN , ClearScreenOnModeSwitch , , FALSE , ()) \ _(BOOLEAN , ProvideConsoleGop , , FALSE , ()) \ _(BOOLEAN , ReplaceTabWithSpace , , FALSE , ()) \ _(BOOLEAN , ReconnectOnResChange , , FALSE , ()) \ _(BOOLEAN , SanitiseClearScreen , , FALSE , ()) \ _(BOOLEAN , UgaPassThrough , , FALSE , ()) \ _(BOOLEAN , DirectGopRendering , , FALSE , ()) \ _(BOOLEAN , ForceResolution , , FALSE , ()) OC_DECLARE (OC_UEFI_OUTPUT) /// /// Prefer own protocol implementation for these protocols. /// #define OC_UEFI_PROTOCOL_OVERRIDES_FIELDS(_, __) \ _(BOOLEAN , AppleAudio , , FALSE , ()) \ _(BOOLEAN , AppleBootPolicy , , FALSE , ()) \ _(BOOLEAN , AppleDebugLog , , FALSE , ()) \ _(BOOLEAN , AppleEg2Info , , FALSE , ()) \ _(BOOLEAN , AppleFramebufferInfo , , FALSE , ()) \ _(BOOLEAN , AppleImageConversion , , FALSE , ()) \ _(BOOLEAN , AppleImg4Verification , , FALSE , ()) \ _(BOOLEAN , AppleKeyMap , , FALSE , ()) \ _(BOOLEAN , AppleRtcRam , , FALSE , ()) \ _(BOOLEAN , AppleSecureBoot , , FALSE , ()) \ _(BOOLEAN , AppleSmcIo , , FALSE , ()) \ _(BOOLEAN , AppleUserInterfaceTheme , , FALSE , ()) \ _(BOOLEAN , DataHub , , FALSE , ()) \ _(BOOLEAN , DeviceProperties , , FALSE , ()) \ _(BOOLEAN , FirmwareVolume , , FALSE , ()) \ _(BOOLEAN , HashServices , , FALSE , ()) \ _(BOOLEAN , OSInfo , , FALSE , ()) \ _(BOOLEAN , UnicodeCollation , , FALSE , ()) OC_DECLARE (OC_UEFI_PROTOCOL_OVERRIDES) /// /// Quirks is a set of hacks for different types of firmware. /// #define OC_UEFI_QUIRKS_FIELDS(_, __) \ _(UINT32 , ExitBootServicesDelay , , 0 , ()) \ _(UINT32 , TscSyncTimeout , , 0 , ()) \ _(BOOLEAN , ActivateHpetSupport , , FALSE , ()) \ _(BOOLEAN , DisableSecurityPolicy , , FALSE , ()) \ _(BOOLEAN , EnableVectorAcceleration , , FALSE , ()) \ _(BOOLEAN , ForgeUefiSupport , , FALSE , ()) \ _(BOOLEAN , IgnoreInvalidFlexRatio , , FALSE , ()) \ _(BOOLEAN , ReleaseUsbOwnership , , FALSE , ()) \ _(BOOLEAN , ReloadOptionRoms , , FALSE , ()) \ _(BOOLEAN , RequestBootVarRouting , , FALSE , ()) \ _(BOOLEAN , UnblockFsConnect , , FALSE , ()) \ _(BOOLEAN , ForceOcWriteFlash , , FALSE , ()) OC_DECLARE (OC_UEFI_QUIRKS) /// /// Reserved memory entries adds. /// #define OC_UEFI_RSVD_ENTRY_FIELDS(_, __) \ _(UINT64 , Address , , 0 , () ) \ _(UINT64 , Size , , 0 , () ) \ _(BOOLEAN , Enabled , , FALSE , () ) \ _(OC_STRING , Type , , OC_STRING_CONSTR ("Reserved", _, __), OC_DESTR (OC_STRING) ) \ _(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) OC_DECLARE (OC_UEFI_RSVD_ENTRY) #define OC_UEFI_RSVD_ARRAY_FIELDS(_, __) \ OC_ARRAY (OC_UEFI_RSVD_ENTRY, _, __) OC_DECLARE (OC_UEFI_RSVD_ARRAY) /// /// Uefi contains firmware tweaks and extra drivers. /// #define OC_UEFI_CONFIG_FIELDS(_, __) \ _(BOOLEAN , ConnectDrivers , , FALSE , ()) \ _(OC_UEFI_APFS , Apfs , , OC_CONSTR2 (OC_UEFI_APFS, _, __) , OC_DESTR (OC_UEFI_APFS)) \ _(OC_UEFI_APPLEINPUT , AppleInput , , OC_CONSTR2 (OC_UEFI_APPLEINPUT, _, __) , OC_DESTR (OC_UEFI_APPLEINPUT)) \ _(OC_UEFI_AUDIO , Audio , , OC_CONSTR2 (OC_UEFI_AUDIO, _, __) , OC_DESTR (OC_UEFI_AUDIO)) \ _(OC_UEFI_DRIVER_ARRAY , Drivers , , OC_CONSTR2 (OC_UEFI_DRIVER_ARRAY, _, __) , OC_DESTR (OC_UEFI_DRIVER_ARRAY)) \ _(OC_UEFI_INPUT , Input , , OC_CONSTR2 (OC_UEFI_INPUT, _, __) , OC_DESTR (OC_UEFI_INPUT)) \ _(OC_UEFI_OUTPUT , Output , , OC_CONSTR2 (OC_UEFI_OUTPUT, _, __) , OC_DESTR (OC_UEFI_OUTPUT)) \ _(OC_UEFI_PROTOCOL_OVERRIDES , ProtocolOverrides , , OC_CONSTR2 (OC_UEFI_PROTOCOL_OVERRIDES, _, __) , OC_DESTR (OC_UEFI_PROTOCOL_OVERRIDES)) \ _(OC_UEFI_QUIRKS , Quirks , , OC_CONSTR2 (OC_UEFI_QUIRKS, _, __) , OC_DESTR (OC_UEFI_QUIRKS)) \ _(OC_UEFI_RSVD_ARRAY , ReservedMemory , , OC_CONSTR2 (OC_UEFI_RSVD_ARRAY, _, __) , OC_DESTR (OC_UEFI_RSVD_ARRAY)) OC_DECLARE (OC_UEFI_CONFIG) /** Root configuration **/ #define OC_GLOBAL_CONFIG_FIELDS(_, __) \ _(OC_ACPI_CONFIG , Acpi , , OC_CONSTR1 (OC_ACPI_CONFIG, _, __) , OC_DESTR (OC_ACPI_CONFIG)) \ _(OC_BOOTER_CONFIG , Booter , , OC_CONSTR1 (OC_BOOTER_CONFIG, _, __) , OC_DESTR (OC_BOOTER_CONFIG)) \ _(OC_DEV_PROP_CONFIG , DeviceProperties , , OC_CONSTR1 (OC_DEV_PROP_CONFIG, _, __) , OC_DESTR (OC_DEV_PROP_CONFIG)) \ _(OC_KERNEL_CONFIG , Kernel , , OC_CONSTR1 (OC_KERNEL_CONFIG, _, __) , OC_DESTR (OC_KERNEL_CONFIG)) \ _(OC_MISC_CONFIG , Misc , , OC_CONSTR1 (OC_MISC_CONFIG, _, __) , OC_DESTR (OC_MISC_CONFIG)) \ _(OC_NVRAM_CONFIG , Nvram , , OC_CONSTR1 (OC_NVRAM_CONFIG, _, __) , OC_DESTR (OC_NVRAM_CONFIG)) \ _(OC_PLATFORM_CONFIG , PlatformInfo , , OC_CONSTR1 (OC_PLATFORM_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_CONFIG)) \ _(OC_UEFI_CONFIG , Uefi , , OC_CONSTR1 (OC_UEFI_CONFIG, _, __) , OC_DESTR (OC_UEFI_CONFIG)) OC_DECLARE (OC_GLOBAL_CONFIG) /** Initialize configuration with plist data. @param[out] Config Configuration structure. @param[in] Buffer Configuration buffer in plist format. @param[in] Size Configuration buffer size. @param[in,out] ErrorCount Errors detected duing initialisation. Optional. @retval EFI_SUCCESS on success **/ EFI_STATUS OcConfigurationInit ( OUT OC_GLOBAL_CONFIG *Config, IN VOID *Buffer, IN UINT32 Size, IN OUT UINT32 *ErrorCount OPTIONAL ); /** Free configuration structure. @param[in,out] Config Configuration structure. **/ VOID OcConfigurationFree ( IN OUT OC_GLOBAL_CONFIG *Config ); #endif // OC_CONFIGURATION_LIB_H
#ifndef CAFFE2_CORE_NET_PARALLEL_H #define CAFFE2_CORE_NET_PARALLEL_H #include "caffe2/core/net_async_base.h" #include "caffe2/core/net_async_task_graph.h" C10_DECLARE_string(caffe2_task_graph_engine); namespace caffe2 { class ParallelNetExecutorHelper; class TORCH_API ParallelNet : public NetBase { public: ParallelNet(const std::shared_ptr<const NetDef>& net_def, Workspace* ws); bool RunAsync() override; void Wait() override; bool SupportsAsync() override; std::vector<OperatorBase*> GetOperators() const override; TaskThreadPoolBase* Pool(const DeviceOption& device_option); protected: bool handleRunError() override; virtual void finishRun(); virtual void reset(); ExecutionOptions options_; int num_workers_; std::unique_ptr<ParallelNetExecutorHelper> helper_; std::shared_ptr<AsyncTaskGraphBase> task_graph_; AsyncTaskFuture* run_future_; std::vector<dag_utils::OperatorNode> operator_nodes_; std::vector<OperatorBase*> operators_; std::mutex pools_mutex_; typedef std::unordered_map< int, std::unordered_map<int, std::shared_ptr<TaskThreadPoolBase>>> PoolsMap; PoolsMap cpu_pools_; PoolsMap gpu_pools_; TaskThreadPoolBase* poolGetter(PoolsMap& pools, int device_type, int device_id, int pool_size); friend class ParallelNetExecutorHelper; C10_DISABLE_COPY_AND_ASSIGN(ParallelNet); }; C10_DECLARE_SHARED_REGISTRY( TaskGraphRegistry, AsyncTaskGraphBase, ExecutorHelper*, const ExecutionOptions&); std::shared_ptr<AsyncTaskGraphBase> GetAsyncTaskGraph( ExecutorHelper* helper, const ExecutionOptions& options); class ParallelNetExecutorHelper : public ExecutorHelper { public: explicit ParallelNetExecutorHelper(ParallelNet* net) : net_(net) {} TaskThreadPoolBase* GetPool(const DeviceOption& option) const override { return net_->Pool(option); } std::vector<OperatorBase*> GetOperators() const override { return net_->GetOperators(); } int GetNumWorkers() const override { return net_->num_workers_; } private: ParallelNet* net_; }; } // namespace caffe2 #endif // CAFFE2_CORE_NET_PARALLEL_H
#include "upb/def.h" #include <ctype.h> #include <errno.h> #include <setjmp.h> #include <stdlib.h> #include <string.h> #include "google/protobuf/descriptor.upb.h" #include "upb/port_def.inc" typedef struct { size_t len; char str[1]; /* Null-terminated string data follows. */ } str_t; struct upb_fielddef { const upb_filedef *file; const upb_msgdef *msgdef; const char *full_name; const char *json_name; union { int64_t sint; uint64_t uint; double dbl; float flt; bool boolean; str_t *str; } defaultval; const upb_oneofdef *oneof; union { const upb_msgdef *msgdef; const upb_enumdef *enumdef; const google_protobuf_FieldDescriptorProto *unresolved; } sub; uint32_t number_; uint16_t index_; uint16_t layout_index; uint32_t selector_base; /* Used to index into a upb::Handlers table. */ bool is_extension_; bool lazy_; bool packed_; bool proto3_optional_; upb_descriptortype_t type_; upb_label_t label_; }; struct upb_msgdef { const upb_msglayout *layout; const upb_filedef *file; const char *full_name; uint32_t selector_count; uint32_t submsg_field_count; /* Tables for looking up fields by number and name. */ upb_inttable itof; upb_strtable ntof; const upb_fielddef *fields; const upb_oneofdef *oneofs; int field_count; int oneof_count; int real_oneof_count; /* Is this a map-entry message? */ bool map_entry; upb_wellknowntype_t well_known_type; /* TODO(haberman): proper extension ranges (there can be multiple). */ }; struct upb_enumdef { const upb_filedef *file; const char *full_name; upb_strtable ntoi; upb_inttable iton; int32_t defaultval; }; struct upb_oneofdef { const upb_msgdef *parent; const char *full_name; int field_count; bool synthetic; const upb_fielddef **fields; upb_strtable ntof; upb_inttable itof; }; struct upb_filedef { const char *name; const char *package; const char *phpprefix; const char *phpnamespace; upb_syntax_t syntax; const upb_filedef **deps; const upb_msgdef *msgs; const upb_enumdef *enums; const upb_fielddef *exts; int dep_count; int msg_count; int enum_count; int ext_count; }; struct upb_symtab { upb_arena *arena; upb_strtable syms; /* full_name -> packed def ptr */ upb_strtable files; /* file_name -> upb_filedef* */ size_t bytes_loaded; }; /* Inside a symtab we store tagged pointers to specific def types. */ typedef enum { UPB_DEFTYPE_FIELD = 0, /* Only inside symtab table. */ UPB_DEFTYPE_MSG = 1, UPB_DEFTYPE_ENUM = 2, /* Only inside message table. */ UPB_DEFTYPE_ONEOF = 1, UPB_DEFTYPE_FIELD_JSONNAME = 2 } upb_deftype_t; static const void *unpack_def(upb_value v, upb_deftype_t type) { uintptr_t num = (uintptr_t)upb_value_getconstptr(v); return (num & 3) == type ? (const void*)(num & ~3) : NULL; } static upb_value pack_def(const void *ptr, upb_deftype_t type) { uintptr_t num = (uintptr_t)ptr | type; return upb_value_constptr((const void*)num); } /* isalpha() etc. from <ctype.h> are locale-dependent, which we don't want. */ static bool upb_isbetween(char c, char low, char high) { return c >= low && c <= high; } static bool upb_isletter(char c) { return upb_isbetween(c, 'A', 'Z') || upb_isbetween(c, 'a', 'z') || c == '_'; } static bool upb_isalphanum(char c) { return upb_isletter(c) || upb_isbetween(c, '0', '9'); } static const char *shortdefname(const char *fullname) { const char *p; if (fullname == NULL) { return NULL; } else if ((p = strrchr(fullname, '.')) == NULL) { /* No '.' in the name, return the full string. */ return fullname; } else { /* Return one past the last '.'. */ return p + 1; } } /* All submessage fields are lower than all other fields. * Secondly, fields are increasing in order. */ uint32_t field_rank(const upb_fielddef *f) { uint32_t ret = upb_fielddef_number(f); const uint32_t high_bit = 1 << 30; UPB_ASSERT(ret < high_bit); if (!upb_fielddef_issubmsg(f)) ret |= high_bit; return ret; } int cmp_fields(const void *p1, const void *p2) { const upb_fielddef *f1 = *(upb_fielddef*const*)p1; const upb_fielddef *f2 = *(upb_fielddef*const*)p2; return field_rank(f1) - field_rank(f2); } /* A few implementation details of handlers. We put these here to avoid * a def -> handlers dependency. */ #define UPB_STATIC_SELECTOR_COUNT 3 /* Warning: also in upb/handlers.h. */ static uint32_t upb_handlers_selectorbaseoffset(const upb_fielddef *f) { return upb_fielddef_isseq(f) ? 2 : 0; } static uint32_t upb_handlers_selectorcount(const upb_fielddef *f) { uint32_t ret = 1; if (upb_fielddef_isseq(f)) ret += 2; /* STARTSEQ/ENDSEQ */ if (upb_fielddef_isstring(f)) ret += 2; /* [STRING]/STARTSTR/ENDSTR */ if (upb_fielddef_issubmsg(f)) { /* ENDSUBMSG (STARTSUBMSG is at table beginning) */ ret += 0; if (upb_fielddef_lazy(f)) { /* STARTSTR/ENDSTR/STRING (for lazy) */ ret += 3; } } return ret; } static void upb_status_setoom(upb_status *status) { upb_status_seterrmsg(status, "out of memory"); } static void assign_msg_wellknowntype(upb_msgdef *m) { const char *name = upb_msgdef_fullname(m); if (name == NULL) { m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED; return; } if (!strcmp(name, "google.protobuf.Any")) { m->well_known_type = UPB_WELLKNOWN_ANY; } else if (!strcmp(name, "google.protobuf.FieldMask")) { m->well_known_type = UPB_WELLKNOWN_FIELDMASK; } else if (!strcmp(name, "google.protobuf.Duration")) { m->well_known_type = UPB_WELLKNOWN_DURATION; } else if (!strcmp(name, "google.protobuf.Timestamp")) { m->well_known_type = UPB_WELLKNOWN_TIMESTAMP; } else if (!strcmp(name, "google.protobuf.DoubleValue")) { m->well_known_type = UPB_WELLKNOWN_DOUBLEVALUE; } else if (!strcmp(name, "google.protobuf.FloatValue")) { m->well_known_type = UPB_WELLKNOWN_FLOATVALUE; } else if (!strcmp(name, "google.protobuf.Int64Value")) { m->well_known_type = UPB_WELLKNOWN_INT64VALUE; } else if (!strcmp(name, "google.protobuf.UInt64Value")) { m->well_known_type = UPB_WELLKNOWN_UINT64VALUE; } else if (!strcmp(name, "google.protobuf.Int32Value")) { m->well_known_type = UPB_WELLKNOWN_INT32VALUE; } else if (!strcmp(name, "google.protobuf.UInt32Value")) { m->well_known_type = UPB_WELLKNOWN_UINT32VALUE; } else if (!strcmp(name, "google.protobuf.BoolValue")) { m->well_known_type = UPB_WELLKNOWN_BOOLVALUE; } else if (!strcmp(name, "google.protobuf.StringValue")) { m->well_known_type = UPB_WELLKNOWN_STRINGVALUE; } else if (!strcmp(name, "google.protobuf.BytesValue")) { m->well_known_type = UPB_WELLKNOWN_BYTESVALUE; } else if (!strcmp(name, "google.protobuf.Value")) { m->well_known_type = UPB_WELLKNOWN_VALUE; } else if (!strcmp(name, "google.protobuf.ListValue")) { m->well_known_type = UPB_WELLKNOWN_LISTVALUE; } else if (!strcmp(name, "google.protobuf.Struct")) { m->well_known_type = UPB_WELLKNOWN_STRUCT; } else { m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED; } } /* upb_enumdef ****************************************************************/ const char *upb_enumdef_fullname(const upb_enumdef *e) { return e->full_name; } const char *upb_enumdef_name(const upb_enumdef *e) { return shortdefname(e->full_name); } const upb_filedef *upb_enumdef_file(const upb_enumdef *e) { return e->file; } int32_t upb_enumdef_default(const upb_enumdef *e) { UPB_ASSERT(upb_enumdef_iton(e, e->defaultval)); return e->defaultval; } int upb_enumdef_numvals(const upb_enumdef *e) { return (int)upb_strtable_count(&e->ntoi); } void upb_enum_begin(upb_enum_iter *i, const upb_enumdef *e) { /* We iterate over the ntoi table, to account for duplicate numbers. */ upb_strtable_begin(i, &e->ntoi); } void upb_enum_next(upb_enum_iter *iter) { upb_strtable_next(iter); } bool upb_enum_done(upb_enum_iter *iter) { return upb_strtable_done(iter); } bool upb_enumdef_ntoi(const upb_enumdef *def, const char *name, size_t len, int32_t *num) { upb_value v; if (!upb_strtable_lookup2(&def->ntoi, name, len, &v)) { return false; } if (num) *num = upb_value_getint32(v); return true; } const char *upb_enumdef_iton(const upb_enumdef *def, int32_t num) { upb_value v; return upb_inttable_lookup32(&def->iton, num, &v) ? upb_value_getcstr(v) : NULL; } const char *upb_enum_iter_name(upb_enum_iter *iter) { return upb_strtable_iter_key(iter).data; } int32_t upb_enum_iter_number(upb_enum_iter *iter) { return upb_value_getint32(upb_strtable_iter_value(iter)); } /* upb_fielddef ***************************************************************/ const char *upb_fielddef_fullname(const upb_fielddef *f) { return f->full_name; } upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) { switch (f->type_) { case UPB_DESCRIPTOR_TYPE_DOUBLE: return UPB_TYPE_DOUBLE; case UPB_DESCRIPTOR_TYPE_FLOAT: return UPB_TYPE_FLOAT; case UPB_DESCRIPTOR_TYPE_INT64: case UPB_DESCRIPTOR_TYPE_SINT64: case UPB_DESCRIPTOR_TYPE_SFIXED64: return UPB_TYPE_INT64; case UPB_DESCRIPTOR_TYPE_INT32: case UPB_DESCRIPTOR_TYPE_SFIXED32: case UPB_DESCRIPTOR_TYPE_SINT32: return UPB_TYPE_INT32; case UPB_DESCRIPTOR_TYPE_UINT64: case UPB_DESCRIPTOR_TYPE_FIXED64: return UPB_TYPE_UINT64; case UPB_DESCRIPTOR_TYPE_UINT32: case UPB_DESCRIPTOR_TYPE_FIXED32: return UPB_TYPE_UINT32; case UPB_DESCRIPTOR_TYPE_ENUM: return UPB_TYPE_ENUM; case UPB_DESCRIPTOR_TYPE_BOOL: return UPB_TYPE_BOOL; case UPB_DESCRIPTOR_TYPE_STRING: return UPB_TYPE_STRING; case UPB_DESCRIPTOR_TYPE_BYTES: return UPB_TYPE_BYTES; case UPB_DESCRIPTOR_TYPE_GROUP: case UPB_DESCRIPTOR_TYPE_MESSAGE: return UPB_TYPE_MESSAGE; } UPB_UNREACHABLE(); } upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { return f->type_; } uint32_t upb_fielddef_index(const upb_fielddef *f) { return f->index_; } upb_label_t upb_fielddef_label(const upb_fielddef *f) { return f->label_; } uint32_t upb_fielddef_number(const upb_fielddef *f) { return f->number_; } bool upb_fielddef_isextension(const upb_fielddef *f) { return f->is_extension_; } bool upb_fielddef_lazy(const upb_fielddef *f) { return f->lazy_; } bool upb_fielddef_packed(const upb_fielddef *f) { return f->packed_; } const char *upb_fielddef_name(const upb_fielddef *f) { return shortdefname(f->full_name); } const char *upb_fielddef_jsonname(const upb_fielddef *f) { return f->json_name; } uint32_t upb_fielddef_selectorbase(const upb_fielddef *f) { return f->selector_base; } const upb_filedef *upb_fielddef_file(const upb_fielddef *f) { return f->file; } const upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f) { return f->msgdef; } const upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f) { return f->oneof; } const upb_oneofdef *upb_fielddef_realcontainingoneof(const upb_fielddef *f) { if (!f->oneof || upb_oneofdef_issynthetic(f->oneof)) return NULL; return f->oneof; } static void chkdefaulttype(const upb_fielddef *f, int ctype) { UPB_UNUSED(f); UPB_UNUSED(ctype); } int64_t upb_fielddef_defaultint64(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_INT64); return f->defaultval.sint; } int32_t upb_fielddef_defaultint32(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_INT32); return (int32_t)f->defaultval.sint; } uint64_t upb_fielddef_defaultuint64(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_UINT64); return f->defaultval.uint; } uint32_t upb_fielddef_defaultuint32(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_UINT32); return (uint32_t)f->defaultval.uint; } bool upb_fielddef_defaultbool(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_BOOL); return f->defaultval.boolean; } float upb_fielddef_defaultfloat(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_FLOAT); return f->defaultval.flt; } double upb_fielddef_defaultdouble(const upb_fielddef *f) { chkdefaulttype(f, UPB_TYPE_DOUBLE); return f->defaultval.dbl; } const char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) { str_t *str = f->defaultval.str; UPB_ASSERT(upb_fielddef_type(f) == UPB_TYPE_STRING || upb_fielddef_type(f) == UPB_TYPE_BYTES || upb_fielddef_type(f) == UPB_TYPE_ENUM); if (str) { if (len) *len = str->len; return str->str; } else { if (len) *len = 0; return NULL; } } const upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f) { return upb_fielddef_type(f) == UPB_TYPE_MESSAGE ? f->sub.msgdef : NULL; } const upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f) { return upb_fielddef_type(f) == UPB_TYPE_ENUM ? f->sub.enumdef : NULL; } const upb_msglayout_field *upb_fielddef_layout(const upb_fielddef *f) { return &f->msgdef->layout->fields[f->layout_index]; } bool upb_fielddef_issubmsg(const upb_fielddef *f) { return upb_fielddef_type(f) == UPB_TYPE_MESSAGE; } bool upb_fielddef_isstring(const upb_fielddef *f) { return upb_fielddef_type(f) == UPB_TYPE_STRING || upb_fielddef_type(f) == UPB_TYPE_BYTES; } bool upb_fielddef_isseq(const upb_fielddef *f) { return upb_fielddef_label(f) == UPB_LABEL_REPEATED; } bool upb_fielddef_isprimitive(const upb_fielddef *f) { return !upb_fielddef_isstring(f) && !upb_fielddef_issubmsg(f); } bool upb_fielddef_ismap(const upb_fielddef *f) { return upb_fielddef_isseq(f) && upb_fielddef_issubmsg(f) && upb_msgdef_mapentry(upb_fielddef_msgsubdef(f)); } bool upb_fielddef_hassubdef(const upb_fielddef *f) { return upb_fielddef_issubmsg(f) || upb_fielddef_type(f) == UPB_TYPE_ENUM; } bool upb_fielddef_haspresence(const upb_fielddef *f) { if (upb_fielddef_isseq(f)) return false; return upb_fielddef_issubmsg(f) || upb_fielddef_containingoneof(f) || f->file->syntax == UPB_SYNTAX_PROTO2; } static bool between(int32_t x, int32_t low, int32_t high) { return x >= low && x <= high; } bool upb_fielddef_checklabel(int32_t label) { return between(label, 1, 3); } bool upb_fielddef_checktype(int32_t type) { return between(type, 1, 11); } bool upb_fielddef_checkintfmt(int32_t fmt) { return between(fmt, 1, 3); } bool upb_fielddef_checkdescriptortype(int32_t type) { return between(type, 1, 18); } /* upb_msgdef *****************************************************************/ const char *upb_msgdef_fullname(const upb_msgdef *m) { return m->full_name; } const upb_filedef *upb_msgdef_file(const upb_msgdef *m) { return m->file; } const char *upb_msgdef_name(const upb_msgdef *m) { return shortdefname(m->full_name); } upb_syntax_t upb_msgdef_syntax(const upb_msgdef *m) { return m->file->syntax; } size_t upb_msgdef_selectorcount(const upb_msgdef *m) { return m->selector_count; } uint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m) { return m->submsg_field_count; } const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i) { upb_value val; return upb_inttable_lookup32(&m->itof, i, &val) ? upb_value_getconstptr(val) : NULL; } const upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name, size_t len) { upb_value val; if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { return NULL; } return unpack_def(val, UPB_DEFTYPE_FIELD); } const upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name, size_t len) { upb_value val; if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { return NULL; } return unpack_def(val, UPB_DEFTYPE_ONEOF); } bool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len, const upb_fielddef **f, const upb_oneofdef **o) { upb_value val; if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { return false; } *o = unpack_def(val, UPB_DEFTYPE_ONEOF); *f = unpack_def(val, UPB_DEFTYPE_FIELD); return *o || *f; /* False if this was a JSON name. */ } const upb_fielddef *upb_msgdef_lookupjsonname(const upb_msgdef *m, const char *name, size_t len) { upb_value val; const upb_fielddef* f; if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) { return NULL; } f = unpack_def(val, UPB_DEFTYPE_FIELD); if (!f) f = unpack_def(val, UPB_DEFTYPE_FIELD_JSONNAME); return f; } int upb_msgdef_numfields(const upb_msgdef *m) { return m->field_count; } int upb_msgdef_numoneofs(const upb_msgdef *m) { return m->oneof_count; } int upb_msgdef_numrealoneofs(const upb_msgdef *m) { return m->real_oneof_count; } int upb_msgdef_fieldcount(const upb_msgdef *m) { return m->field_count; } int upb_msgdef_oneofcount(const upb_msgdef *m) { return m->oneof_count; } int upb_msgdef_realoneofcount(const upb_msgdef *m) { return m->real_oneof_count; } const upb_msglayout *upb_msgdef_layout(const upb_msgdef *m) { return m->layout; } const upb_fielddef *upb_msgdef_field(const upb_msgdef *m, int i) { UPB_ASSERT(i >= 0 && i < m->field_count); return &m->fields[i]; } const upb_oneofdef *upb_msgdef_oneof(const upb_msgdef *m, int i) { UPB_ASSERT(i >= 0 && i < m->oneof_count); return &m->oneofs[i]; } bool upb_msgdef_mapentry(const upb_msgdef *m) { return m->map_entry; } upb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m) { return m->well_known_type; } bool upb_msgdef_isnumberwrapper(const upb_msgdef *m) { upb_wellknowntype_t type = upb_msgdef_wellknowntype(m); return type >= UPB_WELLKNOWN_DOUBLEVALUE && type <= UPB_WELLKNOWN_UINT32VALUE; } bool upb_msgdef_iswrapper(const upb_msgdef *m) { upb_wellknowntype_t type = upb_msgdef_wellknowntype(m); return type >= UPB_WELLKNOWN_DOUBLEVALUE && type <= UPB_WELLKNOWN_BOOLVALUE; } void upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m) { upb_inttable_begin(iter, &m->itof); } void upb_msg_field_next(upb_msg_field_iter *iter) { upb_inttable_next(iter); } bool upb_msg_field_done(const upb_msg_field_iter *iter) { return upb_inttable_done(iter); } upb_fielddef *upb_msg_iter_field(const upb_msg_field_iter *iter) { return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter)); } void upb_msg_field_iter_setdone(upb_msg_field_iter *iter) { upb_inttable_iter_setdone(iter); } bool upb_msg_field_iter_isequal(const upb_msg_field_iter * iter1, const upb_msg_field_iter * iter2) { return upb_inttable_iter_isequal(iter1, iter2); } void upb_msg_oneof_begin(upb_msg_oneof_iter *iter, const upb_msgdef *m) { upb_strtable_begin(iter, &m->ntof); /* We need to skip past any initial fields. */ while (!upb_strtable_done(iter) && !unpack_def(upb_strtable_iter_value(iter), UPB_DEFTYPE_ONEOF)) { upb_strtable_next(iter); } } void upb_msg_oneof_next(upb_msg_oneof_iter *iter) { /* We need to skip past fields to return only oneofs. */ do { upb_strtable_next(iter); } while (!upb_strtable_done(iter) && !unpack_def(upb_strtable_iter_value(iter), UPB_DEFTYPE_ONEOF)); } bool upb_msg_oneof_done(const upb_msg_oneof_iter *iter) { return upb_strtable_done(iter); } const upb_oneofdef *upb_msg_iter_oneof(const upb_msg_oneof_iter *iter) { return unpack_def(upb_strtable_iter_value(iter), UPB_DEFTYPE_ONEOF); } void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter *iter) { upb_strtable_iter_setdone(iter); } bool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1, const upb_msg_oneof_iter *iter2) { return upb_strtable_iter_isequal(iter1, iter2); } /* upb_oneofdef ***************************************************************/ const char *upb_oneofdef_name(const upb_oneofdef *o) { return shortdefname(o->full_name); } const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o) { return o->parent; } int upb_oneofdef_fieldcount(const upb_oneofdef *o) { return o->field_count; } const upb_fielddef *upb_oneofdef_field(const upb_oneofdef *o, int i) { UPB_ASSERT(i < o->field_count); return o->fields[i]; } int upb_oneofdef_numfields(const upb_oneofdef *o) { return o->field_count; } uint32_t upb_oneofdef_index(const upb_oneofdef *o) { return o - o->parent->oneofs; } bool upb_oneofdef_issynthetic(const upb_oneofdef *o) { return o->synthetic; } const upb_fielddef *upb_oneofdef_ntof(const upb_oneofdef *o, const char *name, size_t length) { upb_value val; return upb_strtable_lookup2(&o->ntof, name, length, &val) ? upb_value_getptr(val) : NULL; } const upb_fielddef *upb_oneofdef_itof(const upb_oneofdef *o, uint32_t num) { upb_value val; return upb_inttable_lookup32(&o->itof, num, &val) ? upb_value_getptr(val) : NULL; } void upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o) { upb_inttable_begin(iter, &o->itof); } void upb_oneof_next(upb_oneof_iter *iter) { upb_inttable_next(iter); } bool upb_oneof_done(upb_oneof_iter *iter) { return upb_inttable_done(iter); } upb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter) { return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter)); } void upb_oneof_iter_setdone(upb_oneof_iter *iter) { upb_inttable_iter_setdone(iter); } /* upb_filedef ****************************************************************/ const char *upb_filedef_name(const upb_filedef *f) { return f->name; } const char *upb_filedef_package(const upb_filedef *f) { return f->package; } const char *upb_filedef_phpprefix(const upb_filedef *f) { return f->phpprefix; } const char *upb_filedef_phpnamespace(const upb_filedef *f) { return f->phpnamespace; } upb_syntax_t upb_filedef_syntax(const upb_filedef *f) { return f->syntax; } int upb_filedef_msgcount(const upb_filedef *f) { return f->msg_count; } int upb_filedef_depcount(const upb_filedef *f) { return f->dep_count; } int upb_filedef_enumcount(const upb_filedef *f) { return f->enum_count; } const upb_filedef *upb_filedef_dep(const upb_filedef *f, int i) { return i < 0 || i >= f->dep_count ? NULL : f->deps[i]; } const upb_msgdef *upb_filedef_msg(const upb_filedef *f, int i) { return i < 0 || i >= f->msg_count ? NULL : &f->msgs[i]; } const upb_enumdef *upb_filedef_enum(const upb_filedef *f, int i) { return i < 0 || i >= f->enum_count ? NULL : &f->enums[i]; } void upb_symtab_free(upb_symtab *s) { upb_arena_free(s->arena); upb_gfree(s); } upb_symtab *upb_symtab_new(void) { upb_symtab *s = upb_gmalloc(sizeof(*s)); upb_alloc *alloc; if (!s) { return NULL; } s->arena = upb_arena_new(); s->bytes_loaded = 0; alloc = upb_arena_alloc(s->arena); if (!upb_strtable_init2(&s->syms, UPB_CTYPE_CONSTPTR, 32, alloc) || !upb_strtable_init2(&s->files, UPB_CTYPE_CONSTPTR, 4, alloc)) { upb_arena_free(s->arena); upb_gfree(s); s = NULL; } return s; } const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) { upb_value v; return upb_strtable_lookup(&s->syms, sym, &v) ? unpack_def(v, UPB_DEFTYPE_MSG) : NULL; } const upb_msgdef *upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym, size_t len) { upb_value v; return upb_strtable_lookup2(&s->syms, sym, len, &v) ? unpack_def(v, UPB_DEFTYPE_MSG) : NULL; } const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) { upb_value v; return upb_strtable_lookup(&s->syms, sym, &v) ? unpack_def(v, UPB_DEFTYPE_ENUM) : NULL; } const upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name) { upb_value v; return upb_strtable_lookup(&s->files, name, &v) ? upb_value_getconstptr(v) : NULL; } const upb_filedef *upb_symtab_lookupfile2( const upb_symtab *s, const char *name, size_t len) { upb_value v; return upb_strtable_lookup2(&s->files, name, len, &v) ? upb_value_getconstptr(v) : NULL; } int upb_symtab_filecount(const upb_symtab *s) { return (int)upb_strtable_count(&s->files); } /* Code to build defs from descriptor protos. *********************************/ /* There is a question of how much validation to do here. It will be difficult * to perfectly match the amount of validation performed by proto2. But since * this code is used to directly build defs from Ruby (for example) we do need * to validate important constraints like uniqueness of names and numbers. */ #define CHK_OOM(x) if (!(x)) { symtab_oomerr(ctx); } typedef struct { upb_symtab *symtab; upb_filedef *file; /* File we are building. */ upb_arena *file_arena; /* Allocate defs here. */ upb_alloc *alloc; /* Alloc of file_arena, for tables. */ const upb_msglayout **layouts; /* NULL if we should build layouts. */ upb_status *status; /* Record errors here. */ jmp_buf err; /* longjmp() on error. */ } symtab_addctx; UPB_NORETURN UPB_NOINLINE static void symtab_errf(symtab_addctx *ctx, const char *fmt, ...) { va_list argp; va_start(argp, fmt); upb_status_vseterrf(ctx->status, fmt, argp); va_end(argp); UPB_LONGJMP(ctx->err, 1); } UPB_NORETURN UPB_NOINLINE static void symtab_oomerr(symtab_addctx *ctx) { upb_status_setoom(ctx->status); UPB_LONGJMP(ctx->err, 1); } void *symtab_alloc(symtab_addctx *ctx, size_t bytes) { void *ret = upb_arena_malloc(ctx->file_arena, bytes); if (!ret) symtab_oomerr(ctx); return ret; } static void check_ident(symtab_addctx *ctx, upb_strview name, bool full) { const char *str = name.data; size_t len = name.size; bool start = true; size_t i; for (i = 0; i < len; i++) { char c = str[i]; if (c == '.') { if (start || !full) { symtab_errf(ctx, "invalid name: unexpected '.' (%.*s)", (int)len, str); } start = true; } else if (start) { if (!upb_isletter(c)) { symtab_errf( ctx, "invalid name: path components must start with a letter (%.*s)", (int)len, str); } start = false; } else { if (!upb_isalphanum(c)) { symtab_errf(ctx, "invalid name: non-alphanumeric character (%.*s)", (int)len, str); } } } if (start) { symtab_errf(ctx, "invalid name: empty part (%.*s)", (int)len, str); } } static size_t div_round_up(size_t n, size_t d) { return (n + d - 1) / d; } static size_t upb_msgval_sizeof(upb_fieldtype_t type) { switch (type) { case UPB_TYPE_DOUBLE: case UPB_TYPE_INT64: case UPB_TYPE_UINT64: return 8; case UPB_TYPE_ENUM: case UPB_TYPE_INT32: case UPB_TYPE_UINT32: case UPB_TYPE_FLOAT: return 4; case UPB_TYPE_BOOL: return 1; case UPB_TYPE_MESSAGE: return sizeof(void*); case UPB_TYPE_BYTES: case UPB_TYPE_STRING: return sizeof(upb_strview); } UPB_UNREACHABLE(); } static uint8_t upb_msg_fielddefsize(const upb_fielddef *f) { if (upb_msgdef_mapentry(upb_fielddef_containingtype(f))) { upb_map_entry ent; UPB_ASSERT(sizeof(ent.k) == sizeof(ent.v)); return sizeof(ent.k); } else if (upb_fielddef_isseq(f)) { return sizeof(void*); } else { return upb_msgval_sizeof(upb_fielddef_type(f)); } } static uint32_t upb_msglayout_place(upb_msglayout *l, size_t size) { uint32_t ret; l->size = UPB_ALIGN_UP(l->size, size); ret = l->size; l->size += size; return ret; } static int field_number_cmp(const void *p1, const void *p2) { const upb_msglayout_field *f1 = p1; const upb_msglayout_field *f2 = p2; return f1->number - f2->number; } static void assign_layout_indices(const upb_msgdef *m, upb_msglayout_field *fields) { int i; int n = upb_msgdef_numfields(m); for (i = 0; i < n; i++) { upb_fielddef *f = (upb_fielddef*)upb_msgdef_itof(m, fields[i].number); UPB_ASSERT(f); f->layout_index = i; } } /* This function is the dynamic equivalent of message_layout.{cc,h} in upbc. * It computes a dynamic layout for all of the fields in |m|. */ static void make_layout(symtab_addctx *ctx, const upb_msgdef *m) { upb_msglayout *l = (upb_msglayout*)m->layout; upb_msg_field_iter it; upb_msg_oneof_iter oit; size_t hasbit; size_t submsg_count = m->submsg_field_count; const upb_msglayout **submsgs; upb_msglayout_field *fields; memset(l, 0, sizeof(*l) + sizeof(_upb_fasttable_entry)); fields = symtab_alloc(ctx, upb_msgdef_numfields(m) * sizeof(*fields)); submsgs = symtab_alloc(ctx, submsg_count * sizeof(*submsgs)); l->field_count = upb_msgdef_numfields(m); l->fields = fields; l->submsgs = submsgs; l->table_mask = 0; /* TODO(haberman): initialize fast tables so that reflection-based parsing * can get the same speeds as linked-in types. */ l->fasttable[0].field_parser = &fastdecode_generic; l->fasttable[0].field_data = 0; if (upb_msgdef_mapentry(m)) { /* TODO(haberman): refactor this method so this special case is more * elegant. */ const upb_fielddef *key = upb_msgdef_itof(m, 1); const upb_fielddef *val = upb_msgdef_itof(m, 2); fields[0].number = 1; fields[1].number = 2; fields[0].label = UPB_LABEL_OPTIONAL; fields[1].label = UPB_LABEL_OPTIONAL; fields[0].presence = 0; fields[1].presence = 0; fields[0].descriptortype = upb_fielddef_descriptortype(key); fields[1].descriptortype = upb_fielddef_descriptortype(val); fields[0].offset = 0; fields[1].offset = sizeof(upb_strview); fields[1].submsg_index = 0; if (upb_fielddef_type(val) == UPB_TYPE_MESSAGE) { submsgs[0] = upb_fielddef_msgsubdef(val)->layout; } l->field_count = 2; l->size = 2 * sizeof(upb_strview); l->size = UPB_ALIGN_UP(l->size, 8); return; } /* Allocate data offsets in three stages: * * 1. hasbits. * 2. regular fields. * 3. oneof fields. * * OPT: There is a lot of room for optimization here to minimize the size. */ /* Allocate hasbits and set basic field attributes. */ submsg_count = 0; for (upb_msg_field_begin(&it, m), hasbit = 0; !upb_msg_field_done(&it); upb_msg_field_next(&it)) { upb_fielddef* f = upb_msg_iter_field(&it); upb_msglayout_field *field = &fields[upb_fielddef_index(f)]; field->number = upb_fielddef_number(f); field->descriptortype = upb_fielddef_descriptortype(f); field->label = upb_fielddef_label(f); if (field->descriptortype == UPB_DTYPE_STRING && f->file->syntax == UPB_SYNTAX_PROTO2) { /* See TableDescriptorType() in upbc/generator.cc for details and * rationale. */ field->descriptortype = UPB_DTYPE_BYTES; } if (upb_fielddef_ismap(f)) { field->label = _UPB_LABEL_MAP; } else if (upb_fielddef_packed(f)) { field->label = _UPB_LABEL_PACKED; } if (upb_fielddef_issubmsg(f)) { const upb_msgdef *subm = upb_fielddef_msgsubdef(f); field->submsg_index = submsg_count++; submsgs[field->submsg_index] = subm->layout; } if (upb_fielddef_haspresence(f) && !upb_fielddef_realcontainingoneof(f)) { /* We don't use hasbit 0, so that 0 can indicate "no presence" in the * table. This wastes one hasbit, but we don't worry about it for now. */ field->presence = ++hasbit; } else { field->presence = 0; } } /* Account for space used by hasbits. */ l->size = div_round_up(hasbit, 8); /* Allocate non-oneof fields. */ for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it); upb_msg_field_next(&it)) { const upb_fielddef* f = upb_msg_iter_field(&it); size_t field_size = upb_msg_fielddefsize(f); size_t index = upb_fielddef_index(f); if (upb_fielddef_realcontainingoneof(f)) { /* Oneofs are handled separately below. */ continue; } fields[index].offset = upb_msglayout_place(l, field_size); } /* Allocate oneof fields. Each oneof field consists of a uint32 for the case * and space for the actual data. */ for (upb_msg_oneof_begin(&oit, m); !upb_msg_oneof_done(&oit); upb_msg_oneof_next(&oit)) { const upb_oneofdef* o = upb_msg_iter_oneof(&oit); upb_oneof_iter fit; size_t case_size = sizeof(uint32_t); /* Could potentially optimize this. */ size_t field_size = 0; uint32_t case_offset; uint32_t data_offset; if (upb_oneofdef_issynthetic(o)) continue; /* Calculate field size: the max of all field sizes. */ for (upb_oneof_begin(&fit, o); !upb_oneof_done(&fit); upb_oneof_next(&fit)) { const upb_fielddef* f = upb_oneof_iter_field(&fit); field_size = UPB_MAX(field_size, upb_msg_fielddefsize(f)); } /* Align and allocate case offset. */ case_offset = upb_msglayout_place(l, case_size); data_offset = upb_msglayout_place(l, field_size); for (upb_oneof_begin(&fit, o); !upb_oneof_done(&fit); upb_oneof_next(&fit)) { const upb_fielddef* f = upb_oneof_iter_field(&fit); fields[upb_fielddef_index(f)].offset = data_offset; fields[upb_fielddef_index(f)].presence = ~case_offset; } } /* Size of the entire structure should be a multiple of its greatest * alignment. TODO: track overall alignment for real? */ l->size = UPB_ALIGN_UP(l->size, 8); /* Sort fields by number. */ qsort(fields, upb_msgdef_numfields(m), sizeof(*fields), field_number_cmp); assign_layout_indices(m, fields); } static void assign_msg_indices(symtab_addctx *ctx, upb_msgdef *m) { /* Sort fields. upb internally relies on UPB_TYPE_MESSAGE fields having the * lowest indexes, but we do not publicly guarantee this. */ upb_msg_field_iter j; int i; uint32_t selector; int n = upb_msgdef_numfields(m); upb_fielddef **fields; if (n == 0) { m->selector_count = UPB_STATIC_SELECTOR_COUNT; m->submsg_field_count = 0; return; } fields = upb_gmalloc(n * sizeof(*fields)); m->submsg_field_count = 0; for(i = 0, upb_msg_field_begin(&j, m); !upb_msg_field_done(&j); upb_msg_field_next(&j), i++) { upb_fielddef *f = upb_msg_iter_field(&j); UPB_ASSERT(f->msgdef == m); if (upb_fielddef_issubmsg(f)) { m->submsg_field_count++; } fields[i] = f; } qsort(fields, n, sizeof(*fields), cmp_fields); selector = UPB_STATIC_SELECTOR_COUNT + m->submsg_field_count; for (i = 0; i < n; i++) { upb_fielddef *f = fields[i]; f->index_ = i; f->selector_base = selector + upb_handlers_selectorbaseoffset(f); selector += upb_handlers_selectorcount(f); } m->selector_count = selector; upb_gfree(fields); } static char *strviewdup(symtab_addctx *ctx, upb_strview view) { return upb_strdup2(view.data, view.size, ctx->alloc); } static bool streql2(const char *a, size_t n, const char *b) { return n == strlen(b) && memcmp(a, b, n) == 0; } static bool streql_view(upb_strview view, const char *b) { return streql2(view.data, view.size, b); } static const char *makefullname(symtab_addctx *ctx, const char *prefix, upb_strview name) { if (prefix) { /* ret = prefix + '.' + name; */ size_t n = strlen(prefix); char *ret = symtab_alloc(ctx, n + name.size + 2); strcpy(ret, prefix); ret[n] = '.'; memcpy(&ret[n + 1], name.data, name.size); ret[n + 1 + name.size] = '\0'; return ret; } else { return strviewdup(ctx, name); } } static void finalize_oneofs(symtab_addctx *ctx, upb_msgdef *m) { int i; int synthetic_count = 0; upb_oneofdef *mutable_oneofs = (upb_oneofdef*)m->oneofs; for (i = 0; i < m->oneof_count; i++) { upb_oneofdef *o = &mutable_oneofs[i]; if (o->synthetic && o->field_count != 1) { symtab_errf(ctx, "Synthetic oneofs must have one field, not %d: %s", o->field_count, upb_oneofdef_name(o)); } if (o->synthetic) { synthetic_count++; } else if (synthetic_count != 0) { symtab_errf(ctx, "Synthetic oneofs must be after all other oneofs: %s", upb_oneofdef_name(o)); } o->fields = symtab_alloc(ctx, sizeof(upb_fielddef *) * o->field_count); o->field_count = 0; } for (i = 0; i < m->field_count; i++) { const upb_fielddef *f = &m->fields[i]; upb_oneofdef *o = (upb_oneofdef*)f->oneof; if (o) { o->fields[o->field_count++] = f; } } m->real_oneof_count = m->oneof_count - synthetic_count; } size_t getjsonname(const char *name, char *buf, size_t len) { size_t src, dst = 0; bool ucase_next = false; #define WRITE(byte) \ ++dst; \ if (dst < len) buf[dst - 1] = byte; \ else if (dst == len) buf[dst - 1] = '\0' if (!name) { WRITE('\0'); return 0; } /* Implement the transformation as described in the spec: * 1. upper case all letters after an underscore. * 2. remove all underscores. */ for (src = 0; name[src]; src++) { if (name[src] == '_') { ucase_next = true; continue; } if (ucase_next) { WRITE(toupper(name[src])); ucase_next = false; } else { WRITE(name[src]); } } WRITE('\0'); return dst; #undef WRITE } static char* makejsonname(symtab_addctx *ctx, const char* name) { size_t size = getjsonname(name, NULL, 0); char* json_name = symtab_alloc(ctx, size); getjsonname(name, json_name, size); return json_name; } static void symtab_add(symtab_addctx *ctx, const char *name, upb_value v) { if (upb_strtable_lookup(&ctx->symtab->syms, name, NULL)) { symtab_errf(ctx, "duplicate symbol '%s'", name); } upb_alloc *alloc = upb_arena_alloc(ctx->symtab->arena); size_t len = strlen(name); CHK_OOM(upb_strtable_insert3(&ctx->symtab->syms, name, len, v, alloc)); } /* Given a symbol and the base symbol inside which it is defined, find the * symbol's definition in t. */ static const void *symtab_resolve(symtab_addctx *ctx, const upb_fielddef *f, const char *base, upb_strview sym, upb_deftype_t type) { const upb_strtable *t = &ctx->symtab->syms; if(sym.size == 0) goto notfound; if(sym.data[0] == '.') { /* Symbols starting with '.' are absolute, so we do a single lookup. * Slice to omit the leading '.' */ upb_value v; if (!upb_strtable_lookup2(t, sym.data + 1, sym.size - 1, &v)) { goto notfound; } const void *ret = unpack_def(v, type); if (!ret) { symtab_errf(ctx, "type mismatch when resolving field %s, name %s", f->full_name, sym.data); } return ret; } else { /* Remove components from base until we find an entry or run out. * TODO: This branch is totally broken, but currently not used. */ (void)base; UPB_ASSERT(false); goto notfound; } notfound: symtab_errf(ctx, "couldn't resolve name '%s'", sym.data); } static void create_oneofdef( symtab_addctx *ctx, upb_msgdef *m, const google_protobuf_OneofDescriptorProto *oneof_proto) { upb_oneofdef *o; upb_strview name = google_protobuf_OneofDescriptorProto_name(oneof_proto); upb_value v; o = (upb_oneofdef*)&m->oneofs[m->oneof_count++]; o->parent = m; o->full_name = makefullname(ctx, m->full_name, name); o->field_count = 0; o->synthetic = false; v = pack_def(o, UPB_DEFTYPE_ONEOF); symtab_add(ctx, o->full_name, v); CHK_OOM(upb_strtable_insert3(&m->ntof, name.data, name.size, v, ctx->alloc)); CHK_OOM(upb_inttable_init2(&o->itof, UPB_CTYPE_CONSTPTR, ctx->alloc)); CHK_OOM(upb_strtable_init2(&o->ntof, UPB_CTYPE_CONSTPTR, 4, ctx->alloc)); } static str_t *newstr(symtab_addctx *ctx, const char *data, size_t len) { str_t *ret = symtab_alloc(ctx, sizeof(*ret) + len); if (!ret) return NULL; ret->len = len; if (len) memcpy(ret->str, data, len); ret->str[len] = '\0'; return ret; } static void parse_default(symtab_addctx *ctx, const char *str, size_t len, upb_fielddef *f) { char *end; char nullz[64]; errno = 0; switch (upb_fielddef_type(f)) { case UPB_TYPE_INT32: case UPB_TYPE_INT64: case UPB_TYPE_UINT32: case UPB_TYPE_UINT64: case UPB_TYPE_DOUBLE: case UPB_TYPE_FLOAT: /* Standard C number parsing functions expect null-terminated strings. */ if (len >= sizeof(nullz) - 1) { symtab_errf(ctx, "Default too long: %.*s", (int)len, str); } memcpy(nullz, str, len); nullz[len] = '\0'; str = nullz; break; default: break; } switch (upb_fielddef_type(f)) { case UPB_TYPE_INT32: { long val = strtol(str, &end, 0); if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end) { goto invalid; } f->defaultval.sint = val; break; } case UPB_TYPE_ENUM: { const upb_enumdef *e = f->sub.enumdef; int32_t val; if (!upb_enumdef_ntoi(e, str, len, &val)) { goto invalid; } f->defaultval.sint = val; break; } case UPB_TYPE_INT64: { /* XXX: Need to write our own strtoll, since it's not available in c89. */ int64_t val = strtol(str, &end, 0); if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end) { goto invalid; } f->defaultval.sint = val; break; } case UPB_TYPE_UINT32: { unsigned long val = strtoul(str, &end, 0); if (val > UINT32_MAX || errno == ERANGE || *end) { goto invalid; } f->defaultval.uint = val; break; } case UPB_TYPE_UINT64: { /* XXX: Need to write our own strtoull, since it's not available in c89. */ uint64_t val = strtoul(str, &end, 0); if (val > UINT64_MAX || errno == ERANGE || *end) { goto invalid; } f->defaultval.uint = val; break; } case UPB_TYPE_DOUBLE: { double val = strtod(str, &end); if (errno == ERANGE || *end) { goto invalid; } f->defaultval.dbl = val; break; } case UPB_TYPE_FLOAT: { /* XXX: Need to write our own strtof, since it's not available in c89. */ float val = strtod(str, &end); if (errno == ERANGE || *end) { goto invalid; } f->defaultval.flt = val; break; } case UPB_TYPE_BOOL: { if (streql2(str, len, "false")) { f->defaultval.boolean = false; } else if (streql2(str, len, "true")) { f->defaultval.boolean = true; } else { } break; } case UPB_TYPE_STRING: f->defaultval.str = newstr(ctx, str, len); break; case UPB_TYPE_BYTES: /* XXX: need to interpret the C-escaped value. */ f->defaultval.str = newstr(ctx, str, len); break; case UPB_TYPE_MESSAGE: /* Should not have a default value. */ symtab_errf(ctx, "Message should not have a default (%s)", upb_fielddef_fullname(f)); } return; invalid: symtab_errf(ctx, "Invalid default '%.*s' for field %f", (int)len, str, upb_fielddef_fullname(f)); } static void set_default_default(symtab_addctx *ctx, upb_fielddef *f) { switch (upb_fielddef_type(f)) { case UPB_TYPE_INT32: case UPB_TYPE_INT64: case UPB_TYPE_ENUM: f->defaultval.sint = 0; break; case UPB_TYPE_UINT64: case UPB_TYPE_UINT32: f->defaultval.uint = 0; break; case UPB_TYPE_DOUBLE: case UPB_TYPE_FLOAT: f->defaultval.dbl = 0; break; case UPB_TYPE_STRING: case UPB_TYPE_BYTES: f->defaultval.str = newstr(ctx, NULL, 0); break; case UPB_TYPE_BOOL: f->defaultval.boolean = false; break; case UPB_TYPE_MESSAGE: break; } } static void create_fielddef( symtab_addctx *ctx, const char *prefix, upb_msgdef *m, const google_protobuf_FieldDescriptorProto *field_proto) { upb_alloc *alloc = ctx->alloc; upb_fielddef *f; const google_protobuf_FieldOptions *options; upb_strview name; const char *full_name; const char *json_name; const char *shortname; uint32_t field_number; if (!google_protobuf_FieldDescriptorProto_has_name(field_proto)) { symtab_errf(ctx, "field has no name (%s)", upb_msgdef_fullname(m)); } name = google_protobuf_FieldDescriptorProto_name(field_proto); check_ident(ctx, name, false); full_name = makefullname(ctx, prefix, name); shortname = shortdefname(full_name); if (google_protobuf_FieldDescriptorProto_has_json_name(field_proto)) { json_name = strviewdup( ctx, google_protobuf_FieldDescriptorProto_json_name(field_proto)); } else { json_name = makejsonname(ctx, shortname); } field_number = google_protobuf_FieldDescriptorProto_number(field_proto); if (field_number == 0 || field_number > UPB_MAX_FIELDNUMBER) { symtab_errf(ctx, "invalid field number (%u)", field_number); } if (m) { /* direct message field. */ upb_value v, field_v, json_v; size_t json_size; f = (upb_fielddef*)&m->fields[m->field_count++]; f->msgdef = m; f->is_extension_ = false; if (upb_strtable_lookup(&m->ntof, shortname, NULL)) { symtab_errf(ctx, "duplicate field name (%s)", shortname); } if (upb_strtable_lookup(&m->ntof, json_name, NULL)) { symtab_errf(ctx, "duplicate json_name (%s)", json_name); } if (upb_inttable_lookup(&m->itof, field_number, NULL)) { symtab_errf(ctx, "duplicate field number (%u)", field_number); } field_v = pack_def(f, UPB_DEFTYPE_FIELD); json_v = pack_def(f, UPB_DEFTYPE_FIELD_JSONNAME); v = upb_value_constptr(f); json_size = strlen(json_name); CHK_OOM( upb_strtable_insert3(&m->ntof, name.data, name.size, field_v, alloc)); CHK_OOM(upb_inttable_insert2(&m->itof, field_number, v, alloc)); if (strcmp(shortname, json_name) != 0) { upb_strtable_insert3(&m->ntof, json_name, json_size, json_v, alloc); } if (ctx->layouts) { const upb_msglayout_field *fields = m->layout->fields; int count = m->layout->field_count; bool found = false; int i; for (i = 0; i < count; i++) { if (fields[i].number == field_number) { f->layout_index = i; found = true; break; } } UPB_ASSERT(found); } } else { /* extension field. */ f = (upb_fielddef*)&ctx->file->exts[ctx->file->ext_count++]; f->is_extension_ = true; symtab_add(ctx, full_name, pack_def(f, UPB_DEFTYPE_FIELD)); } f->full_name = full_name; f->json_name = json_name; f->file = ctx->file; f->type_ = (int)google_protobuf_FieldDescriptorProto_type(field_proto); f->label_ = (int)google_protobuf_FieldDescriptorProto_label(field_proto); f->number_ = field_number; f->oneof = NULL; f->proto3_optional_ = google_protobuf_FieldDescriptorProto_proto3_optional(field_proto); /* We can't resolve the subdef or (in the case of extensions) the containing * message yet, because it may not have been defined yet. We stash a pointer * to the field_proto until later when we can properly resolve it. */ f->sub.unresolved = field_proto; if (f->label_ == UPB_LABEL_REQUIRED && f->file->syntax == UPB_SYNTAX_PROTO3) { symtab_errf(ctx, "proto3 fields cannot be required (%s)", f->full_name); } if (google_protobuf_FieldDescriptorProto_has_oneof_index(field_proto)) { int oneof_index = google_protobuf_FieldDescriptorProto_oneof_index(field_proto); upb_oneofdef *oneof; upb_value v = upb_value_constptr(f); if (upb_fielddef_label(f) != UPB_LABEL_OPTIONAL) { symtab_errf(ctx, "fields in oneof must have OPTIONAL label (%s)", f->full_name); } if (!m) { symtab_errf(ctx, "oneof_index provided for extension field (%s)", f->full_name); } if (oneof_index >= m->oneof_count) { symtab_errf(ctx, "oneof_index out of range (%s)", f->full_name); } oneof = (upb_oneofdef*)&m->oneofs[oneof_index]; f->oneof = oneof; oneof->field_count++; if (f->proto3_optional_) { oneof->synthetic = true; } CHK_OOM(upb_inttable_insert2(&oneof->itof, f->number_, v, alloc)); CHK_OOM(upb_strtable_insert3(&oneof->ntof, name.data, name.size, v, alloc)); } else { f->oneof = NULL; if (f->proto3_optional_) { symtab_errf(ctx, "field with proto3_optional was not in a oneof (%s)", f->full_name); } } options = google_protobuf_FieldDescriptorProto_has_options(field_proto) ? google_protobuf_FieldDescriptorProto_options(field_proto) : NULL; if (options && google_protobuf_FieldOptions_has_packed(options)) { f->packed_ = google_protobuf_FieldOptions_packed(options); } else { /* Repeated fields default to packed for proto3 only. */ f->packed_ = upb_fielddef_isprimitive(f) && f->label_ == UPB_LABEL_REPEATED && f->file->syntax == UPB_SYNTAX_PROTO3; } if (options) { f->lazy_ = google_protobuf_FieldOptions_lazy(options); } else { f->lazy_ = false; } } static void create_enumdef( symtab_addctx *ctx, const char *prefix, const google_protobuf_EnumDescriptorProto *enum_proto) { upb_enumdef *e; const google_protobuf_EnumValueDescriptorProto *const *values; upb_strview name; size_t i, n; name = google_protobuf_EnumDescriptorProto_name(enum_proto); check_ident(ctx, name, false); e = (upb_enumdef*)&ctx->file->enums[ctx->file->enum_count++]; e->full_name = makefullname(ctx, prefix, name); symtab_add(ctx, e->full_name, pack_def(e, UPB_DEFTYPE_ENUM)); values = google_protobuf_EnumDescriptorProto_value(enum_proto, &n); CHK_OOM(upb_strtable_init2(&e->ntoi, UPB_CTYPE_INT32, n, ctx->alloc)); CHK_OOM(upb_inttable_init2(&e->iton, UPB_CTYPE_CSTR, ctx->alloc)); e->file = ctx->file; e->defaultval = 0; if (n == 0) { symtab_errf(ctx, "enums must contain at least one value (%s)", e->full_name); } for (i = 0; i < n; i++) { const google_protobuf_EnumValueDescriptorProto *value = values[i]; upb_strview name = google_protobuf_EnumValueDescriptorProto_name(value); char *name2 = strviewdup(ctx, name); int32_t num = google_protobuf_EnumValueDescriptorProto_number(value); upb_value v = upb_value_int32(num); if (i == 0 && e->file->syntax == UPB_SYNTAX_PROTO3 && num != 0) { symtab_errf(ctx, "for proto3, the first enum value must be zero (%s)", e->full_name); } if (upb_strtable_lookup(&e->ntoi, name2, NULL)) { symtab_errf(ctx, "duplicate enum label '%s'", name2); } CHK_OOM(name2) CHK_OOM( upb_strtable_insert3(&e->ntoi, name2, strlen(name2), v, ctx->alloc)); if (!upb_inttable_lookup(&e->iton, num, NULL)) { upb_value v = upb_value_cstr(name2); CHK_OOM(upb_inttable_insert2(&e->iton, num, v, ctx->alloc)); } } upb_inttable_compact2(&e->iton, ctx->alloc); } static void create_msgdef(symtab_addctx *ctx, const char *prefix, const google_protobuf_DescriptorProto *msg_proto) { upb_msgdef *m; const google_protobuf_MessageOptions *options; const google_protobuf_OneofDescriptorProto *const *oneofs; const google_protobuf_FieldDescriptorProto *const *fields; const google_protobuf_EnumDescriptorProto *const *enums; const google_protobuf_DescriptorProto *const *msgs; size_t i, n_oneof, n_field, n; upb_strview name; name = google_protobuf_DescriptorProto_name(msg_proto); check_ident(ctx, name, false); m = (upb_msgdef*)&ctx->file->msgs[ctx->file->msg_count++]; m->full_name = makefullname(ctx, prefix, name); symtab_add(ctx, m->full_name, pack_def(m, UPB_DEFTYPE_MSG)); oneofs = google_protobuf_DescriptorProto_oneof_decl(msg_proto, &n_oneof); fields = google_protobuf_DescriptorProto_field(msg_proto, &n_field); CHK_OOM(upb_inttable_init2(&m->itof, UPB_CTYPE_CONSTPTR, ctx->alloc)); CHK_OOM(upb_strtable_init2(&m->ntof, UPB_CTYPE_CONSTPTR, n_oneof + n_field, ctx->alloc)); m->file = ctx->file; m->map_entry = false; options = google_protobuf_DescriptorProto_options(msg_proto); if (options) { m->map_entry = google_protobuf_MessageOptions_map_entry(options); } if (ctx->layouts) { m->layout = *ctx->layouts; ctx->layouts++; } else { /* Allocate now (to allow cross-linking), populate later. */ m->layout = symtab_alloc( ctx, sizeof(*m->layout) + sizeof(_upb_fasttable_entry)); } m->oneof_count = 0; m->oneofs = symtab_alloc(ctx, sizeof(*m->oneofs) * n_oneof); for (i = 0; i < n_oneof; i++) { create_oneofdef(ctx, m, oneofs[i]); } m->field_count = 0; m->fields = symtab_alloc(ctx, sizeof(*m->fields) * n_field); for (i = 0; i < n_field; i++) { create_fielddef(ctx, m->full_name, m, fields[i]); } assign_msg_indices(ctx, m); finalize_oneofs(ctx, m); assign_msg_wellknowntype(m); upb_inttable_compact2(&m->itof, ctx->alloc); /* This message is built. Now build nested messages and enums. */ enums = google_protobuf_DescriptorProto_enum_type(msg_proto, &n); for (i = 0; i < n; i++) { create_enumdef(ctx, m->full_name, enums[i]); } msgs = google_protobuf_DescriptorProto_nested_type(msg_proto, &n); for (i = 0; i < n; i++) { create_msgdef(ctx, m->full_name, msgs[i]); } } static void count_types_in_msg(const google_protobuf_DescriptorProto *msg_proto, upb_filedef *file) { const google_protobuf_DescriptorProto *const *msgs; size_t i, n; file->msg_count++; msgs = google_protobuf_DescriptorProto_nested_type(msg_proto, &n); for (i = 0; i < n; i++) { count_types_in_msg(msgs[i], file); } google_protobuf_DescriptorProto_enum_type(msg_proto, &n); file->enum_count += n; google_protobuf_DescriptorProto_extension(msg_proto, &n); file->ext_count += n; } static void count_types_in_file( const google_protobuf_FileDescriptorProto *file_proto, upb_filedef *file) { const google_protobuf_DescriptorProto *const *msgs; size_t i, n; msgs = google_protobuf_FileDescriptorProto_message_type(file_proto, &n); for (i = 0; i < n; i++) { count_types_in_msg(msgs[i], file); } google_protobuf_FileDescriptorProto_enum_type(file_proto, &n); file->enum_count += n; google_protobuf_FileDescriptorProto_extension(file_proto, &n); file->ext_count += n; } static void resolve_fielddef(symtab_addctx *ctx, const char *prefix, upb_fielddef *f) { upb_strview name; const google_protobuf_FieldDescriptorProto *field_proto = f->sub.unresolved; if (f->is_extension_) { if (!google_protobuf_FieldDescriptorProto_has_extendee(field_proto)) { symtab_errf(ctx, "extension for field '%s' had no extendee", f->full_name); } name = google_protobuf_FieldDescriptorProto_extendee(field_proto); f->msgdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_MSG); } if ((upb_fielddef_issubmsg(f) || f->type_ == UPB_DESCRIPTOR_TYPE_ENUM) && !google_protobuf_FieldDescriptorProto_has_type_name(field_proto)) { symtab_errf(ctx, "field '%s' is missing type name", f->full_name); } name = google_protobuf_FieldDescriptorProto_type_name(field_proto); if (upb_fielddef_issubmsg(f)) { f->sub.msgdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_MSG); } else if (f->type_ == UPB_DESCRIPTOR_TYPE_ENUM) { f->sub.enumdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_ENUM); } /* Have to delay resolving of the default value until now because of the enum * case, since enum defaults are specified with a label. */ if (google_protobuf_FieldDescriptorProto_has_default_value(field_proto)) { upb_strview defaultval = google_protobuf_FieldDescriptorProto_default_value(field_proto); if (f->file->syntax == UPB_SYNTAX_PROTO3) { symtab_errf(ctx, "proto3 fields cannot have explicit defaults (%s)", f->full_name); } if (upb_fielddef_issubmsg(f)) { symtab_errf(ctx, "message fields cannot have explicit defaults (%s)", f->full_name); } parse_default(ctx, defaultval.data, defaultval.size, f); } else { set_default_default(ctx, f); } } static void build_filedef( symtab_addctx *ctx, upb_filedef *file, const google_protobuf_FileDescriptorProto *file_proto) { const google_protobuf_FileOptions *file_options_proto; const google_protobuf_DescriptorProto *const *msgs; const google_protobuf_EnumDescriptorProto *const *enums; const google_protobuf_FieldDescriptorProto *const *exts; const upb_strview* strs; size_t i, n; count_types_in_file(file_proto, file); file->msgs = symtab_alloc(ctx, sizeof(*file->msgs) * file->msg_count); file->enums = symtab_alloc(ctx, sizeof(*file->enums) * file->enum_count); file->exts = symtab_alloc(ctx, sizeof(*file->exts) * file->ext_count); /* We increment these as defs are added. */ file->msg_count = 0; file->enum_count = 0; file->ext_count = 0; if (!google_protobuf_FileDescriptorProto_has_name(file_proto)) { symtab_errf(ctx, "File has no name"); } file->name = strviewdup(ctx, google_protobuf_FileDescriptorProto_name(file_proto)); file->phpprefix = NULL; file->phpnamespace = NULL; if (google_protobuf_FileDescriptorProto_has_package(file_proto)) { upb_strview package = google_protobuf_FileDescriptorProto_package(file_proto); check_ident(ctx, package, true); file->package = strviewdup(ctx, package); } else { file->package = NULL; } if (google_protobuf_FileDescriptorProto_has_syntax(file_proto)) { upb_strview syntax = google_protobuf_FileDescriptorProto_syntax(file_proto); if (streql_view(syntax, "proto2")) { file->syntax = UPB_SYNTAX_PROTO2; } else if (streql_view(syntax, "proto3")) { file->syntax = UPB_SYNTAX_PROTO3; } else { symtab_errf(ctx, "Invalid syntax '" UPB_STRVIEW_FORMAT "'", UPB_STRVIEW_ARGS(syntax)); } } else { file->syntax = UPB_SYNTAX_PROTO2; } /* Read options. */ file_options_proto = google_protobuf_FileDescriptorProto_options(file_proto); if (file_options_proto) { if (google_protobuf_FileOptions_has_php_class_prefix(file_options_proto)) { file->phpprefix = strviewdup( ctx, google_protobuf_FileOptions_php_class_prefix(file_options_proto)); } if (google_protobuf_FileOptions_has_php_namespace(file_options_proto)) { file->phpnamespace = strviewdup( ctx, google_protobuf_FileOptions_php_namespace(file_options_proto)); } } /* Verify dependencies. */ strs = google_protobuf_FileDescriptorProto_dependency(file_proto, &n); file->deps = symtab_alloc(ctx, sizeof(*file->deps) * n); for (i = 0; i < n; i++) { upb_strview dep_name = strs[i]; upb_value v; if (!upb_strtable_lookup2(&ctx->symtab->files, dep_name.data, dep_name.size, &v)) { symtab_errf(ctx, "Depends on file '" UPB_STRVIEW_FORMAT "', but it has not been loaded", UPB_STRVIEW_ARGS(dep_name)); } file->deps[i] = upb_value_getconstptr(v); } /* Create messages. */ msgs = google_protobuf_FileDescriptorProto_message_type(file_proto, &n); for (i = 0; i < n; i++) { create_msgdef(ctx, file->package, msgs[i]); } /* Create enums. */ enums = google_protobuf_FileDescriptorProto_enum_type(file_proto, &n); for (i = 0; i < n; i++) { create_enumdef(ctx, file->package, enums[i]); } /* Create extensions. */ exts = google_protobuf_FileDescriptorProto_extension(file_proto, &n); file->exts = symtab_alloc(ctx, sizeof(*file->exts) * n); for (i = 0; i < n; i++) { create_fielddef(ctx, file->package, NULL, exts[i]); } /* Now that all names are in the table, build layouts and resolve refs. */ for (i = 0; i < (size_t)file->ext_count; i++) { resolve_fielddef(ctx, file->package, (upb_fielddef*)&file->exts[i]); } for (i = 0; i < (size_t)file->msg_count; i++) { const upb_msgdef *m = &file->msgs[i]; int j; for (j = 0; j < m->field_count; j++) { resolve_fielddef(ctx, m->full_name, (upb_fielddef*)&m->fields[j]); } } if (!ctx->layouts) { for (i = 0; i < (size_t)file->msg_count; i++) { const upb_msgdef *m = &file->msgs[i]; make_layout(ctx, m); } } } static void remove_filedef(upb_symtab *s, upb_filedef *file) { upb_alloc *alloc = upb_arena_alloc(s->arena); int i; for (i = 0; i < file->msg_count; i++) { const char *name = file->msgs[i].full_name; upb_strtable_remove3(&s->syms, name, strlen(name), NULL, alloc); } for (i = 0; i < file->enum_count; i++) { const char *name = file->enums[i].full_name; upb_strtable_remove3(&s->syms, name, strlen(name), NULL, alloc); } for (i = 0; i < file->ext_count; i++) { const char *name = file->exts[i].full_name; upb_strtable_remove3(&s->syms, name, strlen(name), NULL, alloc); } } static const upb_filedef *_upb_symtab_addfile( upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto, const upb_msglayout **layouts, upb_status *status) { upb_arena *file_arena = upb_arena_new(); upb_filedef *file; symtab_addctx ctx; if (!file_arena) return NULL; file = upb_arena_malloc(file_arena, sizeof(*file)); if (!file) goto done; ctx.file = file; ctx.symtab = s; ctx.file_arena = file_arena; ctx.alloc = upb_arena_alloc(file_arena); ctx.layouts = layouts; ctx.status = status; file->msg_count = 0; file->enum_count = 0; file->ext_count = 0; if (UPB_UNLIKELY(UPB_SETJMP(ctx.err))) { UPB_ASSERT(!upb_ok(status)); remove_filedef(s, file); file = NULL; } else { build_filedef(&ctx, file, file_proto); upb_strtable_insert3(&s->files, file->name, strlen(file->name), upb_value_constptr(file), ctx.alloc); UPB_ASSERT(upb_ok(status)); upb_arena_fuse(s->arena, file_arena); } done: upb_arena_free(file_arena); return file; } const upb_filedef *upb_symtab_addfile( upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto, upb_status *status) { return _upb_symtab_addfile(s, file_proto, NULL, status); } /* Include here since we want most of this file to be stdio-free. */ #include <stdio.h> bool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init) { /* Since this function should never fail (it would indicate a bug in upb) we * print errors to stderr instead of returning error status to the user. */ upb_def_init **deps = init->deps; google_protobuf_FileDescriptorProto *file; upb_arena *arena; upb_status status; upb_status_clear(&status); if (upb_strtable_lookup(&s->files, init->filename, NULL)) { return true; } arena = upb_arena_new(); for (; *deps; deps++) { if (!_upb_symtab_loaddefinit(s, *deps)) goto err; } file = google_protobuf_FileDescriptorProto_parse_ex( init->descriptor.data, init->descriptor.size, arena, UPB_DECODE_ALIAS); s->bytes_loaded += init->descriptor.size; if (!file) { upb_status_seterrf( &status, "Failed to parse compiled-in descriptor for file '%s'. This should " "never happen.", init->filename); goto err; } if (!_upb_symtab_addfile(s, file, init->layouts, &status)) goto err; upb_arena_free(arena); return true; err: fprintf(stderr, "Error loading compiled-in descriptor: %s\n", upb_status_errmsg(&status)); upb_arena_free(arena); return false; } size_t _upb_symtab_bytesloaded(const upb_symtab *s) { return s->bytes_loaded; } #undef CHK_OOM
unsigned char string_txt[] = { 0x72, 0x62, 0x0a, 0x77, 0x62, 0x0a, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x0a, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x6e, 0x30, 0x0a, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x6e, 0x31, 0x0a, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x6e, 0x32, 0x0a, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x20, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x0a, 0x23, 0x65, 0x6e, 0x64, 0x0a, 0x23, 0x71, 0x75, 0x69, 0x74, 0x0a, 0x23, 0x64, 0x6f, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x64, 0x69, 0x74, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x0a, 0x0a }; unsigned int string_txt_len = 122;
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_ValueType3640485471.h" // System.Array struct Il2CppArray; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Array/InternalEnumerator`1<System.Collections.Generic.KeyValuePair`2<System.Int16,System.Single>> struct InternalEnumerator_1_t2597342899 { public: // System.Array System.Array/InternalEnumerator`1::array Il2CppArray * ___array_0; // System.Int32 System.Array/InternalEnumerator`1::idx int32_t ___idx_1; public: inline static int32_t get_offset_of_array_0() { return static_cast<int32_t>(offsetof(InternalEnumerator_1_t2597342899, ___array_0)); } inline Il2CppArray * get_array_0() const { return ___array_0; } inline Il2CppArray ** get_address_of_array_0() { return &___array_0; } inline void set_array_0(Il2CppArray * value) { ___array_0 = value; Il2CppCodeGenWriteBarrier(&___array_0, value); } inline static int32_t get_offset_of_idx_1() { return static_cast<int32_t>(offsetof(InternalEnumerator_1_t2597342899, ___idx_1)); } inline int32_t get_idx_1() const { return ___idx_1; } inline int32_t* get_address_of_idx_1() { return &___idx_1; } inline void set_idx_1(int32_t value) { ___idx_1 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
#import "Foundation/Foundation.h" #import "LibC/LibC-Swift.h" #import "LibB/LibB.h" @interface LibDObject : NSObject @property(nonatomic, assign) LibCEnumeration example; @property(nonatomic, assign) LibBClass *example2; @end
/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include <jni.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/resource.h> #include <android/log.h> #include "android_native_app_glue.h" #include "../logger.h" #define TAG "[NativeGlue]" #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOGGER_NAME, __VA_ARGS__)) #ifndef NDEBUG # define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOGGER_NAME, __VA_ARGS__)) #else # define LOGD(...) ((void)0) #endif static void free_saved_state(struct android_app* android_app) { pthread_mutex_lock(&android_app->mutex); if (android_app->savedState != NULL) { free(android_app->savedState); android_app->savedState = NULL; android_app->savedStateSize = 0; } pthread_mutex_unlock(&android_app->mutex); } int8_t android_app_read_cmd(struct android_app* android_app) { int8_t cmd; if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) { switch (cmd) { case APP_CMD_SAVE_STATE: free_saved_state(android_app); break; } return cmd; } else { LOGE("%s: No data on command pipe!", TAG); } return -1; } /*static void print_cur_config(struct android_app* android_app) { char lang[2], country[2]; AConfiguration_getLanguage(android_app->config, lang); AConfiguration_getCountry(android_app->config, country); LOGD("%s: Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d " "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d " "modetype=%d modenight=%d", TAG, AConfiguration_getMcc(android_app->config), AConfiguration_getMnc(android_app->config), lang[0], lang[1], country[0], country[1], AConfiguration_getOrientation(android_app->config), AConfiguration_getTouchscreen(android_app->config), AConfiguration_getDensity(android_app->config), AConfiguration_getKeyboard(android_app->config), AConfiguration_getNavigation(android_app->config), AConfiguration_getKeysHidden(android_app->config), AConfiguration_getNavHidden(android_app->config), AConfiguration_getSdkVersion(android_app->config), AConfiguration_getScreenSize(android_app->config), AConfiguration_getScreenLong(android_app->config), AConfiguration_getUiModeType(android_app->config), AConfiguration_getUiModeNight(android_app->config)); }*/ void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) { switch (cmd) { case APP_CMD_INPUT_CHANGED: LOGD("%s: APP_CMD_INPUT_CHANGED\n", TAG); pthread_mutex_lock(&android_app->mutex); if (android_app->inputQueue != NULL) { AInputQueue_detachLooper(android_app->inputQueue); } android_app->inputQueue = android_app->pendingInputQueue; if (android_app->inputQueue != NULL) { LOGD("%s: Attaching input queue to looper", TAG); AInputQueue_attachLooper(android_app->inputQueue, android_app->looper, LOOPER_ID_INPUT, NULL, &android_app->inputPollSource); } pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); break; case APP_CMD_INIT_WINDOW: LOGD("%s: APP_CMD_INIT_WINDOW\n", TAG); pthread_mutex_lock(&android_app->mutex); android_app->window = android_app->pendingWindow; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); break; case APP_CMD_TERM_WINDOW: LOGD("%s: APP_CMD_TERM_WINDOW\n", TAG); pthread_cond_broadcast(&android_app->cond); break; case APP_CMD_RESUME: case APP_CMD_START: case APP_CMD_PAUSE: case APP_CMD_STOP: LOGD("%s: activityState=%d\n", TAG, cmd); pthread_mutex_lock(&android_app->mutex); android_app->activityState = cmd; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); break; case APP_CMD_CONFIG_CHANGED: LOGD("%s: APP_CMD_CONFIG_CHANGED\n", TAG); AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager); //print_cur_config(android_app); break; case APP_CMD_DESTROY: LOGD("%s: APP_CMD_DESTROY\n", TAG); android_app->destroyRequested = 1; break; } } void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) { switch (cmd) { case APP_CMD_TERM_WINDOW: LOGD("%s: APP_CMD_TERM_WINDOW\n", TAG); pthread_mutex_lock(&android_app->mutex); android_app->window = NULL; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); break; case APP_CMD_SAVE_STATE: LOGD("%s: APP_CMD_SAVE_STATE\n", TAG); pthread_mutex_lock(&android_app->mutex); android_app->stateSaved = 1; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); break; case APP_CMD_RESUME: free_saved_state(android_app); break; } } /*void app_dummy(void) { }*/ static void android_app_destroy(struct android_app* android_app) { LOGD("%s: android_app_destroy!", TAG); free_saved_state(android_app); pthread_mutex_lock(&android_app->mutex); if (android_app->inputQueue != NULL) { AInputQueue_detachLooper(android_app->inputQueue); } AConfiguration_delete(android_app->config); android_app->destroyed = 1; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); // Can't touch android_app object after this. } static void process_input(struct android_app* app, struct android_poll_source* source) { AInputEvent* event = NULL; while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { LOGD("%s: New input event: type=%d\n", TAG, AInputEvent_getType(event)); if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { continue; } int32_t handled = 0; if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); AInputQueue_finishEvent(app->inputQueue, event, handled); } } static void process_cmd(struct android_app* app, struct android_poll_source* source) { int8_t cmd = android_app_read_cmd(app); android_app_pre_exec_cmd(app, cmd); if (app->onAppCmd != NULL) app->onAppCmd(app, cmd); android_app_post_exec_cmd(app, cmd); } static void* android_app_entry(void* param) { struct android_app* android_app = (struct android_app*)param; android_app->config = AConfiguration_new(); AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager); //print_cur_config(android_app); android_app->cmdPollSource.id = LOOPER_ID_MAIN; android_app->cmdPollSource.app = android_app; android_app->cmdPollSource.process = process_cmd; android_app->inputPollSource.id = LOOPER_ID_INPUT; android_app->inputPollSource.app = android_app; android_app->inputPollSource.process = process_input; ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL, &android_app->cmdPollSource); android_app->looper = looper; pthread_mutex_lock(&android_app->mutex); android_app->running = 1; pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); android_main(android_app); android_app_destroy(android_app); return NULL; } // -------------------------------------------------------------------- // Native activity interaction (called from main thread) // -------------------------------------------------------------------- static struct android_app* android_app_create(ANativeActivity* activity, void* savedState, size_t savedStateSize) { struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app)); memset(android_app, 0, sizeof(struct android_app)); android_app->activity = activity; pthread_mutex_init(&android_app->mutex, NULL); pthread_cond_init(&android_app->cond, NULL); if (savedState != NULL) { android_app->savedState = malloc(savedStateSize); android_app->savedStateSize = savedStateSize; memcpy(android_app->savedState, savedState, savedStateSize); } int msgpipe[2]; if (pipe(msgpipe)) { LOGE("%s: could not create pipe: %s", TAG, strerror(errno)); return NULL; } android_app->msgread = msgpipe[0]; android_app->msgwrite = msgpipe[1]; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&android_app->thread, &attr, android_app_entry, android_app); // Wait for thread to start. pthread_mutex_lock(&android_app->mutex); while (!android_app->running) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } pthread_mutex_unlock(&android_app->mutex); return android_app; } static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { LOGE("%s: Failure writing android_app cmd: %s\n", TAG, strerror(errno)); } } static void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) { pthread_mutex_lock(&android_app->mutex); android_app->pendingInputQueue = inputQueue; android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED); while (android_app->inputQueue != android_app->pendingInputQueue) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } pthread_mutex_unlock(&android_app->mutex); } static void android_app_set_window(struct android_app* android_app, ANativeWindow* window) { pthread_mutex_lock(&android_app->mutex); if (android_app->pendingWindow != NULL) { android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW); } android_app->pendingWindow = window; if (window != NULL) { android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW); } while (android_app->window != android_app->pendingWindow) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } pthread_mutex_unlock(&android_app->mutex); } static void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) { pthread_mutex_lock(&android_app->mutex); android_app_write_cmd(android_app, cmd); while (android_app->activityState != cmd) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } pthread_mutex_unlock(&android_app->mutex); } static void android_app_free(struct android_app* android_app) { pthread_mutex_lock(&android_app->mutex); android_app_write_cmd(android_app, APP_CMD_DESTROY); while (!android_app->destroyed) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } pthread_mutex_unlock(&android_app->mutex); close(android_app->msgread); close(android_app->msgwrite); pthread_cond_destroy(&android_app->cond); pthread_mutex_destroy(&android_app->mutex); free(android_app); } static void onDestroy(ANativeActivity* activity) { LOGD("%s: Destroy: %p\n", TAG, activity); android_app_free((struct android_app*)activity->instance); } static void onStart(ANativeActivity* activity) { LOGD("%s: Start: %p\n", TAG, activity); android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_START); } static void onResume(ANativeActivity* activity) { LOGD("%s: Resume: %p\n", TAG, activity); android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_RESUME); } static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) { struct android_app* android_app = (struct android_app*)activity->instance; void* savedState = NULL; LOGD("%s: SaveInstanceState: %p\n", TAG, activity); pthread_mutex_lock(&android_app->mutex); android_app->stateSaved = 0; android_app_write_cmd(android_app, APP_CMD_SAVE_STATE); while (!android_app->stateSaved) { pthread_cond_wait(&android_app->cond, &android_app->mutex); } if (android_app->savedState != NULL) { savedState = android_app->savedState; *outLen = android_app->savedStateSize; android_app->savedState = NULL; android_app->savedStateSize = 0; } pthread_mutex_unlock(&android_app->mutex); return savedState; } static void onPause(ANativeActivity* activity) { LOGD("%s: Pause: %p\n", TAG, activity); android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_PAUSE); } static void onStop(ANativeActivity* activity) { LOGD("%s: Stop: %p\n", TAG, activity); android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP); } static void onConfigurationChanged(ANativeActivity* activity) { struct android_app* android_app = (struct android_app*)activity->instance; LOGD("%s: ConfigurationChanged: %p\n", TAG, activity); android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED); } static void onLowMemory(ANativeActivity* activity) { struct android_app* android_app = (struct android_app*)activity->instance; LOGD("%s: LowMemory: %p\n", TAG, activity); android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY); } static void onWindowFocusChanged(ANativeActivity* activity, int focused) { LOGD("%s: WindowFocusChanged: %p -- %d\n", TAG, activity, focused); android_app_write_cmd((struct android_app*)activity->instance, focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS); } static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window) { LOGD("%s: NativeWindowCreated: %p -- %p\n", TAG, activity, window); android_app_set_window((struct android_app*)activity->instance, window); } static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) { LOGD("%s: NativeWindowDestroyed: %p -- %p\n", TAG, activity, window); android_app_set_window((struct android_app*)activity->instance, NULL); } static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) { LOGD("%s: InputQueueCreated: %p -- %p\n", TAG, activity, queue); android_app_set_input((struct android_app*)activity->instance, queue); } static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) { LOGD("%s: InputQueueDestroyed: %p -- %p\n", TAG, activity, queue); android_app_set_input((struct android_app*)activity->instance, NULL); } __attribute__((visibility("default"))) void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) { LOGD("%s: Creating: %p\n", TAG, activity); activity->callbacks->onDestroy = onDestroy; activity->callbacks->onStart = onStart; activity->callbacks->onResume = onResume; activity->callbacks->onSaveInstanceState = onSaveInstanceState; activity->callbacks->onPause = onPause; activity->callbacks->onStop = onStop; activity->callbacks->onConfigurationChanged = onConfigurationChanged; activity->callbacks->onLowMemory = onLowMemory; activity->callbacks->onWindowFocusChanged = onWindowFocusChanged; activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed; activity->callbacks->onInputQueueCreated = onInputQueueCreated; activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed; activity->instance = android_app_create(activity, savedState, savedStateSize); }
// // HPTextView.h // // Created by Hans Pinckaers on 29-06-10. // // MIT License // // Copyright (c) 2011 Hans Pinckaers // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #import <UIKit/UIKit.h> #if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000 // UITextAlignment is deprecated in iOS 6.0+, use NSTextAlignment instead. // Reference: https://developer.apple.com/library/ios/documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html #define NSTextAlignment UITextAlignment #endif @class HSGrowingTextView; @class HSTextViewInternal; @protocol HPGrowingTextViewDelegate @optional - (BOOL)growingTextViewShouldBeginEditing:(HSGrowingTextView *)growingTextView; - (BOOL)growingTextViewShouldEndEditing:(HSGrowingTextView *)growingTextView; - (void)growingTextViewDidBeginEditing:(HSGrowingTextView *)growingTextView; - (void)growingTextViewDidEndEditing:(HSGrowingTextView *)growingTextView; - (BOOL)growingTextView:(HSGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text; - (void)growingTextViewDidChange:(HSGrowingTextView *)growingTextView; - (void)growingTextView:(HSGrowingTextView *)growingTextView willChangeHeight:(float)height; - (void)growingTextView:(HSGrowingTextView *)growingTextView didChangeHeight:(float)height; - (void)growingTextViewDidChangeSelection:(HSGrowingTextView *)growingTextView; - (BOOL)growingTextViewShouldReturn:(HSGrowingTextView *)growingTextView; @end @interface HSGrowingTextView : UIView <UITextViewDelegate> { HSTextViewInternal *internalTextView; int minHeight; int maxHeight; //class properties int maxNumberOfLines; int minNumberOfLines; BOOL animateHeightChange; NSTimeInterval animationDuration; //uitextview properties NSObject <HPGrowingTextViewDelegate> *__unsafe_unretained delegate; NSTextAlignment textAlignment; NSRange selectedRange; BOOL editable; UIDataDetectorTypes dataDetectorTypes; UIReturnKeyType returnKeyType; UIKeyboardType keyboardType; UIEdgeInsets contentInset; } //real class properties @property int maxNumberOfLines; @property int minNumberOfLines; @property (nonatomic) int maxHeight; @property (nonatomic) int minHeight; @property BOOL animateHeightChange; @property NSTimeInterval animationDuration; @property (nonatomic, strong) NSString *placeholder; @property (nonatomic, strong) UIColor *placeholderColor; @property (nonatomic, strong) UITextView *internalTextView; //uitextview properties @property(unsafe_unretained) NSObject<HPGrowingTextViewDelegate> *delegate; @property(nonatomic,strong) NSString *text; @property(nonatomic,strong) UIFont *font; @property(nonatomic,strong) UIColor *textColor; @property(nonatomic) NSTextAlignment textAlignment; // default is NSTextAlignmentLeft @property(nonatomic) NSRange selectedRange; // only ranges of length 0 are supported @property(nonatomic,getter=isEditable) BOOL editable; @property(nonatomic) UIDataDetectorTypes dataDetectorTypes __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_0); @property (nonatomic) UIReturnKeyType returnKeyType; @property (nonatomic) UIKeyboardType keyboardType; @property (assign) UIEdgeInsets contentInset; @property (nonatomic) BOOL isScrollable; @property(nonatomic) BOOL enablesReturnKeyAutomatically; //uitextview methods //need others? use .internalTextView - (BOOL)becomeFirstResponder; - (BOOL)resignFirstResponder; - (BOOL)isFirstResponder; - (BOOL)hasText; - (void)scrollRangeToVisible:(NSRange)range; // call to force a height change (e.g. after you change max/min lines) - (void)refreshHeight; - (void)refreshFrame:(CGRect)newFrame; @end
#pragma once #include <torch/csrc/lazy/core/internal_ops/ltc_ops.h> #include <torch/csrc/lazy/core/ir.h> #include <torch/csrc/lazy/core/ir_builder.h> #include <torch/csrc/lazy/core/shape_inference.h> #include <torch/csrc/lazy/generated/LazyNonNativeIr.h> #include <torch/csrc/lazy/ts_backend/dynamic_ir.h> #include <torch/csrc/lazy/ts_backend/ops/device_data.h> #include <torch/csrc/lazy/ts_backend/ops/generic.h> #include <torch/csrc/lazy/ts_backend/ts_node.h> namespace torch { namespace lazy { struct TorchScriptIrBuilder : IrBuilder { NodePtr MakeDeviceData( const std::shared_ptr<BackendData>& data) const override { return DeviceData::Create(data); } // TODO: Scalar node is not currently used by ts_backend. Enable reusing // Scalar node later if needed. NodePtr MakeScalar(const at::Scalar& value, const at::ScalarType& type) const override { return MakeNode<Scalar>(value, type); } NodePtr MakeExpand( const Value& input0, const std::vector<int64_t>& size, const bool& is_scalar_expand) const override { return ReuseOrMakeNode<Expand>(input0, size, is_scalar_expand); } NodePtr MakeView(const Value& input0, const std::vector<int64_t>& output_size) const override { return ReuseOrMakeNode<View>(input0, output_size); } NodePtr MakeCast( const Value& input0, const at::ScalarType& dtype, const c10::optional<at::ScalarType>& stype = c10::nullopt) const override { return ReuseOrMakeNode<Cast>(input0, dtype, stype); } NodePtr MakeTensorList(const OpList& inputs) const override { return ReuseOrMakeNode<TensorList>(inputs); } // Generic needs cleanup NodePtr MakeGeneric( const OpKind& op, const OpList& operands, const Shape& shape, const size_t& num_outputs = 1, const hash_t& hash_seed = static_cast<uint32_t>(0x5a2d296e9)) const override { return MakeNode<Generic>(op, operands, shape, num_outputs, hash_seed); } // View op nodes NodePtr MakeAsStridedViewUpdate( const Value& input0, const Value& input1, const std::vector<int64_t>& size, const std::vector<int64_t>& stride, const int64_t& storage_offset) const override { return ReuseOrMakeNode<AsStridedViewUpdate>( input0, input1, size, stride, storage_offset); } NodePtr MakeAsStrided( const Value& input0, const std::vector<int64_t>& size, const std::vector<int64_t>& stride, const int64_t& storage_offset) const override { return ReuseOrMakeNode<AsStrided>(input0, size, stride, storage_offset); } NodePtr MakeDiagonalViewUpdate( const Value& input0, const Value& input1, const int64_t& offset, const int64_t& dim1, const int64_t& dim2) const override { return ReuseOrMakeNode<DiagonalViewUpdate>( input0, input1, offset, dim1, dim2); } NodePtr MakeDiagonal( const Value& input0, const int64_t& offset, const int64_t& dim1, const int64_t& dim2) const override { return ReuseOrMakeNode<Diagonal>(input0, offset, dim1, dim2); } NodePtr MakeNarrowViewUpdate( const Value& input0, const Value& input1, const std::vector<int64_t>& base_indices) const override { return ReuseOrMakeNode<NarrowViewUpdate>(input0, input1, base_indices); } NodePtr MakeNarrow( const Value& input0, const std::vector<int64_t>& base_indices, const std::vector<int64_t>& sizes) const override { return ReuseOrMakeNode<Narrow>(input0, base_indices, sizes); } NodePtr MakePermute(const Value& input0, const std::vector<int64_t>& dims) const override { return ReuseOrMakeNode<Permute>(input0, dims); } NodePtr MakeResize(const Value& input0, const std::vector<int64_t>& size) const override { return ReuseOrMakeNode<Resize>(input0, size); } NodePtr MakeSelectViewUpdate( const Value& input0, const Value& input1, const int64_t& dim, const int64_t& start, const int64_t& end, const int64_t& stride) const override { return ReuseOrMakeNode<SelectViewUpdate>( input0, input1, dim, start, end, stride); } NodePtr MakeSelect( const Value& input0, const int64_t& dim, const int64_t& start, const int64_t& end, const int64_t& stride) const override { return ReuseOrMakeNode<Select>(input0, dim, start, end, stride); } NodePtr MakeSqueeze(const Value& input0, const int& dim) const override { return ReuseOrMakeNode<Squeeze>(input0, dim); } NodePtr MakeUnsqueeze(const Value& input0, const int& dim) const override { return ReuseOrMakeNode<Unsqueeze>(input0, dim); } // dynamic ir nodes // TODO: verify if IR node reusing works for Dynamic shape ops NodePtr MakeSizeNode(const Value& input, size_t dim) const override { return MakeNode<SizeNode>(input, dim); } NodePtr MakeSizeAdd(const Value& a, const Value& b) const override { return MakeNode<SizeAdd>(a, b); } NodePtr MakeSizeMul(const Value& a, const Value& b) const override { return MakeNode<SizeMul>(a, b); } NodePtr MakeSizeDiv(const Value& a, const Value& b) const override { return MakeNode<SizeDiv>(a, b); } }; } // namespace lazy } // namespace torch
#include "types.h" #include "param.h" #include "memlayout.h" #include "riscv.h" #include "spinlock.h" #include "proc.h" #include "defs.h" struct cpu cpus[NCPU]; struct proc proc[NPROC]; //CHANGED added spinlock for scheduler operations struct spinlock balanced_put_lock; struct spinlock scheduler_lock[NCPU]; struct proc *initproc; int nextpid = 1; struct spinlock pid_lock; extern void forkret(void); static void freeproc(struct proc *p); extern char trampoline[]; // trampoline.S // helps ensure that wakeups of wait()ing // parents are not lost. helps obey the // memory model when using p->parent. // must be acquired before any p->lock. struct spinlock wait_lock; uint8 SCHEDULING_TYPE; //CHANGED Added balanced put enum processor_state { LL, NL, HL, FP }; //HEAP FP_H; //HEAP HL_H; //HEAP NL_H; //HEAP LL_H; // //Scheduler * //balanced_cpu() { // if (LL_H.size) { // struct cpu *cpu = (struct cpu *) pop(&LL_H); // cpu->_nproc++; // if (cpu->_nproc >> 1 == NCPU - cpu->_nproc) { // insert(&NL_H, cpu); // } else { // insert(&LL_H, cpu); // } // return cpu->scheduler; // } else if (NL_H.size) { // struct cpu *cpu = (struct cpu *) pop(&NL_H); // cpu->_nproc++; // if (cpu->_nproc >> 1 < NCPU - cpu->_nproc) { // insert(&HL_H, cpu); // } else { // insert(&NL_H, cpu); // } // return cpu->scheduler; // } else if (HL_H.size) { // struct cpu *cpu = (struct cpu *) pop(&HL_H); // cpu->_nproc++; // if (cpu->_nproc == NCPU) { // insert(&FP_H, cpu); // } else { // insert(&HL_H, cpu); // } // return cpu->scheduler; // } // return 0; //} //CHANGED added global put function void gput(struct proc* p){ Scheduler *_scheduler = mycpu()->scheduler; // acquire(&balanced_put_lock); // _scheduler = balanced_cpu(); // release(&balanced_put_lock); // if (_scheduler == 0) { // panic("Loaded!"); // } acquire(&scheduler_lock[_scheduler->ID]); _scheduler->put(_scheduler, p); release(&scheduler_lock[_scheduler->ID]); } //CHANGED added functions for scheduler void * get_SJF(Scheduler *scheduler) { if (is_empty(scheduler)) return 0; struct proc *p = (struct proc *) pop(&scheduler->processes_cpu); if(SCHEDULING_TYPE == PREEMPTIVE) { p->timeslice = p->default_timeslice; }else{ p->timeslice = 0; } return p; } void * get_CFS(Scheduler *scheduler) { if (is_empty(scheduler))return 0; struct proc *p = (struct proc *) pop(&scheduler->processes_cpu); uint maximum_execution_time; if(scheduler->processes_cpu.size) { maximum_execution_time = (ticks - p->blocked_tick) / scheduler->processes_cpu.size +1; }else { maximum_execution_time = (ticks - p->blocked_tick)+1; } p->timeslice = maximum_execution_time; return p; } void put_SJF(Scheduler *scheduler, void *data) { unsigned long alpha = scheduler->alpha; struct proc *p = ((struct proc *) data); if (p->blocked_by_IO){ p->tau_n = (p->t_n * alpha + p->tau_n * (100 - alpha)) / 100; p->blocked_by_IO = false; p->t_n = 0; } insert(&scheduler->processes_cpu, data); } void put_CFS(Scheduler *scheduler, void *data) { struct proc *p = ((struct proc *) data); p->blocked_tick = ticks; insert(&scheduler->processes_cpu, data); } // Compare functions for scheduling algorithms bool sjf_cmp(NODE *A, NODE *B) { return ((struct proc *) (A->data))->tau_n < ((struct proc *) (B->data))->tau_n; } bool cfs_cmp(NODE *A, NODE *B) { return ((struct proc *) (A->data))->execution_time < ((struct proc *) (B->data))->execution_time; } // Compare funsction for heap bool balanced_cmp(NODE *A, NODE *B){ return ((struct cpu *) (A->data))->_nproc < ((struct cpu *) (B->data))->_nproc; } // Allocate a page for each process's kernel stack. // Map it high in memory, followed by an invalid // guard page. void proc_mapstacks(pagetable_t kpgtbl) { struct proc *p; for (p = proc; p < &proc[NPROC]; p++) { char *pa = kalloc(); if (pa == 0) panic("kalloc"); uint64 va = KSTACK((int) (p - proc)); kvmmap(kpgtbl, va, (uint64) pa, PGSIZE, PTE_R | PTE_W); } } // initialize the proc table at boot time. void procinit(void) { struct proc *p; initlock(&pid_lock, "nextpid"); initlock(&wait_lock, "wait_lock"); for (p = proc; p < &proc[NPROC]; p++) { initlock(&p->lock, "proc"); p->kstack = KSTACK((int) (p - proc)); } // CHANGED Added SCHEDULER init // create_heap(&LL_H); // create_heap(&NL_H); // create_heap(&HL_H); // create_heap(&FP_H); // Add compare function for every heap; // LL_H.cmp = NL_H.cmp = HL_H.cmp = FP_H.cmp = balanced_cmp; for (int i = 0; i < NCPU; i++) { create_scheduler(i); // insert(&LL_H, &cpus[i]); initlock(&scheduler_lock[i],"schedlock"); // Add scheduler for every cpu cpus[i]._nproc = 0; cpus[i].scheduler = &SCHEDULERS[i]; } SCHEDULING_TYPE = NONPREEMPTIVE; } // Must be called with interrupts disabled, // to prevent race with process being moved // to a different CPU. int cpuid() { int id = r_tp(); return id; } // Return this CPU's cpu struct. // Interrupts must be disabled. struct cpu * mycpu(void) { int id = cpuid(); struct cpu *c = &cpus[id]; return c; } // Return the current struct proc *, or zero if none. struct proc * myproc(void) { push_off(); struct cpu *c = mycpu(); struct proc *p = c->proc; pop_off(); return p; } int allocpid() { int pid; acquire(&pid_lock); pid = nextpid; nextpid = nextpid + 1; release(&pid_lock); return pid; } // Look in the process table for an UNUSED proc. // If found, initialize state required to run in the kernel, // and return with p->lock held. // If there are no free procs, or a memory allocation fails, return 0. static struct proc * allocproc(void) { struct proc *p; for (p = proc; p < &proc[NPROC]; p++) { acquire(&p->lock); if (p->state == UNUSED) { goto found; } else { release(&p->lock); } } return 0; found: p->pid = allocpid(); p->state = USED; //CHANGED Added initial parameters p->timeslice = 1; p->tau_n = 0; p->blocked_by_IO = false; p->default_timeslice = 1; p->execution_time = 0; p->t_n = 0; p->blocked_tick = 0; // Allocate a trapframe page. if ((p->trapframe = (struct trapframe *) kalloc()) == 0) { freeproc(p); release(&p->lock); return 0; } // An empty user page table. p->pagetable = proc_pagetable(p); if (p->pagetable == 0) { freeproc(p); release(&p->lock); return 0; } // Set up new context to start executing at forkret, // which returns to user space. memset(&p->context, 0, sizeof(p->context)); p->context.ra = (uint64) forkret; p->context.sp = p->kstack + PGSIZE; return p; } // free a proc structure and the data hanging from it, // including user pages. // p->lock must be held. static void freeproc(struct proc *p) { if (p->trapframe) kfree((void *) p->trapframe); p->trapframe = 0; if (p->pagetable) proc_freepagetable(p->pagetable, p->sz); p->pagetable = 0; p->sz = 0; p->pid = 0; p->parent = 0; p->name[0] = 0; p->chan = 0; p->killed = 0; p->xstate = 0; p->state = UNUSED; } // Create a user page table for a given process, // with no user memory, but with trampoline pages. pagetable_t proc_pagetable(struct proc *p) { pagetable_t pagetable; // An empty page table. pagetable = uvmcreate(); if (pagetable == 0) return 0; // map the trampoline code (for system call return) // at the highest user virtual address. // only the supervisor uses it, on the way // to/from user space, so not PTE_U. if (mappages(pagetable, TRAMPOLINE, PGSIZE, (uint64) trampoline, PTE_R | PTE_X) < 0) { uvmfree(pagetable, 0); return 0; } // map the trapframe just below TRAMPOLINE, for trampoline.S. if (mappages(pagetable, TRAPFRAME, PGSIZE, (uint64) (p->trapframe), PTE_R | PTE_W) < 0) { uvmunmap(pagetable, TRAMPOLINE, 1, 0); uvmfree(pagetable, 0); return 0; } return pagetable; } // Free a process's page table, and free the // physical memory it refers to. void proc_freepagetable(pagetable_t pagetable, uint64 sz) { uvmunmap(pagetable, TRAMPOLINE, 1, 0); uvmunmap(pagetable, TRAPFRAME, 1, 0); uvmfree(pagetable, sz); } // a user program that calls exec("/init") // od -t xC initcode uchar initcode[] = { 0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x45, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x35, 0x02, 0x93, 0x08, 0x70, 0x00, 0x73, 0x00, 0x00, 0x00, 0x93, 0x08, 0x20, 0x00, 0x73, 0x00, 0x00, 0x00, 0xef, 0xf0, 0x9f, 0xff, 0x2f, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Set up first user process. void userinit(void) { struct proc *p; p = allocproc(); initproc = p; // allocate one user page and copy init's instructions // and data into it. uvminit(p->pagetable, initcode, sizeof(initcode)); p->sz = PGSIZE; // prepare for the very first "return" from kernel to user. p->trapframe->epc = 0; // user program counter p->trapframe->sp = PGSIZE; // user stack pointer safestrcpy(p->name, "initcode", sizeof(p->name)); p->cwd = namei("/"); p->state = RUNNABLE; //---------------------------------------------------------------- //CHANGED added put gput(p); //---------------------------------------------------------------- release(&p->lock); } // Grow or shrink user memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { uint sz; struct proc *p = myproc(); sz = p->sz; if (n > 0) { if ((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) { return -1; } } else if (n < 0) { sz = uvmdealloc(p->pagetable, sz, sz + n); } p->sz = sz; return 0; } // Create a new process, copying the parent. // Sets up child kernel stack to return as if from fork() system call. int fork(void) { int i, pid; struct proc *np; struct proc *p = myproc(); // Allocate process. if ((np = allocproc()) == 0) { return -1; } // Copy user memory from parent to child. if (uvmcopy(p->pagetable, np->pagetable, p->sz) < 0) { freeproc(np); release(&np->lock); return -1; } np->sz = p->sz; //CHANGED fork copy new things np->tau_n = p->tau_n; np->execution_time = p->execution_time; np->t_n = p->t_n; np->blocked_by_IO = p->blocked_by_IO; np->blocked_tick = np->blocked_tick; // copy saved user registers. *(np->trapframe) = *(p->trapframe); // Cause fork to return 0 in the child. np->trapframe->a0 = 0; // increment reference counts on open file descriptors. for (i = 0; i < NOFILE; i++) if (p->ofile[i]) np->ofile[i] = filedup(p->ofile[i]); np->cwd = idup(p->cwd); safestrcpy(np->name, p->name, sizeof(p->name)); pid = np->pid; release(&np->lock); acquire(&wait_lock); np->parent = p; release(&wait_lock); acquire(&np->lock); np->state = RUNNABLE; //---------------------------------------------------------------- //CHANGED added put gput(np); //---------------------------------------------------------------- release(&np->lock); return pid; } // Pass p's abandoned children to init. // Caller must hold wait_lock. void reparent(struct proc *p) { struct proc *pp; for (pp = proc; pp < &proc[NPROC]; pp++) { if (pp->parent == p) { pp->parent = initproc; wakeup(initproc); } } } // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait(). void exit(int status) { struct proc *p = myproc(); if (p == initproc) panic("init exiting"); // Close all open files. for (int fd = 0; fd < NOFILE; fd++) { if (p->ofile[fd]) { struct file *f = p->ofile[fd]; fileclose(f); p->ofile[fd] = 0; } } begin_op(); iput(p->cwd); end_op(); p->cwd = 0; acquire(&wait_lock); // Give any children to init. reparent(p); // Parent might be sleeping in wait(). wakeup(p->parent); acquire(&p->lock); p->xstate = status; p->state = ZOMBIE; release(&wait_lock); // Jump into the scheduler, never to return. sched(); panic("zombie exit"); } // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(uint64 addr) { struct proc *np; int havekids, pid; struct proc *p = myproc(); acquire(&wait_lock); for (;;) { // Scan through table looking for exited children. havekids = 0; for (np = proc; np < &proc[NPROC]; np++) { if (np->parent == p) { // make sure the child isn't still in exit() or swtch(). acquire(&np->lock); havekids = 1; if (np->state == ZOMBIE) { // Found one. pid = np->pid; if (addr != 0 && copyout(p->pagetable, addr, (char *) &np->xstate, sizeof(np->xstate)) < 0) { release(&np->lock); release(&wait_lock); return -1; } freeproc(np); release(&np->lock); release(&wait_lock); return pid; } release(&np->lock); } } // No point waiting if we don't have any children. if (!havekids || p->killed) { release(&wait_lock); return -1; } // Wait for a child to exit. sleep(p, &wait_lock); //DOC: wait-sleep } } // Per-CPU process scheduler. // Each CPU calls scheduler() after setting itself up. // Scheduler never returns. It loops, doing: // - choose a process to run. // - swtch to start running that process. // - eventually that process transfers control // via swtch back to the scheduler. void scheduler(void) { struct proc *p; struct cpu *c = mycpu(); Scheduler * _scheduler = mycpu()->scheduler; c->proc = 0; for (;;) { // Avoid deadlock by ensuring that devices can interrupt. intr_on(); // for (p = proc; p < &proc[NPROC]; p++) { // acquire(&p->lock); // if (p->state == RUNNABLE) { // // Switch to chosen process. It is the process's job // // to release its lock and then reacquire it // // before jumping back to us. // // p->state = RUNNING; // c->proc = p; // swtch(&c->context, &p->context); // // // Process is done running for now. // // It should have changed its p->state before coming back. // c->proc = 0; // } // release(&p->lock); // } acquire(&scheduler_lock[_scheduler->ID]); p = _scheduler->get(_scheduler); release(&scheduler_lock[_scheduler->ID]); if(!p)continue; acquire(&p->lock); p->state = RUNNING; c->_nproc--; c->proc = p; swtch(&c->context, &p->context); c->proc = 0; release(&p->lock); } } // Switch to scheduler. Must hold only p->lock // and have changed proc->state. Saves and restores // intena because intena is a property of this // kernel thread, not this CPU. It should // be proc->intena and proc->noff, but that would // break in the few places where a lock is held but // there's no process. void sched(void) { int intena; struct proc *p = myproc(); if (!holding(&p->lock)) panic("sched p->lock"); if (mycpu()->noff != 1) panic("sched locks"); if (p->state == RUNNING) panic("sched running"); if (intr_get()) panic("sched interruptible"); intena = mycpu()->intena; swtch(&p->context, &mycpu()->context); mycpu()->intena = intena; } // Give up the CPU for one scheduling round. void yield(void) { struct proc *p = myproc(); acquire(&p->lock); p->state = RUNNABLE; p->tau_n++; p->execution_time++; //---------------------------------------------------------------- //CHANGED added put gput(p); //---------------------------------------------------------------- sched(); release(&p->lock); } // A fork child's very first scheduling by scheduler() // will swtch to forkret. void forkret(void) { static int first = 1; // Still holding p->lock from scheduler. release(&myproc()->lock); if (first) { // File system initialization must be run in the context of a // regular process (e.g., because it calls sleep), and thus cannot // be run from main(). first = 0; fsinit(ROOTDEV); } usertrapret(); } // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { struct proc *p = myproc(); // Must acquire p->lock in order to // change p->state and then call sched. // Once we hold p->lock, we can be // guaranteed that we won't miss any wakeup // (wakeup locks p->lock), // so it's okay to release lk. acquire(&p->lock); //DOC: sleeplock1 release(lk); // Go to sleep. p->chan = chan; p->state = SLEEPING; sched(); // Tidy up. p->chan = 0; // Reacquire original lock. release(&p->lock); acquire(lk); } // Wake up all processes sleeping on chan. // Must be called without any p->lock. void wakeup(void *chan) { struct proc *p; for (p = proc; p < &proc[NPROC]; p++) { if (p != myproc()) { acquire(&p->lock); if (p->state == SLEEPING && p->chan == chan) { p->state = RUNNABLE; //CHANGED p->blocked_by_IO = true; //---------------------------------------------------------------- //CHANGED added put gput(p); //---------------------------------------------------------------- } release(&p->lock); } } } // Kill the process with the given pid. // The victim won't exit until it tries to return // to user space (see usertrap() in trap.c). int kill(int pid) { struct proc *p; for (p = proc; p < &proc[NPROC]; p++) { acquire(&p->lock); if (p->pid == pid) { p->killed = 1; if (p->state == SLEEPING) { // Wake process from sleep(). p->state = RUNNABLE; //---------------------------------------------------------------- //CHANGED added put gput(p); //---------------------------------------------------------------- } release(&p->lock); return 0; } release(&p->lock); } return -1; } // Copy to either a user address, or kernel address, // depending on usr_dst. // Returns 0 on success, -1 on error. int either_copyout(int user_dst, uint64 dst, void *src, uint64 len) { struct proc *p = myproc(); if (user_dst) { return copyout(p->pagetable, dst, src, len); } else { memmove((char *) dst, src, len); return 0; } } // Copy from either a user address, or kernel address, // depending on usr_src. // Returns 0 on success, -1 on error. int either_copyin(void *dst, int user_src, uint64 src, uint64 len) { struct proc *p = myproc(); if (user_src) { return copyin(p->pagetable, dst, src, len); } else { memmove(dst, (char *) src, len); return 0; } } // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { static char *states[] = { [UNUSED] "unused", [SLEEPING] "sleep ", [RUNNABLE] "runble", [RUNNING] "run ", [ZOMBIE] "zombie" }; struct proc *p; char *state; printf("\n"); for (p = proc; p < &proc[NPROC]; p++) { if (p->state == UNUSED) continue; if (p->state >= 0 && p->state < NELEM(states) && states[p->state]) state = states[p->state]; else state = "???"; printf("%d %s %s", p->pid, state, p->name); printf("\n"); } } // // Created by os on 12/24/21. // //#include "../kernel/types.h" //#include "user.h" //#include "../kernel/stat.h" //void //main(){ // // int pid = getpid(); // // for(int i = 0 ;i<10;i++){ // if( i == 0 && pid != 0){ // pid = fork(); // } // if(pid == 0) printf("Tekst 0\n"); // else printf("Tekst 1\n"); // //printf("Tekst %d : %d\n",i,pid); // for(int j = 0;j<30000;j++) // for(int k = 0;k<10000;k++); // } // //printf("TIME:%d\n",t); // exit(0); //}
/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "vpx_config.h" #include "vpx_rtcd.h" void vp8_dequant_idct_add_y_block_v6(short *q, short *dq, unsigned char *dst, int stride, char *eobs) { int i; for (i = 0; i < 4; i++) { if (eobs[0] > 1) vp8_dequant_idct_add_v6 (q, dq, dst, stride); else if (eobs[0] == 1) { vp8_dc_only_idct_add_v6 (q[0]*dq[0], dst, stride, dst, stride); ((int *)q)[0] = 0; } if (eobs[1] > 1) vp8_dequant_idct_add_v6 (q+16, dq, dst+4, stride); else if (eobs[1] == 1) { vp8_dc_only_idct_add_v6 (q[16]*dq[0], dst+4, stride, dst+4, stride); ((int *)(q+16))[0] = 0; } if (eobs[2] > 1) vp8_dequant_idct_add_v6 (q+32, dq, dst+8, stride); else if (eobs[2] == 1) { vp8_dc_only_idct_add_v6 (q[32]*dq[0], dst+8, stride, dst+8, stride); ((int *)(q+32))[0] = 0; } if (eobs[3] > 1) vp8_dequant_idct_add_v6 (q+48, dq, dst+12, stride); else if (eobs[3] == 1) { vp8_dc_only_idct_add_v6 (q[48]*dq[0], dst+12, stride,dst+12,stride); ((int *)(q+48))[0] = 0; } q += 64; dst += 4*stride; eobs += 4; } } void vp8_dequant_idct_add_uv_block_v6(short *q, short *dq, unsigned char *dstu, unsigned char *dstv, int stride, char *eobs) { int i; for (i = 0; i < 2; i++) { if (eobs[0] > 1) vp8_dequant_idct_add_v6 (q, dq, dstu, stride); else if (eobs[0] == 1) { vp8_dc_only_idct_add_v6 (q[0]*dq[0], dstu, stride, dstu, stride); ((int *)q)[0] = 0; } if (eobs[1] > 1) vp8_dequant_idct_add_v6 (q+16, dq, dstu+4, stride); else if (eobs[1] == 1) { vp8_dc_only_idct_add_v6 (q[16]*dq[0], dstu+4, stride, dstu+4, stride); ((int *)(q+16))[0] = 0; } q += 32; dstu += 4*stride; eobs += 2; } for (i = 0; i < 2; i++) { if (eobs[0] > 1) vp8_dequant_idct_add_v6 (q, dq, dstv, stride); else if (eobs[0] == 1) { vp8_dc_only_idct_add_v6 (q[0]*dq[0], dstv, stride, dstv, stride); ((int *)q)[0] = 0; } if (eobs[1] > 1) vp8_dequant_idct_add_v6 (q+16, dq, dstv+4, stride); else if (eobs[1] == 1) { vp8_dc_only_idct_add_v6 (q[16]*dq[0], dstv+4, stride, dstv+4, stride); ((int *)(q+16))[0] = 0; } q += 32; dstv += 4*stride; eobs += 2; } }
/****************************************************************************** * The MIT License (MIT) * * Copyright (c) 2016-2019 Baldur Karlsson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ #pragma once #include "driver/shaders/dxbc/dxbc_container.h" #include "d3d12_device.h" #include "d3d12_manager.h" class TrackedResource12 { public: TrackedResource12() { m_ID = ResourceIDGen::GetNewUniqueID(); m_pRecord = NULL; } ResourceId GetResourceID() { return m_ID; } D3D12ResourceRecord *GetResourceRecord() { return m_pRecord; } void SetResourceRecord(D3D12ResourceRecord *record) { m_pRecord = record; } protected: TrackedResource12(const TrackedResource12 &); TrackedResource12 &operator=(const TrackedResource12 &); ResourceId m_ID; D3D12ResourceRecord *m_pRecord; }; extern const GUID RENDERDOC_ID3D12ShaderGUID_ShaderDebugMagicValue; template <typename NestedType, typename NestedType1 = NestedType, typename NestedType2 = NestedType1> class WrappedDeviceChild12 : public RefCounter12<NestedType>, public NestedType2, public TrackedResource12 { protected: WrappedID3D12Device *m_pDevice; ULONG m_InternalRefcount; WrappedDeviceChild12(NestedType *real, WrappedID3D12Device *device) : RefCounter12(real), m_pDevice(device) { m_InternalRefcount = 0; m_pDevice->SoftRef(); if(real) { bool ret = m_pDevice->GetResourceManager()->AddWrapper(this, real); if(!ret) RDCERR("Error adding wrapper for type %s", ToStr(__uuidof(NestedType)).c_str()); } m_pDevice->GetResourceManager()->AddCurrentResource(GetResourceID(), this); } virtual void Shutdown() { if(m_pReal) m_pDevice->GetResourceManager()->RemoveWrapper(m_pReal); m_pDevice->GetResourceManager()->ReleaseCurrentResource(GetResourceID()); m_pDevice->ReleaseResource((NestedType *)this); SAFE_RELEASE(m_pReal); m_pDevice = NULL; } virtual ~WrappedDeviceChild12() { // should have already called shutdown (needs to be called from child class to ensure // vtables are still in place when we call ReleaseResource) RDCASSERT(m_pDevice == NULL && m_pReal == NULL); } public: typedef NestedType InnerType; // some applications wrongly check refcount return values and expect them to // match D3D's values. When we have some internal refs we need to hide, we // add them here and they're subtracted from return values void AddInternalRef() { InterlockedIncrement(&m_InternalRefcount); } void ReleaseInternalRef() { InterlockedDecrement(&m_InternalRefcount); } NestedType *GetReal() { return m_pReal; } ULONG STDMETHODCALLTYPE AddRef() { ULONG ret = RefCounter12::SoftRef(m_pDevice); if(ret >= m_InternalRefcount) ret -= m_InternalRefcount; return ret; } ULONG STDMETHODCALLTYPE Release() { ULONG ret = RefCounter12::SoftRelease(m_pDevice); if(ret >= m_InternalRefcount) ret -= m_InternalRefcount; return ret; } HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) { if(riid == __uuidof(IUnknown)) { *ppvObject = (IUnknown *)(NestedType *)this; AddRef(); return S_OK; } else if(riid == __uuidof(NestedType)) { *ppvObject = (NestedType *)this; AddRef(); return S_OK; } else if(riid == __uuidof(NestedType1)) { if(!m_pReal) return E_NOINTERFACE; // check that the real interface supports this NestedType1 *dummy = NULL; HRESULT check = m_pReal->QueryInterface(riid, (void **)&dummy); SAFE_RELEASE(dummy); if(FAILED(check)) return check; *ppvObject = (NestedType1 *)this; AddRef(); return S_OK; } else if(riid == __uuidof(NestedType2)) { if(!m_pReal) return E_NOINTERFACE; // check that the real interface supports this NestedType2 *dummy = NULL; HRESULT check = m_pReal->QueryInterface(riid, (void **)&dummy); SAFE_RELEASE(dummy); if(FAILED(check)) return check; *ppvObject = (NestedType2 *)this; AddRef(); return S_OK; } else if(riid == __uuidof(ID3D12Pageable)) { // not all child classes support this, so check it on the real interface if(!m_pReal) return E_NOINTERFACE; // check that the real interface supports this ID3D12Pageable *dummy = NULL; HRESULT check = m_pReal->QueryInterface(riid, (void **)&dummy); SAFE_RELEASE(dummy); if(FAILED(check)) return check; *ppvObject = (ID3D12Pageable *)this; AddRef(); return S_OK; } else if(riid == __uuidof(ID3D12Object)) { *ppvObject = (ID3D12DeviceChild *)this; AddRef(); return S_OK; } else if(riid == __uuidof(ID3D12DeviceChild)) { *ppvObject = (ID3D12DeviceChild *)this; AddRef(); return S_OK; } // for DXGI object queries, just make a new throw-away WrappedDXGIObject // and return. if(riid == __uuidof(IDXGIObject) || riid == __uuidof(IDXGIDeviceSubObject) || riid == __uuidof(IDXGIResource) || riid == __uuidof(IDXGIKeyedMutex) || riid == __uuidof(IDXGISurface) || riid == __uuidof(IDXGISurface1) || riid == __uuidof(IDXGIResource1) || riid == __uuidof(IDXGISurface2)) { if(m_pReal == NULL) return E_NOINTERFACE; // ensure the real object has this interface void *outObj; HRESULT hr = m_pReal->QueryInterface(riid, &outObj); IUnknown *unk = (IUnknown *)outObj; SAFE_RELEASE(unk); if(FAILED(hr)) { return hr; } auto dxgiWrapper = new WrappedDXGIInterface<WrappedDeviceChild12>(this, m_pDevice); // anything could happen outside of our wrapped ecosystem, so immediately mark dirty m_pDevice->GetResourceManager()->MarkDirtyResource(GetResourceID()); if(riid == __uuidof(IDXGIObject)) { *ppvObject = (IDXGIObject *)(IDXGIKeyedMutex *)dxgiWrapper; } else if(riid == __uuidof(IDXGIDeviceSubObject)) { *ppvObject = (IDXGIDeviceSubObject *)(IDXGIKeyedMutex *)dxgiWrapper; } else if(riid == __uuidof(IDXGIResource)) { *ppvObject = (IDXGIResource *)dxgiWrapper; } else if(riid == __uuidof(IDXGIKeyedMutex)) { *ppvObject = (IDXGIKeyedMutex *)dxgiWrapper; } else if(riid == __uuidof(IDXGISurface)) { *ppvObject = (IDXGISurface *)dxgiWrapper; } else if(riid == __uuidof(IDXGISurface1)) { *ppvObject = (IDXGISurface1 *)dxgiWrapper; } else if(riid == __uuidof(IDXGIResource1)) { *ppvObject = (IDXGIResource1 *)dxgiWrapper; } else if(riid == __uuidof(IDXGISurface2)) { *ppvObject = (IDXGISurface2 *)dxgiWrapper; } else { RDCWARN("Unexpected guid %s", ToStr(riid).c_str()); SAFE_DELETE(dxgiWrapper); } return S_OK; } return RefCounter12::QueryInterface(riid, ppvObject); } ////////////////////////////// // implement ID3D12Object HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID guid, UINT *pDataSize, void *pData) { if(!m_pReal) { if(pDataSize) *pDataSize = 0; return S_OK; } return m_pReal->GetPrivateData(guid, pDataSize, pData); } HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData) { if(guid == RENDERDOC_ID3D12ShaderGUID_ShaderDebugMagicValue) return m_pDevice->SetShaderDebugPath(this, (const char *)pData); if(guid == WKPDID_D3DDebugObjectName) { m_pDevice->SetName(this, (const char *)pData); } else if(guid == WKPDID_D3DDebugObjectNameW) { rdcwstr wName((const wchar_t *)pData, DataSize / 2); rdcstr sName = StringFormat::Wide2UTF8(wName); m_pDevice->SetName(this, sName.c_str()); } if(!m_pReal) return S_OK; return m_pReal->SetPrivateData(guid, DataSize, pData); } HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID guid, const IUnknown *pData) { if(!m_pReal) return S_OK; return m_pReal->SetPrivateDataInterface(guid, pData); } HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name) { rdcstr utf8 = Name ? StringFormat::Wide2UTF8(Name) : ""; m_pDevice->SetName(this, utf8.c_str()); if(!m_pReal) return S_OK; return m_pReal->SetName(Name); } ////////////////////////////// // implement ID3D12DeviceChild virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice) { return m_pDevice->GetDevice(riid, ppvDevice); } }; class WrappedID3D12CommandAllocator : public WrappedDeviceChild12<ID3D12CommandAllocator> { public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12CommandAllocator); enum { TypeEnum = Resource_CommandAllocator, }; WrappedID3D12CommandAllocator(ID3D12CommandAllocator *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { } virtual ~WrappedID3D12CommandAllocator() { Shutdown(); } ////////////////////////////// // implement ID3D12CommandAllocator virtual HRESULT STDMETHODCALLTYPE Reset() { return m_pReal->Reset(); } }; class WrappedID3D12CommandSignature : public WrappedDeviceChild12<ID3D12CommandSignature> { public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12CommandSignature); D3D12CommandSignature sig; enum { TypeEnum = Resource_CommandSignature, }; WrappedID3D12CommandSignature(ID3D12CommandSignature *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { } virtual ~WrappedID3D12CommandSignature() { Shutdown(); } }; struct D3D12Descriptor; class WrappedID3D12DescriptorHeap : public WrappedDeviceChild12<ID3D12DescriptorHeap> { D3D12_CPU_DESCRIPTOR_HANDLE realCPUBase; D3D12_GPU_DESCRIPTOR_HANDLE realGPUBase; UINT increment : 24; UINT resident : 8; UINT numDescriptors; D3D12Descriptor *descriptors; public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12DescriptorHeap); enum { TypeEnum = Resource_DescriptorHeap, }; WrappedID3D12DescriptorHeap(ID3D12DescriptorHeap *real, WrappedID3D12Device *device, const D3D12_DESCRIPTOR_HEAP_DESC &desc); virtual ~WrappedID3D12DescriptorHeap(); D3D12Descriptor *GetDescriptors() { return descriptors; } UINT GetNumDescriptors() { return numDescriptors; } bool Resident() { return resident != 0; } void SetResident(bool r) { resident = r ? 1 : 0; } ////////////////////////////// // implement ID3D12DescriptorHeap virtual D3D12_DESCRIPTOR_HEAP_DESC STDMETHODCALLTYPE GetDesc() { return m_pReal->GetDesc(); } virtual D3D12_CPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE GetCPUDescriptorHandleForHeapStart() { D3D12_CPU_DESCRIPTOR_HANDLE handle; handle.ptr = (SIZE_T)descriptors; return handle; } virtual D3D12_GPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE GetGPUDescriptorHandleForHeapStart() { D3D12_GPU_DESCRIPTOR_HANDLE handle; handle.ptr = (UINT64)descriptors; return handle; } D3D12_CPU_DESCRIPTOR_HANDLE GetCPU(uint32_t idx) { D3D12_CPU_DESCRIPTOR_HANDLE handle = realCPUBase; handle.ptr += idx * increment; return handle; } D3D12_GPU_DESCRIPTOR_HANDLE GetGPU(uint32_t idx) { D3D12_GPU_DESCRIPTOR_HANDLE handle = realGPUBase; handle.ptr += idx * increment; return handle; } }; class WrappedID3D12Fence1 : public WrappedDeviceChild12<ID3D12Fence, ID3D12Fence1> { ID3D12Fence1 *m_pReal1 = NULL; public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12Fence1); enum { TypeEnum = Resource_Fence, }; WrappedID3D12Fence1(ID3D12Fence *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { real->QueryInterface(__uuidof(ID3D12Fence1), (void **)&m_pReal1); } virtual ~WrappedID3D12Fence1() { SAFE_RELEASE(m_pReal1); Shutdown(); } ////////////////////////////// // implement ID3D12Fence virtual UINT64 STDMETHODCALLTYPE GetCompletedValue() { return m_pReal->GetCompletedValue(); } virtual HRESULT STDMETHODCALLTYPE SetEventOnCompletion(UINT64 Value, HANDLE hEvent) { return m_pReal->SetEventOnCompletion(Value, hEvent); } virtual HRESULT STDMETHODCALLTYPE Signal(UINT64 Value) { return m_pReal->Signal(Value); } ////////////////////////////// // implement ID3D12Fence1 virtual D3D12_FENCE_FLAGS STDMETHODCALLTYPE GetCreationFlags() { return m_pReal1->GetCreationFlags(); } }; class WrappedID3D12ProtectedResourceSession : public WrappedDeviceChild12<ID3D12ProtectedResourceSession> { public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12ProtectedResourceSession); enum { TypeEnum = Resource_ProtectedResourceSession, }; WrappedID3D12ProtectedResourceSession(ID3D12ProtectedResourceSession *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { } virtual ~WrappedID3D12ProtectedResourceSession() { Shutdown(); } ////////////////////////////// // implement ID3D12ProtectedSession virtual HRESULT STDMETHODCALLTYPE GetStatusFence(REFIID riid, _COM_Outptr_opt_ void **ppFence) { if(riid != __uuidof(ID3D12Fence) && riid != __uuidof(ID3D12Fence1)) { RDCERR("Unsupported fence interface %s", ToStr(riid).c_str()); return E_NOINTERFACE; } void *iface = NULL; HRESULT ret = m_pReal->GetStatusFence(riid, &iface); if(ret != S_OK) return ret; ID3D12Fence *fence = NULL; if(riid == __uuidof(ID3D12Fence)) fence = (ID3D12Fence *)iface; else if(riid == __uuidof(ID3D12Fence1)) fence = (ID3D12Fence *)(ID3D12Fence1 *)iface; // if we already have this fence wrapped, return the existing wrapper if(m_pDevice->GetResourceManager()->HasWrapper(fence)) { *ppFence = (ID3D12Fence *)m_pDevice->GetResourceManager()->GetWrapper((ID3D12DeviceChild *)fence); return S_OK; } // if not, record its creation *ppFence = m_pDevice->CreateProtectedSessionFence(fence); return S_OK; } virtual D3D12_PROTECTED_SESSION_STATUS STDMETHODCALLTYPE GetSessionStatus(void) { return m_pReal->GetSessionStatus(); } ////////////////////////////// // implement ID3D12ProtectedResourceSession virtual D3D12_PROTECTED_RESOURCE_SESSION_DESC STDMETHODCALLTYPE GetDesc(void) { return m_pReal->GetDesc(); } }; class WrappedID3D12Heap1 : public WrappedDeviceChild12<ID3D12Heap, ID3D12Heap1> { ID3D12Heap1 *m_pReal1 = NULL; public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12Heap1); enum { TypeEnum = Resource_Heap, }; WrappedID3D12Heap1(ID3D12Heap *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { real->QueryInterface(__uuidof(ID3D12Heap1), (void **)&m_pReal1); } virtual ~WrappedID3D12Heap1() { SAFE_RELEASE(m_pReal1); Shutdown(); } ////////////////////////////// // implement ID3D12Heap virtual D3D12_HEAP_DESC STDMETHODCALLTYPE GetDesc() { return m_pReal->GetDesc(); } ////////////////////////////// // implement ID3D12Heap1 virtual HRESULT STDMETHODCALLTYPE GetProtectedResourceSession(REFIID riid, _COM_Outptr_opt_ void **ppProtectedSession) { void *iface = NULL; HRESULT ret = m_pReal1->GetProtectedResourceSession(riid, &iface); if(ret != S_OK) return ret; if(riid == __uuidof(ID3D12ProtectedResourceSession)) { *ppProtectedSession = new WrappedID3D12ProtectedResourceSession( (ID3D12ProtectedResourceSession *)iface, m_pDevice); } else { RDCERR("Unsupported interface %s", ToStr(riid).c_str()); return E_NOINTERFACE; } return S_OK; } }; class WrappedID3D12PipelineState : public WrappedDeviceChild12<ID3D12PipelineState> { public: static const int AllocPoolCount = 65536; static const int AllocMaxByteSize = 5 * 1024 * 1024; ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12PipelineState, AllocPoolCount, AllocMaxByteSize); D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC *graphics = NULL; D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC *compute = NULL; void Fill(D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC &desc) { if(graphics) { desc = *graphics; if(VS()) desc.VS = VS()->GetDesc(); if(HS()) desc.HS = HS()->GetDesc(); if(DS()) desc.DS = DS()->GetDesc(); if(GS()) desc.GS = GS()->GetDesc(); if(PS()) desc.PS = PS()->GetDesc(); } else { desc = *compute; desc.CS = CS()->GetDesc(); } } bool IsGraphics() { return graphics != NULL; } bool IsCompute() { return compute != NULL; } struct DXBCKey { DXBCKey(const D3D12_SHADER_BYTECODE &byteCode) { byteLen = (uint32_t)byteCode.BytecodeLength; DXBC::DXBCContainer::GetHash(hash, byteCode.pShaderBytecode, byteCode.BytecodeLength); } // assume that byte length + hash is enough to uniquely identify a shader bytecode uint32_t byteLen; uint32_t hash[4]; bool operator<(const DXBCKey &o) const { if(byteLen != o.byteLen) return byteLen < o.byteLen; for(size_t i = 0; i < 4; i++) if(hash[i] != o.hash[i]) return hash[i] < o.hash[i]; return false; } bool operator==(const DXBCKey &o) const { return byteLen == o.byteLen && hash[0] == o.hash[0] && hash[1] == o.hash[1] && hash[2] == o.hash[2] && hash[3] == o.hash[3]; } }; class ShaderEntry : public WrappedDeviceChild12<ID3D12DeviceChild> { public: static const int AllocPoolCount = 16384; static const int AllocMaxByteSize = 10 * 1024 * 1024; ALLOCATE_WITH_WRAPPED_POOL(ShaderEntry, AllocPoolCount, AllocMaxByteSize); static bool m_InternalResources; static void InternalResources(bool internalResources) { m_InternalResources = internalResources; } ShaderEntry(const D3D12_SHADER_BYTECODE &byteCode, WrappedID3D12Device *device) : WrappedDeviceChild12(NULL, device), m_Key(byteCode) { m_Bytecode.assign((const byte *)byteCode.pShaderBytecode, byteCode.BytecodeLength); m_DebugInfoSearchPaths = NULL; m_DXBCFile = NULL; device->GetResourceManager()->AddLiveResource(GetResourceID(), this); if(!m_InternalResources) { device->AddResource(GetResourceID(), ResourceType::Shader, "Shader"); ResourceDescription &desc = device->GetResourceDesc(GetResourceID()); // this will be appended to in the function above. desc.initialisationChunks.clear(); // since these don't have live IDs, let's use the first uint of the hash as the name. Slight // chance of collision but not that bad. desc.name = StringFormat::Fmt("Shader {%08x}", m_Key.hash[0]); } m_Built = false; } virtual ~ShaderEntry() { m_Shaders.erase(m_Key); m_Bytecode.clear(); SAFE_DELETE(m_DXBCFile); Shutdown(); } static ShaderEntry *AddShader(const D3D12_SHADER_BYTECODE &byteCode, WrappedID3D12Device *device, WrappedID3D12PipelineState *pipeline) { DXBCKey key(byteCode); ShaderEntry *shader = m_Shaders[key]; if(shader == NULL) shader = m_Shaders[key] = new ShaderEntry(byteCode, device); else shader->AddRef(); return shader; } static void ReleaseShader(ShaderEntry *shader) { if(shader == NULL) return; shader->Release(); } DXBCKey GetKey() { return m_Key; } void SetDebugInfoPath(rdcarray<rdcstr> *searchPaths, const rdcstr &path) { m_DebugInfoSearchPaths = searchPaths; m_DebugInfoPath = path; } D3D12_SHADER_BYTECODE GetDesc() { D3D12_SHADER_BYTECODE ret; ret.BytecodeLength = m_Bytecode.size(); ret.pShaderBytecode = (const void *)&m_Bytecode[0]; return ret; } DXBC::DXBCContainer *GetDXBC() { if(m_DXBCFile == NULL && !m_Bytecode.empty()) { TryReplaceOriginalByteCode(); m_DXBCFile = new DXBC::DXBCContainer((const void *)&m_Bytecode[0], m_Bytecode.size()); } return m_DXBCFile; } ShaderReflection &GetDetails() { if(!m_Built && GetDXBC() != NULL) BuildReflection(); m_Built = true; return m_Details; } const ShaderBindpointMapping &GetMapping() { if(!m_Built && GetDXBC() != NULL) BuildReflection(); m_Built = true; return m_Mapping; } private: ShaderEntry(const ShaderEntry &e); void TryReplaceOriginalByteCode(); ShaderEntry &operator=(const ShaderEntry &e); void BuildReflection(); DXBCKey m_Key; rdcstr m_DebugInfoPath; rdcarray<rdcstr> *m_DebugInfoSearchPaths; rdcarray<byte> m_Bytecode; bool m_Built; DXBC::DXBCContainer *m_DXBCFile; ShaderReflection m_Details; ShaderBindpointMapping m_Mapping; static std::map<DXBCKey, ShaderEntry *> m_Shaders; }; enum { TypeEnum = Resource_PipelineState, }; ShaderEntry *VS() { return (ShaderEntry *)graphics->VS.pShaderBytecode; } ShaderEntry *HS() { return (ShaderEntry *)graphics->HS.pShaderBytecode; } ShaderEntry *DS() { return (ShaderEntry *)graphics->DS.pShaderBytecode; } ShaderEntry *GS() { return (ShaderEntry *)graphics->GS.pShaderBytecode; } ShaderEntry *PS() { return (ShaderEntry *)graphics->PS.pShaderBytecode; } ShaderEntry *CS() { return (ShaderEntry *)compute->CS.pShaderBytecode; } WrappedID3D12PipelineState(ID3D12PipelineState *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { if(IsReplayMode(m_pDevice->GetState())) m_pDevice->GetPipelineList().push_back(this); } virtual ~WrappedID3D12PipelineState() { if(IsReplayMode(m_pDevice->GetState())) m_pDevice->GetPipelineList().removeOne(this); Shutdown(); if(graphics) { ShaderEntry::ReleaseShader(VS()); ShaderEntry::ReleaseShader(HS()); ShaderEntry::ReleaseShader(DS()); ShaderEntry::ReleaseShader(GS()); ShaderEntry::ReleaseShader(PS()); SAFE_DELETE_ARRAY(graphics->InputLayout.pInputElementDescs); SAFE_DELETE_ARRAY(graphics->StreamOutput.pSODeclaration); SAFE_DELETE_ARRAY(graphics->StreamOutput.pBufferStrides); SAFE_DELETE(graphics); } if(compute) { ShaderEntry::ReleaseShader(CS()); SAFE_DELETE(compute); } } ////////////////////////////// // implement ID3D12PipelineState virtual HRESULT STDMETHODCALLTYPE GetCachedBlob(ID3DBlob **ppBlob) { return m_pReal->GetCachedBlob(ppBlob); } }; typedef WrappedID3D12PipelineState::ShaderEntry WrappedID3D12Shader; class WrappedID3D12QueryHeap : public WrappedDeviceChild12<ID3D12QueryHeap> { public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12QueryHeap); enum { TypeEnum = Resource_QueryHeap, }; WrappedID3D12QueryHeap(ID3D12QueryHeap *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { } virtual ~WrappedID3D12QueryHeap() { Shutdown(); } }; class WrappedID3D12Resource1 : public WrappedDeviceChild12<ID3D12Resource, ID3D12Resource1> { ID3D12Resource1 *m_pReal1 = NULL; static GPUAddressRangeTracker m_Addresses; bool resident; WriteSerialiser &GetThreadSerialiser(); public: static const int AllocPoolCount = 16384; static const int AllocMaxByteSize = 1536 * 1024; ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12Resource1, AllocPoolCount, AllocMaxByteSize, false); static void RefBuffers(D3D12ResourceManager *rm); static void GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr, ResourceId &id, UINT64 &offs) { m_Addresses.GetResIDFromAddr(addr, id, offs); } // overload to just return the id in case the offset isn't needed static ResourceId GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr) { ResourceId id; UINT64 offs; m_Addresses.GetResIDFromAddr(addr, id, offs); return id; } enum { TypeEnum = Resource_Resource, }; WrappedID3D12Resource1(ID3D12Resource *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { if(IsReplayMode(device->GetState())) device->GetResourceList()[GetResourceID()] = this; real->QueryInterface(__uuidof(ID3D12Resource1), (void **)&m_pReal1); SetResident(true); // assuming only valid for buffers if(m_pReal->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { D3D12_GPU_VIRTUAL_ADDRESS addr = m_pReal->GetGPUVirtualAddress(); GPUAddressRange range; range.start = addr; range.end = addr + m_pReal->GetDesc().Width; range.id = GetResourceID(); m_Addresses.AddTo(range); } } virtual ~WrappedID3D12Resource1(); bool Resident() { return resident; } void SetResident(bool r) { resident = r; } byte *GetMap(UINT Subresource); byte *GetShadow(UINT Subresource); void AllocShadow(UINT Subresource, size_t size); void FreeShadow(); virtual uint64_t GetGPUVirtualAddressIfBuffer() { if(m_pReal->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) return m_pReal->GetGPUVirtualAddress(); return 0; } ////////////////////////////// // implement ID3D12Resource virtual D3D12_RESOURCE_DESC STDMETHODCALLTYPE GetDesc() { return m_pReal->GetDesc(); } virtual D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE GetGPUVirtualAddress() { return m_pReal->GetGPUVirtualAddress(); } virtual HRESULT STDMETHODCALLTYPE GetHeapProperties(D3D12_HEAP_PROPERTIES *pHeapProperties, D3D12_HEAP_FLAGS *pHeapFlags) { return m_pReal->GetHeapProperties(pHeapProperties, pHeapFlags); } virtual HRESULT STDMETHODCALLTYPE Map(UINT Subresource, const D3D12_RANGE *pReadRange, void **ppData); virtual void STDMETHODCALLTYPE Unmap(UINT Subresource, const D3D12_RANGE *pWrittenRange); virtual HRESULT STDMETHODCALLTYPE WriteToSubresource(UINT DstSubresource, const D3D12_BOX *pDstBox, const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch); virtual HRESULT STDMETHODCALLTYPE ReadFromSubresource(void *pDstData, UINT DstRowPitch, UINT DstDepthPitch, UINT SrcSubresource, const D3D12_BOX *pSrcBox) { // don't have to do anything here return m_pReal->ReadFromSubresource(pDstData, DstRowPitch, DstDepthPitch, SrcSubresource, pSrcBox); } ////////////////////////////// // implement ID3D12Resource1 virtual HRESULT STDMETHODCALLTYPE GetProtectedResourceSession(REFIID riid, _COM_Outptr_opt_ void **ppProtectedSession) { void *iface = NULL; HRESULT ret = m_pReal1->GetProtectedResourceSession(riid, &iface); if(ret != S_OK) return ret; if(riid == __uuidof(ID3D12ProtectedResourceSession)) { *ppProtectedSession = new WrappedID3D12ProtectedResourceSession( (ID3D12ProtectedResourceSession *)iface, m_pDevice); } else { RDCERR("Unsupported interface %s", ToStr(riid).c_str()); return E_NOINTERFACE; } return S_OK; } }; class WrappedID3D12RootSignature : public WrappedDeviceChild12<ID3D12RootSignature> { public: static const int AllocPoolCount = 8192; static const int AllocMaxByteSize = 2 * 1024 * 1024; ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12RootSignature, AllocPoolCount, AllocMaxByteSize); D3D12RootSignature sig; enum { TypeEnum = Resource_RootSignature, }; WrappedID3D12RootSignature(ID3D12RootSignature *real, WrappedID3D12Device *device) : WrappedDeviceChild12(real, device) { } virtual ~WrappedID3D12RootSignature() { Shutdown(); } }; class WrappedID3D12PipelineLibrary1 : public WrappedDeviceChild12<ID3D12PipelineLibrary1> { public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12PipelineLibrary1); enum { TypeEnum = Resource_PipelineLibrary, }; WrappedID3D12PipelineLibrary1(WrappedID3D12Device *device) : WrappedDeviceChild12(NULL, device) {} virtual ~WrappedID3D12PipelineLibrary1() { Shutdown(); } virtual HRESULT STDMETHODCALLTYPE StorePipeline(_In_opt_ LPCWSTR pName, _In_ ID3D12PipelineState *pPipeline) { // do nothing return S_OK; } virtual HRESULT STDMETHODCALLTYPE LoadGraphicsPipeline(_In_ LPCWSTR pName, _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, REFIID riid, _COM_Outptr_ void **ppPipelineState) { // pretend we don't have it - assume that the application won't store then // load in the same run, or will handle that if it happens return E_INVALIDARG; } virtual HRESULT STDMETHODCALLTYPE LoadComputePipeline(_In_ LPCWSTR pName, _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, REFIID riid, _COM_Outptr_ void **ppPipelineState) { // pretend we don't have it - assume that the application won't store then // load in the same run, or will handle that if it happens return E_INVALIDARG; } static const SIZE_T DummyBytes = 32; virtual SIZE_T STDMETHODCALLTYPE GetSerializedSize(void) { // simple dummy serialisation since applications might not expect 0 bytes return DummyBytes; } virtual HRESULT STDMETHODCALLTYPE Serialize(_Out_writes_(DataSizeInBytes) void *pData, SIZE_T DataSizeInBytes) { if(DataSizeInBytes < DummyBytes) return E_INVALIDARG; memset(pData, 0, DummyBytes); return S_OK; } ////////////////////////////// // implement ID3D12PipelineLibrary1 virtual HRESULT STDMETHODCALLTYPE LoadPipeline(LPCWSTR pName, const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, REFIID riid, void **ppPipelineState) { // pretend we don't have it - assume that the application won't store then // load in the same run, or will handle that if it happens return E_INVALIDARG; } }; #define ALL_D3D12_TYPES \ D3D12_TYPE_MACRO(ID3D12CommandAllocator); \ D3D12_TYPE_MACRO(ID3D12CommandSignature); \ D3D12_TYPE_MACRO(ID3D12DescriptorHeap); \ D3D12_TYPE_MACRO(ID3D12Fence1); \ D3D12_TYPE_MACRO(ID3D12Heap1); \ D3D12_TYPE_MACRO(ID3D12PipelineState); \ D3D12_TYPE_MACRO(ID3D12QueryHeap); \ D3D12_TYPE_MACRO(ID3D12Resource1); \ D3D12_TYPE_MACRO(ID3D12RootSignature); \ D3D12_TYPE_MACRO(ID3D12PipelineLibrary1); \ D3D12_TYPE_MACRO(ID3D12ProtectedResourceSession); // template magic voodoo to unwrap types template <typename inner> struct UnwrapHelper { }; #undef D3D12_TYPE_MACRO #define D3D12_TYPE_MACRO(iface) \ template <> \ struct UnwrapHelper<iface> \ { \ typedef CONCAT(Wrapped, iface) Outer; \ static bool IsAlloc(void *ptr) { return Outer::IsAlloc(ptr); } \ static D3D12ResourceType GetTypeEnum() { return (D3D12ResourceType)Outer::TypeEnum; } \ static Outer *FromHandle(iface *wrapped) { return (Outer *)wrapped; } \ }; \ template <> \ struct UnwrapHelper<CONCAT(Wrapped, iface)> \ { \ typedef CONCAT(Wrapped, iface) Outer; \ static bool IsAlloc(void *ptr) { return Outer::IsAlloc(ptr); } \ static D3D12ResourceType GetTypeEnum() { return (D3D12ResourceType)Outer::TypeEnum; } \ static Outer *FromHandle(iface *wrapped) { return (Outer *)wrapped; } \ }; ALL_D3D12_TYPES; // extra helpers here for '1' or '2' extended interfaces #define D3D12_UNWRAP_EXTENDED(iface, ifaceX) \ template <> \ struct UnwrapHelper<iface> \ { \ typedef CONCAT(Wrapped, ifaceX) Outer; \ static bool IsAlloc(void *ptr) { return Outer::IsAlloc(ptr); } \ static D3D12ResourceType GetTypeEnum() { return (D3D12ResourceType)Outer::TypeEnum; } \ static Outer *FromHandle(iface *wrapped) { return (Outer *)wrapped; } \ }; D3D12_UNWRAP_EXTENDED(ID3D12Fence, ID3D12Fence1); D3D12_UNWRAP_EXTENDED(ID3D12PipelineLibrary, ID3D12PipelineLibrary1); D3D12_UNWRAP_EXTENDED(ID3D12Heap, ID3D12Heap1); D3D12_UNWRAP_EXTENDED(ID3D12Resource, ID3D12Resource1); D3D12ResourceType IdentifyTypeByPtr(ID3D12Object *ptr); #define WRAPPING_DEBUG 0 template <typename iface> typename UnwrapHelper<iface>::Outer *GetWrapped(iface *obj) { if(obj == NULL) return NULL; typename UnwrapHelper<iface>::Outer *wrapped = UnwrapHelper<iface>::FromHandle(obj); #if WRAPPING_DEBUG if(obj != NULL && !wrapped->IsAlloc(wrapped)) { RDCERR("Trying to unwrap invalid type"); return NULL; } #endif return wrapped; } class WrappedID3D12GraphicsCommandList; template <typename ifaceptr> ifaceptr Unwrap(ifaceptr obj) { if(obj == NULL) return NULL; return GetWrapped(obj)->GetReal(); } template <typename ifaceptr> ResourceId GetResID(ifaceptr obj) { if(obj == NULL) return ResourceId(); return GetWrapped(obj)->GetResourceID(); } template <typename ifaceptr> D3D12ResourceRecord *GetRecord(ifaceptr obj) { if(obj == NULL) return NULL; return GetWrapped(obj)->GetResourceRecord(); } // specialisations that use the IsAlloc() function to identify the real type template <> ResourceId GetResID(ID3D12Object *ptr); template <> ID3D12Object *Unwrap(ID3D12Object *ptr); template <> D3D12ResourceRecord *GetRecord(ID3D12Object *ptr); template <> ResourceId GetResID(ID3D12DeviceChild *ptr); template <> ResourceId GetResID(ID3D12Pageable *ptr); template <> ResourceId GetResID(ID3D12CommandList *ptr); template <> ResourceId GetResID(ID3D12GraphicsCommandList *ptr); template <> ResourceId GetResID(ID3D12CommandQueue *ptr); template <> ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr); template <> D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr);
// // Copyright (c) 2015-2018 The NRDI developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef NRDI_CONCURRENTQUEUE_H #define NRDI_CONCURRENTQUEUE_H #include <mutex> #include <condition_variable> #include <deque> template <typename T> class concurrentqueue { private: std::mutex mutex; std::condition_variable condition; std::deque<T> queue; public: void push(T const& value) { { std::unique_lock<std::mutex> lock(this->mutex); queue.push_front(value); } this->condition.notify_one(); } T pop() { std::unique_lock<std::mutex> lock(this->mutex); this->condition.wait(lock, [=]{ return !this->queue.empty(); }); T rc(std::move(this->queue.back())); this->queue.pop_back(); return rc; } T popNotWait(){ std::unique_lock<std::mutex> lock(this->mutex); T rc(std::move(this->queue.back())); this->queue.pop_back(); return rc; } bool hasElements(){ std::unique_lock<std::mutex> lock(this->mutex); return !queue.empty(); } }; #endif //NRDI_CONCURRENTQUEUE_H
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "intermediatenodes.h" #include "querybuilder.h" #include "queryvisitor.h" #include "termnodes.h" namespace search::query { /** * Creates a new query tree based on an existing one. The traits class * specifies what concrete types the query tree classes should have. */ template <class NodeTypes> class QueryReplicator : private QueryVisitor { QueryBuilder<NodeTypes> _builder; public: Node::UP replicate(const Node &node) { // The visitor doesn't deal with const nodes. However, we are // not changing the node, so we can safely remove the const. const_cast<Node &>(node).accept(*this); return _builder.build(); } private: void visitNodes(const std::vector<Node *> &nodes) { for (size_t i = 0; i < nodes.size(); ++i) { nodes[i]->accept(*this); } } void visit(And &node) override { _builder.addAnd(node.getChildren().size()); visitNodes(node.getChildren()); } void visit(AndNot &node) override { _builder.addAndNot(node.getChildren().size()); visitNodes(node.getChildren()); } void visit(WeakAnd &node) override { _builder.addWeakAnd(node.getChildren().size(), node.getMinHits(), node.getView()); visitNodes(node.getChildren()); } void visit(Equiv &node) override { _builder.addEquiv(node.getChildren().size(), node.getId(), node.getWeight()); visitNodes(node.getChildren()); } void visit(Near &node) override { _builder.addNear(node.getChildren().size(), node.getDistance()); visitNodes(node.getChildren()); } void visit(ONear &node) override { _builder.addONear(node.getChildren().size(), node.getDistance()); visitNodes(node.getChildren()); } void visit(Or &node) override { _builder.addOr(node.getChildren().size()); visitNodes(node.getChildren()); } void visit(Phrase &node) override { replicate(node, _builder.addPhrase(node.getChildren().size(), node.getView(), node.getId(), node.getWeight()).set_expensive(node.is_expensive())); visitNodes(node.getChildren()); } void visit(SameElement &node) override { _builder.addSameElement(node.getChildren().size(), node.getView()).set_expensive(node.is_expensive()); visitNodes(node.getChildren()); } void visit(WeightedSetTerm &node) override { replicate(node, _builder.addWeightedSetTerm(node.getChildren().size(), node.getView(), node.getId(), node.getWeight())); visitNodes(node.getChildren()); } void visit(DotProduct &node) override { replicate(node, _builder.addDotProduct(node.getChildren().size(), node.getView(), node.getId(), node.getWeight())); visitNodes(node.getChildren()); } void visit(WandTerm &node) override { replicate(node, _builder.addWandTerm(node.getChildren().size(), node.getView(), node.getId(), node.getWeight(), node.getTargetNumHits(), node.getScoreThreshold(), node.getThresholdBoostFactor())); visitNodes(node.getChildren()); } void visit(Rank &node) override { _builder.addRank(node.getChildren().size()); visitNodes(node.getChildren()); } void replicate(const Term &original, Term &replica) { replica.setStateFrom(original); } void visit(NumberTerm &node) override { replicate(node, _builder.addNumberTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(LocationTerm &node) override { replicate(node,_builder.addLocationTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(PrefixTerm &node) override { replicate(node, _builder.addPrefixTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(RangeTerm &node) override { replicate(node, _builder.addRangeTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(StringTerm &node) override { replicate(node, _builder.addStringTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(SubstringTerm &node) override { replicate(node, _builder.addSubstringTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(SuffixTerm &node) override { replicate(node, _builder.addSuffixTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(PredicateQuery &node) override { replicate(node, _builder.addPredicateQuery( std::make_unique<PredicateQueryTerm>(*node.getTerm()), node.getView(), node.getId(), node.getWeight())); } void visit(RegExpTerm &node) override { replicate(node, _builder.addRegExpTerm( node.getTerm(), node.getView(), node.getId(), node.getWeight())); } void visit(NearestNeighborTerm &node) override { replicate(node, _builder.add_nearest_neighbor_term(node.get_query_tensor_name(), node.getView(), node.getId(), node.getWeight(), node.get_target_num_hits(), node.get_allow_approximate(), node.get_explore_additional_hits())); } }; }
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * * Libmemcached library * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2009 Brian Aker All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * * The names of its contributors may not be used to endorse or * promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #pragma once #ifdef __cplusplus extern "C" { #endif /* The two public hash bits */ LIBMEMCACHED_API uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm); LIBMEMCACHED_API const hashkit_st *memcached_get_hashkit(const memcached_st *ptr); LIBMEMCACHED_API memcached_return_t memcached_set_hashkit(memcached_st *ptr, hashkit_st *hashk); LIBMEMCACHED_API uint32_t memcached_generate_hash(const memcached_st *ptr, const char *key, size_t key_length); LIBMEMCACHED_LOCAL uint32_t memcached_generate_hash_with_redistribution(memcached_st *ptr, const char *key, size_t key_length); LIBMEMCACHED_API void memcached_autoeject(memcached_st *ptr); LIBMEMCACHED_API const char * libmemcached_string_hash(memcached_hash_t type); #ifdef __cplusplus } #endif
/** * FreeRDP: A Remote Desktop Protocol Client * T.124 Generic Conference Control (GCC) * * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <freerdp/utils/print.h> #include "gcc.h" #include "certificate.h" /** * T.124 GCC is defined in: * * http://www.itu.int/rec/T-REC-T.124-199802-S/en * ITU-T T.124 (02/98): Generic Conference Control */ /** * ConnectData ::= SEQUENCE * { * t124Identifier Key, * connectPDU OCTET_STRING * } * * Key ::= CHOICE * { * object OBJECT_IDENTIFIER, * h221NonStandard H221NonStandardIdentifier * } * * ConnectGCCPDU ::= CHOICE * { * conferenceCreateRequest ConferenceCreateRequest, * conferenceCreateResponse ConferenceCreateResponse, * conferenceQueryRequest ConferenceQueryRequest, * conferenceQueryResponse ConferenceQueryResponse, * conferenceJoinRequest ConferenceJoinRequest, * conferenceJoinResponse ConferenceJoinResponse, * conferenceInviteRequest ConferenceInviteRequest, * conferenceInviteResponse ConferenceInviteResponse, * ... * } * * ConferenceCreateRequest ::= SEQUENCE * { * conferenceName ConferenceName, * convenerPassword Password OPTIONAL, * password Password OPTIONAL, * lockedConference BOOLEAN, * listedConference BOOLEAN, * conductibleConference BOOLEAN, * terminationMethod TerminationMethod, * conductorPrivileges SET OF Privilege OPTIONAL, * conductedPrivileges SET OF Privilege OPTIONAL, * nonConductedPrivileges SET OF Privilege OPTIONAL, * conferenceDescription TextString OPTIONAL, * callerIdentifier TextString OPTIONAL, * userData UserData OPTIONAL, * ..., * conferencePriority ConferencePriority OPTIONAL, * conferenceMode ConferenceMode OPTIONAL * } * * ConferenceCreateResponse ::= SEQUENCE * { * nodeID UserID, * tag INTEGER, * result ENUMERATED * { * success (0), * userRejected (1), * resourcesNotAvailable (2), * rejectedForSymmetryBreaking (3), * lockedConferenceNotSupported (4) * }, * userData UserData OPTIONAL, * ... * } * * ConferenceName ::= SEQUENCE * { * numeric SimpleNumericString * text SimpleTextString OPTIONAL, * ... * } * * SimpleNumericString ::= NumericString (SIZE (1..255)) (FROM ("0123456789")) * * UserData ::= SET OF SEQUENCE * { * key Key, * value OCTET_STRING OPTIONAL * } * * H221NonStandardIdentifier ::= OCTET STRING (SIZE (4..255)) * * UserID ::= DynamicChannelID * * ChannelID ::= INTEGER (1..65535) * StaticChannelID ::= INTEGER (1..1000) * DynamicChannelID ::= INTEGER (1001..65535) * */ /* * OID = 0.0.20.124.0.1 * { itu-t(0) recommendation(0) t(20) t124(124) version(0) 1 } * v.1 of ITU-T Recommendation T.124 (Feb 1998): "Generic Conference Control" */ uint8 t124_02_98_oid[6] = { 0, 0, 20, 124, 0, 1 }; uint8 h221_cs_key[4] = "Duca"; uint8 h221_sc_key[4] = "McDn"; /** * Read a GCC Conference Create Request.\n * @msdn{cc240836} * @param s stream * @param settings rdp settings */ boolean gcc_read_conference_create_request(STREAM* s, rdpSettings* settings) { uint16 length; uint8 choice; uint8 number; uint8 selection; /* ConnectData */ if (!per_read_choice(s, &choice)) return false; if (!per_read_object_identifier(s, t124_02_98_oid)) return false; /* ConnectData::connectPDU (OCTET_STRING) */ if (!per_read_length(s, &length)) return false; /* ConnectGCCPDU */ if (!per_read_choice(s, &choice)) return false; if (!per_read_selection(s, &selection)) return false; /* ConferenceCreateRequest::conferenceName */ if (!per_read_numeric_string(s, 1)) /* ConferenceName::numeric */ return false; if (!per_read_padding(s, 1)) /* padding */ return false; /* UserData (SET OF SEQUENCE) */ if (!per_read_number_of_sets(s, &number) || number != 1) /* one set of UserData */ return false; if (!per_read_choice(s, &choice) || choice != 0xC0) /* UserData::value present + select h221NonStandard (1) */ return false; /* h221NonStandard */ if (!per_read_octet_string(s, h221_cs_key, 4, 4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */ return false; /* userData::value (OCTET_STRING) */ if (!per_read_length(s, &length)) return false; if (stream_get_left(s) < length) return false; if (!gcc_read_client_data_blocks(s, settings, length)) return false; return true; } /** * Write a GCC Conference Create Request.\n * @msdn{cc240836} * @param s stream * @param user_data client data blocks */ void gcc_write_conference_create_request(STREAM* s, STREAM* user_data) { /* ConnectData */ per_write_choice(s, 0); /* From Key select object (0) of type OBJECT_IDENTIFIER */ per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */ /* ConnectData::connectPDU (OCTET_STRING) */ per_write_length(s, stream_get_length(user_data) + 14); /* connectPDU length */ /* ConnectGCCPDU */ per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */ per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */ /* ConferenceCreateRequest::conferenceName */ per_write_numeric_string(s, (uint8*)"1", 1, 1); /* ConferenceName::numeric */ per_write_padding(s, 1); /* padding */ /* UserData (SET OF SEQUENCE) */ per_write_number_of_sets(s, 1); /* one set of UserData */ per_write_choice(s, 0xC0); /* UserData::value present + select h221NonStandard (1) */ /* h221NonStandard */ per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */ /* userData::value (OCTET_STRING) */ per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of client data blocks */ } boolean gcc_read_conference_create_response(STREAM* s, rdpSettings* settings) { uint16 length; uint32 tag; uint16 nodeID; uint8 result; uint8 choice; uint8 number; /* ConnectData */ per_read_choice(s, &choice); per_read_object_identifier(s, t124_02_98_oid); /* ConnectData::connectPDU (OCTET_STRING) */ per_read_length(s, &length); /* ConnectGCCPDU */ per_read_choice(s, &choice); /* ConferenceCreateResponse::nodeID (UserID) */ per_read_integer16(s, &nodeID, 1001); /* ConferenceCreateResponse::tag (INTEGER) */ per_read_integer(s, &tag); /* ConferenceCreateResponse::result (ENUMERATED) */ per_read_enumerated(s, &result, MCS_Result_enum_length); /* number of UserData sets */ per_read_number_of_sets(s, &number); /* UserData::value present + select h221NonStandard (1) */ per_read_choice(s, &choice); /* h221NonStandard */ if (!per_read_octet_string(s, h221_sc_key, 4, 4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */ return false; /* userData (OCTET_STRING) */ per_read_length(s, &length); if (!gcc_read_server_data_blocks(s, settings, length)) { printf("gcc_read_conference_create_response: gcc_read_server_data_blocks failed\n"); return false; } return true; } void gcc_write_conference_create_response(STREAM* s, STREAM* user_data) { /* ConnectData */ per_write_choice(s, 0); per_write_object_identifier(s, t124_02_98_oid); /* ConnectData::connectPDU (OCTET_STRING) */ per_write_length(s, stream_get_length(user_data) + 2); /* ConnectGCCPDU */ per_write_choice(s, 0x14); /* ConferenceCreateResponse::nodeID (UserID) */ per_write_integer16(s, 0x79F3, 1001); /* ConferenceCreateResponse::tag (INTEGER) */ per_write_integer(s, 1); /* ConferenceCreateResponse::result (ENUMERATED) */ per_write_enumerated(s, 0, MCS_Result_enum_length); /* number of UserData sets */ per_write_number_of_sets(s, 1); /* UserData::value present + select h221NonStandard (1) */ per_write_choice(s, 0xC0); /* h221NonStandard */ per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */ /* userData (OCTET_STRING) */ per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of server data blocks */ } boolean gcc_read_client_data_blocks(STREAM* s, rdpSettings* settings, int length) { uint16 type; uint16 blockLength; int pos; while (length > 0) { pos = stream_get_pos(s); gcc_read_user_data_header(s, &type, &blockLength); switch (type) { case CS_CORE: if (!gcc_read_client_core_data(s, settings, blockLength - 4)) return false; break; case CS_SECURITY: if (!gcc_read_client_security_data(s, settings, blockLength - 4)) return false; break; case CS_NET: if (!gcc_read_client_network_data(s, settings, blockLength - 4)) return false; break; case CS_CLUSTER: if (!gcc_read_client_cluster_data(s, settings, blockLength - 4)) return false; break; case CS_MONITOR: if (!gcc_read_client_monitor_data(s, settings, blockLength - 4)) return false; break; default: break; } length -= blockLength; stream_set_pos(s, pos + blockLength); } return true; } void gcc_write_client_data_blocks(STREAM* s, rdpSettings* settings) { gcc_write_client_core_data(s, settings); gcc_write_client_cluster_data(s, settings); gcc_write_client_security_data(s, settings); gcc_write_client_network_data(s, settings); /* extended client data supported */ if (settings->negotiationFlags) gcc_write_client_monitor_data(s, settings); } boolean gcc_read_server_data_blocks(STREAM* s, rdpSettings* settings, int length) { uint16 type; uint16 offset = 0; uint16 blockLength; uint8* holdp; while (offset < length) { holdp = s->p; if (!gcc_read_user_data_header(s, &type, &blockLength)) { printf("gcc_read_server_data_blocks: gcc_read_user_data_header failed\n"); return false; } switch (type) { case SC_CORE: if (!gcc_read_server_core_data(s, settings)) { printf("gcc_read_server_data_blocks: gcc_read_server_core_data failed\n"); return false; } break; case SC_SECURITY: if (!gcc_read_server_security_data(s, settings)) { printf("gcc_read_server_data_blocks: gcc_read_server_security_data failed\n"); return false; } break; case SC_NET: if (!gcc_read_server_network_data(s, settings)) { printf("gcc_read_server_data_blocks: gcc_read_server_network_data failed\n"); return false; } break; default: printf("gcc_read_server_data_blocks: ignoring type=%hu\n", type); break; } offset += blockLength; s->p = holdp + blockLength; } return true; } void gcc_write_server_data_blocks(STREAM* s, rdpSettings* settings) { gcc_write_server_core_data(s, settings); gcc_write_server_network_data(s, settings); gcc_write_server_security_data(s, settings); } boolean gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length) { stream_read_uint16(s, *type); /* type */ stream_read_uint16(s, *length); /* length */ if (*length < 4) return false; if (stream_get_left(s) < *length - 4) return false; return true; } /** * Write a user data header (TS_UD_HEADER).\n * @msdn{cc240509} * @param s stream * @param type data block type * @param length data block length */ void gcc_write_user_data_header(STREAM* s, uint16 type, uint16 length) { stream_write_uint16(s, type); /* type */ stream_write_uint16(s, length); /* length */ } /** * Read a client core data block (TS_UD_CS_CORE).\n * @msdn{cc240510} * @param s stream * @param settings rdp settings */ boolean gcc_read_client_core_data(STREAM* s, rdpSettings* settings, uint16 blockLength) { char* str; uint32 version; uint32 color_depth; uint16 colorDepth = 0; uint16 postBeta2ColorDepth = 0; uint16 highColorDepth = 0; uint16 supportedColorDepths = 0; uint16 earlyCapabilityFlags = 0; uint32 serverSelectedProtocol = 0; /* Length of all required fields, until imeFileName */ if (blockLength < 128) return false; stream_read_uint32(s, version); /* version */ settings->rdp_version = (version == RDP_VERSION_4 ? 4 : 7); stream_read_uint16(s, settings->width); /* desktopWidth */ stream_read_uint16(s, settings->height); /* desktopHeight */ stream_read_uint16(s, colorDepth); /* colorDepth */ stream_seek_uint16(s); /* SASSequence (Secure Access Sequence) */ stream_read_uint32(s, settings->kbd_layout); /* keyboardLayout */ stream_read_uint32(s, settings->client_build); /* clientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 32); stream_seek(s, 32); snprintf(settings->client_hostname, 31, "%s", str); settings->client_hostname[31] = 0; xfree(str); stream_read_uint32(s, settings->kbd_type); /* keyboardType */ stream_read_uint32(s, settings->kbd_subtype); /* keyboardSubType */ stream_read_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */ stream_seek(s, 64); /* imeFileName */ blockLength -= 128; /** * The following fields are all optional. If one field is present, all of the preceding * fields MUST also be present. If one field is not present, all of the subsequent fields * MUST NOT be present. * We must check the bytes left before reading each field. */ do { if (blockLength < 2) break; stream_read_uint16(s, postBeta2ColorDepth); /* postBeta2ColorDepth */ blockLength -= 2; if (blockLength < 2) break; stream_seek_uint16(s); /* clientProductID */ blockLength -= 2; if (blockLength < 4) break; stream_seek_uint32(s); /* serialNumber */ blockLength -= 4; if (blockLength < 2) break; stream_read_uint16(s, highColorDepth); /* highColorDepth */ blockLength -= 2; if (blockLength < 2) break; stream_read_uint16(s, supportedColorDepths); /* supportedColorDepths */ blockLength -= 2; if (blockLength < 2) break; stream_read_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */ blockLength -= 2; if (blockLength < 64) break; str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64); stream_seek(s, 64); snprintf(settings->client_product_id, 32, "%s", str); xfree(str); blockLength -= 64; if (blockLength < 1) break; stream_read_uint8(s, settings->performance_flags); /* connectionType */ blockLength -= 1; if (blockLength < 1) break; stream_seek_uint8(s); /* pad1octet */ blockLength -= 1; if (blockLength < 4) break; stream_read_uint32(s, serverSelectedProtocol); /* serverSelectedProtocol */ blockLength -= 4; if (settings->selected_protocol != serverSelectedProtocol) return false; } while (0); if (highColorDepth > 0) color_depth = highColorDepth; else if (postBeta2ColorDepth > 0) { switch (postBeta2ColorDepth) { case RNS_UD_COLOR_4BPP: color_depth = 4; break; case RNS_UD_COLOR_8BPP: color_depth = 8; break; case RNS_UD_COLOR_16BPP_555: color_depth = 15; break; case RNS_UD_COLOR_16BPP_565: color_depth = 16; break; case RNS_UD_COLOR_24BPP: color_depth = 24; break; default: return false; } } else { switch (colorDepth) { case RNS_UD_COLOR_4BPP: color_depth = 4; break; case RNS_UD_COLOR_8BPP: color_depth = 8; break; default: return false; } } /* * If we are in server mode, accepth client's color depth only if * it is smaller than ours. This is what Windows server does. */ if (color_depth < settings->color_depth || !settings->server_mode) settings->color_depth = color_depth; return true; } /** * Write a client core data block (TS_UD_CS_CORE).\n * @msdn{cc240510} * @param s stream * @param settings rdp settings */ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) { uint32 version; char* clientName; size_t clientNameLength; uint8 connectionType; uint16 highColorDepth; uint16 supportedColorDepths; uint16 earlyCapabilityFlags; char* clientDigProductId; size_t clientDigProductIdLength; gcc_write_user_data_header(s, CS_CORE, 216); version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4; clientName = freerdp_uniconv_out(settings->uniconv, settings->client_hostname, &clientNameLength); clientDigProductId = freerdp_uniconv_out(settings->uniconv, settings->client_product_id, &clientDigProductIdLength); stream_write_uint32(s, version); /* version */ stream_write_uint16(s, settings->width); /* desktopWidth */ stream_write_uint16(s, settings->height); /* desktopHeight */ stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* colorDepth, ignored because of postBeta2ColorDepth */ stream_write_uint16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */ stream_write_uint32(s, settings->kbd_layout); /* keyboardLayout */ stream_write_uint32(s, settings->client_build); /* clientBuild */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ if (clientNameLength > 30) { clientNameLength = 30; clientName[clientNameLength] = 0; clientName[clientNameLength + 1] = 0; } stream_write(s, clientName, clientNameLength + 2); stream_write_zero(s, 32 - clientNameLength - 2); xfree(clientName); stream_write_uint32(s, settings->kbd_type); /* keyboardType */ stream_write_uint32(s, settings->kbd_subtype); /* keyboardSubType */ stream_write_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */ stream_write_zero(s, 64); /* imeFileName */ stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */ stream_write_uint16(s, 1); /* clientProductID */ stream_write_uint32(s, 0); /* serialNumber (should be initialized to 0) */ highColorDepth = MIN(settings->color_depth, 24); supportedColorDepths = RNS_UD_24BPP_SUPPORT | RNS_UD_16BPP_SUPPORT | RNS_UD_15BPP_SUPPORT; connectionType = settings->connection_type; earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU; if (settings->rfx_codec) connectionType = CONNECTION_TYPE_LAN; if (connectionType != 0) earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE; if (settings->color_depth == 32) { supportedColorDepths |= RNS_UD_32BPP_SUPPORT; earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION; } stream_write_uint16(s, highColorDepth); /* highColorDepth */ stream_write_uint16(s, supportedColorDepths); /* supportedColorDepths */ stream_write_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */ /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */ if (clientDigProductIdLength > 62) { clientDigProductIdLength = 62; clientDigProductId[clientDigProductIdLength] = 0; clientDigProductId[clientDigProductIdLength + 1] = 0; } stream_write(s, clientDigProductId, clientDigProductIdLength + 2); stream_write_zero(s, 64 - clientDigProductIdLength - 2); xfree(clientDigProductId); stream_write_uint8(s, connectionType); /* connectionType */ stream_write_uint8(s, 0); /* pad1octet */ stream_write_uint32(s, settings->selected_protocol); /* serverSelectedProtocol */ } boolean gcc_read_server_core_data(STREAM* s, rdpSettings* settings) { uint32 version; uint32 clientRequestedProtocols; stream_read_uint32(s, version); /* version */ stream_read_uint32(s, clientRequestedProtocols); /* clientRequestedProtocols */ if (version == RDP_VERSION_4 && settings->rdp_version > 4) settings->rdp_version = 4; else if (version == RDP_VERSION_5_PLUS && settings->rdp_version < 5) settings->rdp_version = 7; return true; } void gcc_write_server_core_data(STREAM* s, rdpSettings* settings) { gcc_write_user_data_header(s, SC_CORE, 12); stream_write_uint32(s, settings->rdp_version == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS); stream_write_uint32(s, settings->requested_protocols); /* clientRequestedProtocols */ } /** * Read a client security data block (TS_UD_CS_SEC).\n * @msdn{cc240511} * @param s stream * @param settings rdp settings */ boolean gcc_read_client_security_data(STREAM* s, rdpSettings* settings, uint16 blockLength) { if (blockLength < 8) return false; if (settings->encryption) { stream_read_uint32(s, settings->encryption_method); /* encryptionMethods */ if (settings->encryption_method == 0) stream_read_uint32(s, settings->encryption_method); /* extEncryptionMethods */ } else { stream_seek(s, 8); } return true; } /** * Write a client security data block (TS_UD_CS_SEC).\n * @msdn{cc240511} * @param s stream * @param settings rdp settings */ void gcc_write_client_security_data(STREAM* s, rdpSettings* settings) { gcc_write_user_data_header(s, CS_SECURITY, 12); if (settings->encryption) { stream_write_uint32(s, settings->encryption_method); /* encryptionMethods */ stream_write_uint32(s, 0); /* extEncryptionMethods */ } else { /* French locale, disable encryption */ stream_write_uint32(s, 0); /* encryptionMethods */ stream_write_uint32(s, settings->encryption_method); /* extEncryptionMethods */ } } boolean gcc_read_server_security_data(STREAM* s, rdpSettings* settings) { uint8* data; uint32 length; uint32 serverRandomLen; uint32 serverCertLen; stream_read_uint32(s, settings->encryption_method); /* encryptionMethod */ stream_read_uint32(s, settings->encryption_level); /* encryptionLevel */ if (settings->encryption_method == 0 && settings->encryption_level == 0) { /* serverRandom and serverRandom must not be present */ settings->encryption = false; settings->encryption_method = ENCRYPTION_METHOD_NONE; settings->encryption_level = ENCRYPTION_LEVEL_NONE; return true; } stream_read_uint32(s, serverRandomLen); /* serverRandomLen */ stream_read_uint32(s, serverCertLen); /* serverCertLen */ if (serverRandomLen > 0) { /* serverRandom */ freerdp_blob_alloc(settings->server_random, serverRandomLen); stream_read(s, settings->server_random->data, serverRandomLen); } else { return false; } if (serverCertLen > 0) { /* serverCertificate */ freerdp_blob_alloc(settings->server_certificate, serverCertLen); stream_read(s, settings->server_certificate->data, serverCertLen); certificate_free(settings->server_cert); settings->server_cert = certificate_new(); data = settings->server_certificate->data; length = settings->server_certificate->length; if (!certificate_read_server_certificate(settings->server_cert, data, length)) return false; } else { return false; } return true; } static const uint8 initial_signature[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01 }; /* * Terminal Services Signing Keys. * Yes, Terminal Services Private Key is publicly available. */ const uint8 tssk_modulus[] = { 0x3d, 0x3a, 0x5e, 0xbd, 0x72, 0x43, 0x3e, 0xc9, 0x4d, 0xbb, 0xc1, 0x1e, 0x4a, 0xba, 0x5f, 0xcb, 0x3e, 0x88, 0x20, 0x87, 0xef, 0xf5, 0xc1, 0xe2, 0xd7, 0xb7, 0x6b, 0x9a, 0xf2, 0x52, 0x45, 0x95, 0xce, 0x63, 0x65, 0x6b, 0x58, 0x3a, 0xfe, 0xef, 0x7c, 0xe7, 0xbf, 0xfe, 0x3d, 0xf6, 0x5c, 0x7d, 0x6c, 0x5e, 0x06, 0x09, 0x1a, 0xf5, 0x61, 0xbb, 0x20, 0x93, 0x09, 0x5f, 0x05, 0x6d, 0xea, 0x87 }; const uint8 tssk_privateExponent[] = { 0x87, 0xa7, 0x19, 0x32, 0xda, 0x11, 0x87, 0x55, 0x58, 0x00, 0x16, 0x16, 0x25, 0x65, 0x68, 0xf8, 0x24, 0x3e, 0xe6, 0xfa, 0xe9, 0x67, 0x49, 0x94, 0xcf, 0x92, 0xcc, 0x33, 0x99, 0xe8, 0x08, 0x60, 0x17, 0x9a, 0x12, 0x9f, 0x24, 0xdd, 0xb1, 0x24, 0x99, 0xc7, 0x3a, 0xb8, 0x0a, 0x7b, 0x0d, 0xdd, 0x35, 0x07, 0x79, 0x17, 0x0b, 0x51, 0x9b, 0xb3, 0xc7, 0x10, 0x01, 0x13, 0xe7, 0x3f, 0xf3, 0x5f }; const uint8 tssk_exponent[] = { 0x5b, 0x7b, 0x88, 0xc0 }; void gcc_write_server_security_data(STREAM* s, rdpSettings* settings) { CryptoMd5 md5; uint8* sigData; int expLen, keyLen, sigDataLen; uint8 encryptedSignature[TSSK_KEY_LENGTH]; uint8 signature[sizeof(initial_signature)]; uint32 headerLen, serverRandomLen, serverCertLen, wPublicKeyBlobLen; if (!settings->encryption) { settings->encryption_method = ENCRYPTION_METHOD_NONE; settings->encryption_level = ENCRYPTION_LEVEL_NONE; } else if ((settings->encryption_method & ENCRYPTION_METHOD_FIPS) != 0) { settings->encryption_method = ENCRYPTION_METHOD_FIPS; } else if ((settings->encryption_method & ENCRYPTION_METHOD_128BIT) != 0) { settings->encryption_method = ENCRYPTION_METHOD_128BIT; } else if ((settings->encryption_method & ENCRYPTION_METHOD_40BIT) != 0) { settings->encryption_method = ENCRYPTION_METHOD_40BIT; } if (settings->encryption_method != ENCRYPTION_METHOD_NONE) settings->encryption_level = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE; headerLen = 12; keyLen = 0; wPublicKeyBlobLen = 0; serverRandomLen = 0; serverCertLen = 0; if (settings->encryption_method != ENCRYPTION_METHOD_NONE || settings->encryption_level != ENCRYPTION_LEVEL_NONE) { serverRandomLen = 32; keyLen = settings->server_key->modulus.length; expLen = sizeof(settings->server_key->exponent); wPublicKeyBlobLen = 4; /* magic (RSA1) */ wPublicKeyBlobLen += 4; /* keylen */ wPublicKeyBlobLen += 4; /* bitlen */ wPublicKeyBlobLen += 4; /* datalen */ wPublicKeyBlobLen += expLen; wPublicKeyBlobLen += keyLen; wPublicKeyBlobLen += 8; /* 8 bytes of zero padding */ serverCertLen = 4; /* dwVersion */ serverCertLen += 4; /* dwSigAlgId */ serverCertLen += 4; /* dwKeyAlgId */ serverCertLen += 2; /* wPublicKeyBlobType */ serverCertLen += 2; /* wPublicKeyBlobLen */ serverCertLen += wPublicKeyBlobLen; serverCertLen += 2; /* wSignatureBlobType */ serverCertLen += 2; /* wSignatureBlobLen */ serverCertLen += sizeof(encryptedSignature); /* SignatureBlob */ serverCertLen += 8; /* 8 bytes of zero padding */ headerLen += sizeof(serverRandomLen); headerLen += sizeof(serverCertLen); headerLen += serverRandomLen; headerLen += serverCertLen; } gcc_write_user_data_header(s, SC_SECURITY, headerLen); stream_write_uint32(s, settings->encryption_method); /* encryptionMethod */ stream_write_uint32(s, settings->encryption_level); /* encryptionLevel */ if (settings->encryption_method == ENCRYPTION_METHOD_NONE && settings->encryption_level == ENCRYPTION_LEVEL_NONE) { return; } stream_write_uint32(s, serverRandomLen); /* serverRandomLen */ stream_write_uint32(s, serverCertLen); /* serverCertLen */ freerdp_blob_alloc(settings->server_random, serverRandomLen); crypto_nonce(settings->server_random->data, serverRandomLen); stream_write(s, settings->server_random->data, serverRandomLen); sigData = stream_get_tail(s); stream_write_uint32(s, CERT_CHAIN_VERSION_1); /* dwVersion (4 bytes) */ stream_write_uint32(s, SIGNATURE_ALG_RSA); /* dwSigAlgId */ stream_write_uint32(s, KEY_EXCHANGE_ALG_RSA); /* dwKeyAlgId */ stream_write_uint16(s, BB_RSA_KEY_BLOB); /* wPublicKeyBlobType */ stream_write_uint16(s, wPublicKeyBlobLen); /* wPublicKeyBlobLen */ stream_write(s, "RSA1", 4); /* magic */ stream_write_uint32(s, keyLen + 8); /* keylen */ stream_write_uint32(s, keyLen * 8); /* bitlen */ stream_write_uint32(s, keyLen - 1); /* datalen */ stream_write(s, settings->server_key->exponent, expLen); stream_write(s, settings->server_key->modulus.data, keyLen); stream_write_zero(s, 8); sigDataLen = stream_get_tail(s) - sigData; stream_write_uint16(s, BB_RSA_SIGNATURE_BLOB); /* wSignatureBlobType */ stream_write_uint16(s, keyLen + 8); /* wSignatureBlobLen */ memcpy(signature, initial_signature, sizeof(initial_signature)); md5 = crypto_md5_init(); crypto_md5_update(md5, sigData, sigDataLen); crypto_md5_final(md5, signature); crypto_rsa_private_encrypt(signature, sizeof(signature), TSSK_KEY_LENGTH, tssk_modulus, tssk_privateExponent, encryptedSignature); stream_write(s, encryptedSignature, sizeof(encryptedSignature)); stream_write_zero(s, 8); } /** * Read a client network data block (TS_UD_CS_NET).\n * @msdn{cc240512} * @param s stream * @param settings rdp settings */ boolean gcc_read_client_network_data(STREAM* s, rdpSettings* settings, uint16 blockLength) { int i; if (blockLength < 4) return false; stream_read_uint32(s, settings->num_channels); /* channelCount */ if (blockLength < 4 + settings->num_channels * 12) return false; if (settings->num_channels > 16) return false; /* channelDefArray */ for (i = 0; i < settings->num_channels; i++) { /* CHANNEL_DEF */ stream_read(s, settings->channels[i].name, 8); /* name (8 bytes) */ stream_read_uint32(s, settings->channels[i].options); /* options (4 bytes) */ settings->channels[i].channel_id = MCS_GLOBAL_CHANNEL_ID + 1 + i; } return true; } /** * Write a client network data block (TS_UD_CS_NET).\n * @msdn{cc240512} * @param s stream * @param settings rdp settings */ void gcc_write_client_network_data(STREAM* s, rdpSettings* settings) { int i; uint16 length; if (settings->num_channels > 0) { length = settings->num_channels * 12 + 8; gcc_write_user_data_header(s, CS_NET, length); stream_write_uint32(s, settings->num_channels); /* channelCount */ /* channelDefArray */ for (i = 0; i < settings->num_channels; i++) { /* CHANNEL_DEF */ stream_write(s, settings->channels[i].name, 8); /* name (8 bytes) */ stream_write_uint32(s, settings->channels[i].options); /* options (4 bytes) */ } } } boolean gcc_read_server_network_data(STREAM* s, rdpSettings* settings) { int i; uint16 MCSChannelId; uint16 channelCount; uint16 channelId; stream_read_uint16(s, MCSChannelId); /* MCSChannelId */ stream_read_uint16(s, channelCount); /* channelCount */ if (channelCount != settings->num_channels) { printf("requested %d channels, got %d instead\n", settings->num_channels, channelCount); } for (i = 0; i < channelCount; i++) { stream_read_uint16(s, channelId); /* channelId */ settings->channels[i].channel_id = channelId; } if (channelCount % 2 == 1) stream_seek(s, 2); /* padding */ return true; } void gcc_write_server_network_data(STREAM* s, rdpSettings* settings) { int i; gcc_write_user_data_header(s, SC_NET, 8 + settings->num_channels * 2 + (settings->num_channels % 2 == 1 ? 2 : 0)); stream_write_uint16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */ stream_write_uint16(s, settings->num_channels); /* channelCount */ for (i = 0; i < settings->num_channels; i++) { stream_write_uint16(s, settings->channels[i].channel_id); } if (settings->num_channels % 2 == 1) stream_write_uint16(s, 0); } /** * Read a client cluster data block (TS_UD_CS_CLUSTER).\n * @msdn{cc240514} * @param s stream * @param settings rdp settings */ boolean gcc_read_client_cluster_data(STREAM* s, rdpSettings* settings, uint16 blockLength) { uint32 flags; if (blockLength < 8) return false; stream_read_uint32(s, flags); /* flags */ if ((flags & REDIRECTED_SESSIONID_FIELD_VALID)) stream_read_uint32(s, settings->redirected_session_id); /* redirectedSessionID */ return true; } /** * Write a client cluster data block (TS_UD_CS_CLUSTER).\n * @msdn{cc240514} * @param s stream * @param settings rdp settings */ void gcc_write_client_cluster_data(STREAM* s, rdpSettings* settings) { uint32 flags; gcc_write_user_data_header(s, CS_CLUSTER, 12); flags = REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2); if (settings->console_session || settings->redirected_session_id) flags |= REDIRECTED_SESSIONID_FIELD_VALID; stream_write_uint32(s, flags); /* flags */ stream_write_uint32(s, settings->redirected_session_id); /* redirectedSessionID */ } /** * Read a client monitor data block (TS_UD_CS_MONITOR).\n * @msdn{dd305336} * @param s stream * @param settings rdp settings */ boolean gcc_read_client_monitor_data(STREAM* s, rdpSettings* settings, uint16 blockLength) { printf("CS_MONITOR\n"); return true; } /** * Write a client monitor data block (TS_UD_CS_MONITOR).\n * @msdn{dd305336} * @param s stream * @param settings rdp settings */ void gcc_write_client_monitor_data(STREAM* s, rdpSettings* settings) { int i; uint16 length; uint32 left, top, right, bottom, flags; if (settings->num_monitors > 1) { length = (20 * settings->num_monitors) + 12; gcc_write_user_data_header(s, CS_MONITOR, length); stream_write_uint32(s, 0); /* flags */ stream_write_uint32(s, settings->num_monitors); /* monitorCount */ for (i = 0; i < settings->num_monitors; i++) { left = settings->monitors[i].x; top = settings->monitors[i].y; right = settings->monitors[i].x + settings->monitors[i].width - 1; bottom = settings->monitors[i].y + settings->monitors[i].height - 1; flags = settings->monitors[i].is_primary ? MONITOR_PRIMARY : 0; stream_write_uint32(s, left); /* left */ stream_write_uint32(s, top); /* top */ stream_write_uint32(s, right); /* right */ stream_write_uint32(s, bottom); /* bottom */ stream_write_uint32(s, flags); /* flags */ } } }
/* * arch/arm/mach-sun6i/arisc/include/arisc_messages.h * * Copyright (c) 2012 Allwinner. * sunny (sunny@allwinnertech.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __ARISC_MESSAGES_H__ #define __ARISC_MESSAGES_H__ //message attributes(only use 8bit) #define ARISC_MESSAGE_ATTR_SOFTSYN (1<<0) //need soft syn with another cpu #define ARISC_MESSAGE_ATTR_HARDSYN (1<<1) //need hard syn with another cpu //message states #define ARISC_MESSAGE_FREED (0x0) //freed state #define ARISC_MESSAGE_ALLOCATED (0x1) //allocated state #define ARISC_MESSAGE_INITIALIZED (0x2) //initialized state #define ARISC_MESSAGE_RECEIVED (0x3) //received state #define ARISC_MESSAGE_PROCESSING (0x4) //processing state #define ARISC_MESSAGE_PROCESSED (0x5) //processed state #define ARISC_MESSAGE_FEEDBACKED (0x6) //feedback state typedef int (*arisc_cb_t)(void *arg); /* call back struct */ typedef struct arisc_msg_cb { arisc_cb_t handler; void *arg; } arisc_msg_cb_t; //the structure of message frame, //this structure will transfer between arisc and ac327. //sizeof(struct message) : 32Byte. typedef struct arisc_message { volatile unsigned char state; /* identify the used status of message frame */ volatile unsigned char attr; /* message attribute : SYN OR ASYN */ volatile unsigned char type; /* message type : DVFS_REQ */ volatile unsigned char result; /* message process result */ volatile struct arisc_message *next; /* pointer of next message frame */ volatile struct arisc_msg_cb cb; /* the callback function and arg of message */ volatile void *private; /* message private data */ volatile unsigned int paras[11]; /* the parameters of message */ } arisc_message_t; //the base of messages #define ARISC_MESSAGE_BASE (0x10) //standby commands #define ARISC_SSTANDBY_ENTER_REQ (ARISC_MESSAGE_BASE + 0x00) //request to enter(ac327 to arisc) #define ARISC_SSTANDBY_RESTORE_NOTIFY (ARISC_MESSAGE_BASE + 0x01) //restore finished(ac327 to arisc) #define ARISC_NSTANDBY_ENTER_REQ (ARISC_MESSAGE_BASE + 0x02) //request to enter(ac327 to arisc) #define ARISC_NSTANDBY_WAKEUP_NOTIFY (ARISC_MESSAGE_BASE + 0x03) //wakeup notify (arisc to ac327) #define ARISC_NSTANDBY_RESTORE_REQ (ARISC_MESSAGE_BASE + 0x04) //request to restore (ac327 to arisc) #define ARISC_NSTANDBY_RESTORE_COMPLETE (ARISC_MESSAGE_BASE + 0x05) //arisc restore complete(arisc to ac327) #define ARISC_ESSTANDBY_ENTER_REQ (ARISC_MESSAGE_BASE + 0x06) /* request to enter (ac327 to arisc) */ #define ARISC_TSTANDBY_ENTER_REQ (ARISC_MESSAGE_BASE + 0x07) /* request to enter(ac327 to arisc) */ #define ARISC_TSTANDBY_RESTORE_NOTIFY (ARISC_MESSAGE_BASE + 0x08) /* restore finished(ac327 to arisc) */ #define ARISC_FAKE_POWER_OFF_REQ (ARISC_MESSAGE_BASE + 0x09) /* request to enter(ac327 to arisc) */ //dvfs commands #define ARISC_CPUX_DVFS_REQ (ARISC_MESSAGE_BASE + 0x20) //request dvfs (ac327 to arisc) //pmu commands #define ARISC_AXP_POWEROFF_REQ (ARISC_MESSAGE_BASE + 0x40) //request power-off(ac327 to arisc) #define ARISC_AXP_READ_REGS (ARISC_MESSAGE_BASE + 0x41) //read registers (ac327 to arisc) #define ARISC_AXP_WRITE_REGS (ARISC_MESSAGE_BASE + 0x42) //write registers (ac327 to arisc) #define ARISC_AXP_SET_BATTERY (ARISC_MESSAGE_BASE + 0x43) //set battery (ac327 to arisc) #define ARISC_AXP_GET_BATTERY (ARISC_MESSAGE_BASE + 0x44) //get battery (ac327 to arisc) #define ARISC_AXP_INT_COMING_NOTIFY (ARISC_MESSAGE_BASE + 0x45) //interrupt coming notify(arisc to ac327) //arisc initialize state notify commands #define ARISC_STARTUP_NOTIFY (ARISC_MESSAGE_BASE + 0x80) //arisc init state notify(arisc to ac327) #endif //__ARISC_MESSAGES_H__
/* ** $Id: ltablib.c,v 1.65.1.1 2013/04/12 18:48:47 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ #include <stddef.h> #define ltablib_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n)) #if defined(LUA_COMPAT_MAXN) static int maxn (lua_State *L) { lua_Number max = 0; luaL_checktype(L, 1, LUA_TTABLE); lua_pushnil(L); /* first key */ while (lua_next(L, 1)) { lua_pop(L, 1); /* remove value */ if (lua_type(L, -1) == LUA_TNUMBER) { lua_Number v = lua_tonumber(L, -1); if (v > max) max = v; } } lua_pushnumber(L, max); return 1; } #endif static int tinsert (lua_State *L) { int e = aux_getn(L, 1) + 1; /* first empty element */ int pos; /* where to insert new element */ switch (lua_gettop(L)) { case 2: { /* called with only 2 arguments */ pos = e; /* insert new element at the end */ break; } case 3: { int i; pos = luaL_checkint(L, 2); /* 2nd argument is the position */ luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); for (i = e; i > pos; i--) { /* move up elements */ lua_rawgeti(L, 1, i-1); lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ } break; } default: { return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); } } lua_rawseti(L, 1, pos); /* t[pos] = v */ return 0; } static int tremove (lua_State *L) { int size = aux_getn(L, 1); int pos = luaL_optint(L, 2, size); if (pos != size) /* validate 'pos' if given */ luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); lua_rawgeti(L, 1, pos); /* result = t[pos] */ for ( ; pos < size; pos++) { lua_rawgeti(L, 1, pos+1); lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */ } lua_pushnil(L); lua_rawseti(L, 1, pos); /* t[pos] = nil */ return 1; } static void addfield (lua_State *L, luaL_Buffer *b, int i) { lua_rawgeti(L, 1, i); if (!lua_isstring(L, -1)) luaL_error(L, "invalid value (%s) at index %d in table for " LUA_QL("concat"), luaL_typename(L, -1), i); luaL_addvalue(b); } static int tconcat (lua_State *L) { luaL_Buffer b; size_t lsep; int i, last; const char *sep = luaL_optlstring(L, 2, "", &lsep); luaL_checktype(L, 1, LUA_TTABLE); i = luaL_optint(L, 3, 1); last = luaL_opt(L, luaL_checkint, 4, luaL_len(L, 1)); luaL_buffinit(L, &b); for (; i < last; i++) { addfield(L, &b, i); luaL_addlstring(&b, sep, lsep); } if (i == last) /* add last value (if interval was not empty) */ addfield(L, &b, i); luaL_pushresult(&b); return 1; } /* ** {====================================================== ** Pack/unpack ** ======================================================= */ static int pack (lua_State *L) { int n = lua_gettop(L); /* number of elements to pack */ lua_createtable(L, n, 1); /* create result table */ lua_pushinteger(L, n); lua_setfield(L, -2, "n"); /* t.n = number of elements */ if (n > 0) { /* at least one element? */ int i; lua_pushvalue(L, 1); lua_rawseti(L, -2, 1); /* insert first element */ lua_replace(L, 1); /* move table into index 1 */ for (i = n; i >= 2; i--) /* assign other elements */ lua_rawseti(L, 1, i); } return 1; /* return table */ } static int unpack (lua_State *L) { int i, e, n; luaL_checktype(L, 1, LUA_TTABLE); i = luaL_optint(L, 2, 1); e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1)); if (i > e) return 0; /* empty range */ n = e - i + 1; /* number of elements */ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ return luaL_error(L, "too many results to unpack"); lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ while (i++ < e) /* push arg[i + 1...e] */ lua_rawgeti(L, 1, i); return n; } /* }====================================================== */ /* ** {====================================================== ** Quicksort ** (based on `Algorithms in MODULA-3', Robert Sedgewick; ** Addison-Wesley, 1993.) ** ======================================================= */ static void set2 (lua_State *L, int i, int j) { lua_rawseti(L, 1, i); lua_rawseti(L, 1, j); } static int sort_comp (lua_State *L, int a, int b) { if (!lua_isnil(L, 2)) { /* function? */ int res; lua_pushvalue(L, 2); lua_pushvalue(L, a-1); /* -1 to compensate function */ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ lua_call(L, 2, 1); res = lua_toboolean(L, -1); lua_pop(L, 1); return res; } else /* a < b? */ return lua_compare(L, a, b, LUA_OPLT); } static void auxsort (lua_State *L, int l, int u) { while (l < u) { /* for tail recursion */ int i, j; /* sort elements a[l], a[(l+u)/2] and a[u] */ lua_rawgeti(L, 1, l); lua_rawgeti(L, 1, u); if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ set2(L, l, u); /* swap a[l] - a[u] */ else lua_pop(L, 2); if (u-l == 1) break; /* only 2 elements */ i = (l+u)/2; lua_rawgeti(L, 1, i); lua_rawgeti(L, 1, l); if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */ set2(L, i, l); else { lua_pop(L, 1); /* remove a[l] */ lua_rawgeti(L, 1, u); if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */ set2(L, i, u); else lua_pop(L, 2); } if (u-l == 2) break; /* only 3 elements */ lua_rawgeti(L, 1, i); /* Pivot */ lua_pushvalue(L, -1); lua_rawgeti(L, 1, u-1); set2(L, i, u-1); /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */ i = l; j = u-1; for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ /* repeat ++i until a[i] >= P */ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i>=u) luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[i] */ } /* repeat --j until a[j] <= P */ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { if (j<=l) luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[j] */ } if (j<i) { lua_pop(L, 3); /* pop pivot, a[i], a[j] */ break; } set2(L, i, j); } lua_rawgeti(L, 1, u-1); lua_rawgeti(L, 1, i); set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */ /* a[l..i-1] <= a[i] == P <= a[i+1..u] */ /* adjust so that smaller half is in [j..i] and larger one in [l..u] */ if (i-l < u-i) { j=l; i=i-1; l=i+2; } else { j=i+1; i=u; u=j-2; } auxsort(L, j, i); /* call recursively the smaller one */ } /* repeat the routine for the larger one */ } static int sort (lua_State *L) { int n = aux_getn(L, 1); luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ luaL_checktype(L, 2, LUA_TFUNCTION); lua_settop(L, 2); /* make sure there is two arguments */ auxsort(L, 1, n); return 0; } /* }====================================================== */ static const luaL_Reg tab_funcs[] = { {"concat", tconcat}, #if defined(LUA_COMPAT_MAXN) {"maxn", maxn}, #endif {"insert", tinsert}, {"pack", pack}, {"unpack", unpack}, {"remove", tremove}, {"sort", sort}, {NULL, NULL} }; LUAMOD_API int luaopen_table (lua_State *L) { luaL_newlib(L, tab_funcs); #if defined(LUA_COMPAT_UNPACK) /* _G.unpack = table.unpack */ lua_getfield(L, -1, "unpack"); lua_setglobal(L, "unpack"); #endif return 1; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. // // // =========================================================================== // File: winnt.h // // =========================================================================== // dummy winnt.h for PAL #include "palrt.h"
/* -*- mode:C++; c-basic-offset:4 -*- Shore-MT -- Multi-threaded port of the SHORE storage manager Copyright (c) 2007-2009 Data Intensive Applications and Systems Labaratory (DIAS) Ecole Polytechnique Federale de Lausanne All Rights Reserved. Permission to use, copy, modify and distribute this software and its documentation is hereby granted, provided that both the copyright notice and this permission notice appear in all copies of the software, derivative works or modified versions, and any portions thereof, and that both notices appear in supporting documentation. This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. */ /*<std-header orig-src='shore' incl-file-exclusion='SCAN_H'> $Id: scan.h,v 1.91 2010/06/08 22:28:55 nhall Exp $ SHORE -- Scalable Heterogeneous Object REpository Copyright (c) 1994-99 Computer Sciences Department, University of Wisconsin -- Madison All Rights Reserved. Permission to use, copy, modify and distribute this software and its documentation is hereby granted, provided that both the copyright notice and this permission notice appear in all copies of the software, derivative works or modified versions, and any portions thereof, and that both notices appear in supporting documentation. THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. This software was developed with support by the Advanced Research Project Agency, ARPA order number 018 (formerly 8230), monitored by the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518. Further funding for this work was provided by DARPA through Rome Research Laboratory Contract No. F30602-97-2-0247. */ #ifndef SCAN_H #define SCAN_H #include "w_defines.h" /* -- do not edit anything above this line -- </std-header>*/ #ifdef __GNUG__ #pragma interface #endif #ifndef XCT_DEPENDENT_H #include <xct_dependent.h> #endif /* XCT_DEPENDENT_H */ #include <page_alias.h> /**\addtogroup SSMSCAN * Scans can be performed on B+tree and R-tree indexes and on files * of records. Iterator classes scan_index_i, scan_rt_i and scan_file_i are * used for Btree's, Rtree's and files, respectively. * * Scans begin by creating an iterator to specify what * to scan and the range of the scan. * * An iterator's next() function is used to retrieve values from * the scan (including the first). Next() will set the eof * parameter to true only when no value can be retrieved for the * current call, so * if a file contains 2 records and next() has been called * twice, eof will return false on the first and second calls, but * true on the third. * * The eof() function reports the value of eof returned * from the \b last call to next(). This means you might find * eof to be false, call next(), and get nothing back from next() * (eof is now true). * * The scan destructor frees and un-fixes (un-pins) all resources * used by the scan. */ /**\addtogrup SSMSCAN * * The finish() function frees (and un-fixes) resources used * by the scan. finish() is called by the destructor, * but it is sometimes useful to call it early for scan objects * on the stack when the destructor might not be called until * the end of the function. * * All of the scan constructors have a concurrency control * parameter. This controls the granularity of locking * done by the scan. The possible values of cc are: * * - t_cc_none: IS lock the file/index and * obtain no other locks during the scan * - t_cc_kvl: IS lock the index and obtain SH key-value locks * on every entry as encountered; used only for btrees (scan_index_i) * - t_cc_record:IS lock the file and obtain SH locks on every * record as encountered * - t_cc_page: IS lock the file/index and obtain SH locks on pages * (leaf pages, used only for rtrees) * - t_cc_file: SH lock the file/index * */ class bt_cursor_t; /**\brief Iterator over an index. * \details * \ingroup SSMSCANI * To iterate over the {key,value} pairs in an index, * construct an instance of this class, * and use its next() method to advance the cursor and the curr() method * to copy out keys and values into server-space. * It is unwise to delete or insert associations while you have a scan open on * the index (in the same transaction). * * Example code: * \code * stid_t fid(1,7); * scan_index_i scan(fid, scan_index_i::ge, vec_t::neg_inf, scan_index_i::le, vec_t::pos_inf, false, ss_m::t_cc_kvl); * bool eof(false); * do { * w_rc_t rc = scan.next(eof); * if(rc.is_error()) { * // handle error * ... * } * if(eof) break; * * // get the key len and element len * W_DO(scan.curr(NULL, klen, NULL, elen)); * * // Create vectors for the given lengths. * vec_t key(keybuf, klen); * vec_t elem(&info, elen); * * // Get the key and element value * W_DO(scan.curr(&key, klen, &elem, elen)); * ... * } while (1); * \endcode * */ class scan_index_i : public smlevel_top, public xct_dependent_t { public: /**\brief Construct an iterator. * \details * @param[in] stid ID of the B-Tree to be scanned. * @param[in] c1 Comparison type to be used in the scan for * lower bound comparison : * eq, gt, ge, lt, le * @param[in] bound1 Lower bound * @param[in] c2 Comparison type to be used in the scan for * upper bound comparison : * eq, gt, ge, lt, le * @param[in] bound2 Upper bound * @param[in] include_nulls If true, we will consider null keys * as satisfying the condition. * @param[in] cc Can be used to override the concurrency_t stored in * the store descriptor (see ss_m::get_store_info and sm_store_info_t)) * in a few situations. * @param[in] mode Can be used to override the mode in which the * store is locked. * * The following table describes the way these two values are used. * The columns represent the values of this parameter, cc. * The rows represent the value with which the store was created, * and may be determined with ss_m::get_store_info. * The table entries tell what kinds of locks are acquired on the store * and on the key-value pairs. * \verbatim cc | t_cc_none | t_cc_modkvl | t_cc_im | t_cc_kvl | t_cc_file Created | ------------------------------------------------------------------- t_cc_none | IS/none | IS/modkvl | IS/im | IS/kvl | SH/none ------------------------------------------------------------------- t_cc_modkvl| IS/none | IS/none | IS/modkvl | IS/modkvl | SH/none ------------------------------------------------------------------- t_cc_im | IS/im | IS/im | IS/im | IS/im | SH/file ------------------------------------------------------------------- t_cc_kvl | IS/kvl | IS/kvl | IS/kvl | IS/kvl | SH/file ------------------------------------------------------------------- t_cc_file | error | error | error | error | SH/none ------------------------------------------------------------------- \endverbatim * * \anchor MODKVL * The protocol t_cc_modkvl is a modified key-value locking protocol * created for the Paradise project, and behaves as follows: * -only allow "eq" comparsons : bound1 : eq X and boudn2: eq X * -grabs an SH lock on the bound X, whether or not the index is unique * * \anchor IM * The protocol t_cc_im treats the value part of a key-value pair as * a record id, and it acquires a lock on the record rather than on * they key-value pair. Otherwise it is like normal key-value locking. * * Although they are called "lower bound" and "upper bound", * technically the two conditions can be reversed, for example, * c1= le, bound1= vec_t::pos_inf * and * c2= ge, bound2= vec_t::neg_inf. */ NORET scan_index_i( const stid_t& stid, cmp_t c1, const cvec_t& bound1, cmp_t c2, const cvec_t& bound2, bool include_nulls = false, concurrency_t cc = t_cc_kvl, lock_mode_t mode = SH ); NORET ~scan_index_i(); /**brief Get the key and value where the cursor points. * * @param[out] key Pointer to vector supplied by caller. curr() writes into this vector. * A null pointer indicates that the caller is not interested in the key. * @param[out] klen Pointer to sm_size_t variable. Length of key is written here. * @param[out] el Pointer to vector supplied by caller. curr() writes into this vector. * A null pointer indicates that the caller is not interested in the value. * @param[out] elen Pointer to sm_size_t variable. Length of value is written here. */ rc_t curr( vec_t* key, smsize_t& klen, vec_t* el, smsize_t& elen) { return _fetch(key, &klen, el, &elen, false); } /**brief Move to the next key-value pair in the index. * * @param[out] eof True is returned if there are no more pairs in the index. * If false, curr() may be called. */ rc_t next(bool& eof) { rc_t rc = _fetch(0, 0, 0, 0, true); eof = _eof; return rc.reset(); } /// Free the resources used by this iterator. Called by desctructor if /// necessary. void finish(); /// If false, curr() may be called. bool eof() { return _eof; } /// If false, curr() may be called. tid_t xid() const { return tid; } ndx_t ndx() const { return ntype; } const rc_t & error_code() const { return _error_occurred; } private: stid_t _stid; tid_t tid; ndx_t ntype; cmp_t cond2; bool _eof; w_rc_t _error_occurred; bt_cursor_t* _btcursor; bool _finished; bool _skip_nulls; concurrency_t _cc; lock_mode_t _mode; rc_t _fetch( vec_t* key, smsize_t* klen, vec_t* el, smsize_t* elen, bool skip); void _init( cmp_t cond, const cvec_t& bound, cmp_t c2, const cvec_t& b2, lock_mode_t mode = SH); void xct_state_changed( xct_state_t old_state, xct_state_t new_state); // disabled NORET scan_index_i(const scan_index_i&); scan_index_i& operator=(const scan_index_i&); }; // R-Tree Scanning class rt_cursor_t; /**\brief Iterator for scanning an R*-Tree. *\ingroup SSMSCANRT *\details * To iterate over the {key,value} pairs in a spatial index, * construct an instance of this class, * and use its next() method to advance the cursor and the curr() method * to copy out keys and values into server-space. * It is unwise to delete or insert associations while you have a scan open on * the index (in the same transaction). * *\sa SSMRTREE */ class scan_rt_i : public smlevel_top, public xct_dependent_t { public: /// Store id of the R-Tree. stid_t stid; /// Transaction ID of the transaction that initialized this iterator. tid_t tid; /// Type of this index. ndx_t ntype; /**\brief Construct an iterator. * \details * @param[in] stid ID of the R-Tree to be scanned. * @param[in] c Comparison type to be used in the scan : t_exact, * t_overlap, t_cover, t_inside. * @param[in] box Box to reference for the comparison above. * @param[in] include_nulls If true, we will consider null keys * as satisfying the condition. * @param[in] cc Must be t_cc_none, t_cc_page or t_cc_file. * In the first two cases, an IS lock is acquired; in the * last, an SH lock is acquired; this lock applies to the * entire index. */ NORET scan_rt_i( const stid_t& stid, nbox_t::sob_cmp_t c, const nbox_t& box, bool include_nulls = false, concurrency_t cc = t_cc_page); NORET ~scan_rt_i(); rc_t next( nbox_t& key, void* el, smsize_t& elen, bool& eof) { return _fetch(key, el, elen, eof, true); } /* curr(nbox_t& key, void* el, smsize_t& elen, bool& eof) { return _fetch(key, el, elen, eof, false); } */ void finish(); bool eof() { return _eof; } const rc_t & error_code() const { return _error_occurred; } private: bool _eof; rc_t _error_occurred; rt_cursor_t* _cursor; bool _finished; bool _skip_nulls; concurrency_t _cc; rc_t _fetch( nbox_t& key, void* el, smsize_t& elen, bool& eof, bool skip); void _init( nbox_t::sob_cmp_t c, const nbox_t& qbox); void xct_state_changed( xct_state_t old_state, xct_state_t new_state); // disabled NORET scan_rt_i(const scan_rt_i&); scan_rt_i& operator=(const scan_rt_i&); }; class bf_prefetch_thread_t; /** \brief Iterator over a file of records. * \ingroup SSMSCANF * \details * To iterate over the records in a file, construct an instance of this class, * and use its next, next_page and eof methods to located the * records in the file. * The methods next and next_page return a pin_i, * which lets you manipulate the record (pin it in the buffer pool while you * use it). * It is unwise to delete or insert records while you have a scan open on * the file (in the same transaction). * * \code * stid_t fid(1,7); * scan_file_i scan(fid); * pin_i* cursor(NULL); * bool eof(false); * do { * w_rc_t rc = scan.next(cursor, 0, eof); * if(rc.is_error()) { * // handle error * ... * } * if(eof) break; * // handle record * ... * const char *body = cursor->body(); * ... * } while (1); * \endcode */ class scan_file_i : public smlevel_top, public xct_dependent_t { public: stid_t stid; rid_t curr_rid; /**\brief Construct an iterator over the given store (file). * * @param[in] stid ID of the file over which to iterate. * @param[in] start ID of the first record of interest, can be * used to start a scan in the middle of the file. * @param[in] cc Locking granularity to be used. See discussion * for other constructor. * @param[in] prefetch If true, a background thread will pre-fetch * pages in support of this scan. For this to work * the server option sm_prefetch must be enabled. * @param[in] ignored \e not used * * Record-level locking is not supported here because there are problems * with phantoms if another transaction is altering the file while * this scan is going on. Thus, if you try to use record-level * locking, you will get page-level locking instead. */ NORET scan_file_i( const stid_t& stid, const rid_t& start, concurrency_t cc = t_cc_file, bool prefetch=false, lock_mode_t ignored = SH); /**\brief Construct an iterator over the given store (file). * * @param[in] stid ID of the file over which to iterate. * @param[in] cc Locking granularity to be used. The following are * permissible, and their implied store, page and record * lock modes are given: * - t_cc_none : store - IS page - none record - none * - t_cc_record : store - IS page - SH record - none * - t_cc_page : store - IS page - SH record - none * - t_cc_append : store - IX page - EX record - EX * - t_cc_file : store - SH page - none record - none * @param[in] prefetch If true, a background thread will pre-fetch * pages in support of this scan. For this to work * the server option sm_prefetch must be enabled. * @param[in] ignored \e not used * * Record-level locking is not supported here because there are problems * with phantoms if another transaction is altering the file while * this scan is going on. Thus, if you try to use record-level * locking, you will get page-level locking instead. */ NORET scan_file_i( const stid_t& stid, concurrency_t cc = t_cc_file, bool prefetch=false, lock_mode_t ignored = SH); NORET ~scan_file_i(); /* needed for tcl scripts */ /**\brief Return the pin_i that represents the scan state. * @param[out] pin_ptr Populate the caller's pointer. * @param[out] eof False if the pin_i points to a record, * true if there were no next record to pin. * */ void cursor( pin_i*& pin_ptr, bool& eof ) { pin_ptr = &_cursor; eof = _eof; } /**\brief Advance to the next record of the file. * * @param[out] pin_ptr Populate the caller's pointer. * @param[in] start_offset Pin the next record at this offset. Meaningful * only for large records. * @param[out] eof False if the pin_i points to a record, * true if there were no next record to pin. * * This must be called once to get the first record of the file. */ rc_t next( pin_i*& pin_ptr, smsize_t start_offset, bool& eof); /**\brief Advance to the first record on the next page in the file. * * @param[out] pin_ptr Populate the caller's pointer. * This pin_i represents the state of this scan. * @param[in] start_offset Pin the next record at this offset. * This is meaningful only for large records. * @param[out] eof False if the pin_i points to a record, * true if there were no next record to pin. * * If next_page is * called after the scan_file_i is initialized it will advance * the cursor to the first record in the file, just as * next() would do. */ rc_t next_page( pin_i*& pin_ptr, smsize_t start_offset, bool& eof); /**\brief Free resources acquired by this iterator. Useful if * you are finished with the scan but not ready to delete it. */ void finish(); /**\brief End of file was reached. Cursor is not usable.*/ bool eof() { return _eof; } /**\brief Error code returned from last method call. */ const rc_t & error_code() const { return _error_occurred; } /**\brief ID of the transaction that created this iterator */ tid_t xid() const { return tid; } protected: tid_t tid; bool _eof; w_rc_t _error_occurred; pin_i _cursor; lpid_t _next_pid; concurrency_t _cc; // concurrency control lock_mode_t _page_lock_mode; lock_mode_t _rec_lock_mode; rc_t _init(bool for_append=false); rc_t _next( pin_i*& pin_ptr, smsize_t start_offset, bool& eof); void xct_state_changed( xct_state_t old_state, xct_state_t new_state); private: bool _do_prefetch; bf_prefetch_thread_t* _prefetch; // disabled NORET scan_file_i(const scan_file_i&); scan_file_i& operator=(const scan_file_i&); }; #include <cstring> #ifndef SDESC_H #include "sdesc.h" #endif /**\brief Pseudo-iterator used to append to a file. * \details * Just creating a record doesn't ensure that it appears at the * end of the file; when new pages are allocated, they could be * in extents in the middle of the file, and unused slots in * pages in the middle of the file can be scavenged for create_rec. * * If you want to ensure that the records are appended to a file, * use this. * * \attention * Clearly, this cannot be used in a meaningful way when other * threads are updating the same file. The constructor acquires * an exclusive lock on the file to protect it from updates by * other transactions, but this does not protect it from updates * from other threads in the same transaction. * The server must ensure that no more than one thread attached * to the locking transaction is using the file, and that the only use * of the file is through the append_file_i while the instance * exists. */ class append_file_i : public scan_file_i { public: /**\brief Construct an append_file_i for a given file. * @param[in] stid ID of the file in which to create records. */ NORET append_file_i( const stid_t& stid); NORET ~append_file_i(); /**\brief Place-holder method. Returns error. * * You cannot scan with an append_file_i. */ rc_t next( pin_i*& pin_ptr, smsize_t start_offset, bool& eof); /**\brief Append a new record to the end of the file. * \ingroup SSMFILE * @param[in] hdr The client-defined record header. * @param[in] len_hint The length of the record, more or less. More * accuracy here helps the sm reduce its work. * @param[in] data The client-defined record contents. * @param[out] rid The identifier of the new record. */ rc_t create_rec( const vec_t& hdr, smsize_t len_hint, const vec_t& data, rid_t& rid); private: void _init_constructor(); // See comments in pin.h, which does the same thing // file_p page; file_p& _page(); char _page_alias[PAGE_ALIAS_FILE]; sdesc_t _cached_sdesc; }; /*<std-footer incl-file-exclusion='SCAN_H'> -- do not edit anything below this line -- */ #endif /*</std-footer>*/
/* * jdarith.c * * This file was part of the Independent JPEG Group's software: * Developed 1997-2015 by Guido Vollbeding. * libjpeg-turbo Modifications: * Copyright (C) 2015-2018, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * * This file contains portable arithmetic entropy encoding routines for JPEG * (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1). * * Both sequential and progressive modes are supported in this single module. * * Suspension is not currently supported in this module. * * NOTE: All referenced figures are from * Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994. */ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" #define NEG_1 ((unsigned int)-1) /* Expanded entropy decoder object for arithmetic decoding. */ typedef struct { struct jpeg_entropy_decoder pub; /* public fields */ JLONG c; /* C register, base of coding interval + input bit buffer */ JLONG a; /* A register, normalized size of coding interval */ int ct; /* bit shift counter, # of bits left in bit buffer part of C */ /* init: ct = -16 */ /* run: ct = 0..7 */ /* error: ct = -1 */ int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */ unsigned int restarts_to_go; /* MCUs left in this restart interval */ /* Pointers to statistics areas (these workspaces have image lifespan) */ unsigned char *dc_stats[NUM_ARITH_TBLS]; unsigned char *ac_stats[NUM_ARITH_TBLS]; /* Statistics bin for coding with fixed probability 0.5 */ unsigned char fixed_bin[4]; } arith_entropy_decoder; typedef arith_entropy_decoder *arith_entropy_ptr; /* The following two definitions specify the allocation chunk size * for the statistics area. * According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least * 49 statistics bins for DC, and 245 statistics bins for AC coding. * * We use a compact representation with 1 byte per statistics bin, * thus the numbers directly represent byte sizes. * This 1 byte per statistics bin contains the meaning of the MPS * (more probable symbol) in the highest bit (mask 0x80), and the * index into the probability estimation state machine table * in the lower bits (mask 0x7F). */ #define DC_STAT_BINS 64 #define AC_STAT_BINS 256 LOCAL(int) get_byte(j_decompress_ptr cinfo) /* Read next input byte; we do not support suspension in this module. */ { struct jpeg_source_mgr *src = cinfo->src; if (src->bytes_in_buffer == 0) if (!(*src->fill_input_buffer) (cinfo)) ERREXIT(cinfo, JERR_CANT_SUSPEND); src->bytes_in_buffer--; return GETJOCTET(*src->next_input_byte++); } /* * The core arithmetic decoding routine (common in JPEG and JBIG). * This needs to go as fast as possible. * Machine-dependent optimization facilities * are not utilized in this portable implementation. * However, this code should be fairly efficient and * may be a good base for further optimizations anyway. * * Return value is 0 or 1 (binary decision). * * Note: I've changed the handling of the code base & bit * buffer register C compared to other implementations * based on the standards layout & procedures. * While it also contains both the actual base of the * coding interval (16 bits) and the next-bits buffer, * the cut-point between these two parts is floating * (instead of fixed) with the bit shift counter CT. * Thus, we also need only one (variable instead of * fixed size) shift for the LPS/MPS decision, and * we can do away with any renormalization update * of C (except for new data insertion, of course). * * I've also introduced a new scheme for accessing * the probability estimation state machine table, * derived from Markus Kuhn's JBIG implementation. */ LOCAL(int) arith_decode(j_decompress_ptr cinfo, unsigned char *st) { register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy; register unsigned char nl, nm; register JLONG qe, temp; register int sv, data; /* Renormalization & data input per section D.2.6 */ while (e->a < 0x8000L) { if (--e->ct < 0) { /* Need to fetch next data byte */ if (cinfo->unread_marker) data = 0; /* stuff zero data */ else { data = get_byte(cinfo); /* read next input byte */ if (data == 0xFF) { /* zero stuff or marker code */ do data = get_byte(cinfo); while (data == 0xFF); /* swallow extra 0xFF bytes */ if (data == 0) data = 0xFF; /* discard stuffed zero byte */ else { /* Note: Different from the Huffman decoder, hitting * a marker while processing the compressed data * segment is legal in arithmetic coding. * The convention is to supply zero data * then until decoding is complete. */ cinfo->unread_marker = data; data = 0; } } } e->c = (e->c << 8) | data; /* insert data into C register */ if ((e->ct += 8) < 0) /* update bit shift counter */ /* Need more initial bytes */ if (++e->ct == 0) /* Got 2 initial bytes -> re-init A and exit loop */ e->a = 0x8000L; /* => e->a = 0x10000L after loop exit */ } e->a <<= 1; } /* Fetch values from our compact representation of Table D.2: * Qe values and probability estimation state machine */ sv = *st; qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */ nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */ nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */ /* Decode & estimation procedures per sections D.2.4 & D.2.5 */ temp = e->a - qe; e->a = temp; temp <<= e->ct; if (e->c >= temp) { e->c -= temp; /* Conditional LPS (less probable symbol) exchange */ if (e->a < qe) { e->a = qe; *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */ } else { e->a = qe; *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */ sv ^= 0x80; /* Exchange LPS/MPS */ } } else if (e->a < 0x8000L) { /* Conditional MPS (more probable symbol) exchange */ if (e->a < qe) { *st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */ sv ^= 0x80; /* Exchange LPS/MPS */ } else { *st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */ } } return sv >> 7; } /* * Check for a restart marker & resynchronize decoder. */ LOCAL(void) process_restart(j_decompress_ptr cinfo) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; int ci; jpeg_component_info *compptr; /* Advance past the RSTn marker */ if (!(*cinfo->marker->read_restart_marker) (cinfo)) ERREXIT(cinfo, JERR_CANT_SUSPEND); /* Re-initialize statistics areas */ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; if (!cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) { MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS); /* Reset DC predictions to 0 */ entropy->last_dc_val[ci] = 0; entropy->dc_context[ci] = 0; } if (!cinfo->progressive_mode || cinfo->Ss) { MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS); } } /* Reset arithmetic decoding variables */ entropy->c = 0; entropy->a = 0; entropy->ct = -16; /* force reading 2 initial bytes to fill C */ /* Reset restart counter */ entropy->restarts_to_go = cinfo->restart_interval; } /* * Arithmetic MCU decoding. * Each of these routines decodes and returns one MCU's worth of * arithmetic-compressed coefficients. * The coefficients are reordered from zigzag order into natural array order, * but are not dequantized. * * The i'th block of the MCU is stored into the block pointed to by * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. */ /* * MCU decoding for DC initial scan (either spectral selection, * or first pass of successive approximation). */ METHODDEF(boolean) decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; JBLOCKROW block; unsigned char *st; int blkn, ci, tbl, sign; int v, m; /* Process restart marker if needed */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) process_restart(cinfo); entropy->restarts_to_go--; } if (entropy->ct == -1) return TRUE; /* if error do nothing */ /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = MCU_data[blkn]; ci = cinfo->MCU_membership[blkn]; tbl = cinfo->cur_comp_info[ci]->dc_tbl_no; /* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */ /* Table F.4: Point to statistics bin S0 for DC coefficient coding */ st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; /* Figure F.19: Decode_DC_DIFF */ if (arith_decode(cinfo, st) == 0) entropy->dc_context[ci] = 0; else { /* Figure F.21: Decoding nonzero value v */ /* Figure F.22: Decoding the sign of v */ sign = arith_decode(cinfo, st + 1); st += 2; st += sign; /* Figure F.23: Decoding the magnitude category of v */ if ((m = arith_decode(cinfo, st)) != 0) { st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ while (arith_decode(cinfo, st)) { if ((m <<= 1) == 0x8000) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* magnitude overflow */ return TRUE; } st += 1; } } /* Section F.1.4.4.1.2: Establish dc_context conditioning category */ if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1)) entropy->dc_context[ci] = 0; /* zero diff category */ else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1)) entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */ else entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */ v = m; /* Figure F.24: Decoding the magnitude bit pattern of v */ st += 14; while (m >>= 1) if (arith_decode(cinfo, st)) v |= m; v += 1; if (sign) v = -v; entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff; } /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */ (*block)[0] = (JCOEF)LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al); } return TRUE; } /* * MCU decoding for AC initial scan (either spectral selection, * or first pass of successive approximation). */ METHODDEF(boolean) decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; JBLOCKROW block; unsigned char *st; int tbl, sign, k; int v, m; /* Process restart marker if needed */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) process_restart(cinfo); entropy->restarts_to_go--; } if (entropy->ct == -1) return TRUE; /* if error do nothing */ /* There is always only one block per MCU */ block = MCU_data[0]; tbl = cinfo->cur_comp_info[0]->ac_tbl_no; /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */ /* Figure F.20: Decode_AC_coefficients */ for (k = cinfo->Ss; k <= cinfo->Se; k++) { st = entropy->ac_stats[tbl] + 3 * (k - 1); if (arith_decode(cinfo, st)) break; /* EOB flag */ while (arith_decode(cinfo, st + 1) == 0) { st += 3; k++; if (k > cinfo->Se) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* spectral overflow */ return TRUE; } } /* Figure F.21: Decoding nonzero value v */ /* Figure F.22: Decoding the sign of v */ sign = arith_decode(cinfo, entropy->fixed_bin); st += 2; /* Figure F.23: Decoding the magnitude category of v */ if ((m = arith_decode(cinfo, st)) != 0) { if (arith_decode(cinfo, st)) { m <<= 1; st = entropy->ac_stats[tbl] + (k <= cinfo->arith_ac_K[tbl] ? 189 : 217); while (arith_decode(cinfo, st)) { if ((m <<= 1) == 0x8000) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* magnitude overflow */ return TRUE; } st += 1; } } } v = m; /* Figure F.24: Decoding the magnitude bit pattern of v */ st += 14; while (m >>= 1) if (arith_decode(cinfo, st)) v |= m; v += 1; if (sign) v = -v; /* Scale and output coefficient in natural (dezigzagged) order */ (*block)[jpeg_natural_order[k]] = (JCOEF)((unsigned)v << cinfo->Al); } return TRUE; } /* * MCU decoding for DC successive approximation refinement scan. */ METHODDEF(boolean) decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; unsigned char *st; int p1, blkn; /* Process restart marker if needed */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) process_restart(cinfo); entropy->restarts_to_go--; } st = entropy->fixed_bin; /* use fixed probability estimation */ p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { /* Encoded data is simply the next bit of the two's-complement DC value */ if (arith_decode(cinfo, st)) MCU_data[blkn][0][0] |= p1; } return TRUE; } /* * MCU decoding for AC successive approximation refinement scan. */ METHODDEF(boolean) decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; JBLOCKROW block; JCOEFPTR thiscoef; unsigned char *st; int tbl, k, kex; int p1, m1; /* Process restart marker if needed */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) process_restart(cinfo); entropy->restarts_to_go--; } if (entropy->ct == -1) return TRUE; /* if error do nothing */ /* There is always only one block per MCU */ block = MCU_data[0]; tbl = cinfo->cur_comp_info[0]->ac_tbl_no; p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ m1 = (NEG_1) << cinfo->Al; /* -1 in the bit position being coded */ /* Establish EOBx (previous stage end-of-block) index */ for (kex = cinfo->Se; kex > 0; kex--) if ((*block)[jpeg_natural_order[kex]]) break; for (k = cinfo->Ss; k <= cinfo->Se; k++) { st = entropy->ac_stats[tbl] + 3 * (k - 1); if (k > kex) if (arith_decode(cinfo, st)) break; /* EOB flag */ for (;;) { thiscoef = *block + jpeg_natural_order[k]; if (*thiscoef) { /* previously nonzero coef */ if (arith_decode(cinfo, st + 2)) { if (*thiscoef < 0) *thiscoef += m1; else *thiscoef += p1; } break; } if (arith_decode(cinfo, st + 1)) { /* newly nonzero coef */ if (arith_decode(cinfo, entropy->fixed_bin)) *thiscoef = m1; else *thiscoef = p1; break; } st += 3; k++; if (k > cinfo->Se) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* spectral overflow */ return TRUE; } } } return TRUE; } /* * Decode one MCU's worth of arithmetic-compressed coefficients. */ METHODDEF(boolean) decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; jpeg_component_info *compptr; JBLOCKROW block; unsigned char *st; int blkn, ci, tbl, sign, k; int v, m; /* Process restart marker if needed */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) process_restart(cinfo); entropy->restarts_to_go--; } if (entropy->ct == -1) return TRUE; /* if error do nothing */ /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = MCU_data ? MCU_data[blkn] : NULL; ci = cinfo->MCU_membership[blkn]; compptr = cinfo->cur_comp_info[ci]; /* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */ tbl = compptr->dc_tbl_no; /* Table F.4: Point to statistics bin S0 for DC coefficient coding */ st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; /* Figure F.19: Decode_DC_DIFF */ if (arith_decode(cinfo, st) == 0) entropy->dc_context[ci] = 0; else { /* Figure F.21: Decoding nonzero value v */ /* Figure F.22: Decoding the sign of v */ sign = arith_decode(cinfo, st + 1); st += 2; st += sign; /* Figure F.23: Decoding the magnitude category of v */ if ((m = arith_decode(cinfo, st)) != 0) { st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ while (arith_decode(cinfo, st)) { if ((m <<= 1) == 0x8000) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* magnitude overflow */ return TRUE; } st += 1; } } /* Section F.1.4.4.1.2: Establish dc_context conditioning category */ if (m < (int)((1L << cinfo->arith_dc_L[tbl]) >> 1)) entropy->dc_context[ci] = 0; /* zero diff category */ else if (m > (int)((1L << cinfo->arith_dc_U[tbl]) >> 1)) entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */ else entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */ v = m; /* Figure F.24: Decoding the magnitude bit pattern of v */ st += 14; while (m >>= 1) if (arith_decode(cinfo, st)) v |= m; v += 1; if (sign) v = -v; entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff; } if (block) (*block)[0] = (JCOEF)entropy->last_dc_val[ci]; /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */ tbl = compptr->ac_tbl_no; /* Figure F.20: Decode_AC_coefficients */ for (k = 1; k <= DCTSIZE2 - 1; k++) { st = entropy->ac_stats[tbl] + 3 * (k - 1); if (arith_decode(cinfo, st)) break; /* EOB flag */ while (arith_decode(cinfo, st + 1) == 0) { st += 3; k++; if (k > DCTSIZE2 - 1) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* spectral overflow */ return TRUE; } } /* Figure F.21: Decoding nonzero value v */ /* Figure F.22: Decoding the sign of v */ sign = arith_decode(cinfo, entropy->fixed_bin); st += 2; /* Figure F.23: Decoding the magnitude category of v */ if ((m = arith_decode(cinfo, st)) != 0) { if (arith_decode(cinfo, st)) { m <<= 1; st = entropy->ac_stats[tbl] + (k <= cinfo->arith_ac_K[tbl] ? 189 : 217); while (arith_decode(cinfo, st)) { if ((m <<= 1) == 0x8000) { WARNMS(cinfo, JWRN_ARITH_BAD_CODE); entropy->ct = -1; /* magnitude overflow */ return TRUE; } st += 1; } } } v = m; /* Figure F.24: Decoding the magnitude bit pattern of v */ st += 14; while (m >>= 1) if (arith_decode(cinfo, st)) v |= m; v += 1; if (sign) v = -v; if (block) (*block)[jpeg_natural_order[k]] = (JCOEF)v; } } return TRUE; } /* * Initialize for an arithmetic-compressed scan. */ METHODDEF(void) start_pass(j_decompress_ptr cinfo) { arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; int ci, tbl; jpeg_component_info *compptr; if (cinfo->progressive_mode) { /* Validate progressive scan parameters */ if (cinfo->Ss == 0) { if (cinfo->Se != 0) goto bad; } else { /* need not check Ss/Se < 0 since they came from unsigned bytes */ if (cinfo->Se < cinfo->Ss || cinfo->Se > DCTSIZE2 - 1) goto bad; /* AC scans may have only one component */ if (cinfo->comps_in_scan != 1) goto bad; } if (cinfo->Ah != 0) { /* Successive approximation refinement scan: must have Al = Ah-1. */ if (cinfo->Ah - 1 != cinfo->Al) goto bad; } if (cinfo->Al > 13) { /* need not check for < 0 */ bad: ERREXIT4(cinfo, JERR_BAD_PROGRESSION, cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); } /* Update progression status, and verify that scan order is legal. * Note that inter-scan inconsistencies are treated as warnings * not fatal errors ... not clear if this is right way to behave. */ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { int coefi, cindex = cinfo->cur_comp_info[ci]->component_index; int *coef_bit_ptr = &cinfo->coef_bits[cindex][0]; if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; if (cinfo->Ah != expected) WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); coef_bit_ptr[coefi] = cinfo->Al; } } /* Select MCU decoding routine */ if (cinfo->Ah == 0) { if (cinfo->Ss == 0) entropy->pub.decode_mcu = decode_mcu_DC_first; else entropy->pub.decode_mcu = decode_mcu_AC_first; } else { if (cinfo->Ss == 0) entropy->pub.decode_mcu = decode_mcu_DC_refine; else entropy->pub.decode_mcu = decode_mcu_AC_refine; } } else { /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. * This ought to be an error condition, but we make it a warning. */ if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 || (cinfo->Se < DCTSIZE2 && cinfo->Se != DCTSIZE2 - 1)) WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); /* Select MCU decoding routine */ entropy->pub.decode_mcu = decode_mcu; } /* Allocate & initialize requested statistics areas */ for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; if (!cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) { tbl = compptr->dc_tbl_no; if (tbl < 0 || tbl >= NUM_ARITH_TBLS) ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl); if (entropy->dc_stats[tbl] == NULL) entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS); MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS); /* Initialize DC predictions to 0 */ entropy->last_dc_val[ci] = 0; entropy->dc_context[ci] = 0; } if (!cinfo->progressive_mode || cinfo->Ss) { tbl = compptr->ac_tbl_no; if (tbl < 0 || tbl >= NUM_ARITH_TBLS) ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl); if (entropy->ac_stats[tbl] == NULL) entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS); MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS); } } /* Initialize arithmetic decoding variables */ entropy->c = 0; entropy->a = 0; entropy->ct = -16; /* force reading 2 initial bytes to fill C */ /* Initialize restart counter */ entropy->restarts_to_go = cinfo->restart_interval; } /* * Module initialization routine for arithmetic entropy decoding. */ GLOBAL(void) jinit_arith_decoder(j_decompress_ptr cinfo) { arith_entropy_ptr entropy; int i; entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, sizeof(arith_entropy_decoder)); cinfo->entropy = (struct jpeg_entropy_decoder *)entropy; entropy->pub.start_pass = start_pass; /* Mark tables unallocated */ for (i = 0; i < NUM_ARITH_TBLS; i++) { entropy->dc_stats[i] = NULL; entropy->ac_stats[i] = NULL; } /* Initialize index for fixed probability estimation */ entropy->fixed_bin[0] = 113; if (cinfo->progressive_mode) { /* Create progression status table */ int *coef_bit_ptr, ci; cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, cinfo->num_components * DCTSIZE2 * sizeof(int)); coef_bit_ptr = &cinfo->coef_bits[0][0]; for (ci = 0; ci < cinfo->num_components; ci++) for (i = 0; i < DCTSIZE2; i++) *coef_bit_ptr++ = -1; } }
#pragma once #include <vector> #include "dice_module.h" namespace cq::event { struct MessageEvent; } namespace dice { class draw_module : public dice_module { public: bool match(const cq::event::MessageEvent& e, const std::wstring& ws) override; void process(const cq::event::MessageEvent& e, const std::wstring& ws) override; }; } // namespace dice
#include "VDP_Extra.h" #include <tab_vram.h> void MyVDP_setTileMapRect(u16 plan, const u16 *data, u16 basetile, u16 x, u16 y, u16 w, u16 h) { vu32 *plctrl; vu16 *pwdata; const u16 *src; u32 addr; u32 planwidth; u16 i, j; VDP_setAutoInc(2); /* point to vdp port */ plctrl = (u32 *) GFX_CTRL_PORT; pwdata = (u16 *) GFX_DATA_PORT; planwidth = VDP_getPlanWidth(); addr = plan + ((x + (planwidth * y)) << 1); src = data; i = h; while (i--) { *plctrl = GFX_WRITE_VRAM_ADDR(addr); j = w; //while (j--) *pwdata = basetile | *src++; // old "buggy" line. while (j--) *pwdata = basetile + *src++; // "fixed" version. addr += planwidth << 1; } } void VDP_setAllHorizontalScrollLines(u16 plan, u16 value) { vu16 *pw; vu32 *pl; u16 addr; /* Point to vdp port */ pw = (u16 *) GFX_DATA_PORT; pl = (u32 *) GFX_CTRL_PORT; addr = HSCRL; if (plan == BPLAN) addr += 2; VDP_setAutoInc(4); *pl = GFX_WRITE_VRAM_ADDR(addr); u16 loop = 224; while(loop--) { *pw = value; } } void VDP_setHorizontalScrollLines(u16 plan, u16* lines, u16 value) { vu16 *pw; vu32 *pl; u16 addr; /* Point to vdp port */ pw = (u16 *) GFX_DATA_PORT; pl = (u32 *) GFX_CTRL_PORT; addr = HSCRL; if (plan == BPLAN) addr += 2; VDP_setAutoInc(4); *pl = GFX_WRITE_VRAM_ADDR(addr); u16* tempLines = lines; u16 loop = 224; while(loop--) { *pw = *tempLines; tempLines++; } } void MyVDP_doVRamDMACopy(u16 from, u16 to, u16 len, u16 autoInc) { vu16 *pw; vu32 *pl; VDP_setAutoInc(autoInc); pw = (u16 *) GFX_CTRL_PORT; // Setup DMA length *pw = 0x9300 + (len & 0xff); *pw = 0x9400 + ((len >> 8) & 0xff); // Setup DMA address *pw = 0x9500 + (from & 0xff); *pw = 0x9600 + ((from >> 8) & 0xff); // Setup DMA operation (VRAM COPY) *pw = 0x97C0; // Write VRam DMA destination address (start DMA copy operation) pl = (u32 *) GFX_CTRL_PORT; *pl = GFX_DMA_VRAM_ADDR(to); } void MyVDP_doDMA(u8 location, u32 from, u16 to, u16 len, u16 autoInc) { vu16 *pw; vu32 *pl; u32 newlen; u32 banklimit; // DMA works on 128 KB bank banklimit = 0x20000 - (from & 0x1FFFF); // bank limit exceded if (len > banklimit) { // we first do the second bank transfert MyVDP_doDMA(location, from + banklimit, to + banklimit, len - banklimit, autoInc); newlen = banklimit; } // ok, use normal len else newlen = len; VDP_setAutoInc(autoInc); pw = (u16 *) GFX_CTRL_PORT; // Setup DMA length (in word here) newlen >>= 1; *pw = 0x9300 + (newlen & 0xff); newlen >>= 8; *pw = 0x9400 + (newlen & 0xff); // Setup DMA address from >>= 1; *pw = 0x9500 + (from & 0xff); from >>= 8; *pw = 0x9600 + (from & 0xff); from >>= 8; *pw = 0x9700 + (from & 0x7f); // Halt the Z80 for DMA // Z80_RequestBus(0); // Enable DMA pl = (u32 *) GFX_CTRL_PORT; switch(location) { case VDP_DMA_VRAM: *pl = GFX_DMA_VRAM_ADDR(to); break; case VDP_DMA_CRAM: *pl = GFX_DMA_CRAM_ADDR(to); break; case VDP_DMA_VSRAM: *pl = GFX_DMA_VSRAM_ADDR(to); break; } // Enable Z80 // Z80_ReleaseBus(); } void MyVDP_waitVSync() { vu16 *pw; u16 vdp_state; vdp_state = VDP_VBLANK_FLAG; pw = (u16 *) GFX_CTRL_PORT; while (vdp_state & VDP_VBLANK_FLAG) vdp_state = *pw; while (!(vdp_state & VDP_VBLANK_FLAG)) vdp_state = *pw; }
//===--------- Definition of the AddressSanitizer class ---------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file declares the AddressSanitizer class which is a port of the legacy // AddressSanitizer pass to use the new PassManager infrastructure. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZER_H #define LLVM_TRANSFORMS_INSTRUMENTATION_ADDRESSSANITIZER_H #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" namespace llvm { /// Frontend-provided metadata for source location. struct LocationMetadata { StringRef Filename; int LineNo = 0; int ColumnNo = 0; LocationMetadata() = default; bool empty() const { return Filename.empty(); } void parse(MDNode *MDN); }; /// Frontend-provided metadata for global variables. class GlobalsMetadata { public: struct Entry { LocationMetadata SourceLoc; StringRef Name; bool IsDynInit = false; bool IsExcluded = false; Entry() = default; }; /// Create a default uninitialized GlobalsMetadata instance. GlobalsMetadata() = default; /// Create an initialized GlobalsMetadata instance. GlobalsMetadata(Module &M); /// Returns metadata entry for a given global. Entry get(GlobalVariable *G) const { auto Pos = Entries.find(G); return (Pos != Entries.end()) ? Pos->second : Entry(); } /// Handle invalidation from the pass manager. /// These results are never invalidated. bool invalidate(Module &, const PreservedAnalyses &, ModuleAnalysisManager::Invalidator &) { return false; } bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &) { return false; } private: DenseMap<GlobalVariable *, Entry> Entries; }; /// The ASanGlobalsMetadataAnalysis initializes and returns a GlobalsMetadata /// object. More specifically, ASan requires looking at all globals registered /// in 'llvm.asan.globals' before running, which only depends on reading module /// level metadata. This analysis is required to run before running the /// AddressSanitizerPass since it collects that metadata. /// The legacy pass manager equivalent of this is ASanGlobalsMetadataLegacyPass. class ASanGlobalsMetadataAnalysis : public AnalysisInfoMixin<ASanGlobalsMetadataAnalysis> { public: using Result = GlobalsMetadata; Result run(Module &, ModuleAnalysisManager &); private: friend AnalysisInfoMixin<ASanGlobalsMetadataAnalysis>; static AnalysisKey Key; }; struct AddressSanitizerOptions { bool CompileKernel = false; bool Recover = false; bool UseAfterScope = false; AsanDetectStackUseAfterReturnMode UseAfterReturn = AsanDetectStackUseAfterReturnMode::Runtime; }; /// Public interface to the address sanitizer pass for instrumenting code to /// check for various memory errors at runtime. /// /// The sanitizer itself is a function pass that works by inserting various /// calls to the ASan runtime library functions. The runtime library essentially /// replaces malloc() and free() with custom implementations that allow regions /// surrounding requested memory to be checked for invalid accesses. class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> { public: AddressSanitizerPass(const AddressSanitizerOptions &Options) : Options(Options){}; PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); void printPipeline(raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName); static bool isRequired() { return true; } private: AddressSanitizerOptions Options; }; /// Public interface to the address sanitizer module pass for instrumenting code /// to check for various memory errors. /// /// This adds 'asan.module_ctor' to 'llvm.global_ctors'. This pass may also /// run intependently of the function address sanitizer. class ModuleAddressSanitizerPass : public PassInfoMixin<ModuleAddressSanitizerPass> { public: ModuleAddressSanitizerPass( const AddressSanitizerOptions &Options, bool UseGlobalGC = true, bool UseOdrIndicator = false, AsanDtorKind DestructorKind = AsanDtorKind::Global); PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); void printPipeline(raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName); static bool isRequired() { return true; } private: AddressSanitizerOptions Options; bool UseGlobalGC; bool UseOdrIndicator; AsanDtorKind DestructorKind; }; // Insert AddressSanitizer (address basic correctness checking) instrumentation FunctionPass *createAddressSanitizerFunctionPass( bool CompileKernel = false, bool Recover = false, bool UseAfterScope = false, AsanDetectStackUseAfterReturnMode UseAfterReturn = AsanDetectStackUseAfterReturnMode::Runtime); ModulePass *createModuleAddressSanitizerLegacyPassPass( bool CompileKernel = false, bool Recover = false, bool UseGlobalsGC = true, bool UseOdrIndicator = true, AsanDtorKind DestructorKind = AsanDtorKind::Global); struct ASanAccessInfo { const int32_t Packed; const uint8_t AccessSizeIndex; const bool IsWrite; const bool CompileKernel; explicit ASanAccessInfo(int32_t Packed); ASanAccessInfo(bool IsWrite, bool CompileKernel, uint8_t AccessSizeIndex); }; } // namespace llvm #endif
/** * MIT License * Copyright (c) 2020 Jiacheng Huang * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef FUNDOT_SYMBOL_H #define FUNDOT_SYMBOL_H #include <cstddef> #include <string> namespace fundot { class Symbol { public: Symbol() = default; Symbol(std::string&& str) : ident_(std::move(str)) {} explicit operator std::string() const { return ident_; } explicit operator const std::string&() const { return ident_; } char& operator[](std::size_t idx) { return ident_[idx]; } char operator[](std::size_t idx) const { return ident_[idx]; } char& back() { return ident_.back(); } char back() const { return ident_.back(); } bool empty() const { return ident_.empty(); } std::size_t size() const { return ident_.size(); } void clear() { ident_.clear(); } void pushBack(char c) { ident_.push_back(c); } void popBack() { ident_.pop_back(); } private: std::string ident_; }; } // namespace fundot #endif
/* * This header is generated by classdump-dyld 1.0 * on Saturday, August 24, 2019 at 9:41:42 PM Mountain Standard Time * Operating System: Version 12.4 (Build 16M568) * Image Source: /System/Library/Frameworks/Foundation.framework/Foundation * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @class NSURLFileTypeMappingsInternal; @interface NSURLFileTypeMappings : NSObject { NSURLFileTypeMappingsInternal* _internal; } +(id)sharedMappings; -(id)_UTIMIMETypeForExtension:(id)arg1 ; -(id)_UTIextensionForMIMEType:(id)arg1 ; -(id)preferredExtensionForMIMEType:(id)arg1 ; -(id)extensionsForMIMEType:(id)arg1 ; -(id)MIMETypeForExtension:(id)arg1 ; -(id)_init; @end
// Copyright 2010 and onwards Google Inc. // Author: jmarantz@google.com (Joshua Marantz) #ifndef NET_INSTAWEB_UTIL_PUBLIC_STRING_H_ #define NET_INSTAWEB_UTIL_PUBLIC_STRING_H_ #include <string.h> #include <string> typedef std::string GoogleString; #endif // NET_INSTAWEB_UTIL_PUBLIC_STRING_H_
#include <string.h> #include "huffman/tree.h" #include "huffman/malloc.h" #include "huffman/sys.h" // Write the path to the root node of the Huffman // tree starting from the specified node into the // buffer. huf_error_t huf_node_to_string( const huf_node_t *self, uint8_t *buf, size_t *len) { routine_m(); const huf_node_t *node = self; size_t position = 0; routine_param_m(buf); routine_param_m(len); while(node) { if (!node->parent) { break; } // Keep borders of the buffer. if (position >= *len) { routine_success_m(); } if (node->parent->left == node) { buf[position] = '0'; } else { buf[position] = '1'; } position++; node = node->parent; } routine_ensure_m(); *len = position; routine_defer_m(); } // Initialize a new instance of the Huffman tree. huf_error_t huf_tree_init(huf_tree_t **self) { routine_m(); routine_param_m(self); huf_error_t err = huf_malloc(void_pptr_m(self), sizeof(huf_tree_t), 1); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } huf_tree_t *self_ptr = *self; err = huf_malloc(void_pptr_m(&self_ptr->leaves), sizeof(huf_node_t*), HUF_ASCII_COUNT * 2); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } routine_yield_m(); } // Recursively release memory occupied // by the Huffman nodes. static void __huf_tree_free(huf_node_t* node) { if (!node) { return; } if (node->left) { __huf_tree_free(node->left); free(node->left); node->left = NULL; } if (node->right) { __huf_tree_free(node->right); free(node->right); node->left = NULL; } } // Release memory occupied by the Huffman tree. huf_error_t huf_tree_free(huf_tree_t **self) { routine_m(); routine_param_m(self); huf_tree_t *self_ptr = *self; __huf_tree_free(self_ptr->root); free(self_ptr->root); free(self_ptr->leaves); free(self_ptr); *self = NULL; routine_yield_m(); } // Release the memory occupied by the Huffman // tree nodes. huf_error_t huf_tree_reset(huf_tree_t *self) { routine_m(); routine_param_m(self); __huf_tree_free(self->root); free(self->root); self->root = NULL; // Reset the memory occupied by the leaves. memset(self->leaves, 0, (sizeof(huf_node_t*) * HUF_ASCII_COUNT * 2)); routine_yield_m(); } // Recursively de-serialize the Huffman tree into the // provided buffer. static huf_error_t __huf_deserialize_tree( huf_node_t **node, const int16_t *buf, size_t *len) { routine_m(); int16_t node_index = HUF_LEAF_NODE; size_t left_branch_len = 0; size_t right_branch_len = 0; routine_param_m(node); routine_param_m(buf); routine_param_m(len); size_t buf_len = *len; if (buf_len < 1) { // Set length of the read data to zero, since there is // nothing to read; *len = 0; routine_success_m(); } huf_node_t *node_ptr = *node; node_index = *buf; if (node_index == HUF_LEAF_NODE) { // Set length of the read data to one, since leaf is a // part of the serialized tree. *len = 1; routine_success_m(); } huf_error_t err = huf_malloc(void_pptr_m(&node_ptr), sizeof(huf_node_t), 1); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } *node = node_ptr; node_ptr->index = node_index; huf_node_t **node_left = &node_ptr->left; huf_node_t **node_right = &node_ptr->right; const int16_t *buf_ptr = buf + 1; // Current node is de-serialized, so shift pointer to // the next one and reduce overall length of buffer by one. left_branch_len = buf_len - 1; // Recursively de-serialize a left branch of the tree. err = __huf_deserialize_tree(node_left, buf_ptr, &left_branch_len); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } buf_ptr += left_branch_len; right_branch_len = buf_len - left_branch_len - 1; // Recursively de-serialize a right branch of the tree. err = __huf_deserialize_tree(node_right, buf_ptr, &right_branch_len); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } // Return in *len* argument length of the read data. *len = left_branch_len + right_branch_len + 1; routine_yield_m(); } // De-serialize the Huffman tree into the // provided buffer. huf_error_t huf_tree_deserialize( huf_tree_t *self, const int16_t *buf, size_t len) { routine_m(); routine_param_m(self); routine_param_m(buf); huf_error_t err = __huf_deserialize_tree( &self->root, buf, &len); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } routine_yield_m(); } // Recursively serialize the Huffman tree from the // provided buffer. static huf_error_t __huf_serialize_tree( const huf_node_t *node, int16_t *buf, size_t *len) { routine_m(); size_t left_branch_len = 0; size_t right_branch_len = 0; routine_param_m(buf); routine_param_m(len); if (node) { *buf = node->index; int16_t *buf_ptr = buf + 1; // Serialize the left branch of the tree. huf_error_t err = __huf_serialize_tree( node->left, buf_ptr, &left_branch_len); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } buf_ptr += left_branch_len; // Serialize the right branch of the tree. err = __huf_serialize_tree(node->right, buf_ptr, &right_branch_len); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } } else { *buf = HUF_LEAF_NODE; } *len = left_branch_len + right_branch_len + 1; routine_yield_m(); } // Serialize the Huffman tree from the // provided buffer. huf_error_t huf_tree_serialize( huf_tree_t *self, int16_t *buf, size_t *len) { routine_m(); routine_param_m(self); routine_param_m(buf); routine_param_m(len); huf_error_t err = __huf_serialize_tree( self->root, buf, len); if (err != HUF_ERROR_SUCCESS) { routine_error_m(err); } routine_yield_m(); }
/* * Copyright (C) 2007-2014 German Aerospace Center (DLR/SC) * * Created: 2014-02-17 Tobias Stollenwerk <tobias.stollenwerk@dlr.de> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file CCPACSFuselageProfileGetPointAlgo.h * @brief Get point and tangent depending on the parameter on a fuselage guide curves * * This class takes a fuselage profile wire and provides the point and the tangent * for a given parameter along the curve, as it is needed by * The curve starts at alpha=0 and ends at alpha=1 */ #include "tigl_internal.h" #include "TopoDS_Wire.hxx" #include "TopoDS_Edge.hxx" #include "TopTools_SequenceOfShape.hxx" #include "gp_Pnt.hxx" #include "gp_Vec.hxx" #ifndef CCPACSFUSELAGEPROFILEGETPOINTALGO_H #define CCPACSFUSELAGEPROFILEGETPOINTALGO_H namespace tigl { class CCPACSFuselageProfileGetPointAlgo { public: /** * \brief Constructor which expects a fuselage profile wire * * * \param wireContainer Contains exactly one Fuselage profile wire */ TIGL_EXPORT CCPACSFuselageProfileGetPointAlgo (const TopTools_SequenceOfShape& wireContainer); /** * \brief Get point and the tangent on fuselage profile at curve parameter alpha * * \param alpha The curve parameter which starts at alpha=0 and ends at alpha=1 * * \param point Point on the profile corresponding to the parameter alpha * \param tangent Tangent on the profile corresponding to the parameter alpha */ TIGL_EXPORT void GetPointTangent(const double& alpha, gp_Pnt& point, gp_Vec& tangent); private: TopoDS_Wire wire; /**< Wire of the fuselage profile */ Standard_Real wireLength; /**< Circumfence of the wing profile */ }; } // end namespace tigl #endif // CCPACSFUSELAGEPROFILEGETPOINTALGO_H
/* * Copyright (c) 2007-12 ETH Zurich. * All rights reserved. * * This file is distributed under the terms in the attached LICENSE file. * If you do not find this file, copies can be found by writing to: * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. */ #include <barrelfish/barrelfish.h> #include <barrelfish/nameservice_client.h> #include <barrelfish/net_constants.h> #include <if/net_ARP_defs.h> #include <barrelfish/waitset.h> // for handling contiuations #include <contmng/contmng.h> // standard libraries #include <stdio.h> #include <string.h> #include <lwip/init.h> #include <netif/etharp.h> // local includes #include "netd.h" #include "netd_debug.h" // ***** Special cases ******** // local ip address (your own ip address) (valid request) // broadcast ip address (invalid request) // multicast IP address (invalid request) // // // // How can I get my own MAC address // Where can I find the code which is looking up local MAC address? // struct eth_addr *srcaddr = (struct eth_addr *) netif->hwaddr; // // // return etharp_query(netif, ipaddr, q); // q is pbuf // lib/lwip/src/netif/etharp.c // find_entry // src/netif/etharp.c /**************************************************************** * data-structures *****************************************************************/ // app connection closure struct ARP_user_cl { // This will be used to remember who all are waiting for response struct net_ARP_binding *cl; // binding struct cont_queue *q; // for continuation management struct ARP_user_cl *next; // for singly linked list bool died; // is the user still connected }; /**************************************************************** * Local states *****************************************************************/ // The name of exported service for ARP lookup (which we are implementing) static char ARP_service_name[MAX_NET_SERVICE_NAME_LEN] = {0}; // is service exported? marks that initialization is done static bool ARP_service_exported = false; // singly linked list of apps connected with this service struct ARP_user_cl *registerd_user_list = NULL; /***************************************************************** * Prototypes *****************************************************************/ static void get_ip_info(struct net_ARP_binding *cc, uint32_t iface); static void ARP_resolve_request(struct net_ARP_binding *cc, ipv4addr_t ip, uint32_t iface, bool force); // service mappings static struct net_ARP_rx_vtbl rx_ARP_vtbl = { .ip_info_call = get_ip_info, .ARP_lookup_call = ARP_resolve_request, }; /***************************************************************** * Housekeeping functions prototypes *****************************************************************/ static void wrapper_ip_info_response(struct net_ARP_binding *cc, errval_t err, ipv4addr_t ip, ipv4addr_t gw, ipv4addr_t nm); static void wrapper_ARP_lookup_response(struct net_ARP_binding *cc, errval_t err, uint64_t mac); /***************************************************************** * Dealing with new connections *****************************************************************/ static errval_t connect_ARP_cb(void *st, struct net_ARP_binding *b) { errval_t err = SYS_ERR_OK; NETD_DEBUG("########### new application came in\n"); // using the b->st to store session specific data (net_user) struct ARP_user_cl *new_app = malloc(sizeof(struct ARP_user_cl)); if (new_app == NULL) { NETD_DEBUG("error: malloc failed...\n"); err = PORT_ERR_NOT_ENOUGH_MEMORY; return err; } memset(new_app, 0, sizeof(struct ARP_user_cl)); new_app->next = registerd_user_list; registerd_user_list = new_app; b->st = (void *) new_app; new_app->q = create_cont_q("ARP2APP"); b->rx_vtbl = rx_ARP_vtbl; return err; } // end function: connect_ARP_cb /***************************************************************** * exporting service *****************************************************************/ static void export_ARP_cb(void *st, errval_t err, iref_t iref) { if (err_is_fail(err)) { DEBUG_ERR(err, "service[%s] export failed", ARP_service_name); abort(); // FIXME: Do I need abort after DEBUG_ERR? } NETD_DEBUG("service [%s] exported at iref %u\n", ARP_service_name, iref); // register this iref with the name service err = nameservice_register(ARP_service_name, iref); if (err_is_fail(err)) { DEBUG_ERR(err, "nameservice_register failed for [%s]", ARP_service_name); abort(); // FIXME: Do I need abort after DEBUG_ERR? } ARP_service_exported = true; NETD_DEBUG("service [%s] export successful!\n", ARP_service_name); } // end function: export_ARP_cb // Initialzes the ARP lookup service int init_ARP_lookup_service(char *dev_name) { errval_t err = SYS_ERR_OK; // default return value // sanity check on parameter assert(dev_name != NULL); // start the port management service snprintf(ARP_service_name, sizeof(ARP_service_name), "%s%s", dev_name, NET_ARP_LOOKUP_SUFFIX); NETD_DEBUG("init_ARP_lookup_service called [%s]\n", ARP_service_name); // exporting net_ports interface err = net_ARP_export(NULL, export_ARP_cb, connect_ARP_cb, get_default_waitset(), IDC_EXPORT_FLAGS_DEFAULT); if (err_is_fail(err)) { USER_PANIC("net_ARP_export failed!"); return err; } // wait till ports export is actually done struct waitset *ws = get_default_waitset(); while (!ARP_service_exported) { err = event_dispatch(ws); if (err_is_fail(err)) { DEBUG_ERR(err, "in event_dispatch for init_ARP_service"); return err; } } // end while: return err; } // end function: init_ARP_service // ************************************************************************ // ARP lookup interface function // ************************************************************************ static void get_ip_info(struct net_ARP_binding *cc, uint32_t iface) { printf("####### get IP info called ######\n"); NETD_DEBUG("get_ip_info: client asking for ip over %"PRIu32"\n", iface); wrapper_ip_info_response(cc, SYS_ERR_OK, netif_ptr->ip_addr.addr, netif_ptr->gw.addr, netif_ptr->netmask.addr); NETD_DEBUG("get_ip_info: terminating\n"); } static uint64_t refresh_cache(uint32_t dst_ip_addr) { struct ip_addr dst_ip; struct netif *netif; dst_ip.addr = dst_ip_addr; netif = ip_route(&dst_ip); NETD_DEBUG("refresh_cache: calling etharp_request\n"); errval_t r = etharp_request(netif, &dst_ip); assert(err_is_ok(r)); struct waitset *ws = NULL; ws = get_default_waitset(); while (is_ip_present_in_arp_cache(&dst_ip) == false) { // NETD_DEBUG("refresh_arp_cache: event dispatched\n"); r = event_dispatch(ws); if (err_is_fail(r)) { DEBUG_ERR(r, "in event_dispatch"); abort(); } } // end while: till arp not present return find_ip_arp_cache(&dst_ip); } static void ARP_resolve_request(struct net_ARP_binding *cc, ipv4addr_t ip, uint32_t iface, bool force) { NETD_DEBUG("ARP_resolve_request: client asking ARP lookup for ip %" PRIu32" over iface %"PRIu32"\n", ip, iface); uint64_t found_mac = refresh_cache(ip); assert(found_mac != 0); // assert(!"NYI ARP resolve request"); NETD_DEBUG("ARP_resolve_request: MAC found for ARP request ip %" PRIu32" over iface %"PRIu32" == %"PRIu64"\n", ip, iface, found_mac); wrapper_ARP_lookup_response(cc, SYS_ERR_OK, found_mac); } // end function: ARP_resolve_request // ************************************************************************ // housekeeping functions // ************************************************************************ static errval_t send_ip_info(struct q_entry e) { struct net_ARP_binding *b = (struct net_ARP_binding *) e.binding_ptr; struct ARP_user_cl *au = (struct ARP_user_cl *) b->st; if (b->can_send(b)) { return b->tx_vtbl.ip_info_response(b, MKCONT(cont_queue_callback, au->q), e.plist[0], e.plist[1], e.plist[2], e.plist[3]); // e.err, e.ip, e.gw, e.mask } else { NETD_DEBUG("send_assign_ip: Flounder busy,rtry++\n"); return FLOUNDER_ERR_TX_BUSY; } } static void wrapper_ip_info_response(struct net_ARP_binding *cc, errval_t err, ipv4addr_t ip, ipv4addr_t gw, ipv4addr_t nm) { struct q_entry entry; memset(&entry, 0, sizeof(struct q_entry)); entry.handler = send_ip_info; entry.binding_ptr = (void *) cc; entry.plist[1] = err; entry.plist[1] = ip; entry.plist[2] = gw; entry.plist[3] = nm; // err, e.ip, e.gw, e.mask struct ARP_user_cl *au = (struct ARP_user_cl *) cc->st; enqueue_cont_q(au->q, &entry); } static errval_t send_ARP_lookup_info(struct q_entry e) { struct net_ARP_binding *b = (struct net_ARP_binding *) e.binding_ptr; struct ARP_user_cl *au = (struct ARP_user_cl *) b->st; if (b->can_send(b)) { return b->tx_vtbl.ARP_lookup_response(b, MKCONT(cont_queue_callback, au->q), e.plist[0], e.plist[1]); // e.err, e.mac } else { NETD_DEBUG("send_assign_ip: Flounder busy,rtry++\n"); return FLOUNDER_ERR_TX_BUSY; } } static void wrapper_ARP_lookup_response(struct net_ARP_binding *cc, errval_t err, uint64_t mac) { struct q_entry entry; memset(&entry, 0, sizeof(struct q_entry)); entry.handler = send_ARP_lookup_info; entry.binding_ptr = (void *) cc; entry.plist[1] = err; entry.plist[1] = mac; // err, e.mac, struct ARP_user_cl *au = (struct ARP_user_cl *) cc->st; enqueue_cont_q(au->q, &entry); }
#ifndef INCLUDED_ENGINE_LEADERBOARD_SYSTEM_H #define INCLUDED_ENGINE_LEADERBOARD_SYSTEM_H #include "core/scene.h" #include "engine/system.h" #include "core/map_start_event.h" #include "client_datas_changed_event.h" #include "core/ctf_program_state.h" #include "core/program_state.h" namespace engine { class LeaderboardSystem : public System { public: DEFINE_SYSTEM_BASE( LeaderboardSystem ) LeaderboardSystem(); protected: virtual void Init(); virtual void Update( double DeltaTime ); private: Scene& mScene; core::ProgramState& mProgramState; ::ctf::ProgramState& mCtfProgramState; ModelValue mLeaderBoardModel; std::vector<std::string> mBlueNames; std::vector<std::string> mBlueKills; std::vector<std::string> mBlueDeaths; std::vector<std::string> mBlueScores; std::vector<std::string> BlueNames(); std::vector<std::string> BlueKills(); std::vector<std::string> BlueDeaths(); std::vector<std::string> BlueScores(); std::vector<std::string> mRedNames; std::vector<std::string> mRedKills; std::vector<std::string> mRedDeaths; std::vector<std::string> mRedScores; std::vector<std::string> RedNames(); std::vector<std::string> RedKills(); std::vector<std::string> RedDeaths(); std::vector<std::string> RedScores(); boost::ptr_vector<ModelValue> mKDASModels; AutoReg mOnMapStart; void OnMapStart( core::MapStartEvent const& Evt ); AutoReg mOnClientDatasChanged; AutoReg mOnScore; AutoReg mOnClientScore; AutoReg mOnKillScore; void UpdateBoard(); std::string mBlueColor; std::string mRedColor; std::string const& GetColor( Team::Type team ) const; }; } // namespace engine #endif//INCLUDED_ENGINE_LEADERBOARD_SYSTEM_H //command: "classgenerator.exe" -g "system" -c "leaderboard_system" -e "core-mapStart engine-clientDatasChanged"
// SPDX-License-Identifier: GPL-2.0-only /* * Joshua Henderson <joshua.henderson@microchip.com> * Copyright (C) 2015 Microchip Technology Inc. All rights reserved. */ #include <asm/mach-pic32/pic32.h> #include "pic32mzda.h" /* Oscillators, PLL & clocks */ #define ICLK_MASK 0x00000080 #define PLLDIV_MASK 0x00000007 #define CUROSC_MASK 0x00000007 #define PLLMUL_MASK 0x0000007F #define PB_MASK 0x00000007 #define FRC1 0 #define FRC2 7 #define SPLL 1 #define POSC 2 #define FRC_CLK 8000000 #define PIC32_POSC_FREQ 24000000 #define OSCCON 0x0000 #define SPLLCON 0x0020 #define PB1DIV 0x0140 u32 pic32_get_sysclk(void) { u32 osc_freq = 0; u32 pllclk; u32 frcdivn; u32 osccon; u32 spllcon; int curr_osc; u32 plliclk; u32 pllidiv; u32 pllodiv; u32 pllmult; u32 frcdiv; void __iomem *osc_base = ioremap(PIC32_BASE_OSC, 0x200); osccon = __raw_readl(osc_base + OSCCON); spllcon = __raw_readl(osc_base + SPLLCON); plliclk = (spllcon & ICLK_MASK); pllidiv = ((spllcon >> 8) & PLLDIV_MASK) + 1; pllodiv = ((spllcon >> 24) & PLLDIV_MASK); pllmult = ((spllcon >> 16) & PLLMUL_MASK) + 1; frcdiv = ((osccon >> 24) & PLLDIV_MASK); pllclk = plliclk ? FRC_CLK : PIC32_POSC_FREQ; frcdivn = ((1 << frcdiv) + 1) + (128 * (frcdiv == 7)); if (pllodiv < 2) pllodiv = 2; else if (pllodiv < 5) pllodiv = (1 << pllodiv); else pllodiv = 32; curr_osc = (int)((osccon >> 12) & CUROSC_MASK); switch (curr_osc) { case FRC1: case FRC2: osc_freq = FRC_CLK / frcdivn; break; case SPLL: osc_freq = ((pllclk / pllidiv) * pllmult) / pllodiv; break; case POSC: osc_freq = PIC32_POSC_FREQ; break; default: break; } iounmap(osc_base); return osc_freq; } u32 pic32_get_pbclk(int bus) { u32 clk_freq; void __iomem *osc_base = ioremap(PIC32_BASE_OSC, 0x200); u32 pbxdiv = PB1DIV + ((bus - 1) * 0x10); u32 pbdiv = (__raw_readl(osc_base + pbxdiv) & PB_MASK) + 1; iounmap(osc_base); clk_freq = pic32_get_sysclk(); return clk_freq / pbdiv; }
/* -*- Mode: C; c-basic-offset:4 ; -*- */ /* * (C) 2001 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. * * This file is automatically generated by buildiface * DO NOT EDIT */ #include "mpi_fortimpl.h" #ifdef MPI_WIN_DUP_FN #undef MPI_WIN_DUP_FN #endif /* Begin MPI profiling block */ #if defined(USE_WEAK_SYMBOLS) && !defined(USE_ONLY_MPI_NAMES) #if defined(HAVE_MULTIPLE_PRAGMA_WEAK) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #if defined(F77_NAME_UPPER) #pragma weak MPI_WIN_DUP_FN = PMPI_WIN_DUP_FN #pragma weak mpi_win_dup_fn__ = PMPI_WIN_DUP_FN #pragma weak mpi_win_dup_fn_ = PMPI_WIN_DUP_FN #pragma weak mpi_win_dup_fn = PMPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #pragma weak MPI_WIN_DUP_FN = pmpi_win_dup_fn__ #pragma weak mpi_win_dup_fn__ = pmpi_win_dup_fn__ #pragma weak mpi_win_dup_fn_ = pmpi_win_dup_fn__ #pragma weak mpi_win_dup_fn = pmpi_win_dup_fn__ #elif defined(F77_NAME_LOWER_USCORE) #pragma weak MPI_WIN_DUP_FN = pmpi_win_dup_fn_ #pragma weak mpi_win_dup_fn__ = pmpi_win_dup_fn_ #pragma weak mpi_win_dup_fn_ = pmpi_win_dup_fn_ #pragma weak mpi_win_dup_fn = pmpi_win_dup_fn_ #else #pragma weak MPI_WIN_DUP_FN = pmpi_win_dup_fn #pragma weak mpi_win_dup_fn__ = pmpi_win_dup_fn #pragma weak mpi_win_dup_fn_ = pmpi_win_dup_fn #pragma weak mpi_win_dup_fn = pmpi_win_dup_fn #endif #elif defined(HAVE_PRAGMA_WEAK) #if defined(F77_NAME_UPPER) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #pragma weak MPI_WIN_DUP_FN = PMPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #pragma weak mpi_win_dup_fn__ = pmpi_win_dup_fn__ #elif !defined(F77_NAME_LOWER_USCORE) extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #pragma weak mpi_win_dup_fn = pmpi_win_dup_fn #else extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #pragma weak mpi_win_dup_fn_ = pmpi_win_dup_fn_ #endif #elif defined(HAVE_PRAGMA_HP_SEC_DEF) #if defined(F77_NAME_UPPER) #pragma _HP_SECONDARY_DEF PMPI_WIN_DUP_FN MPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #pragma _HP_SECONDARY_DEF pmpi_win_dup_fn__ mpi_win_dup_fn__ #elif !defined(F77_NAME_LOWER_USCORE) #pragma _HP_SECONDARY_DEF pmpi_win_dup_fn mpi_win_dup_fn #else #pragma _HP_SECONDARY_DEF pmpi_win_dup_fn_ mpi_win_dup_fn_ #endif #elif defined(HAVE_PRAGMA_CRI_DUP) #if defined(F77_NAME_UPPER) #pragma _CRI duplicate MPI_WIN_DUP_FN as PMPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #pragma _CRI duplicate mpi_win_dup_fn__ as pmpi_win_dup_fn__ #elif !defined(F77_NAME_LOWER_USCORE) #pragma _CRI duplicate mpi_win_dup_fn as pmpi_win_dup_fn #else #pragma _CRI duplicate mpi_win_dup_fn_ as pmpi_win_dup_fn_ #endif #elif defined(HAVE_WEAK_ATTRIBUTE) #if defined(F77_NAME_UPPER) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); #elif defined(F77_NAME_LOWER_2USCORE) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); #elif defined(F77_NAME_LOWER_USCORE) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); #else extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); #endif #endif /* HAVE_PRAGMA_WEAK */ #endif /* USE_WEAK_SYMBOLS */ /* End MPI profiling block */ /* These definitions are used only for generating the Fortran wrappers */ #if defined(USE_WEAK_SYMBOLS) && defined(USE_ONLY_MPI_NAMES) #if defined(HAVE_MULTIPLE_PRAGMA_WEAK) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #if defined(F77_NAME_UPPER) #pragma weak mpi_win_dup_fn__ = MPI_WIN_DUP_FN #pragma weak mpi_win_dup_fn_ = MPI_WIN_DUP_FN #pragma weak mpi_win_dup_fn = MPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #pragma weak MPI_WIN_DUP_FN = mpi_win_dup_fn__ #pragma weak mpi_win_dup_fn_ = mpi_win_dup_fn__ #pragma weak mpi_win_dup_fn = mpi_win_dup_fn__ #elif defined(F77_NAME_LOWER_USCORE) #pragma weak MPI_WIN_DUP_FN = mpi_win_dup_fn_ #pragma weak mpi_win_dup_fn__ = mpi_win_dup_fn_ #pragma weak mpi_win_dup_fn = mpi_win_dup_fn_ #else #pragma weak MPI_WIN_DUP_FN = mpi_win_dup_fn #pragma weak mpi_win_dup_fn__ = mpi_win_dup_fn #pragma weak mpi_win_dup_fn_ = mpi_win_dup_fn #endif #elif defined(HAVE_WEAK_ATTRIBUTE) #if defined(F77_NAME_UPPER) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("MPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("MPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("MPI_WIN_DUP_FN"))); #elif defined(F77_NAME_LOWER_2USCORE) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn__"))); #elif defined(F77_NAME_LOWER_USCORE) extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn_"))); #else extern FORT_DLL_SPEC void FORT_CALL MPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("mpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #endif #endif #endif /* Map the name to the correct form */ #ifndef MPICH_MPI_FROM_PMPI #if defined(USE_WEAK_SYMBOLS) #if defined(HAVE_MULTIPLE_PRAGMA_WEAK) /* Define the weak versions of the PMPI routine*/ #ifndef F77_NAME_UPPER extern FORT_DLL_SPEC void FORT_CALL PMPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #endif #ifndef F77_NAME_LOWER_2USCORE extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #endif #ifndef F77_NAME_LOWER_USCORE extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #endif #ifndef F77_NAME_LOWER extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ); #endif #if defined(F77_NAME_UPPER) #pragma weak pmpi_win_dup_fn__ = PMPI_WIN_DUP_FN #pragma weak pmpi_win_dup_fn_ = PMPI_WIN_DUP_FN #pragma weak pmpi_win_dup_fn = PMPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #pragma weak PMPI_WIN_DUP_FN = pmpi_win_dup_fn__ #pragma weak pmpi_win_dup_fn_ = pmpi_win_dup_fn__ #pragma weak pmpi_win_dup_fn = pmpi_win_dup_fn__ #elif defined(F77_NAME_LOWER_USCORE) #pragma weak PMPI_WIN_DUP_FN = pmpi_win_dup_fn_ #pragma weak pmpi_win_dup_fn__ = pmpi_win_dup_fn_ #pragma weak pmpi_win_dup_fn = pmpi_win_dup_fn_ #else #pragma weak PMPI_WIN_DUP_FN = pmpi_win_dup_fn #pragma weak pmpi_win_dup_fn__ = pmpi_win_dup_fn #pragma weak pmpi_win_dup_fn_ = pmpi_win_dup_fn #endif /* Test on name mapping */ #elif defined(HAVE_WEAK_ATTRIBUTE) #if defined(F77_NAME_UPPER) extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("PMPI_WIN_DUP_FN"))); #elif defined(F77_NAME_LOWER_2USCORE) extern FORT_DLL_SPEC void FORT_CALL PMPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn__"))); #elif defined(F77_NAME_LOWER_USCORE) extern FORT_DLL_SPEC void FORT_CALL PMPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn_"))); #else extern FORT_DLL_SPEC void FORT_CALL PMPI_WIN_DUP_FN( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn__( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); extern FORT_DLL_SPEC void FORT_CALL pmpi_win_dup_fn_( MPI_Fint*, MPI_Fint*, void*, MPI_Aint *, MPI_Aint *, MPI_Fint*, MPI_Fint * ) __attribute__((weak,alias("pmpi_win_dup_fn"))); #endif /* Test on name mapping */ #endif /* HAVE_MULTIPLE_PRAGMA_WEAK */ #endif /* USE_WEAK_SYMBOLS */ #ifdef F77_NAME_UPPER #define mpi_win_dup_fn_ PMPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #define mpi_win_dup_fn_ pmpi_win_dup_fn__ #elif !defined(F77_NAME_LOWER_USCORE) #define mpi_win_dup_fn_ pmpi_win_dup_fn #else #define mpi_win_dup_fn_ pmpi_win_dup_fn_ #endif /* Test on name mapping */ #ifdef F77_USE_PMPI /* This defines the routine that we call, which must be the PMPI version since we're renaming the Fortran entry as the pmpi version. The MPI name must be undefined first to prevent any conflicts with previous renamings. */ #undef MPI_mpi_win_dup_fn #define MPI_mpi_win_dup_fn PMPI_mpi_win_dup_fn #endif #else #ifdef F77_NAME_UPPER #define mpi_win_dup_fn_ MPI_WIN_DUP_FN #elif defined(F77_NAME_LOWER_2USCORE) #define mpi_win_dup_fn_ mpi_win_dup_fn__ #elif !defined(F77_NAME_LOWER_USCORE) #define mpi_win_dup_fn_ mpi_win_dup_fn /* Else leave name alone */ #endif #endif /* MPICH_MPI_FROM_PMPI */ /* Prototypes for the Fortran interfaces */ #include "fproto.h" FORT_DLL_SPEC void FORT_CALL mpi_win_dup_fn_ ( MPI_Fint*v1, MPI_Fint*v2, void*v3, MPI_Aint *v4, MPI_Aint *v5, MPI_Fint*v6, MPI_Fint *ierr ){ *v5 = *v4; *v6 = MPII_TO_FLOG(1); *ierr = MPI_SUCCESS; }
/* swc: libswc/shell_surface.c * * Copyright (c) 2013, 2014 Michael Forney * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "shell_surface.h" #include "compositor.h" #include "internal.h" #include "output.h" #include "screen.h" #include "seat.h" #include "surface.h" #include "swc.h" #include "util.h" #include "view.h" #include "window.h" #include <stdlib.h> #include <signal.h> struct shell_surface { struct window window; struct wl_resource *resource; struct wl_listener surface_destroy_listener; }; static void configure(struct window *window, uint32_t width, uint32_t height) { struct shell_surface *shell_surface = wl_container_of(window, shell_surface, window); wl_shell_surface_send_configure(shell_surface->resource, WL_SHELL_SURFACE_RESIZE_NONE, width, height); /* wl_shell does not support acknowledging configures. */ window->configure.acknowledged = true; } static void close(struct window *window) { struct shell_surface *shell_surface = wl_container_of(window, shell_surface, window); struct wl_client *client; pid_t pid; client = wl_resource_get_client(shell_surface->resource); wl_client_get_credentials(client, &pid, NULL, NULL); kill(pid, SIGTERM); } static const struct window_impl window_impl = { .configure = configure, .close = close, }; static void pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial) { } static void move(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); struct button *button; if (!(button = pointer_get_button(swc.seat->pointer, serial))) return; window_begin_move(&shell_surface->window, button); } static void resize(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial, uint32_t edges) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); struct button *button; if (!(button = pointer_get_button(swc.seat->pointer, serial))) return; window_begin_resize(&shell_surface->window, edges, button); } static void set_toplevel(struct wl_client *client, struct wl_resource *resource) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); window_manage(&shell_surface->window); window_set_parent(&shell_surface->window, NULL); } static void set_transient(struct wl_client *client, struct wl_resource *resource, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); struct surface *parent_surface = wl_resource_get_user_data(parent_resource); struct compositor_view *parent_view = compositor_view(parent_surface->view); if (!parent_view || !parent_view->window) return; window_manage(&shell_surface->window); window_set_parent(&shell_surface->window, parent_view->window); } static void set_fullscreen(struct wl_client *client, struct wl_resource *resource, uint32_t method, uint32_t framerate, struct wl_resource *output_resource) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); struct output *output = output_resource ? wl_resource_get_user_data(output_resource) : NULL; struct screen *screen; screen = output ? output->screen : wl_container_of(swc.screens.next, screen, link); /* TODO: Handle fullscreen windows. */ window_manage(&shell_surface->window); window_set_parent(&shell_surface->window, NULL); } static void set_popup(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial, struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); struct surface *parent_surface = wl_resource_get_user_data(parent_resource); struct compositor_view *parent_view = compositor_view(parent_surface->view); if (!parent_view || !parent_view->window) return; window_unmanage(&shell_surface->window); window_set_parent(&shell_surface->window, parent_view->window); view_move(&shell_surface->window.view->base, parent_view->base.geometry.x + x, parent_view->base.geometry.y + y); } static void set_maximized(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); /* TODO: Handle maximized windows. */ window_manage(&shell_surface->window); window_set_parent(&shell_surface->window, NULL); } static void set_title(struct wl_client *client, struct wl_resource *resource, const char *title) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); window_set_title(&shell_surface->window, title, -1); } static void set_class(struct wl_client *client, struct wl_resource *resource, const char *class) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); window_set_app_id(&shell_surface->window, class); } static const struct wl_shell_surface_interface shell_surface_implementation = { .pong = pong, .move = move, .resize = resize, .set_toplevel = set_toplevel, .set_transient = set_transient, .set_fullscreen = set_fullscreen, .set_popup = set_popup, .set_maximized = set_maximized, .set_title = set_title, .set_class = set_class, }; static void handle_surface_destroy(struct wl_listener *listener, void *data) { struct shell_surface *shell_surface = wl_container_of(listener, shell_surface, surface_destroy_listener); wl_resource_destroy(shell_surface->resource); } static void destroy_shell_surface(struct wl_resource *resource) { struct shell_surface *shell_surface = wl_resource_get_user_data(resource); window_finalize(&shell_surface->window); free(shell_surface); } struct shell_surface * shell_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface) { struct shell_surface *shell_surface; shell_surface = malloc(sizeof(*shell_surface)); if (!shell_surface) goto error0; shell_surface->resource = wl_resource_create(client, &wl_shell_surface_interface, version, id); if (!shell_surface->resource) goto error1; wl_resource_set_implementation(shell_surface->resource, &shell_surface_implementation, shell_surface, &destroy_shell_surface); window_initialize(&shell_surface->window, &window_impl, surface); shell_surface->surface_destroy_listener.notify = &handle_surface_destroy; wl_resource_add_destroy_listener(surface->resource, &shell_surface->surface_destroy_listener); return shell_surface; error1: free(shell_surface); error0: return NULL; }
// // rubyext.c // the ruby binding to bloopsaphone // // (c) 2009 why the lucky stiff // #include <ruby.h> #include "bloopsaphone.h" static VALUE cBloops, cSound, cTrack; static bloops *Btest; static bloopsaphone *Pplain; static bloopsatrack *Ttest; #ifndef RSTRING_LEN #define RSTRING_LEN(str) RSTRING(str)->len #define RSTRING_PTR(str) RSTRING(str)->ptr #endif // // Main Bloops object // static void rb_bloops_free(bloops *B) { bloops_destroy(B); } VALUE rb_bloops_alloc(VALUE klass) { bloops *B = bloops_new(); return Data_Wrap_Struct(klass, NULL, rb_bloops_free, B); } VALUE rb_bloops_clear(VALUE self) { bloops *B; Data_Get_Struct(self, bloops, B); bloops_clear(B); return self; } VALUE rb_bloops_play(VALUE self) { bloops *B; Data_Get_Struct(self, bloops, B); bloops_play(B); return self; } VALUE rb_bloops_is_stopped(VALUE self) { bloops *B; Data_Get_Struct(self, bloops, B); return bloops_is_done(B) ? Qtrue : Qfalse; } VALUE rb_bloops_get_tempo(VALUE self) { bloops *B; Data_Get_Struct(self, bloops, B); return INT2NUM(B->tempo); } VALUE rb_bloops_set_tempo(VALUE self, VALUE tempo) { bloops *B; Data_Get_Struct(self, bloops, B); bloops_tempo(B, NUM2INT(tempo)); return tempo; } // // Instrument creation // static void rb_bloops_sound_free(bloopsaphone *sound) { free(sound); } VALUE rb_bloops_load(VALUE self, VALUE fname) { bloops *B; bloopsaphone *P; Data_Get_Struct(self, bloops, B); StringValue(fname); P = bloops_sound_file(B, RSTRING_PTR(fname)); if (P == NULL) return Qnil; return Data_Wrap_Struct(cSound, NULL, rb_bloops_sound_free, P); } VALUE rb_bloops_sound(VALUE self, VALUE type) { bloopsaphone *P = bloops_square(); P->type = (unsigned char)NUM2INT(type); return Data_Wrap_Struct(cSound, NULL, rb_bloops_sound_free, P); } VALUE rb_bloops_sound_str(VALUE self) { bloopsaphone *P; Data_Get_Struct(self, bloopsaphone, P); return rb_str_new2(bloops_sound_str(P)); } VALUE rb_bloops_reset(VALUE self) { bloopsaphone *P; Data_Get_Struct(self, bloopsaphone, P); MEMCPY(P, Pplain, bloopsaphone, 1); return self; } VALUE rb_bloops_test(VALUE self) { bloopsaphone *P; Data_Get_Struct(self, bloopsaphone, P); Ttest->P = P; bloops_play(Btest); return self; } VALUE rb_bloops_get_type(VALUE self) { bloopsaphone *P; Data_Get_Struct(self, bloopsaphone, P); return INT2NUM((int)P->type); } VALUE rb_bloops_set_type(VALUE self, VALUE type) { bloopsaphone *P; Data_Get_Struct(self, bloopsaphone, P); P->type = (unsigned char)NUM2INT(type); return type; } #define SOUND_ACCESSOR(name) \ VALUE rb_bloops_get_##name(VALUE self) { \ bloopsaphone *P; \ Data_Get_Struct(self, bloopsaphone, P); \ return rb_float_new(P->name); \ } \ VALUE rb_bloops_set_##name(VALUE self, VALUE f) { \ bloopsaphone *P; \ Data_Get_Struct(self, bloopsaphone, P); \ P->name = (float)NUM2DBL(f); \ return f; \ } SOUND_ACCESSOR(arp); SOUND_ACCESSOR(aspeed); SOUND_ACCESSOR(attack); SOUND_ACCESSOR(decay); SOUND_ACCESSOR(dslide); SOUND_ACCESSOR(freq); SOUND_ACCESSOR(hpf); SOUND_ACCESSOR(hsweep); SOUND_ACCESSOR(limit); SOUND_ACCESSOR(lpf); SOUND_ACCESSOR(lsweep); SOUND_ACCESSOR(phase); SOUND_ACCESSOR(psweep); SOUND_ACCESSOR(repeat); SOUND_ACCESSOR(resonance); SOUND_ACCESSOR(slide); SOUND_ACCESSOR(square); SOUND_ACCESSOR(sustain); SOUND_ACCESSOR(sweep); SOUND_ACCESSOR(punch); SOUND_ACCESSOR(vibe); SOUND_ACCESSOR(vspeed); SOUND_ACCESSOR(vdelay); SOUND_ACCESSOR(volume); // // Individual track object // static void rb_bloops_track_free(bloopsatrack *track) { bloops_track_destroy(track); } VALUE rb_bloops_tune(VALUE self, VALUE sound, VALUE notes) { int i; bloops *B; bloopsaphone *phone; bloopsatrack *track; Data_Get_Struct(self, bloops, B); Data_Get_Struct(sound, bloopsaphone, phone); StringValue(notes); track = bloops_track(B, phone, RSTRING_PTR(notes), RSTRING_LEN(notes)); for (i = 0; i < BLOOPS_MAX_TRACKS; i++) if (B->tracks[i] == NULL) { bloops_track_at(B, track, i); break; } return Data_Wrap_Struct(cTrack, NULL, rb_bloops_track_free, track); } VALUE rb_bloops_track_str(VALUE self) { char *str; VALUE obj; bloopsatrack *track; Data_Get_Struct(self, bloopsatrack, track); str = bloops_track_str(track); obj = rb_str_new2(str); free(str); return obj; } // // Ruby extension startup // void Init_bloops() { Btest = bloops_new(); bloops_tempo(Btest, 120); Pplain = bloops_square(); Ttest = bloops_track2(Btest, Pplain, "C"); Ttest->notes[0].tone = 'n'; bloops_track_at(Btest, Ttest, 0); cBloops = rb_define_class("Bloops", rb_cObject); rb_define_alloc_func(cBloops, rb_bloops_alloc); rb_define_method(cBloops, "clear", rb_bloops_clear, 0); rb_define_method(cBloops, "load", rb_bloops_load, 1); rb_define_method(cBloops, "play", rb_bloops_play, 0); rb_define_method(cBloops, "sound", rb_bloops_sound, 1); rb_define_singleton_method(cBloops, "sound", rb_bloops_sound, 1); rb_define_method(cBloops, "stopped?", rb_bloops_is_stopped, 0); rb_define_method(cBloops, "tempo", rb_bloops_get_tempo, 0); rb_define_method(cBloops, "tempo=", rb_bloops_set_tempo, 1); rb_define_method(cBloops, "tune", rb_bloops_tune, 2); rb_const_set(cBloops, rb_intern("SQUARE"), INT2NUM(BLOOPS_SQUARE)); rb_const_set(cBloops, rb_intern("SAWTOOTH"), INT2NUM(BLOOPS_SAWTOOTH)); rb_const_set(cBloops, rb_intern("SINE"), INT2NUM(BLOOPS_SINE)); rb_const_set(cBloops, rb_intern("NOISE"), INT2NUM(BLOOPS_NOISE)); cSound = rb_define_class_under(cBloops, "Sound", rb_cObject); rb_define_method(cSound, "to_s", rb_bloops_sound_str, 0); rb_define_method(cSound, "reset", rb_bloops_reset, 0); rb_define_method(cSound, "test", rb_bloops_test, 0); rb_define_method(cSound, "arp", rb_bloops_get_arp, 0); rb_define_method(cSound, "arp=", rb_bloops_set_arp, 1); rb_define_method(cSound, "aspeed", rb_bloops_get_aspeed, 0); rb_define_method(cSound, "aspeed=", rb_bloops_set_aspeed, 1); rb_define_method(cSound, "attack", rb_bloops_get_attack, 0); rb_define_method(cSound, "attack=", rb_bloops_set_attack, 1); rb_define_method(cSound, "decay", rb_bloops_get_decay, 0); rb_define_method(cSound, "decay=", rb_bloops_set_decay, 1); rb_define_method(cSound, "dslide", rb_bloops_get_dslide, 0); rb_define_method(cSound, "dslide=", rb_bloops_set_dslide, 1); rb_define_method(cSound, "freq", rb_bloops_get_freq, 0); rb_define_method(cSound, "freq=", rb_bloops_set_freq, 1); rb_define_method(cSound, "hpf", rb_bloops_get_hpf, 0); rb_define_method(cSound, "hpf=", rb_bloops_set_hpf, 1); rb_define_method(cSound, "hsweep", rb_bloops_get_hsweep, 0); rb_define_method(cSound, "hsweep=", rb_bloops_set_hsweep, 1); rb_define_method(cSound, "limit", rb_bloops_get_limit, 0); rb_define_method(cSound, "limit=", rb_bloops_set_limit, 1); rb_define_method(cSound, "lpf", rb_bloops_get_lpf, 0); rb_define_method(cSound, "lpf=", rb_bloops_set_lpf, 1); rb_define_method(cSound, "lsweep", rb_bloops_get_lsweep, 0); rb_define_method(cSound, "lsweep=", rb_bloops_set_lsweep, 1); rb_define_method(cSound, "phase", rb_bloops_get_phase, 0); rb_define_method(cSound, "phase=", rb_bloops_set_phase, 1); rb_define_method(cSound, "psweep", rb_bloops_get_psweep, 0); rb_define_method(cSound, "psweep=", rb_bloops_set_psweep, 1); rb_define_method(cSound, "punch", rb_bloops_get_punch, 0); rb_define_method(cSound, "punch=", rb_bloops_set_punch, 1); rb_define_method(cSound, "repeat", rb_bloops_get_repeat, 0); rb_define_method(cSound, "repeat=", rb_bloops_set_repeat, 1); rb_define_method(cSound, "resonance", rb_bloops_get_resonance, 0); rb_define_method(cSound, "resonance=", rb_bloops_set_resonance, 1); rb_define_method(cSound, "slide", rb_bloops_get_slide, 0); rb_define_method(cSound, "slide=", rb_bloops_set_slide, 1); rb_define_method(cSound, "square", rb_bloops_get_square, 0); rb_define_method(cSound, "square=", rb_bloops_set_square, 1); rb_define_method(cSound, "sweep", rb_bloops_get_sweep, 0); rb_define_method(cSound, "sweep=", rb_bloops_set_sweep, 1); rb_define_method(cSound, "sustain", rb_bloops_get_sustain, 0); rb_define_method(cSound, "sustain=", rb_bloops_set_sustain, 1); rb_define_method(cSound, "type", rb_bloops_get_type, 0); rb_define_method(cSound, "type=", rb_bloops_set_type, 1); rb_define_method(cSound, "vibe", rb_bloops_get_vibe, 0); rb_define_method(cSound, "vibe=", rb_bloops_set_vibe, 1); rb_define_method(cSound, "vspeed", rb_bloops_get_vspeed, 0); rb_define_method(cSound, "vspeed=", rb_bloops_set_vspeed, 1); rb_define_method(cSound, "vdelay", rb_bloops_get_vdelay, 0); rb_define_method(cSound, "vdelay=", rb_bloops_set_vdelay, 1); rb_define_method(cSound, "volume", rb_bloops_get_volume, 0); rb_define_method(cSound, "volume=", rb_bloops_set_volume, 1); cTrack = rb_define_class_under(cBloops, "Track", rb_cObject); rb_define_method(cTrack, "to_s", rb_bloops_track_str, 0); }
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "seccomon.h" #include "prio.h" #include "prprf.h" #include "plhash.h" /* * The following provides a default example for operating systems to set up * and manage applications loading NSS on their OS globally. * * This code hooks in to the system pkcs11.txt, which controls all the loading * of pkcs11 modules common to all applications. */ /* * OS Specific function to get where the NSS user database should reside. */ #ifdef XP_UNIX #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> static int testdir(char *dir) { struct stat buf; memset(&buf, 0, sizeof(buf)); if (stat(dir,&buf) < 0) { return 0; } return S_ISDIR(buf.st_mode); } #define NSS_USER_PATH1 "/.pki" #define NSS_USER_PATH2 "/nssdb" static char * getUserDB(void) { char *userdir = getenv("HOME"); char *nssdir = NULL; if (userdir == NULL) { return NULL; } nssdir = PORT_Alloc(strlen(userdir) +sizeof(NSS_USER_PATH1)+sizeof(NSS_USER_PATH2)); if (nssdir == NULL) { return NULL; } PORT_Strcpy(nssdir, userdir); /* verify it exists */ if (!testdir(nssdir)) { PORT_Free(nssdir); return NULL; } PORT_Strcat(nssdir, NSS_USER_PATH1); if (!testdir(nssdir) && mkdir(nssdir, 0760)) { PORT_Free(nssdir); return NULL; } PORT_Strcat(nssdir, NSS_USER_PATH2); if (!testdir(nssdir) && mkdir(nssdir, 0760)) { PORT_Free(nssdir); return NULL; } return nssdir; } #define NSS_DEFAULT_SYSTEM "/etc/pki/nssdb" static char * getSystemDB(void) { return PORT_Strdup(NSS_DEFAULT_SYSTEM); } static PRBool userIsRoot() { /* this works for linux and all unixes that we know off though it isn't stated as such in POSIX documentation */ return getuid() == 0; } static PRBool userCanModifySystemDB() { return (access(NSS_DEFAULT_SYSTEM, W_OK) == 0); } #else #ifdef XP_WIN static char * getUserDB(void) { /* use the registry to find the user's NSS_DIR. if no entry exists, create * one in the users Appdir location */ return NULL; } static char * getSystemDB(void) { /* use the registry to find the system's NSS_DIR. if no entry exists, create * one based on the windows system data area */ return NULL; } static PRBool userIsRoot() { /* use the registry to find if the user is the system administrator. */ return PR_FALSE; } static PRBool userCanModifySystemDB() { /* use the registry to find if the user has administrative privilege * to modify the system's nss database. */ return PR_FALSE; } #else #error "Need to write getUserDB, SystemDB, userIsRoot, and userCanModifySystemDB functions" #endif #endif static PRBool getFIPSEnv(void) { char *fipsEnv = getenv("NSS_FIPS"); if (!fipsEnv) { return PR_FALSE; } if ((strcasecmp(fipsEnv,"fips") == 0) || (strcasecmp(fipsEnv,"true") == 0) || (strcasecmp(fipsEnv,"on") == 0) || (strcasecmp(fipsEnv,"1") == 0)) { return PR_TRUE; } return PR_FALSE; } #ifdef XP_LINUX static PRBool getFIPSMode(void) { FILE *f; char d; size_t size; f = fopen("/proc/sys/crypto/fips_enabled", "r"); if (!f) { /* if we don't have a proc flag, fall back to the * environment variable */ return getFIPSEnv(); } size = fread(&d, 1, 1, f); fclose(f); if (size != 1) return PR_FALSE; if (d != '1') return PR_FALSE; return PR_TRUE; } #else static PRBool getFIPSMode(void) { return getFIPSEnv(); } #endif #define NSS_DEFAULT_FLAGS "flags=readonly" /* configuration flags according to * https://developer.mozilla.org/en/PKCS11_Module_Specs * As stated there the slotParams start with a slot name which is a slotID * Slots 1 through 3 are reserved for the nss internal modules as follows: * 1 for crypto operations slot non-fips, * 2 for the key slot, and * 3 for the crypto operations slot fips */ #define CIPHER_ORDER_FLAGS "cipherOrder=100" #define SLOT_FLAGS \ "[slotFlags=RSA,RC4,RC2,DES,DH,SHA1,MD5,MD2,SSL,TLS,AES,RANDOM" \ " askpw=any timeout=30 ]" static const char *nssDefaultFlags = CIPHER_ORDER_FLAGS " slotParams={0x00000001=" SLOT_FLAGS " } "; static const char *nssDefaultFIPSFlags = CIPHER_ORDER_FLAGS " slotParams={0x00000003=" SLOT_FLAGS " } "; /* * This function builds the list of databases and modules to load, and sets * their configuration. For the sample we have a fixed set. * 1. We load the user's home nss database. * 2. We load the user's custom PKCS #11 modules. * 3. We load the system nss database readonly. * * Any space allocated in get_list must be freed in release_list. * This function can use whatever information is available to the application. * it is running in the process of the application for which it is making * decisions, so it's possible to acquire the application name as part of * the decision making process. * */ static char ** get_list(char *filename, char *stripped_parameters) { char **module_list = PORT_ZNewArray(char *, 5); char *userdb, *sysdb; int isFIPS = getFIPSMode(); const char *nssflags = isFIPS ? nssDefaultFIPSFlags : nssDefaultFlags; int next = 0; /* can't get any space */ if (module_list == NULL) { return NULL; } sysdb = getSystemDB(); userdb = getUserDB(); /* Don't open root's user DB */ if (userdb != NULL && !userIsRoot()) { /* return a list of databases to open. First the user Database */ module_list[next++] = PR_smprintf( "library= " "module=\"NSS User database\" " "parameters=\"configdir='sql:%s' %s tokenDescription='NSS user database'\" " "NSS=\"trustOrder=75 %sflags=internal%s\"", userdb, stripped_parameters, nssflags, isFIPS ? ",FIPS" : ""); /* now open the user's defined PKCS #11 modules */ /* skip the local user DB entry */ module_list[next++] = PR_smprintf( "library= " "module=\"NSS User database\" " "parameters=\"configdir='sql:%s' %s\" " "NSS=\"flags=internal,moduleDBOnly,defaultModDB,skipFirst\"", userdb, stripped_parameters); } /* now the system database (always read only unless it's root) */ if (sysdb) { const char *readonly = userCanModifySystemDB() ? "" : "flags=readonly"; module_list[next++] = PR_smprintf( "library= " "module=\"NSS system database\" " "parameters=\"configdir='sql:%s' tokenDescription='NSS system database' %s\" " "NSS=\"trustOrder=80 %sflags=internal,critical\"",sysdb, readonly, nssflags); } /* that was the last module */ module_list[next] = 0; PORT_Free(userdb); PORT_Free(sysdb); return module_list; } static char ** release_list(char **arg) { static char *success = "Success"; int next; for (next = 0; arg[next]; next++) { free(arg[next]); } PORT_Free(arg); return &success; } #include "utilpars.h" #define TARGET_SPEC_COPY(new, start, end) \ if (end > start) { \ int _cnt = end - start; \ PORT_Memcpy(new, start, _cnt); \ new += _cnt; \ } /* * According the strcpy man page: * * The strings may not overlap, and the destination string dest must be * large enough to receive the copy. * * This implementation allows target to overlap with src. * It does not allow the src to overlap the target. * example: overlapstrcpy(string, string+4) is fine * overlapstrcpy(string+4, string) is not. */ static void overlapstrcpy(char *target, char *src) { while (*src) { *target++ = *src++; } *target = 0; } /* determine what options the user was trying to open this database with */ /* filename is the directory pointed to by configdir= */ /* stripped is the rest of the parameters with configdir= stripped out */ static SECStatus parse_parameters(char *parameters, char **filename, char **stripped) { char *sourcePrev; char *sourceCurr; char *targetCurr; char *newStripped; *filename = NULL; *stripped = NULL; newStripped = PORT_Alloc(PORT_Strlen(parameters)+2); targetCurr = newStripped; sourcePrev = parameters; sourceCurr = NSSUTIL_ArgStrip(parameters); TARGET_SPEC_COPY(targetCurr, sourcePrev, sourceCurr); while (*sourceCurr) { int next; sourcePrev = sourceCurr; NSSUTIL_HANDLE_STRING_ARG(sourceCurr, *filename, "configdir=", sourcePrev = sourceCurr; ) NSSUTIL_HANDLE_FINAL_ARG(sourceCurr); TARGET_SPEC_COPY(targetCurr, sourcePrev, sourceCurr); } *targetCurr = 0; if (*filename == NULL) { PORT_Free(newStripped); return SECFailure; } /* strip off any directives from the filename */ if (strncmp("sql:", *filename, 4) == 0) { overlapstrcpy(*filename, (*filename)+4); } else if (strncmp("dbm:", *filename, 4) == 0) { overlapstrcpy(*filename, (*filename)+4); } else if (strncmp("extern:", *filename, 7) == 0) { overlapstrcpy(*filename, (*filename)+7); } *stripped = newStripped; return SECSuccess; } /* entry point */ char ** NSS_ReturnModuleSpecData(unsigned long function, char *parameters, void *args) { char *filename = NULL; char *stripped = NULL; char **retString = NULL; SECStatus rv; rv = parse_parameters(parameters, &filename, &stripped); if (rv != SECSuccess) { /* use defaults */ filename = getSystemDB(); if (!filename) { return NULL; } stripped = PORT_Strdup(NSS_DEFAULT_FLAGS); if (!stripped) { free(filename); return NULL; } } switch (function) { case SECMOD_MODULE_DB_FUNCTION_FIND: retString = get_list(filename, stripped); break; case SECMOD_MODULE_DB_FUNCTION_RELEASE: retString = release_list((char **)args); break; /* can't add or delete from this module DB */ case SECMOD_MODULE_DB_FUNCTION_ADD: case SECMOD_MODULE_DB_FUNCTION_DEL: retString = NULL; break; default: retString = NULL; break; } PORT_Free(filename); PORT_Free(stripped); return retString; }
// Gmsh - Copyright (C) 1997-2019 C. Geuzaine, J.-F. Remacle // // See the LICENSE.txt file for license information. Please report all // issues on https://gitlab.onelab.info/gmsh/gmsh/issues. #ifndef MTRIHEDRON_H #define MTRIHEDRON_H #include "MElement.h" /* * MTrihedron * A MTrihedron is a plane element composed of * a quadrangle and two triangles. * It serves as an interface between two non-conforming * elements * * v * ^ * | * 3-----------2 * |'\ | | * | '\ | | * | +---- | --> u * | '\ | * | '\ | * 0-----------1 * */ class MTrihedron : public MElement { protected: MVertex *_v[4]; void _getEdgeVertices(const int num, std::vector<MVertex *> &v) const { v[0] = _v[edges_trihedron(num, 0)]; v[1] = _v[edges_trihedron(num, 1)]; } void _getFaceVertices(const int num, std::vector<MVertex *> &v) const { if(num > 0) { v[0] = _v[faces_trihedron(num, 0)]; v[1] = _v[faces_trihedron(num, 1)]; v[2] = _v[faces_trihedron(num, 2)]; } else { v[0] = _v[0]; v[1] = _v[1]; v[2] = _v[2]; v[3] = _v[3]; } } public: MTrihedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num = 0, int part = 0) : MElement(num, part) { _v[0] = v0; _v[1] = v1; _v[2] = v2; _v[3] = v3; } MTrihedron(const std::vector<MVertex *> &v, int num = 0, int part = 0) : MElement(num, part) { for(int i = 0; i < 4; i++) _v[i] = v[i]; } ~MTrihedron() {} virtual int getDim() const { return 3; } // Can have a volume... virtual std::size_t getNumVertices() const { return 4; } virtual MVertex *getVertex(int num) { return _v[num]; } virtual const MVertex *getVertex(int num) const { return _v[num]; } virtual void setVertex(int num, MVertex *v) { _v[num] = v; } virtual int getNumEdges() const { return 5; } virtual MEdge getEdge(int num) const { return MEdge(_v[edges_trihedron(num, 0)], _v[edges_trihedron(num, 1)]); } virtual int getNumEdgesRep(bool curved) { return 5; } virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n) { MEdge e(getEdge(num)); _getEdgeRep(e.getVertex(0), e.getVertex(1), x, y, z, n, 0); } virtual void getEdgeVertices(const int num, std::vector<MVertex *> &v) const { v.resize(2); _getEdgeVertices(num, v); } virtual int getNumFaces() { return 3; } virtual MFace getFace(int num) const { if(num > 0) return MFace(_v[faces_trihedron(num, 0)], _v[faces_trihedron(num, 1)], _v[faces_trihedron(num, 2)]); else return MFace(_v[0], _v[1], _v[2], _v[3]); } virtual int getNumFacesRep(bool curved) { return 2; } virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n) { static const int f[2][3] = {{0, 1, 3}, {1, 2, 3}}; _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]), getVertex(f[num][2]), x, y, z, n); } virtual void getFaceVertices(const int num, std::vector<MVertex *> &v) const { v.resize((num == 0) ? 4 : 3); _getFaceVertices(num, v); } virtual int getType() const { return TYPE_TRIH; } virtual int getTypeForMSH() const { return MSH_TRIH_4; } virtual void reverse() { MVertex *tmp = _v[1]; _v[1] = _v[3]; _v[3] = tmp; } virtual int getVolumeSign() { return 0; }; virtual double getVolume() { return 0; }; virtual bool setVolumePositive() { return false; }; virtual void getNode(int num, double &u, double &v, double &w) const { w = 0; switch(num) { case 0: u = -1.; v = -1.; break; case 1: u = 1.; v = -1.; break; case 2: u = 1.; v = 1.; break; case 3: u = -1.; v = 1.; break; default: u = 0.; v = 0.; break; } } virtual SPoint3 barycenterUVW() const { return SPoint3(0., 0., 0.); } virtual bool isInside(double u, double v, double w) const { double tol = getTolerance(); if(u < -(1. + tol) || v < -(1. + tol) || u > (1. + tol) || v > (1. + tol) || fabs(w) > tol) return false; return true; } static int edges_trihedron(const int edge, const int vert) { static const int e[5][2] = { {0, 1}, {1, 2}, {2, 3}, {3, 0}, {1, 3}, }; return e[edge][vert]; } static int faces_trihedron(const int face, const int vert) { static const int f[3][4] = { {0, 1, 2, 3}, {0, 3, 1, -1}, {1, 3, 2, -1}, }; return f[face][vert]; } // Return the number of nodes that this element must have with the other in // order to put an edge between them in the dual graph used during the // partitioning. virtual int numCommonNodesInDualGraph(const MElement *const other) const; }; #endif
// // Copyright (c) 2009, Markus Rickert // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #ifndef RL_HAL_ANALOGINPUTREADER_H #define RL_HAL_ANALOGINPUTREADER_H #include <vector> #include <rl/math/Real.h> #include "AnalogInput.h" namespace rl { namespace hal { class AnalogInputReader : public virtual AnalogInput { public: AnalogInputReader(); virtual ~AnalogInputReader(); virtual ::std::vector< ::rl::math::Real> getAnalogInput() const; virtual ::rl::math::Real getAnalogInput(const ::std::size_t& i) const = 0; protected: private: }; } } #endif // RL_HAL_ANALOGINPUTREADER_H
/* $NetBSD: bpf.c,v 1.168.2.1 2013/09/11 03:54:35 msaitoh Exp $ */ /* * Copyright (c) 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from the Stanford/CMU enet packet filter, * (net/enet.c) distributed as part of 4.3BSD, and code contributed * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence * Berkeley Laboratory. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)bpf.c 8.4 (Berkeley) 1/9/95 * static char rcsid[] = * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp "; */ #include <special_includes/sys/cdefs.h> __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.168.2.1 2013/09/11 03:54:35 msaitoh Exp $"); #if defined(_KERNEL_OPT) #include "opt_bpf.h" #include "sl.h" #include "strip.h" #endif #include <special_includes/sys/param.h> #include <special_includes/sys/systm.h> #include <special_includes/sys/mbuf.h> #include <special_includes/sys/buf.h> #include <special_includes/sys/time.h> #include <special_includes/sys/proc.h> #include <special_includes/sys/ioctl.h> #include <special_includes/sys/conf.h> #include <special_includes/sys/vnode.h> #include <special_includes/sys/queue.h> #include <special_includes/sys/stat.h> #include <special_includes/sys/module.h> #include <special_includes/sys/once.h> #include <special_includes/sys/atomic.h> #include <special_includes/sys/file.h> #include <special_includes/sys/filedesc.h> #include <special_includes/sys/tty.h> #include <special_includes/sys/uio.h> #include <special_includes/sys/protosw.h> #include <special_includes/sys/socket.h> #include <special_includes/sys/errno.h> #include <special_includes/sys/kernel.h> #include <special_includes/sys/poll.h> #include <special_includes/sys/sysctl.h> #include <special_includes/sys/kauth.h> #include <net/if.h> #include <net/slip.h> #include <net/bpf.h> #include <net/bpfdesc.h> #include <net/if_arc.h> #include <net/if_ether.h> #include <netinet/in.h> #include <netinet/if_inarp.h> #include <compat/sys/sockio.h> #ifndef BPF_BUFSIZE /* * 4096 is too small for FDDI frames. 8192 is too small for gigabit Ethernet * jumbos (circa 9k), ATM, or Intel gig/10gig ethernet jumbos (16k). */ # define BPF_BUFSIZE 32768 #endif #define PRINET 26 /* interruptible */ /* * The default read buffer size, and limit for BIOCSBLEN, is sysctl'able. * XXX the default values should be computed dynamically based * on available memory size and available mbuf clusters. */ int bpf_bufsize = BPF_BUFSIZE; int bpf_maxbufsize = BPF_DFLTBUFSIZE; /* XXX set dynamically, see above */ /* * Global BPF statistics returned by net.bpf.stats sysctl. */ struct bpf_stat bpf_gstats; /* * Use a mutex to avoid a race condition between gathering the stats/peers * and opening/closing the device. */ static kmutex_t bpf_mtx; /* * bpf_iflist is the list of interfaces; each corresponds to an ifnet * bpf_dtab holds the descriptors, indexed by minor device # */ struct bpf_if *bpf_iflist; LIST_HEAD(, bpf_d) bpf_list; static int bpf_allocbufs(struct bpf_d *); static void bpf_deliver(struct bpf_if *, void *(*cpfn)(void *, const void *, size_t), void *, u_int, u_int, struct ifnet *); static void bpf_freed(struct bpf_d *); static void bpf_ifname(struct ifnet *, struct ifreq *); static void *bpf_mcpy(void *, const void *, size_t); static int bpf_movein(struct uio *, int, uint64_t, struct mbuf **, struct sockaddr *); static void bpf_attachd(struct bpf_d *, struct bpf_if *); static void bpf_detachd(struct bpf_d *); static int bpf_setif(struct bpf_d *, struct ifreq *); static void bpf_timed_out(void *); static inline void bpf_wakeup(struct bpf_d *); static int bpf_hdrlen(struct bpf_d *); static void catchpacket(struct bpf_d *, u_char *, u_int, u_int, void *(*)(void *, const void *, size_t), struct timespec *); static void reset_d(struct bpf_d *); static int bpf_getdltlist(struct bpf_d *, struct bpf_dltlist *); static int bpf_setdlt(struct bpf_d *, u_int); static int bpf_read(struct file *, off_t *, struct uio *, kauth_cred_t, int); static int bpf_write(struct file *, off_t *, struct uio *, kauth_cred_t, int); static int bpf_ioctl(struct file *, u_long, void *); static int bpf_poll(struct file *, int); static int bpf_stat(struct file *, struct stat *); static int bpf_close(struct file *); static int bpf_kqfilter(struct file *, struct knote *); static void bpf_softintr(void *); static const struct fileops bpf_fileops = { .fo_read = bpf_read, .fo_write = bpf_write, .fo_ioctl = bpf_ioctl, .fo_fcntl = fnullop_fcntl, .fo_poll = bpf_poll, .fo_stat = bpf_stat, .fo_close = bpf_close, .fo_kqfilter = bpf_kqfilter, .fo_restart = fnullop_restart, }; dev_type_open(bpfopen); const struct cdevsw bpf_cdevsw = { bpfopen, noclose, noread, nowrite, noioctl, nostop, notty, nopoll, nommap, nokqfilter, D_OTHER }; static int bpf_movein(struct uio *uio, int linktype, uint64_t mtu, struct mbuf **mp, struct sockaddr *sockp) { struct mbuf *m; int error; size_t len; size_t hlen; size_t align; /* * Build a sockaddr based on the data link layer type. * We do this at this level because the ethernet header * is copied directly into the data field of the sockaddr. * In the case of SLIP, there is no header and the packet * is forwarded as is. * Also, we are careful to leave room at the front of the mbuf * for the link level header. */ switch (linktype) { case DLT_SLIP: sockp->sa_family = AF_INET; hlen = 0; align = 0; break; case DLT_PPP: sockp->sa_family = AF_UNSPEC; hlen = 0; align = 0; break; case DLT_EN10MB: sockp->sa_family = AF_UNSPEC; /* XXX Would MAXLINKHDR be better? */ /* 6(dst)+6(src)+2(type) */ hlen = sizeof(struct ether_header); align = 2; break; case DLT_ARCNET: sockp->sa_family = AF_UNSPEC; hlen = ARC_HDRLEN; align = 5; break; case DLT_FDDI: sockp->sa_family = AF_LINK; /* XXX 4(FORMAC)+6(dst)+6(src) */ hlen = 16; align = 0; break; case DLT_ECONET: sockp->sa_family = AF_UNSPEC; hlen = 6; align = 2; break; case DLT_NULL: sockp->sa_family = AF_UNSPEC; hlen = 0; align = 0; break; default: return (EIO); } len = uio->uio_resid; /* * If there aren't enough bytes for a link level header or the * packet length exceeds the interface mtu, return an error. */ if (len - hlen > mtu) return (EMSGSIZE); /* * XXX Avoid complicated buffer chaining --- * bail if it won't fit in a single mbuf. * (Take into account possible alignment bytes) */ if (len + align > MCLBYTES) return (EIO); m = m_gethdr(M_WAIT, MT_DATA); m->m_pkthdr.rcvif = 0; m->m_pkthdr.len = (int)(len - hlen); if (len + align > MHLEN) { m_clget(m, M_WAIT); if ((m->m_flags & M_EXT) == 0) { error = ENOBUFS; goto bad; } } /* Insure the data is properly aligned */ if (align > 0) { m->m_data += align; m->m_len -= (int)align; } error = uiomove(mtod(m, void *), len, uio); if (error) goto bad; if (hlen != 0) { memcpy(sockp->sa_data, mtod(m, void *), hlen); m->m_data += hlen; /* XXX */ len -= hlen; } m->m_len = (int)len; *mp = m; return (0); bad: m_freem(m); return (error); } /* * Attach file to the bpf interface, i.e. make d listen on bp. * Must be called at splnet. */ static void bpf_attachd(struct bpf_d *d, struct bpf_if *bp) { /* * Point d at bp, and add d to the interface's list of listeners. * Finally, point the driver's bpf cookie at the interface so * it will divert packets to bpf. */ d->bd_bif = bp; d->bd_next = bp->bif_dlist; bp->bif_dlist = d; *bp->bif_driverp = bp; } /* * Detach a file from its interface. */ static void bpf_detachd(struct bpf_d *d) { struct bpf_d **p; struct bpf_if *bp; bp = d->bd_bif; /* * Check if this descriptor had requested promiscuous mode. * If so, turn it off. */ if (d->bd_promisc) { int error; d->bd_promisc = 0; /* * Take device out of promiscuous mode. Since we were * able to enter promiscuous mode, we should be able * to turn it off. But we can get an error if * the interface was configured down, so only panic * if we don't get an unexpected error. */ error = ifpromisc(bp->bif_ifp, 0); if (error && error != EINVAL) panic("%s: ifpromisc failed: %d", __func__, error); } /* Remove d from the interface's descriptor list. */ p = &bp->bif_dlist; while (*p != d) { p = &(*p)->bd_next; if (*p == 0) panic("%s: descriptor not in list", __func__); } *p = (*p)->bd_next; if (bp->bif_dlist == 0) /* * Let the driver know that there are no more listeners. */ *d->bd_bif->bif_driverp = 0; d->bd_bif = 0; } static int doinit(void) { mutex_init(&bpf_mtx, MUTEX_DEFAULT, IPL_NONE); LIST_INIT(&bpf_list); bpf_gstats.bs_recv = 0; bpf_gstats.bs_drop = 0; bpf_gstats.bs_capt = 0; return 0; } /* * bpfilterattach() is called at boot time. */ /* ARGSUSED */ void bpfilterattach(int n) { static ONCE_DECL(control); RUN_ONCE(&control, doinit); } /* * Open ethernet device. Clones. */ /* ARGSUSED */ int bpfopen(dev_t dev, int flag, int mode, struct lwp *l) { struct bpf_d *d; struct file *fp; int error, fd; /* falloc() will use the descriptor for us. */ if ((error = fd_allocfile(&fp, &fd)) != 0) return error; d = malloc(sizeof(*d), M_DEVBUF, M_WAITOK|M_ZERO); d->bd_bufsize = bpf_bufsize; d->bd_seesent = 1; d->bd_feedback = 0; d->bd_pid = l->l_proc->p_pid; #ifdef _LP64 if (curproc->p_flag & PK_32) d->bd_compat32 = 1; #endif getnanotime(&d->bd_btime); d->bd_atime = d->bd_mtime = d->bd_btime; callout_init(&d->bd_callout, 0); selinit(&d->bd_sel); d->bd_sih = softint_establish(SOFTINT_CLOCK, bpf_softintr, d); mutex_enter(&bpf_mtx); LIST_INSERT_HEAD(&bpf_list, d, bd_list); mutex_exit(&bpf_mtx); return fd_clone(fp, fd, flag, &bpf_fileops, d); } /* * Close the descriptor by detaching it from its interface, * deallocating its buffers, and marking it free. */ /* ARGSUSED */ static int bpf_close(struct file *fp) { struct bpf_d *d = fp->f_data; int s; KERNEL_LOCK(1, NULL); /* * Refresh the PID associated with this bpf file. */ d->bd_pid = curproc->p_pid; s = splnet(); if (d->bd_state == BPF_WAITING) callout_stop(&d->bd_callout); d->bd_state = BPF_IDLE; if (d->bd_bif) bpf_detachd(d); splx(s); bpf_freed(d); mutex_enter(&bpf_mtx); LIST_REMOVE(d, bd_list); mutex_exit(&bpf_mtx); callout_destroy(&d->bd_callout); seldestroy(&d->bd_sel); softint_disestablish(d->bd_sih); free(d, M_DEVBUF); fp->f_data = NULL; KERNEL_UNLOCK_ONE(NULL); return (0); } /* * Rotate the packet buffers in descriptor d. Move the store buffer * into the hold slot, and the free buffer into the store slot. * Zero the length of the new store buffer. */ #define ROTATE_BUFFERS(d) \ (d)->bd_hbuf = (d)->bd_sbuf; \ (d)->bd_hlen = (d)->bd_slen; \ (d)->bd_sbuf = (d)->bd_fbuf; \ (d)->bd_slen = 0; \ (d)->bd_fbuf = 0; /* * bpfread - read next chunk of packets from buffers */ static int bpf_read(struct file *fp, off_t *offp, struct uio *uio, kauth_cred_t cred, int flags) { struct bpf_d *d = fp->f_data; int timed_out; int error; int s; getnanotime(&d->bd_atime); /* * Restrict application to use a buffer the same size as * the kernel buffers. */ if (uio->uio_resid != d->bd_bufsize) return (EINVAL); KERNEL_LOCK(1, NULL); s = splnet(); if (d->bd_state == BPF_WAITING) callout_stop(&d->bd_callout); timed_out = (d->bd_state == BPF_TIMED_OUT); d->bd_state = BPF_IDLE; /* * If the hold buffer is empty, then do a timed sleep, which * ends when the timeout expires or when enough packets * have arrived to fill the store buffer. */ while (d->bd_hbuf == 0) { if (fp->f_flag & FNONBLOCK) { if (d->bd_slen == 0) { splx(s); KERNEL_UNLOCK_ONE(NULL); return (EWOULDBLOCK); } ROTATE_BUFFERS(d); break; } if ((d->bd_immediate || timed_out) && d->bd_slen != 0) { /* * A packet(s) either arrived since the previous * read or arrived while we were asleep. * Rotate the buffers and return what's here. */ ROTATE_BUFFERS(d); break; } error = tsleep(d, PRINET|PCATCH, "bpf", d->bd_rtout); if (error == EINTR || error == ERESTART) { splx(s); KERNEL_UNLOCK_ONE(NULL); return (error); } if (error == EWOULDBLOCK) { /* * On a timeout, return what's in the buffer, * which may be nothing. If there is something * in the store buffer, we can rotate the buffers. */ if (d->bd_hbuf) /* * We filled up the buffer in between * getting the timeout and arriving * here, so we don't need to rotate. */ break; if (d->bd_slen == 0) { splx(s); KERNEL_UNLOCK_ONE(NULL); return (0); } ROTATE_BUFFERS(d); break; } if (error != 0) goto done; } /* * At this point, we know we have something in the hold slot. */ splx(s); /* * Move data from hold buffer into user space. * We know the entire buffer is transferred since * we checked above that the read buffer is bpf_bufsize bytes. */ error = uiomove(d->bd_hbuf, d->bd_hlen, uio); s = splnet(); d->bd_fbuf = d->bd_hbuf; d->bd_hbuf = 0; d->bd_hlen = 0; done: splx(s); KERNEL_UNLOCK_ONE(NULL); return (error); } /* * If there are processes sleeping on this descriptor, wake them up. */ static inline void bpf_wakeup(struct bpf_d *d) { wakeup(d); if (d->bd_async) softint_schedule(d->bd_sih); selnotify(&d->bd_sel, 0, 0); } static void bpf_softintr(void *cookie) { struct bpf_d *d; d = cookie; if (d->bd_async) fownsignal(d->bd_pgid, SIGIO, 0, 0, NULL); } static void bpf_timed_out(void *arg) { struct bpf_d *d = arg; int s; s = splnet(); if (d->bd_state == BPF_WAITING) { d->bd_state = BPF_TIMED_OUT; if (d->bd_slen != 0) bpf_wakeup(d); } splx(s); } static int bpf_write(struct file *fp, off_t *offp, struct uio *uio, kauth_cred_t cred, int flags) { struct bpf_d *d = fp->f_data; struct ifnet *ifp; struct mbuf *m, *mc; int error, s; static struct sockaddr_storage dst; m = NULL; /* XXX gcc */ KERNEL_LOCK(1, NULL); if (d->bd_bif == 0) { KERNEL_UNLOCK_ONE(NULL); return (ENXIO); } getnanotime(&d->bd_mtime); ifp = d->bd_bif->bif_ifp; if (uio->uio_resid == 0) { KERNEL_UNLOCK_ONE(NULL); return (0); } error = bpf_movein(uio, (int)d->bd_bif->bif_dlt, ifp->if_mtu, &m, (struct sockaddr *) &dst); if (error) { KERNEL_UNLOCK_ONE(NULL); return (error); } if (m->m_pkthdr.len > ifp->if_mtu) { KERNEL_UNLOCK_ONE(NULL); m_freem(m); return (EMSGSIZE); } if (d->bd_hdrcmplt) dst.ss_family = pseudo_AF_HDRCMPLT; if (d->bd_feedback) { mc = m_dup(m, 0, M_COPYALL, M_NOWAIT); if (mc != NULL) mc->m_pkthdr.rcvif = ifp; /* Set M_PROMISC for outgoing packets to be discarded. */ if (1 /*d->bd_direction == BPF_D_INOUT*/) m->m_flags |= M_PROMISC; } else mc = NULL; s = splsoftnet(); error = (*ifp->if_output)(ifp, m, (struct sockaddr *) &dst, NULL); if (mc != NULL) { if (error == 0) (*ifp->if_input)(ifp, mc); m_freem(mc); } splx(s); KERNEL_UNLOCK_ONE(NULL); /* * The driver frees the mbuf. */ return (error); } /* * Reset a descriptor by flushing its packet buffer and clearing the * receive and drop counts. Should be called at splnet. */ static void reset_d(struct bpf_d *d) { if (d->bd_hbuf) { /* Free the hold buffer. */ d->bd_fbuf = d->bd_hbuf; d->bd_hbuf = 0; } d->bd_slen = 0; d->bd_hlen = 0; d->bd_rcount = 0; d->bd_dcount = 0; d->bd_ccount = 0; } /* * FIONREAD Check for read packet available. * BIOCGBLEN Get buffer len [for read()]. * BIOCSETF Set ethernet read filter. * BIOCFLUSH Flush read packet buffer. * BIOCPROMISC Put interface into promiscuous mode. * BIOCGDLT Get link layer type. * BIOCGETIF Get interface name. * BIOCSETIF Set interface. * BIOCSRTIMEOUT Set read timeout. * BIOCGRTIMEOUT Get read timeout. * BIOCGSTATS Get packet stats. * BIOCIMMEDIATE Set immediate mode. * BIOCVERSION Get filter language version. * BIOCGHDRCMPLT Get "header already complete" flag. * BIOCSHDRCMPLT Set "header already complete" flag. * BIOCSFEEDBACK Set packet feedback mode. * BIOCGFEEDBACK Get packet feedback mode. * BIOCGSEESENT Get "see sent packets" mode. * BIOCSSEESENT Set "see sent packets" mode. */ /* ARGSUSED */ static int bpf_ioctl(struct file *fp, u_long cmd, void *addr) { struct bpf_d *d = fp->f_data; int s, error = 0; /* * Refresh the PID associated with this bpf file. */ KERNEL_LOCK(1, NULL); d->bd_pid = curproc->p_pid; #ifdef _LP64 if (curproc->p_flag & PK_32) d->bd_compat32 = 1; else d->bd_compat32 = 0; #endif s = splnet(); if (d->bd_state == BPF_WAITING) callout_stop(&d->bd_callout); d->bd_state = BPF_IDLE; splx(s); switch (cmd) { default: error = EINVAL; break; /* * Check for read packet available. */ case FIONREAD: { int n; s = splnet(); n = d->bd_slen; if (d->bd_hbuf) n += d->bd_hlen; splx(s); *(int *)addr = n; break; } /* * Get buffer len [for read()]. */ case BIOCGBLEN: *(u_int *)addr = d->bd_bufsize; break; /* * Set buffer length. */ case BIOCSBLEN: if (d->bd_bif != 0) error = EINVAL; else { u_int size = *(u_int *)addr; if (size > bpf_maxbufsize) *(u_int *)addr = size = bpf_maxbufsize; else if (size < BPF_MINBUFSIZE) *(u_int *)addr = size = BPF_MINBUFSIZE; d->bd_bufsize = size; } break; /* * Set link layer read filter. */ case BIOCSETF: error = bpf_setf(d, addr); break; /* * Flush read packet buffer. */ case BIOCFLUSH: s = splnet(); reset_d(d); splx(s); break; /* * Put interface into promiscuous mode. */ case BIOCPROMISC: if (d->bd_bif == 0) { /* * No interface attached yet. */ error = EINVAL; break; } s = splnet(); if (d->bd_promisc == 0) { error = ifpromisc(d->bd_bif->bif_ifp, 1); if (error == 0) d->bd_promisc = 1; } splx(s); break; /* * Get device parameters. */ case BIOCGDLT: if (d->bd_bif == 0) error = EINVAL; else *(u_int *)addr = d->bd_bif->bif_dlt; break; /* * Get a list of supported device parameters. */ case BIOCGDLTLIST: if (d->bd_bif == 0) error = EINVAL; else error = bpf_getdltlist(d, addr); break; /* * Set device parameters. */ case BIOCSDLT: if (d->bd_bif == 0) error = EINVAL; else error = bpf_setdlt(d, *(u_int *)addr); break; /* * Set interface name. */ #ifdef OBIOCGETIF case OBIOCGETIF: #endif case BIOCGETIF: if (d->bd_bif == 0) error = EINVAL; else bpf_ifname(d->bd_bif->bif_ifp, addr); break; /* * Set interface. */ #ifdef OBIOCSETIF case OBIOCSETIF: #endif case BIOCSETIF: error = bpf_setif(d, addr); break; /* * Set read timeout. */ case BIOCSRTIMEOUT: { struct timeval *tv = addr; /* Compute number of ticks. */ d->bd_rtout = tv->tv_sec * hz + tv->tv_usec / tick; if ((d->bd_rtout == 0) && (tv->tv_usec != 0)) d->bd_rtout = 1; break; } #ifdef BIOCGORTIMEOUT /* * Get read timeout. */ case BIOCGORTIMEOUT: { struct timeval50 *tv = addr; tv->tv_sec = d->bd_rtout / hz; tv->tv_usec = (d->bd_rtout % hz) * tick; break; } #endif #ifdef BIOCSORTIMEOUT /* * Set read timeout. */ case BIOCSORTIMEOUT: { struct timeval50 *tv = addr; /* Compute number of ticks. */ d->bd_rtout = tv->tv_sec * hz + tv->tv_usec / tick; if ((d->bd_rtout == 0) && (tv->tv_usec != 0)) d->bd_rtout = 1; break; } #endif /* * Get read timeout. */ case BIOCGRTIMEOUT: { struct timeval *tv = addr; tv->tv_sec = d->bd_rtout / hz; tv->tv_usec = (d->bd_rtout % hz) * tick; break; } /* * Get packet stats. */ case BIOCGSTATS: { struct bpf_stat *bs = addr; bs->bs_recv = d->bd_rcount; bs->bs_drop = d->bd_dcount; bs->bs_capt = d->bd_ccount; break; } case BIOCGSTATSOLD: { struct bpf_stat_old *bs = addr; bs->bs_recv = d->bd_rcount; bs->bs_drop = d->bd_dcount; break; } /* * Set immediate mode. */ case BIOCIMMEDIATE: d->bd_immediate = *(u_int *)addr; break; case BIOCVERSION: { struct bpf_version *bv = addr; bv->bv_major = BPF_MAJOR_VERSION; bv->bv_minor = BPF_MINOR_VERSION; break; } case BIOCGHDRCMPLT: /* get "header already complete" flag */ *(u_int *)addr = d->bd_hdrcmplt; break; case BIOCSHDRCMPLT: /* set "header already complete" flag */ d->bd_hdrcmplt = *(u_int *)addr ? 1 : 0; break; /* * Get "see sent packets" flag */ case BIOCGSEESENT: *(u_int *)addr = d->bd_seesent; break; /* * Set "see sent" packets flag */ case BIOCSSEESENT: d->bd_seesent = *(u_int *)addr; break; /* * Set "feed packets from bpf back to input" mode */ case BIOCSFEEDBACK: d->bd_feedback = *(u_int *)addr; break; /* * Get "feed packets from bpf back to input" mode */ case BIOCGFEEDBACK: *(u_int *)addr = d->bd_feedback; break; case FIONBIO: /* Non-blocking I/O */ /* * No need to do anything special as we use IO_NDELAY in * bpfread() as an indication of whether or not to block * the read. */ break; case FIOASYNC: /* Send signal on receive packets */ d->bd_async = *(int *)addr; break; case TIOCSPGRP: /* Process or group to send signals to */ case FIOSETOWN: error = fsetown(&d->bd_pgid, cmd, addr); break; case TIOCGPGRP: case FIOGETOWN: error = fgetown(d->bd_pgid, cmd, addr); break; } KERNEL_UNLOCK_ONE(NULL); return (error); } /* * Set d's packet filter program to fp. If this file already has a filter, * free it and replace it. Returns EINVAL for bogus requests. */ int bpf_setf(struct bpf_d *d, struct bpf_program *fp) { struct bpf_insn *fcode, *old; u_int flen, size; int s; old = d->bd_filter; if (fp->bf_insns == 0) { if (fp->bf_len != 0) return (EINVAL); s = splnet(); d->bd_filter = 0; reset_d(d); splx(s); if (old != 0) free(old, M_DEVBUF); return (0); } flen = fp->bf_len; if (flen > BPF_MAXINSNS) return (EINVAL); size = flen * sizeof(*fp->bf_insns); fcode = malloc(size, M_DEVBUF, M_WAITOK); if (copyin(fp->bf_insns, fcode, size) == 0 && bpf_validate(fcode, (int)flen)) { s = splnet(); d->bd_filter = fcode; reset_d(d); splx(s); if (old != 0) free(old, M_DEVBUF); return (0); } free(fcode, M_DEVBUF); return (EINVAL); } /* * Detach a file from its current interface (if attached at all) and attach * to the interface indicated by the name stored in ifr. * Return an errno or 0. */ static int bpf_setif(struct bpf_d *d, struct ifreq *ifr) { struct bpf_if *bp; char *cp; int unit_seen, i, s, error; /* * Make sure the provided name has a unit number, and default * it to '0' if not specified. * XXX This is ugly ... do this differently? */ unit_seen = 0; cp = ifr->ifr_name; cp[sizeof(ifr->ifr_name) - 1] = '\0'; /* sanity */ while (*cp++) if (*cp >= '0' && *cp <= '9') unit_seen = 1; if (!unit_seen) { /* Make sure to leave room for the '\0'. */ for (i = 0; i < (IFNAMSIZ - 1); ++i) { if ((ifr->ifr_name[i] >= 'a' && ifr->ifr_name[i] <= 'z') || (ifr->ifr_name[i] >= 'A' && ifr->ifr_name[i] <= 'Z')) continue; ifr->ifr_name[i] = '0'; } } /* * Look through attached interfaces for the named one. */ for (bp = bpf_iflist; bp != 0; bp = bp->bif_next) { struct ifnet *ifp = bp->bif_ifp; if (ifp == 0 || strcmp(ifp->if_xname, ifr->ifr_name) != 0) continue; /* skip additional entry */ if (bp->bif_driverp != &ifp->if_bpf) continue; /* * We found the requested interface. * Allocate the packet buffers if we need to. * If we're already attached to requested interface, * just flush the buffer. */ if (d->bd_sbuf == 0) { error = bpf_allocbufs(d); if (error != 0) return (error); } s = splnet(); if (bp != d->bd_bif) { if (d->bd_bif) /* * Detach if attached to something else. */ bpf_detachd(d); bpf_attachd(d, bp); } reset_d(d); splx(s); return (0); } /* Not found. */ return (ENXIO); } /* * Copy the interface name to the ifreq. */ static void bpf_ifname(struct ifnet *ifp, struct ifreq *ifr) { memcpy(ifr->ifr_name, ifp->if_xname, IFNAMSIZ); } static int bpf_stat(struct file *fp, struct stat *st) { struct bpf_d *d = fp->f_data; (void)memset(st, 0, sizeof(*st)); KERNEL_LOCK(1, NULL); st->st_dev = makedev(cdevsw_lookup_major(&bpf_cdevsw), d->bd_pid); st->st_atimespec = d->bd_atime; st->st_mtimespec = d->bd_mtime; st->st_ctimespec = st->st_birthtimespec = d->bd_btime; st->st_uid = kauth_cred_geteuid(fp->f_cred); st->st_gid = kauth_cred_getegid(fp->f_cred); st->st_mode = S_IFCHR; KERNEL_UNLOCK_ONE(NULL); return 0; } /* * Support for poll() system call * * Return true iff the specific operation will not block indefinitely - with * the assumption that it is safe to positively acknowledge a request for the * ability to write to the BPF device. * Otherwise, return false but make a note that a selnotify() must be done. */ static int bpf_poll(struct file *fp, int events) { struct bpf_d *d = fp->f_data; int s = splnet(); int revents; /* * Refresh the PID associated with this bpf file. */ KERNEL_LOCK(1, NULL); d->bd_pid = curproc->p_pid; revents = events & (POLLOUT | POLLWRNORM); if (events & (POLLIN | POLLRDNORM)) { /* * An imitation of the FIONREAD ioctl code. */ if (d->bd_hlen != 0 || ((d->bd_immediate || d->bd_state == BPF_TIMED_OUT) && d->bd_slen != 0)) { revents |= events & (POLLIN | POLLRDNORM); } else { selrecord(curlwp, &d->bd_sel); /* Start the read timeout if necessary */ if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) { callout_reset(&d->bd_callout, d->bd_rtout, bpf_timed_out, d); d->bd_state = BPF_WAITING; } } } KERNEL_UNLOCK_ONE(NULL); splx(s); return (revents); } static void filt_bpfrdetach(struct knote *kn) { struct bpf_d *d = kn->kn_hook; int s; KERNEL_LOCK(1, NULL); s = splnet(); SLIST_REMOVE(&d->bd_sel.sel_klist, kn, knote, kn_selnext); splx(s); KERNEL_UNLOCK_ONE(NULL); } static int filt_bpfread(struct knote *kn, long hint) { struct bpf_d *d = kn->kn_hook; int rv; KERNEL_LOCK(1, NULL); kn->kn_data = d->bd_hlen; if (d->bd_immediate) kn->kn_data += d->bd_slen; rv = (kn->kn_data > 0); KERNEL_UNLOCK_ONE(NULL); return rv; } static const struct filterops bpfread_filtops = { 1, NULL, filt_bpfrdetach, filt_bpfread }; static int bpf_kqfilter(struct file *fp, struct knote *kn) { struct bpf_d *d = fp->f_data; struct klist *klist; int s; KERNEL_LOCK(1, NULL); switch (kn->kn_filter) { case EVFILT_READ: klist = &d->bd_sel.sel_klist; kn->kn_fop = &bpfread_filtops; break; default: KERNEL_UNLOCK_ONE(NULL); return (EINVAL); } kn->kn_hook = d; s = splnet(); SLIST_INSERT_HEAD(klist, kn, kn_selnext); splx(s); KERNEL_UNLOCK_ONE(NULL); return (0); } /* * Incoming linkage from device drivers. Process the packet pkt, of length * pktlen, which is stored in a contiguous buffer. The packet is parsed * by each process' filter, and if accepted, stashed into the corresponding * buffer. */ static void _bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) { struct bpf_d *d; u_int slen; struct timespec ts; int gottime=0; /* * Note that the ipl does not have to be raised at this point. * The only problem that could arise here is that if two different * interfaces shared any data. This is not the case. */ for (d = bp->bif_dlist; d != 0; d = d->bd_next) { ++d->bd_rcount; ++bpf_gstats.bs_recv; slen = bpf_filter(d->bd_filter, pkt, pktlen, pktlen); if (slen != 0) { if (!gottime) { nanotime(&ts); gottime = 1; } catchpacket(d, pkt, pktlen, slen, memcpy, &ts); } } } /* * Copy data from an mbuf chain into a buffer. This code is derived * from m_copydata in sys/uipc_mbuf.c. */ static void * bpf_mcpy(void *dst_arg, const void *src_arg, size_t len) { const struct mbuf *m; u_int count; u_char *dst; m = src_arg; dst = dst_arg; while (len > 0) { if (m == NULL) panic("bpf_mcpy"); count = min(m->m_len, len); memcpy(dst, mtod(m, const void *), count); m = m->m_next; dst += count; len -= count; } return dst_arg; } /* * Dispatch a packet to all the listeners on interface bp. * * marg pointer to the packet, either a data buffer or an mbuf chain * buflen buffer length, if marg is a data buffer * cpfn a function that can copy marg into the listener's buffer * pktlen length of the packet * rcvif either NULL or the interface the packet came in on. */ static inline void bpf_deliver(struct bpf_if *bp, void *(*cpfn)(void *, const void *, size_t), void *marg, u_int pktlen, u_int buflen, struct ifnet *rcvif) { u_int slen; struct bpf_d *d; struct timespec ts; int gottime = 0; for (d = bp->bif_dlist; d != 0; d = d->bd_next) { if (!d->bd_seesent && (rcvif == NULL)) continue; ++d->bd_rcount; ++bpf_gstats.bs_recv; slen = bpf_filter(d->bd_filter, marg, pktlen, buflen); if (slen != 0) { if(!gottime) { nanotime(&ts); gottime = 1; } catchpacket(d, marg, pktlen, slen, cpfn, &ts); } } } /* * Incoming linkage from device drivers, when the head of the packet is in * a buffer, and the tail is in an mbuf chain. */ static void _bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m) { u_int pktlen; struct mbuf mb; /* Skip outgoing duplicate packets. */ if ((m->m_flags & M_PROMISC) != 0 && m->m_pkthdr.rcvif == NULL) { m->m_flags &= ~M_PROMISC; return; } pktlen = m_length(m) + dlen; /* * Craft on-stack mbuf suitable for passing to bpf_filter. * Note that we cut corners here; we only setup what's * absolutely needed--this mbuf should never go anywhere else. */ (void)memset(&mb, 0, sizeof(mb)); mb.m_next = m; mb.m_data = data; mb.m_len = dlen; bpf_deliver(bp, bpf_mcpy, &mb, pktlen, 0, m->m_pkthdr.rcvif); } /* * Incoming linkage from device drivers, when packet is in an mbuf chain. */ static void _bpf_mtap(struct bpf_if *bp, struct mbuf *m) { void *(*cpfn)(void *, const void *, size_t); u_int pktlen, buflen; void *marg; /* Skip outgoing duplicate packets. */ if ((m->m_flags & M_PROMISC) != 0 && m->m_pkthdr.rcvif == NULL) { m->m_flags &= ~M_PROMISC; return; } pktlen = m_length(m); if (pktlen == m->m_len) { cpfn = (void *)memcpy; marg = mtod(m, void *); buflen = pktlen; } else { cpfn = bpf_mcpy; marg = m; buflen = 0; } bpf_deliver(bp, cpfn, marg, pktlen, buflen, m->m_pkthdr.rcvif); } /* * We need to prepend the address family as * a four byte field. Cons up a dummy header * to pacify bpf. This is safe because bpf * will only read from the mbuf (i.e., it won't * try to free it or keep a pointer a to it). */ static void _bpf_mtap_af(struct bpf_if *bp, uint32_t af, struct mbuf *m) { struct mbuf m0; m0.m_flags = 0; m0.m_next = m; m0.m_len = 4; m0.m_data = (char *)&af; _bpf_mtap(bp, &m0); } /* * Put the SLIP pseudo-"link header" in place. * Note this M_PREPEND() should never fail, * swince we know we always have enough space * in the input buffer. */ static void _bpf_mtap_sl_in(struct bpf_if *bp, u_char *chdr, struct mbuf **m) { int s; u_char *hp; M_PREPEND(*m, SLIP_HDRLEN, M_DONTWAIT); if (*m == NULL) return; hp = mtod(*m, u_char *); hp[SLX_DIR] = SLIPDIR_IN; (void)memcpy(&hp[SLX_CHDR], chdr, CHDR_LEN); s = splnet(); _bpf_mtap(bp, *m); splx(s); m_adj(*m, SLIP_HDRLEN); } /* * Put the SLIP pseudo-"link header" in * place. The compressed header is now * at the beginning of the mbuf. */ static void _bpf_mtap_sl_out(struct bpf_if *bp, u_char *chdr, struct mbuf *m) { struct mbuf m0; u_char *hp; int s; m0.m_flags = 0; m0.m_next = m; m0.m_data = m0.m_dat; m0.m_len = SLIP_HDRLEN; hp = mtod(&m0, u_char *); hp[SLX_DIR] = SLIPDIR_OUT; (void)memcpy(&hp[SLX_CHDR], chdr, CHDR_LEN); s = splnet(); _bpf_mtap(bp, &m0); splx(s); m_freem(m); } static int bpf_hdrlen(struct bpf_d *d) { int hdrlen = d->bd_bif->bif_hdrlen; /* * Compute the length of the bpf header. This is not necessarily * equal to SIZEOF_BPF_HDR because we want to insert spacing such * that the network layer header begins on a longword boundary (for * performance reasons and to alleviate alignment restrictions). */ #ifdef _LP64 if (d->bd_compat32) return (BPF_WORDALIGN32(hdrlen + SIZEOF_BPF_HDR32) - hdrlen); else #endif return (BPF_WORDALIGN(hdrlen + SIZEOF_BPF_HDR) - hdrlen); } /* * Move the packet data from interface memory (pkt) into the * store buffer. Call the wakeup functions if it's time to wakeup * a listener (buffer full), "cpfn" is the routine called to do the * actual data transfer. memcpy is passed in to copy contiguous chunks, * while bpf_mcpy is passed in to copy mbuf chains. In the latter case, * pkt is really an mbuf. */ static void catchpacket(struct bpf_d *d, u_char *pkt, u_int pktlen, u_int snaplen, void *(*cpfn)(void *, const void *, size_t), struct timespec *ts) { char *h; int totlen, curlen, caplen; int hdrlen = bpf_hdrlen(d); int do_wakeup = 0; ++d->bd_ccount; ++bpf_gstats.bs_capt; /* * Figure out how many bytes to move. If the packet is * greater or equal to the snapshot length, transfer that * much. Otherwise, transfer the whole packet (unless * we hit the buffer size limit). */ totlen = hdrlen + min(snaplen, pktlen); if (totlen > d->bd_bufsize) totlen = d->bd_bufsize; /* * If we adjusted totlen to fit the bufsize, it could be that * totlen is smaller than hdrlen because of the link layer header. */ caplen = totlen - hdrlen; if (caplen < 0) caplen = 0; /* * Round up the end of the previous packet to the next longword. */ #ifdef _LP64 if (d->bd_compat32) curlen = BPF_WORDALIGN32(d->bd_slen); else #endif curlen = BPF_WORDALIGN(d->bd_slen); if (curlen + totlen > d->bd_bufsize) { /* * This packet will overflow the storage buffer. * Rotate the buffers if we can, then wakeup any * pending reads. */ if (d->bd_fbuf == 0) { /* * We haven't completed the previous read yet, * so drop the packet. */ ++d->bd_dcount; ++bpf_gstats.bs_drop; return; } ROTATE_BUFFERS(d); do_wakeup = 1; curlen = 0; } else if (d->bd_immediate || d->bd_state == BPF_TIMED_OUT) { /* * Immediate mode is set, or the read timeout has * already expired during a select call. A packet * arrived, so the reader should be woken up. */ do_wakeup = 1; } /* * Append the bpf header. */ h = (char *)d->bd_sbuf + curlen; #ifdef _LP64 if (d->bd_compat32) { struct bpf_hdr32 *hp32; hp32 = (struct bpf_hdr32 *)h; hp32->bh_tstamp.tv_sec = ts->tv_sec; hp32->bh_tstamp.tv_usec = ts->tv_nsec / 1000; hp32->bh_datalen = pktlen; hp32->bh_hdrlen = hdrlen; hp32->bh_caplen = caplen; } else #endif { struct bpf_hdr *hp; hp = (struct bpf_hdr *)h; hp->bh_tstamp.tv_sec = ts->tv_sec; hp->bh_tstamp.tv_usec = ts->tv_nsec / 1000; hp->bh_datalen = pktlen; hp->bh_hdrlen = hdrlen; hp->bh_caplen = caplen; } /* * Copy the packet data into the store buffer and update its length. */ (*cpfn)(h + hdrlen, pkt, caplen); d->bd_slen = curlen + totlen; /* * Call bpf_wakeup after bd_slen has been updated so that kevent(2) * will cause filt_bpfread() to be called with it adjusted. */ if (do_wakeup) bpf_wakeup(d); } /* * Initialize all nonzero fields of a descriptor. */ static int bpf_allocbufs(struct bpf_d *d) { d->bd_fbuf = malloc(d->bd_bufsize, M_DEVBUF, M_WAITOK | M_CANFAIL); if (!d->bd_fbuf) return (ENOBUFS); d->bd_sbuf = malloc(d->bd_bufsize, M_DEVBUF, M_WAITOK | M_CANFAIL); if (!d->bd_sbuf) { free(d->bd_fbuf, M_DEVBUF); return (ENOBUFS); } d->bd_slen = 0; d->bd_hlen = 0; return (0); } /* * Free buffers currently in use by a descriptor. * Called on close. */ static void bpf_freed(struct bpf_d *d) { /* * We don't need to lock out interrupts since this descriptor has * been detached from its interface and it yet hasn't been marked * free. */ if (d->bd_sbuf != 0) { free(d->bd_sbuf, M_DEVBUF); if (d->bd_hbuf != 0) free(d->bd_hbuf, M_DEVBUF); if (d->bd_fbuf != 0) free(d->bd_fbuf, M_DEVBUF); } if (d->bd_filter) free(d->bd_filter, M_DEVBUF); } /* * Attach an interface to bpf. dlt is the link layer type; * hdrlen is the fixed size of the link header for the specified dlt * (variable length headers not yet supported). */ static void _bpfattach(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp) { struct bpf_if *bp; bp = malloc(sizeof(*bp), M_DEVBUF, M_DONTWAIT); if (bp == 0) panic("bpfattach"); bp->bif_dlist = 0; bp->bif_driverp = driverp; bp->bif_ifp = ifp; bp->bif_dlt = dlt; bp->bif_next = bpf_iflist; bpf_iflist = bp; *bp->bif_driverp = 0; bp->bif_hdrlen = hdrlen; #if 0 printf("bpf: %s attached\n", ifp->if_xname); #endif } /* * Remove an interface from bpf. */ static void _bpfdetach(struct ifnet *ifp) { struct bpf_if *bp, **pbp; struct bpf_d *d; int s; /* Nuke the vnodes for any open instances */ LIST_FOREACH(d, &bpf_list, bd_list) { if (d->bd_bif != NULL && d->bd_bif->bif_ifp == ifp) { /* * Detach the descriptor from an interface now. * It will be free'ed later by close routine. */ s = splnet(); d->bd_promisc = 0; /* we can't touch device. */ bpf_detachd(d); splx(s); } } again: for (bp = bpf_iflist, pbp = &bpf_iflist; bp != NULL; pbp = &bp->bif_next, bp = bp->bif_next) { if (bp->bif_ifp == ifp) { *pbp = bp->bif_next; free(bp, M_DEVBUF); goto again; } } } /* * Change the data link type of a interface. */ static void _bpf_change_type(struct ifnet *ifp, u_int dlt, u_int hdrlen) { struct bpf_if *bp; for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) { if (bp->bif_driverp == &ifp->if_bpf) break; } if (bp == NULL) panic("bpf_change_type"); bp->bif_dlt = dlt; bp->bif_hdrlen = hdrlen; } /* * Get a list of available data link type of the interface. */ static int bpf_getdltlist(struct bpf_d *d, struct bpf_dltlist *bfl) { int n, error; struct ifnet *ifp; struct bpf_if *bp; ifp = d->bd_bif->bif_ifp; n = 0; error = 0; for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) { if (bp->bif_ifp != ifp) continue; if (bfl->bfl_list != NULL) { if (n >= bfl->bfl_len) return ENOMEM; error = copyout(&bp->bif_dlt, bfl->bfl_list + n, sizeof(u_int)); } n++; } bfl->bfl_len = n; return error; } /* * Set the data link type of a BPF instance. */ static int bpf_setdlt(struct bpf_d *d, u_int dlt) { int s, error, opromisc; struct ifnet *ifp; struct bpf_if *bp; if (d->bd_bif->bif_dlt == dlt) return 0; ifp = d->bd_bif->bif_ifp; for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) { if (bp->bif_ifp == ifp && bp->bif_dlt == dlt) break; } if (bp == NULL) return EINVAL; s = splnet(); opromisc = d->bd_promisc; bpf_detachd(d); bpf_attachd(d, bp); reset_d(d); if (opromisc) { error = ifpromisc(bp->bif_ifp, 1); if (error) printf("%s: bpf_setdlt: ifpromisc failed (%d)\n", bp->bif_ifp->if_xname, error); else d->bd_promisc = 1; } splx(s); return 0; } static int sysctl_net_bpf_maxbufsize(SYSCTLFN_ARGS) { int newsize, error; struct sysctlnode node; node = *rnode; node.sysctl_data = &newsize; newsize = bpf_maxbufsize; error = sysctl_lookup(SYSCTLFN_CALL(&node)); if (error || newp == NULL) return (error); if (newsize < BPF_MINBUFSIZE || newsize > BPF_MAXBUFSIZE) return (EINVAL); bpf_maxbufsize = newsize; return (0); } static int sysctl_net_bpf_peers(SYSCTLFN_ARGS) { int error, elem_count; struct bpf_d *dp; struct bpf_d_ext dpe; size_t len, needed, elem_size, out_size; char *sp; if (namelen == 1 && name[0] == CTL_QUERY) return (sysctl_query(SYSCTLFN_CALL(rnode))); if (namelen != 2) return (EINVAL); /* BPF peers is privileged information. */ error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_GETPRIV, NULL, NULL, NULL); if (error) return (EPERM); len = (oldp != NULL) ? *oldlenp : 0; sp = oldp; elem_size = name[0]; elem_count = name[1]; out_size = MIN(sizeof(dpe), elem_size); needed = 0; if (elem_size < 1 || elem_count < 0) return (EINVAL); mutex_enter(&bpf_mtx); LIST_FOREACH(dp, &bpf_list, bd_list) { if (len >= elem_size && elem_count > 0) { #define BPF_EXT(field) dpe.bde_ ## field = dp->bd_ ## field BPF_EXT(bufsize); BPF_EXT(promisc); BPF_EXT(state); BPF_EXT(immediate); BPF_EXT(hdrcmplt); BPF_EXT(seesent); BPF_EXT(pid); BPF_EXT(rcount); BPF_EXT(dcount); BPF_EXT(ccount); #undef BPF_EXT if (dp->bd_bif) (void)strlcpy(dpe.bde_ifname, dp->bd_bif->bif_ifp->if_xname, IFNAMSIZ - 1); else dpe.bde_ifname[0] = '\0'; error = copyout(&dpe, sp, out_size); if (error) break; sp += elem_size; len -= elem_size; } needed += elem_size; if (elem_count > 0 && elem_count != INT_MAX) elem_count--; } mutex_exit(&bpf_mtx); *oldlenp = needed; return (error); } static struct sysctllog *bpf_sysctllog; static void sysctl_net_bpf_setup(void) { const struct sysctlnode *node; sysctl_createv(&bpf_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "net", NULL, NULL, 0, NULL, 0, CTL_NET, CTL_EOL); node = NULL; sysctl_createv(&bpf_sysctllog, 0, NULL, &node, CTLFLAG_PERMANENT, CTLTYPE_NODE, "bpf", SYSCTL_DESCR("BPF options"), NULL, 0, NULL, 0, CTL_NET, CTL_CREATE, CTL_EOL); if (node != NULL) { sysctl_createv(&bpf_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "maxbufsize", SYSCTL_DESCR("Maximum size for data capture buffer"), sysctl_net_bpf_maxbufsize, 0, &bpf_maxbufsize, 0, CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); sysctl_createv(&bpf_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "stats", SYSCTL_DESCR("BPF stats"), NULL, 0, &bpf_gstats, sizeof(bpf_gstats), CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); sysctl_createv(&bpf_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "peers", SYSCTL_DESCR("BPF peers"), sysctl_net_bpf_peers, 0, NULL, 0, CTL_NET, node->sysctl_num, CTL_CREATE, CTL_EOL); } } struct bpf_ops bpf_ops_kernel = { .bpf_attach = _bpfattach, .bpf_detach = _bpfdetach, .bpf_change_type = _bpf_change_type, .bpf_tap = _bpf_tap, .bpf_mtap = _bpf_mtap, .bpf_mtap2 = _bpf_mtap2, .bpf_mtap_af = _bpf_mtap_af, .bpf_mtap_sl_in = _bpf_mtap_sl_in, .bpf_mtap_sl_out = _bpf_mtap_sl_out, }; MODULE(MODULE_CLASS_DRIVER, bpf, NULL); static int bpf_modcmd(modcmd_t cmd, void *arg) { devmajor_t bmajor, cmajor; int error; bmajor = cmajor = NODEVMAJOR; switch (cmd) { case MODULE_CMD_INIT: bpfilterattach(0); error = devsw_attach("bpf", NULL, &bmajor, &bpf_cdevsw, &cmajor); if (error == EEXIST) error = 0; /* maybe built-in ... improve eventually */ if (error) break; bpf_ops_handover_enter(&bpf_ops_kernel); atomic_swap_ptr(&bpf_ops, &bpf_ops_kernel); bpf_ops_handover_exit(); sysctl_net_bpf_setup(); break; case MODULE_CMD_FINI: /* * While there is no reference counting for bpf callers, * unload could at least in theory be done similarly to * system call disestablishment. This should even be * a little simpler: * * 1) replace op vector with stubs * 2) post update to all cpus with xc * 3) check that nobody is in bpf anymore * (it's doubtful we'd want something like l_sysent, * but we could do something like *signed* percpu * counters. if the sum is 0, we're good). * 4) if fail, unroll changes * * NOTE: change won't be atomic to the outside. some * packets may be not captured even if unload is * not succesful. I think packet capture not working * is a perfectly logical consequence of trying to * disable packet capture. */ error = EOPNOTSUPP; /* insert sysctl teardown */ break; default: error = ENOTTY; break; } return error; }
//****************************************************************** // // Copyright 2016 Samsung Electronics All Rights Reserved. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #ifndef _NS_PROVIDER_LISTENER__H_ #define _NS_PROVIDER_LISTENER__H_ #ifdef __cplusplus extern "C" { #endif // __cplusplus #include <octypes.h> #include "ocstack.h" #include "experimental/logger.h" #include "ocpayload.h" #include "NSStructs.h" #include "NSConstants.h" #include "NSProviderSystem.h" #include "NSProviderScheduler.h" #include "cautilinterface.h" #include "oic_string.h" #include "oic_malloc.h" #include "NSUtil.h" #include "NSProviderMemoryCache.h" OCEntityHandlerResult NSEntityHandlerNotificationCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callback); OCEntityHandlerResult NSEntityHandlerMessageCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callback); OCEntityHandlerResult NSEntityHandlerSyncCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callback); OCEntityHandlerResult NSEntityHandlerTopicCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callback); void NSProviderConnectionStateListener(const CAEndpoint_t * info, bool isConnected); void NSProviderAdapterStateListener(CATransportAdapter_t adapter, bool enabled); #ifdef WITH_MQ OCStackApplicationResult NSProviderGetMQResponseCB(void * ctx, OCDoHandle handle, OCClientResponse * clientResponse); OCStackApplicationResult NSProviderPublishMQResponseCB(void *ctx, OCDoHandle handle, OCClientResponse *clientResponse); #endif #endif /* _NS_PROVIDER_LISTENER__H_ */ #ifdef __cplusplus } #endif // __cplusplus
//------------------------------------------------------------------------------ // GB_AxB: hard-coded functions for semiring: C<M>=A*B or A'*B //------------------------------------------------------------------------------ // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2020, All Rights Reserved. // http://suitesparse.com See GraphBLAS/Doc/License.txt for license. //------------------------------------------------------------------------------ // If this file is in the Generated/ folder, do not edit it (auto-generated). #include "GB.h" #ifndef GBCOMPACT #include "GB_control.h" #include "GB_ek_slice.h" #include "GB_bracket.h" #include "GB_iterator.h" #include "GB_sort.h" #include "GB_atomics.h" #include "GB_AxB_saxpy3.h" #include "GB_AxB__include.h" // The C=A*B semiring is defined by the following types and operators: // A'*B function (dot2): GB_Adot2B__eq_ge_int16 // A'*B function (dot3): GB_Adot3B__eq_ge_int16 // C+=A'*B function (dot4): GB_Adot4B__eq_ge_int16 // A*B function (saxpy3): GB_Asaxpy3B__eq_ge_int16 // C type: bool // A type: int16_t // B type: int16_t // Multiply: z = (aik >= bkj) // Add: cij = (cij == z) // 'any' monoid? 0 // atomic? 1 // OpenMP atomic? 0 // MultAdd: cij = (cij == (aik >= bkj)) // Identity: true // Terminal: ; #define GB_ATYPE \ int16_t #define GB_BTYPE \ int16_t #define GB_CTYPE \ bool // aik = Ax [pA] #define GB_GETA(aik,Ax,pA) \ int16_t aik = Ax [pA] // bkj = Bx [pB] #define GB_GETB(bkj,Bx,pB) \ int16_t bkj = Bx [pB] #define GB_CX(p) Cx [p] // multiply operator #define GB_MULT(z, x, y) \ z = (x >= y) // multiply-add #define GB_MULTADD(z, x, y) \ z = (z == (x >= y)) // monoid identity value #define GB_IDENTITY \ true // break if cij reaches the terminal value (dot product only) #define GB_DOT_TERMINAL(cij) \ ; // simd pragma for dot-product loop vectorization #define GB_PRAGMA_VECTORIZE_DOT \ GB_PRAGMA_SIMD // simd pragma for other loop vectorization #define GB_PRAGMA_VECTORIZE GB_PRAGMA_SIMD // declare the cij scalar #define GB_CIJ_DECLARE(cij) \ bool cij // save the value of C(i,j) #define GB_CIJ_SAVE(cij,p) Cx [p] = cij // cij = Cx [pC] #define GB_GETC(cij,pC) \ cij = Cx [pC] // Cx [pC] = cij #define GB_PUTC(cij,pC) \ Cx [pC] = cij // Cx [p] = t #define GB_CIJ_WRITE(p,t) Cx [p] = t // C(i,j) += t #define GB_CIJ_UPDATE(p,t) \ Cx [p] = (Cx [p] == t) // x + y #define GB_ADD_FUNCTION(x,y) \ x == y // type with size of GB_CTYPE, and can be used in compare-and-swap #define GB_CTYPE_PUN \ bool // bit pattern for bool, 8-bit, 16-bit, and 32-bit integers #define GB_CTYPE_BITS \ 0x1L // 1 if monoid update can skipped entirely (the ANY monoid) #define GB_IS_ANY_MONOID \ 0 // 1 if monoid update is EQ #define GB_IS_EQ_MONOID \ 1 // 1 if monoid update can be done atomically, 0 otherwise #define GB_HAS_ATOMIC \ 1 // 1 if monoid update can be done with an OpenMP atomic update, 0 otherwise #define GB_HAS_OMP_ATOMIC \ 0 // 1 for the ANY_PAIR semirings #define GB_IS_ANY_PAIR_SEMIRING \ 0 // 1 if PAIR is the multiply operator #define GB_IS_PAIR_MULTIPLIER \ 0 #if GB_IS_ANY_PAIR_SEMIRING // result is purely symbolic; no numeric work to do. Hx is not used. #define GB_HX_WRITE(i,t) #define GB_CIJ_GATHER(p,i) #define GB_HX_UPDATE(i,t) #define GB_CIJ_MEMCPY(p,i,len) #else // Hx [i] = t #define GB_HX_WRITE(i,t) Hx [i] = t // Cx [p] = Hx [i] #define GB_CIJ_GATHER(p,i) Cx [p] = Hx [i] // Hx [i] += t #define GB_HX_UPDATE(i,t) \ Hx [i] = (Hx [i] == t) // memcpy (&(Cx [p]), &(Hx [i]), len) #define GB_CIJ_MEMCPY(p,i,len) \ memcpy (Cx +(p), Hx +(i), (len) * sizeof(bool)) #endif // disable this semiring and use the generic case if these conditions hold #define GB_DISABLE \ (GxB_NO_EQ || GxB_NO_GE || GxB_NO_INT16 || GxB_NO_EQ_BOOL || GxB_NO_GE_INT16 || GxB_NO_EQ_GE_INT16) //------------------------------------------------------------------------------ // C=A'*B or C<!M>=A'*B: dot product (phase 2) //------------------------------------------------------------------------------ GrB_Info GB_Adot2B__eq_ge_int16 ( GrB_Matrix C, const GrB_Matrix M, const bool Mask_struct, const GrB_Matrix *Aslice, bool A_is_pattern, const GrB_Matrix B, bool B_is_pattern, int64_t *GB_RESTRICT B_slice, int64_t *GB_RESTRICT *C_counts, int nthreads, int naslice, int nbslice ) { // C<M>=A'*B now uses dot3 #if GB_DISABLE return (GrB_NO_VALUE) ; #else #define GB_PHASE_2_OF_2 #include "GB_AxB_dot2_meta.c" #undef GB_PHASE_2_OF_2 return (GrB_SUCCESS) ; #endif } //------------------------------------------------------------------------------ // C<M>=A'*B: masked dot product method (phase 2) //------------------------------------------------------------------------------ GrB_Info GB_Adot3B__eq_ge_int16 ( GrB_Matrix C, const GrB_Matrix M, const bool Mask_struct, const GrB_Matrix A, bool A_is_pattern, const GrB_Matrix B, bool B_is_pattern, const GB_task_struct *GB_RESTRICT TaskList, const int ntasks, const int nthreads ) { #if GB_DISABLE return (GrB_NO_VALUE) ; #else #include "GB_AxB_dot3_template.c" return (GrB_SUCCESS) ; #endif } //------------------------------------------------------------------------------ // C+=A'*B: dense dot product //------------------------------------------------------------------------------ GrB_Info GB_Adot4B__eq_ge_int16 ( GrB_Matrix C, const GrB_Matrix A, bool A_is_pattern, int64_t *GB_RESTRICT A_slice, int naslice, const GrB_Matrix B, bool B_is_pattern, int64_t *GB_RESTRICT B_slice, int nbslice, const int nthreads ) { #if GB_DISABLE return (GrB_NO_VALUE) ; #else #include "GB_AxB_dot4_template.c" return (GrB_SUCCESS) ; #endif } //------------------------------------------------------------------------------ // C=A*B, C<M>=A*B, C<!M>=A*B: saxpy3 method (Gustavson + Hash) //------------------------------------------------------------------------------ #include "GB_AxB_saxpy3_template.h" GrB_Info GB_Asaxpy3B__eq_ge_int16 ( GrB_Matrix C, const GrB_Matrix M, bool Mask_comp, const bool Mask_struct, const GrB_Matrix A, bool A_is_pattern, const GrB_Matrix B, bool B_is_pattern, GB_saxpy3task_struct *GB_RESTRICT TaskList, const int ntasks, const int nfine, const int nthreads, GB_Context Context ) { #if GB_DISABLE return (GrB_NO_VALUE) ; #else #include "GB_AxB_saxpy3_template.c" return (GrB_SUCCESS) ; #endif } #endif
/* * MIT License * * Copyright (c) 2022 Joey Castillo * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef PULSOMETER_FACE_H_ #define PULSOMETER_FACE_H_ #include "movement.h" typedef struct { bool measuring; int16_t pulse; int16_t ticks; } pulsometer_state_t; void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr); void pulsometer_face_activate(movement_settings_t *settings, void *context); bool pulsometer_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void pulsometer_face_resign(movement_settings_t *settings, void *context); #define pulsometer_face ((const watch_face_t){ \ pulsometer_face_setup, \ pulsometer_face_activate, \ pulsometer_face_loop, \ pulsometer_face_resign, \ NULL, \ }) #endif // PULSOMETER_FACE_H_
#pragma once const Colour defaultOffColour = Colours::lightblue; const Colour defaultOnColour = Colours::lightblue; const Colour defaultDisabledColour = Colours::darkgrey; const int defaultFontAudioSize = 18; /* ============================================================================== lookandfeel that goes for fontaudio for possibly all getXYZFont methods ============================================================================== */ class FontaudioLookAndFeel : public LookAndFeel_V4 { private: SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; public: Font getComboBoxFont(ComboBox &) override { return sharedFontAudio->getFont(defaultFontAudioSize); } // void positionComboBoxText (ComboBox& box, Label& label) override // { // label.setBounds (1, 1, // box.getWidth() - 20, // box.getHeight() - 2); // // label.setFont (getComboBoxFont (box)); // label.setJustificationType(Justification::horizontallyCentred); // } Font getLabelFont(Label &) override { return sharedFontAudio->getFont(defaultFontAudioSize); } Font getPopupMenuFont() override { return sharedFontAudio->getFont(defaultFontAudioSize); } Font getTextButtonFont(TextButton &, int buttonHeight) override { return sharedFontAudio->getFont(defaultFontAudioSize); } }; /* ============================================================================== Container component for flex box based demo ============================================================================== */ class FlexBoxDemoPanel : public Component { public: FlexBoxDemoPanel(const String &name, FlexBox::Direction direction) : Component(name), dirty_(false) { masterBox_.alignItems = FlexBox::AlignItems::stretch; masterBox_.alignContent = FlexBox::AlignContent::stretch; masterBox_.flexWrap = FlexBox::Wrap::noWrap; masterBox_.justifyContent = FlexBox::JustifyContent::flexEnd; masterBox_.flexDirection = direction; Label* panelLabel = new Label(name, name); panelLabel->setJustificationType(Justification::topLeft); addControl(panelLabel); }; virtual ~FlexBoxDemoPanel(){}; void clear() { masterBox_.items.clear(); } void addControl(Component *control, float flex = 1.0f) { jassert(control != nullptr); controls_.add(control); flexes_.add(flex); this->addAndMakeVisible(control); dirty_ = true; } void resized() override { Rectangle<float> bounds = getLocalBounds().reduced(2).toFloat(); if (dirty_.load()) clear(); jassert(flexes_.size() == controls_.size()); FlexItem::Margin mrgn{0.0, 0.0, 0.0, 0.0}; for (int i = 0; i < controls_.size(); i++) { masterBox_.items.add(FlexItem(1, 1).withFlex(flexes_[i]).withMargin(mrgn)); auto &flexItem = masterBox_.items.getReference(masterBox_.items.size() - 1); flexItem.associatedComponent = controls_[i]; } masterBox_.performLayout(bounds); } void paint(Graphics &g) override { Rectangle<float> bounds = getLocalBounds().reduced(2).toFloat(); g.setColour(Colours::lightgrey); g.drawRoundedRectangle(0, 0, bounds.getWidth(), bounds.getHeight(), 5.0f, 2.0f); } private: OwnedArray<Component> controls_; Array<float> flexes_; FlexBox masterBox_; std::atomic_bool dirty_; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FlexBoxDemoPanel) }; /* ============================================================================== Hyperlink button using fontaudio for rendering text ============================================================================== */ class FontaudioHyperlinkButton : public HyperlinkButton { private: SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; public: FontaudioHyperlinkButton(const String &linkText, const URL &linkURL) : HyperlinkButton(linkText, linkURL) { setFont(sharedFontAudio->getFont(), true); setColour(textColourId, Colours::lightblue); } }; /* ============================================================================== Toggle button displaying a fontaudio icon based on its state ============================================================================== */ class SwitchButton : public TextButton { public: SwitchButton(fontaudio::IconName onIcon, fontaudio::IconName offIcon, Colour onColour, Colour offColour, Colour disabledColour) : onColour(onColour), offColour(offColour), disabledColour(disabledColour), offIcon(offIcon), onIcon(onIcon) { setClickingTogglesState(true); setTriggeredOnMouseDown(true); }; virtual ~SwitchButton(){}; void paint(Graphics &g) override { g.setFont(sharedFontAudio->getFont(getHeight() * 0.8f)); Colour baseColour = getToggleState() ? onColour : offColour; g.setColour(isEnabled() ? (isMouseOver() ? baseColour.brighter() : baseColour) : disabledColour); g.drawFittedText(getToggleState() ? onIcon : offIcon, getLocalBounds(), Justification::centred, 1, 1); } private: SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; Colour onColour, offColour, disabledColour; fontaudio::IconName offIcon, onIcon; }; /* ============================================================================== Text button displaying a fontaudio icon ============================================================================== */ class PushButton : public TextButton { public: PushButton(fontaudio::IconName icon, Colour textColour, Colour disabledColour) : textColour(textColour), disabledColour(disabledColour), icon(icon) { setClickingTogglesState(false); setTriggeredOnMouseDown(true); }; virtual ~PushButton(){}; void paint(Graphics &g) override { g.setFont(sharedFontAudio->getFont(getHeight() * 0.8f)); g.setColour(isEnabled() ? (isMouseOver() ? textColour.brighter() : textColour) : disabledColour); g.drawFittedText(icon, getLocalBounds(), Justification::centred, 1, 1); } private: SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; Colour textColour, disabledColour; fontaudio::IconName icon; }; /* ============================================================================== Combo box displaying fontaudio icons ============================================================================== */ class IconComboBox : public ComboBox { public: IconComboBox() { setLookAndFeel(&lf); } ~IconComboBox() { setLookAndFeel(nullptr); } private: FontaudioLookAndFeel lf; }; /* ============================================================================== Container component for combo box based demo ============================================================================== */ class ComboBoxDemo : public Component { public: ComboBoxDemo(const String &title) { setOpaque(false); addAndMakeVisible(&combo); addAndMakeVisible(&label); label.setText(title, dontSendNotification); } void resized() override { Rectangle<float> bounds = getLocalBounds().toFloat(); float labelWidth = bounds.getWidth() * 0.33f; float comboHeightReduce = bounds.getHeight() * 0.2f; //Rectangle<int> switchesRow = getLocalBounds().reduced(margin).removeFromTop(blockSize); label.setBounds(bounds.removeFromLeft(labelWidth).toNearestInt()); combo.setBounds(bounds.reduced(0,comboHeightReduce).toNearestInt()); } void addComboItem(fontaudio::IconName icon, int itemId) { combo.addItem(icon, itemId); combo.setSelectedId(1); } private: Label label; IconComboBox combo; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ComboBoxDemo) }; class DigitalClockDemoPanel : public Component, public Timer { public: DigitalClockDemoPanel() { timeRefMilliseconds = 0; startTimer(timerInterval); }; virtual ~DigitalClockDemoPanel(){}; void paint(Graphics &g) override { g.setColour(Colours::lightcoral); g.setFont(sharedFontAudio->getFont(getHeight() * 0.8f)); g.drawFittedText(currentTimecode, getLocalBounds(), Justification::centred, 1, 1); } void timerCallback() override { currentTimecode = String(msToTimecode(timeRefMilliseconds)); repaint(); timeRefMilliseconds += 25; } String msToTimecode(long long inputMilliseconds) { int milliseconds = (int)(inputMilliseconds % 1000); int seconds = (int)(inputMilliseconds / 1000) % 60; int minutes = (int)(inputMilliseconds / (1000 * 60)) % 60; int hours = (int)(inputMilliseconds / (1000 * 60 * 60)) % 24; std::ostringstream str; str << std::setw(2) << std::setfill('0') << hours; str << ":"; str << std::setw(2) << std::setfill('0') << minutes; str << ":"; str << std::setw(2) << std::setfill('0') << seconds; str << "."; str << std::setw(3) << std::setfill('0') << milliseconds; String normalStringTimecode = str.str(); String fontaudioTimecode = ""; for (auto ptr = normalStringTimecode.getCharPointer(); !ptr.isEmpty(); ++ptr) { auto c = *ptr; switch (c) { case '0': fontaudioTimecode += fontaudio::Digital0; break; case '1': fontaudioTimecode += fontaudio::Digital1; break; case '2': fontaudioTimecode += fontaudio::Digital2; break; case '3': fontaudioTimecode += fontaudio::Digital3; break; case '4': fontaudioTimecode += fontaudio::Digital4; break; case '5': fontaudioTimecode += fontaudio::Digital5; break; case '6': fontaudioTimecode += fontaudio::Digital6; break; case '7': fontaudioTimecode += fontaudio::Digital7; break; case '8': fontaudioTimecode += fontaudio::Digital8; break; case '9': fontaudioTimecode += fontaudio::Digital9; break; case '.': fontaudioTimecode += fontaudio::DigitalDot; break; case ':': fontaudioTimecode += fontaudio::DigitalColon; break; } } return fontaudioTimecode; } void stop(){ if(isTimerRunning()){ stopTimer(); } currentTimecode = String(msToTimecode(timeRefMilliseconds=0)); repaint(); } void play(){ if(!isTimerRunning()) startTimer(timerInterval); } void pause(){ if(isTimerRunning()) stopTimer(); else if(timeRefMilliseconds>0) play(); }; private: int64 timeRefMilliseconds; int timerInterval = 25; int currentMilliseconds; String currentTimecode; SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DigitalClockDemoPanel) }; /* ============================================================================== Rotary Slider using a Fontaudio Icon as UI ============================================================================== */ class RotarySlider : public Slider { public: RotarySlider(fontaudio::IconName icon, Colour sliderColour) : sliderColour(sliderColour), icon(icon) { setLookAndFeel(&lookAndFeel); setSliderStyle(SliderStyle::RotaryVerticalDrag); setColour(Slider::rotarySliderOutlineColourId, sliderColour); setTextBoxStyle(TextEntryBoxPosition::NoTextBox, true, 0, 0); }; virtual ~RotarySlider() { setLookAndFeel(nullptr); }; class RotarySliderLookAndFeel : public LookAndFeel_V4 { private: SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; public: void drawRotarySlider(Graphics &g, int x, int y, int width, int height, float sliderPos, const float rotaryStartAngle, const float rotaryEndAngle, Slider &slider) { auto c = slider.findColour(Slider::rotarySliderOutlineColourId); fontaudio::IconName icon = dynamic_cast<RotarySlider *>(&slider)->getIcon(); auto toAngle = rotaryEndAngle + sliderPos * (rotaryStartAngle - rotaryEndAngle); sharedFontAudio->drawCenterdRotated(g, icon, std::min(width, height), slider.isMouseOver() ? c.brighter() : c, slider.getLocalBounds(), toAngle / float_Pi, 1.0f); } }; fontaudio::IconName getIcon() const { return icon; } private: Colour sliderColour; fontaudio::IconName icon; RotarySliderLookAndFeel lookAndFeel; }; /* ============================================================================== Linear Slider using a Fontaudio Icon as UI ============================================================================== */ class LinearSlider : public Slider { public: LinearSlider(fontaudio::IconName icon, Colour sliderColour) : sliderColour(sliderColour), icon(icon) { setLookAndFeel(&lookAndFeel); setSliderStyle(SliderStyle::LinearHorizontal); setColour(Slider::rotarySliderOutlineColourId, sliderColour); setTextBoxStyle(TextEntryBoxPosition::NoTextBox, true, 0, 0); setRange(0.0, 100.0); }; virtual ~LinearSlider() { setLookAndFeel(nullptr); }; class LinearSliderLookAndFeel : public LookAndFeel_V4 { private: SharedResourcePointer<fontaudio::IconHelper> sharedFontAudio; public: void drawLinearSlider(Graphics &g, int x, int y, int width, int height, float sliderPos, const float minSliderPos, const float maxSliderPos, const Slider::SliderStyle style, Slider &slider) { auto c = slider.findColour(Slider::rotarySliderOutlineColourId); double sliderNormalizedValue = slider.valueToProportionOfLength(slider.getValue()); bool isHorizontal = slider.isHorizontal(); auto trackWidth = jmin(6.0f, isHorizontal ? height * 0.25f : width * 0.25f); Point<float> startPoint(isHorizontal ? x + height * 0.5f : x + width * 0.5f, isHorizontal ? y + height * 0.5f : y + height - width * 0.5f); Point<float> endPoint(isHorizontal ? x + width - height*0.5f : startPoint.x, isHorizontal ? startPoint.y : y + width * 0.5f); Point<float> valuePoint(isHorizontal ? startPoint.x + sliderNormalizedValue*(endPoint.x-startPoint.x) : startPoint.x, isHorizontal ? startPoint.y : startPoint.y + sliderNormalizedValue*(endPoint.y-startPoint.y) ); Path backgroundTrack,valueTrack; backgroundTrack.startNewSubPath(startPoint); backgroundTrack.lineTo(endPoint); valueTrack.startNewSubPath(startPoint); valueTrack.lineTo(valuePoint); g.setColour(slider.findColour(Slider::backgroundColourId)); g.strokePath(backgroundTrack, {trackWidth, PathStrokeType::curved, PathStrokeType::rounded}); g.setColour(slider.findColour(Slider::trackColourId)); g.strokePath(valueTrack, {trackWidth, PathStrokeType::curved, PathStrokeType::rounded}); g.setColour(slider.findColour(Slider::thumbColourId)); auto thumbWidth = isHorizontal ? height: width; fontaudio::IconName icon = dynamic_cast<LinearSlider *>(&slider)->getIcon(); Rectangle<int> thumbRect = Rectangle<float>(static_cast<float>(thumbWidth), static_cast<float>(thumbWidth)).withCentre(valuePoint).toNearestInt(); sharedFontAudio->drawCenterdRotated(g, icon, isHorizontal ? height : width, slider.isMouseOver() ? c.brighter() : c, thumbRect, isHorizontal ? -0.5f : 0.0f); } }; fontaudio::IconName getIcon() const { return icon; } private: Colour sliderColour; fontaudio::IconName icon; LinearSliderLookAndFeel lookAndFeel; };
/* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com */ #include "tomcrypt.h" /** @file dsa_decrypt_key.c DSA Crypto, Tom St Denis */ #ifdef MDSA /** Decrypt an DSA encrypted key @param in The ciphertext @param inlen The length of the ciphertext (octets) @param out [out] The plaintext @param outlen [in/out] The max size and resulting size of the plaintext @param key The corresponding private DSA key @return CRYPT_OK if successful */ int dsa_decrypt_key(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen, dsa_key *key) { unsigned char *skey, *expt; void *g_pub; unsigned long x, y, hashOID[32]; int hash, err; ltc_asn1_list decode[3]; LTC_ARGCHK(in != NULL); LTC_ARGCHK(out != NULL); LTC_ARGCHK(outlen != NULL); LTC_ARGCHK(key != NULL); /* right key type? */ if (key->type != PK_PRIVATE) { return CRYPT_PK_NOT_PRIVATE; } /* decode to find out hash */ LTC_SET_ASN1(decode, 0, LTC_ASN1_OBJECT_IDENTIFIER, hashOID, sizeof(hashOID)/sizeof(hashOID[0])); if ((err = der_decode_sequence(in, inlen, decode, 1)) != CRYPT_OK) { return err; } hash = find_hash_oid(hashOID, decode[0].size); if (hash_is_valid(hash) != CRYPT_OK) { return CRYPT_INVALID_PACKET; } /* we now have the hash! */ if ((err = mp_init(&g_pub)) != CRYPT_OK) { return err; } /* allocate memory */ expt = XMALLOC(mp_unsigned_bin_size(key->p) + 1); skey = XMALLOC(MAXBLOCKSIZE); if (expt == NULL || skey == NULL) { if (expt != NULL) { XFREE(expt); } if (skey != NULL) { XFREE(skey); } mp_clear(g_pub); return CRYPT_MEM; } LTC_SET_ASN1(decode, 1, LTC_ASN1_INTEGER, g_pub, 1UL); LTC_SET_ASN1(decode, 2, LTC_ASN1_OCTET_STRING, skey, MAXBLOCKSIZE); /* read the structure in now */ if ((err = der_decode_sequence(in, inlen, decode, 3)) != CRYPT_OK) { goto LBL_ERR; } /* make shared key */ x = mp_unsigned_bin_size(key->p) + 1; if ((err = dsa_shared_secret(key->x, g_pub, key, expt, &x)) != CRYPT_OK) { goto LBL_ERR; } y = MIN(mp_unsigned_bin_size(key->p) + 1, MAXBLOCKSIZE); if ((err = hash_memory(hash, expt, x, expt, &y)) != CRYPT_OK) { goto LBL_ERR; } /* ensure the hash of the shared secret is at least as big as the encrypt itself */ if (decode[2].size > y) { err = CRYPT_INVALID_PACKET; goto LBL_ERR; } /* avoid buffer overflow */ if (*outlen < decode[2].size) { *outlen = decode[2].size; err = CRYPT_BUFFER_OVERFLOW; goto LBL_ERR; } /* Decrypt the key */ for (x = 0; x < decode[2].size; x++) { out[x] = expt[x] ^ skey[x]; } *outlen = x; err = CRYPT_OK; LBL_ERR: #ifdef LTC_CLEAN_STACK zeromem(expt, mp_unsigned_bin_size(key->p) + 1); zeromem(skey, MAXBLOCKSIZE); #endif XFREE(expt); XFREE(skey); mp_clear(g_pub); return err; } #endif /* $Source$ */ /* $Revision: 24838 $ */ /* $Date: 2007-01-23 23:16:57 -0600 (Tue, 23 Jan 2007) $ */
#ifndef _PROCESS_H_ #define _PROCESS_H_ #include "main.h" void parse_process(Process_Info * process_info, const int * inode); void parse_pid(int * pid, const int * inode); void parse_pname(char pname[], const int * pid); void parse_cmd(char cmd[], const int * pid); void parse_opt(char opt[], const int * pid); #endif
/****************************************************************************** * * (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software * without restriction, including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, and to permit * persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * Use of the Software is limited solely to applications: (a) running on a Xilinx device, or * (b) that interact with a Xilinx device through a bus or interconnect. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of the Xilinx shall not be used in advertising or * otherwise to promote the sale, use or other dealings in this Software without prior written * authorization from Xilinx. * ******************************************************************************/ /****************************************************************************/ /** * * @file ps7_init.c * * This file is automatically generated * *****************************************************************************/ #include "ps7_init.h" unsigned long ps7_pll_init_data_3_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: PLL SLCR REGISTERS // .. .. START: ARM PLL INIT // .. .. PLL_RES = 0x2 // .. .. ==> 0XF8000110[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000110[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0xfa // .. .. ==> 0XF8000110[21:12] = 0x000000FAU // .. .. ==> MASK : 0x003FF000U VAL : 0x000FA000U // .. .. EMIT_MASKWRITE(0XF8000110, 0x003FFFF0U ,0x000FA220U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x28 // .. .. .. ==> 0XF8000100[18:12] = 0x00000028U // .. .. .. ==> MASK : 0x0007F000U VAL : 0x00028000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x0007F000U ,0x00028000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000100[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000100[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000100[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. ARM_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000001U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000100[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. .. SRCSEL = 0x0 // .. .. .. ==> 0XF8000120[5:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. .. DIVISOR = 0x2 // .. .. .. ==> 0XF8000120[13:8] = 0x00000002U // .. .. .. ==> MASK : 0x00003F00U VAL : 0x00000200U // .. .. .. CPU_6OR4XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[24:24] = 0x00000001U // .. .. .. ==> MASK : 0x01000000U VAL : 0x01000000U // .. .. .. CPU_3OR2XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[25:25] = 0x00000001U // .. .. .. ==> MASK : 0x02000000U VAL : 0x02000000U // .. .. .. CPU_2XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[26:26] = 0x00000001U // .. .. .. ==> MASK : 0x04000000U VAL : 0x04000000U // .. .. .. CPU_1XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[27:27] = 0x00000001U // .. .. .. ==> MASK : 0x08000000U VAL : 0x08000000U // .. .. .. CPU_PERI_CLKACT = 0x1 // .. .. .. ==> 0XF8000120[28:28] = 0x00000001U // .. .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. .. EMIT_MASKWRITE(0XF8000120, 0x1F003F30U ,0x1F000200U), // .. .. FINISH: ARM PLL INIT // .. .. START: DDR PLL INIT // .. .. PLL_RES = 0x2 // .. .. ==> 0XF8000114[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000114[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0x12c // .. .. ==> 0XF8000114[21:12] = 0x0000012CU // .. .. ==> MASK : 0x003FF000U VAL : 0x0012C000U // .. .. EMIT_MASKWRITE(0XF8000114, 0x003FFFF0U ,0x0012C220U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x20 // .. .. .. ==> 0XF8000104[18:12] = 0x00000020U // .. .. .. ==> MASK : 0x0007F000U VAL : 0x00020000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x0007F000U ,0x00020000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000104[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000104[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000104[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. DDR_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[1:1] = 0x00000001U // .. .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000002U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000104[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. .. DDR_3XCLKACT = 0x1 // .. .. .. ==> 0XF8000124[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. DDR_2XCLKACT = 0x1 // .. .. .. ==> 0XF8000124[1:1] = 0x00000001U // .. .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. .. DDR_3XCLK_DIVISOR = 0x2 // .. .. .. ==> 0XF8000124[25:20] = 0x00000002U // .. .. .. ==> MASK : 0x03F00000U VAL : 0x00200000U // .. .. .. DDR_2XCLK_DIVISOR = 0x3 // .. .. .. ==> 0XF8000124[31:26] = 0x00000003U // .. .. .. ==> MASK : 0xFC000000U VAL : 0x0C000000U // .. .. .. EMIT_MASKWRITE(0XF8000124, 0xFFF00003U ,0x0C200003U), // .. .. FINISH: DDR PLL INIT // .. .. START: IO PLL INIT // .. .. PLL_RES = 0xc // .. .. ==> 0XF8000118[7:4] = 0x0000000CU // .. .. ==> MASK : 0x000000F0U VAL : 0x000000C0U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000118[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0x145 // .. .. ==> 0XF8000118[21:12] = 0x00000145U // .. .. ==> MASK : 0x003FF000U VAL : 0x00145000U // .. .. EMIT_MASKWRITE(0XF8000118, 0x003FFFF0U ,0x001452C0U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x1e // .. .. .. ==> 0XF8000108[18:12] = 0x0000001EU // .. .. .. ==> MASK : 0x0007F000U VAL : 0x0001E000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x0007F000U ,0x0001E000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000108[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000108[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000108[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. IO_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[2:2] = 0x00000001U // .. .. .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000004U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000108[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. FINISH: IO PLL INIT // .. FINISH: PLL SLCR REGISTERS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_clock_init_data_3_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: CLOCK CONTROL SLCR REGISTERS // .. CLKACT = 0x1 // .. ==> 0XF8000128[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. DIVISOR0 = 0x23 // .. ==> 0XF8000128[13:8] = 0x00000023U // .. ==> MASK : 0x00003F00U VAL : 0x00002300U // .. DIVISOR1 = 0x3 // .. ==> 0XF8000128[25:20] = 0x00000003U // .. ==> MASK : 0x03F00000U VAL : 0x00300000U // .. EMIT_MASKWRITE(0XF8000128, 0x03F03F01U ,0x00302301U), // .. CLKACT = 0x1 // .. ==> 0XF8000138[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF8000138[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000138, 0x00000011U ,0x00000001U), // .. CLKACT = 0x1 // .. ==> 0XF8000140[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF8000140[6:4] = 0x00000000U // .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. DIVISOR = 0x8 // .. ==> 0XF8000140[13:8] = 0x00000008U // .. ==> MASK : 0x00003F00U VAL : 0x00000800U // .. DIVISOR1 = 0x1 // .. ==> 0XF8000140[25:20] = 0x00000001U // .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. EMIT_MASKWRITE(0XF8000140, 0x03F03F71U ,0x00100801U), // .. CLKACT = 0x1 // .. ==> 0XF800014C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF800014C[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x5 // .. ==> 0XF800014C[13:8] = 0x00000005U // .. ==> MASK : 0x00003F00U VAL : 0x00000500U // .. EMIT_MASKWRITE(0XF800014C, 0x00003F31U ,0x00000501U), // .. CLKACT0 = 0x1 // .. ==> 0XF8000150[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. CLKACT1 = 0x0 // .. ==> 0XF8000150[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. SRCSEL = 0x0 // .. ==> 0XF8000150[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x14 // .. ==> 0XF8000150[13:8] = 0x00000014U // .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. EMIT_MASKWRITE(0XF8000150, 0x00003F33U ,0x00001401U), // .. CLKACT0 = 0x0 // .. ==> 0XF8000154[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. CLKACT1 = 0x1 // .. ==> 0XF8000154[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. SRCSEL = 0x0 // .. ==> 0XF8000154[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x14 // .. ==> 0XF8000154[13:8] = 0x00000014U // .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. EMIT_MASKWRITE(0XF8000154, 0x00003F33U ,0x00001402U), // .. .. START: TRACE CLOCK // .. .. FINISH: TRACE CLOCK // .. .. CLKACT = 0x1 // .. .. ==> 0XF8000168[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000168[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR = 0x5 // .. .. ==> 0XF8000168[13:8] = 0x00000005U // .. .. ==> MASK : 0x00003F00U VAL : 0x00000500U // .. .. EMIT_MASKWRITE(0XF8000168, 0x00003F31U ,0x00000501U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000170[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0xa // .. .. ==> 0XF8000170[13:8] = 0x0000000AU // .. .. ==> MASK : 0x00003F00U VAL : 0x00000A00U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000170[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000170, 0x03F03F30U ,0x00100A00U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000180[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x7 // .. .. ==> 0XF8000180[13:8] = 0x00000007U // .. .. ==> MASK : 0x00003F00U VAL : 0x00000700U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000180[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000180, 0x03F03F30U ,0x00100700U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000190[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x14 // .. .. ==> 0XF8000190[13:8] = 0x00000014U // .. .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000190[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000190, 0x03F03F30U ,0x00101400U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF80001A0[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x14 // .. .. ==> 0XF80001A0[13:8] = 0x00000014U // .. .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF80001A0[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF80001A0, 0x03F03F30U ,0x00101400U), // .. .. CLK_621_TRUE = 0x1 // .. .. ==> 0XF80001C4[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. EMIT_MASKWRITE(0XF80001C4, 0x00000001U ,0x00000001U), // .. .. DMA_CPU_2XCLKACT = 0x1 // .. .. ==> 0XF800012C[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. USB0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[2:2] = 0x00000001U // .. .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. .. USB1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[3:3] = 0x00000001U // .. .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. .. GEM0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[6:6] = 0x00000001U // .. .. ==> MASK : 0x00000040U VAL : 0x00000040U // .. .. GEM1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. SDI0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[10:10] = 0x00000001U // .. .. ==> MASK : 0x00000400U VAL : 0x00000400U // .. .. SDI1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. SPI0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. SPI1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. CAN0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. CAN1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. I2C0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[18:18] = 0x00000001U // .. .. ==> MASK : 0x00040000U VAL : 0x00040000U // .. .. I2C1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. UART0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. UART1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[21:21] = 0x00000001U // .. .. ==> MASK : 0x00200000U VAL : 0x00200000U // .. .. GPIO_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[22:22] = 0x00000001U // .. .. ==> MASK : 0x00400000U VAL : 0x00400000U // .. .. LQSPI_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[23:23] = 0x00000001U // .. .. ==> MASK : 0x00800000U VAL : 0x00800000U // .. .. SMC_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[24:24] = 0x00000001U // .. .. ==> MASK : 0x01000000U VAL : 0x01000000U // .. .. EMIT_MASKWRITE(0XF800012C, 0x01FFCCCDU ,0x01EC044DU), // .. FINISH: CLOCK CONTROL SLCR REGISTERS // .. START: THIS SHOULD BE BLANK // .. FINISH: THIS SHOULD BE BLANK // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_ddr_init_data_3_0[] = { // START: top // .. START: DDR INITIALIZATION // .. .. START: LOCK DDR // .. .. reg_ddrc_soft_rstb = 0 // .. .. ==> 0XF8006000[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_powerdown_en = 0x0 // .. .. ==> 0XF8006000[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_data_bus_width = 0x0 // .. .. ==> 0XF8006000[3:2] = 0x00000000U // .. .. ==> MASK : 0x0000000CU VAL : 0x00000000U // .. .. reg_ddrc_burst8_refresh = 0x0 // .. .. ==> 0XF8006000[6:4] = 0x00000000U // .. .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. .. reg_ddrc_rdwr_idle_gap = 0x1 // .. .. ==> 0XF8006000[13:7] = 0x00000001U // .. .. ==> MASK : 0x00003F80U VAL : 0x00000080U // .. .. reg_ddrc_dis_rd_bypass = 0x0 // .. .. ==> 0XF8006000[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. reg_ddrc_dis_act_bypass = 0x0 // .. .. ==> 0XF8006000[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_ddrc_dis_auto_refresh = 0x0 // .. .. ==> 0XF8006000[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006000, 0x0001FFFFU ,0x00000080U), // .. .. FINISH: LOCK DDR // .. .. reg_ddrc_t_rfc_nom_x32 = 0x81 // .. .. ==> 0XF8006004[11:0] = 0x00000081U // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000081U // .. .. reserved_reg_ddrc_active_ranks = 0x1 // .. .. ==> 0XF8006004[13:12] = 0x00000001U // .. .. ==> MASK : 0x00003000U VAL : 0x00001000U // .. .. reg_ddrc_addrmap_cs_bit0 = 0x0 // .. .. ==> 0XF8006004[18:14] = 0x00000000U // .. .. ==> MASK : 0x0007C000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006004, 0x0007FFFFU ,0x00001081U), // .. .. reg_ddrc_hpr_min_non_critical_x32 = 0xf // .. .. ==> 0XF8006008[10:0] = 0x0000000FU // .. .. ==> MASK : 0x000007FFU VAL : 0x0000000FU // .. .. reg_ddrc_hpr_max_starve_x32 = 0xf // .. .. ==> 0XF8006008[21:11] = 0x0000000FU // .. .. ==> MASK : 0x003FF800U VAL : 0x00007800U // .. .. reg_ddrc_hpr_xact_run_length = 0xf // .. .. ==> 0XF8006008[25:22] = 0x0000000FU // .. .. ==> MASK : 0x03C00000U VAL : 0x03C00000U // .. .. EMIT_MASKWRITE(0XF8006008, 0x03FFFFFFU ,0x03C0780FU), // .. .. reg_ddrc_lpr_min_non_critical_x32 = 0x1 // .. .. ==> 0XF800600C[10:0] = 0x00000001U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000001U // .. .. reg_ddrc_lpr_max_starve_x32 = 0x2 // .. .. ==> 0XF800600C[21:11] = 0x00000002U // .. .. ==> MASK : 0x003FF800U VAL : 0x00001000U // .. .. reg_ddrc_lpr_xact_run_length = 0x8 // .. .. ==> 0XF800600C[25:22] = 0x00000008U // .. .. ==> MASK : 0x03C00000U VAL : 0x02000000U // .. .. EMIT_MASKWRITE(0XF800600C, 0x03FFFFFFU ,0x02001001U), // .. .. reg_ddrc_w_min_non_critical_x32 = 0x1 // .. .. ==> 0XF8006010[10:0] = 0x00000001U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000001U // .. .. reg_ddrc_w_xact_run_length = 0x8 // .. .. ==> 0XF8006010[14:11] = 0x00000008U // .. .. ==> MASK : 0x00007800U VAL : 0x00004000U // .. .. reg_ddrc_w_max_starve_x32 = 0x2 // .. .. ==> 0XF8006010[25:15] = 0x00000002U // .. .. ==> MASK : 0x03FF8000U VAL : 0x00010000U // .. .. EMIT_MASKWRITE(0XF8006010, 0x03FFFFFFU ,0x00014001U), // .. .. reg_ddrc_t_rc = 0x1b // .. .. ==> 0XF8006014[5:0] = 0x0000001BU // .. .. ==> MASK : 0x0000003FU VAL : 0x0000001BU // .. .. reg_ddrc_t_rfc_min = 0x56 // .. .. ==> 0XF8006014[13:6] = 0x00000056U // .. .. ==> MASK : 0x00003FC0U VAL : 0x00001580U // .. .. reg_ddrc_post_selfref_gap_x32 = 0x10 // .. .. ==> 0XF8006014[20:14] = 0x00000010U // .. .. ==> MASK : 0x001FC000U VAL : 0x00040000U // .. .. EMIT_MASKWRITE(0XF8006014, 0x001FFFFFU ,0x0004159BU), // .. .. reg_ddrc_wr2pre = 0x12 // .. .. ==> 0XF8006018[4:0] = 0x00000012U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000012U // .. .. reg_ddrc_powerdown_to_x32 = 0x6 // .. .. ==> 0XF8006018[9:5] = 0x00000006U // .. .. ==> MASK : 0x000003E0U VAL : 0x000000C0U // .. .. reg_ddrc_t_faw = 0x18 // .. .. ==> 0XF8006018[15:10] = 0x00000018U // .. .. ==> MASK : 0x0000FC00U VAL : 0x00006000U // .. .. reg_ddrc_t_ras_max = 0x24 // .. .. ==> 0XF8006018[21:16] = 0x00000024U // .. .. ==> MASK : 0x003F0000U VAL : 0x00240000U // .. .. reg_ddrc_t_ras_min = 0x14 // .. .. ==> 0XF8006018[26:22] = 0x00000014U // .. .. ==> MASK : 0x07C00000U VAL : 0x05000000U // .. .. reg_ddrc_t_cke = 0x4 // .. .. ==> 0XF8006018[31:28] = 0x00000004U // .. .. ==> MASK : 0xF0000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006018, 0xF7FFFFFFU ,0x452460D2U), // .. .. reg_ddrc_write_latency = 0x5 // .. .. ==> 0XF800601C[4:0] = 0x00000005U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000005U // .. .. reg_ddrc_rd2wr = 0x7 // .. .. ==> 0XF800601C[9:5] = 0x00000007U // .. .. ==> MASK : 0x000003E0U VAL : 0x000000E0U // .. .. reg_ddrc_wr2rd = 0xe // .. .. ==> 0XF800601C[14:10] = 0x0000000EU // .. .. ==> MASK : 0x00007C00U VAL : 0x00003800U // .. .. reg_ddrc_t_xp = 0x4 // .. .. ==> 0XF800601C[19:15] = 0x00000004U // .. .. ==> MASK : 0x000F8000U VAL : 0x00020000U // .. .. reg_ddrc_pad_pd = 0x0 // .. .. ==> 0XF800601C[22:20] = 0x00000000U // .. .. ==> MASK : 0x00700000U VAL : 0x00000000U // .. .. reg_ddrc_rd2pre = 0x4 // .. .. ==> 0XF800601C[27:23] = 0x00000004U // .. .. ==> MASK : 0x0F800000U VAL : 0x02000000U // .. .. reg_ddrc_t_rcd = 0x7 // .. .. ==> 0XF800601C[31:28] = 0x00000007U // .. .. ==> MASK : 0xF0000000U VAL : 0x70000000U // .. .. EMIT_MASKWRITE(0XF800601C, 0xFFFFFFFFU ,0x720238E5U), // .. .. reg_ddrc_t_ccd = 0x4 // .. .. ==> 0XF8006020[4:2] = 0x00000004U // .. .. ==> MASK : 0x0000001CU VAL : 0x00000010U // .. .. reg_ddrc_t_rrd = 0x6 // .. .. ==> 0XF8006020[7:5] = 0x00000006U // .. .. ==> MASK : 0x000000E0U VAL : 0x000000C0U // .. .. reg_ddrc_refresh_margin = 0x2 // .. .. ==> 0XF8006020[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. reg_ddrc_t_rp = 0x7 // .. .. ==> 0XF8006020[15:12] = 0x00000007U // .. .. ==> MASK : 0x0000F000U VAL : 0x00007000U // .. .. reg_ddrc_refresh_to_x32 = 0x8 // .. .. ==> 0XF8006020[20:16] = 0x00000008U // .. .. ==> MASK : 0x001F0000U VAL : 0x00080000U // .. .. reg_ddrc_mobile = 0x0 // .. .. ==> 0XF8006020[22:22] = 0x00000000U // .. .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. .. reg_ddrc_en_dfi_dram_clk_disable = 0x0 // .. .. ==> 0XF8006020[23:23] = 0x00000000U // .. .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. .. reg_ddrc_read_latency = 0x7 // .. .. ==> 0XF8006020[28:24] = 0x00000007U // .. .. ==> MASK : 0x1F000000U VAL : 0x07000000U // .. .. reg_phy_mode_ddr1_ddr2 = 0x1 // .. .. ==> 0XF8006020[29:29] = 0x00000001U // .. .. ==> MASK : 0x20000000U VAL : 0x20000000U // .. .. reg_ddrc_dis_pad_pd = 0x0 // .. .. ==> 0XF8006020[30:30] = 0x00000000U // .. .. ==> MASK : 0x40000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006020, 0x7FDFFFFCU ,0x270872D0U), // .. .. reg_ddrc_en_2t_timing_mode = 0x0 // .. .. ==> 0XF8006024[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_prefer_write = 0x0 // .. .. ==> 0XF8006024[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_mr_wr = 0x0 // .. .. ==> 0XF8006024[6:6] = 0x00000000U // .. .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. .. reg_ddrc_mr_addr = 0x0 // .. .. ==> 0XF8006024[8:7] = 0x00000000U // .. .. ==> MASK : 0x00000180U VAL : 0x00000000U // .. .. reg_ddrc_mr_data = 0x0 // .. .. ==> 0XF8006024[24:9] = 0x00000000U // .. .. ==> MASK : 0x01FFFE00U VAL : 0x00000000U // .. .. ddrc_reg_mr_wr_busy = 0x0 // .. .. ==> 0XF8006024[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reg_ddrc_mr_type = 0x0 // .. .. ==> 0XF8006024[26:26] = 0x00000000U // .. .. ==> MASK : 0x04000000U VAL : 0x00000000U // .. .. reg_ddrc_mr_rdata_valid = 0x0 // .. .. ==> 0XF8006024[27:27] = 0x00000000U // .. .. ==> MASK : 0x08000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006024, 0x0FFFFFC3U ,0x00000000U), // .. .. reg_ddrc_final_wait_x32 = 0x7 // .. .. ==> 0XF8006028[6:0] = 0x00000007U // .. .. ==> MASK : 0x0000007FU VAL : 0x00000007U // .. .. reg_ddrc_pre_ocd_x32 = 0x0 // .. .. ==> 0XF8006028[10:7] = 0x00000000U // .. .. ==> MASK : 0x00000780U VAL : 0x00000000U // .. .. reg_ddrc_t_mrd = 0x4 // .. .. ==> 0XF8006028[13:11] = 0x00000004U // .. .. ==> MASK : 0x00003800U VAL : 0x00002000U // .. .. EMIT_MASKWRITE(0XF8006028, 0x00003FFFU ,0x00002007U), // .. .. reg_ddrc_emr2 = 0x8 // .. .. ==> 0XF800602C[15:0] = 0x00000008U // .. .. ==> MASK : 0x0000FFFFU VAL : 0x00000008U // .. .. reg_ddrc_emr3 = 0x0 // .. .. ==> 0XF800602C[31:16] = 0x00000000U // .. .. ==> MASK : 0xFFFF0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800602C, 0xFFFFFFFFU ,0x00000008U), // .. .. reg_ddrc_mr = 0x930 // .. .. ==> 0XF8006030[15:0] = 0x00000930U // .. .. ==> MASK : 0x0000FFFFU VAL : 0x00000930U // .. .. reg_ddrc_emr = 0x4 // .. .. ==> 0XF8006030[31:16] = 0x00000004U // .. .. ==> MASK : 0xFFFF0000U VAL : 0x00040000U // .. .. EMIT_MASKWRITE(0XF8006030, 0xFFFFFFFFU ,0x00040930U), // .. .. reg_ddrc_burst_rdwr = 0x4 // .. .. ==> 0XF8006034[3:0] = 0x00000004U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000004U // .. .. reg_ddrc_pre_cke_x1024 = 0x16d // .. .. ==> 0XF8006034[13:4] = 0x0000016DU // .. .. ==> MASK : 0x00003FF0U VAL : 0x000016D0U // .. .. reg_ddrc_post_cke_x1024 = 0x1 // .. .. ==> 0XF8006034[25:16] = 0x00000001U // .. .. ==> MASK : 0x03FF0000U VAL : 0x00010000U // .. .. reg_ddrc_burstchop = 0x0 // .. .. ==> 0XF8006034[28:28] = 0x00000000U // .. .. ==> MASK : 0x10000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006034, 0x13FF3FFFU ,0x000116D4U), // .. .. reg_ddrc_force_low_pri_n = 1 // .. .. ==> 0XF8006038[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_ddrc_dis_dq = 0x0 // .. .. ==> 0XF8006038[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006038, 0x00000003U ,0x00000001U), // .. .. reg_ddrc_addrmap_bank_b0 = 0x7 // .. .. ==> 0XF800603C[3:0] = 0x00000007U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000007U // .. .. reg_ddrc_addrmap_bank_b1 = 0x7 // .. .. ==> 0XF800603C[7:4] = 0x00000007U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000070U // .. .. reg_ddrc_addrmap_bank_b2 = 0x7 // .. .. ==> 0XF800603C[11:8] = 0x00000007U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000700U // .. .. reg_ddrc_addrmap_col_b5 = 0x0 // .. .. ==> 0XF800603C[15:12] = 0x00000000U // .. .. ==> MASK : 0x0000F000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b6 = 0x0 // .. .. ==> 0XF800603C[19:16] = 0x00000000U // .. .. ==> MASK : 0x000F0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800603C, 0x000FFFFFU ,0x00000777U), // .. .. reg_ddrc_addrmap_col_b2 = 0x0 // .. .. ==> 0XF8006040[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b3 = 0x0 // .. .. ==> 0XF8006040[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b4 = 0x0 // .. .. ==> 0XF8006040[11:8] = 0x00000000U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b7 = 0x0 // .. .. ==> 0XF8006040[15:12] = 0x00000000U // .. .. ==> MASK : 0x0000F000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b8 = 0x0 // .. .. ==> 0XF8006040[19:16] = 0x00000000U // .. .. ==> MASK : 0x000F0000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b9 = 0xf // .. .. ==> 0XF8006040[23:20] = 0x0000000FU // .. .. ==> MASK : 0x00F00000U VAL : 0x00F00000U // .. .. reg_ddrc_addrmap_col_b10 = 0xf // .. .. ==> 0XF8006040[27:24] = 0x0000000FU // .. .. ==> MASK : 0x0F000000U VAL : 0x0F000000U // .. .. reg_ddrc_addrmap_col_b11 = 0xf // .. .. ==> 0XF8006040[31:28] = 0x0000000FU // .. .. ==> MASK : 0xF0000000U VAL : 0xF0000000U // .. .. EMIT_MASKWRITE(0XF8006040, 0xFFFFFFFFU ,0xFFF00000U), // .. .. reg_ddrc_addrmap_row_b0 = 0x6 // .. .. ==> 0XF8006044[3:0] = 0x00000006U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000006U // .. .. reg_ddrc_addrmap_row_b1 = 0x6 // .. .. ==> 0XF8006044[7:4] = 0x00000006U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000060U // .. .. reg_ddrc_addrmap_row_b2_11 = 0x6 // .. .. ==> 0XF8006044[11:8] = 0x00000006U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000600U // .. .. reg_ddrc_addrmap_row_b12 = 0x6 // .. .. ==> 0XF8006044[15:12] = 0x00000006U // .. .. ==> MASK : 0x0000F000U VAL : 0x00006000U // .. .. reg_ddrc_addrmap_row_b13 = 0x6 // .. .. ==> 0XF8006044[19:16] = 0x00000006U // .. .. ==> MASK : 0x000F0000U VAL : 0x00060000U // .. .. reg_ddrc_addrmap_row_b14 = 0xf // .. .. ==> 0XF8006044[23:20] = 0x0000000FU // .. .. ==> MASK : 0x00F00000U VAL : 0x00F00000U // .. .. reg_ddrc_addrmap_row_b15 = 0xf // .. .. ==> 0XF8006044[27:24] = 0x0000000FU // .. .. ==> MASK : 0x0F000000U VAL : 0x0F000000U // .. .. EMIT_MASKWRITE(0XF8006044, 0x0FFFFFFFU ,0x0FF66666U), // .. .. reg_phy_rd_local_odt = 0x0 // .. .. ==> 0XF8006048[13:12] = 0x00000000U // .. .. ==> MASK : 0x00003000U VAL : 0x00000000U // .. .. reg_phy_wr_local_odt = 0x3 // .. .. ==> 0XF8006048[15:14] = 0x00000003U // .. .. ==> MASK : 0x0000C000U VAL : 0x0000C000U // .. .. reg_phy_idle_local_odt = 0x3 // .. .. ==> 0XF8006048[17:16] = 0x00000003U // .. .. ==> MASK : 0x00030000U VAL : 0x00030000U // .. .. reserved_reg_ddrc_rank0_wr_odt = 0x1 // .. .. ==> 0XF8006048[5:3] = 0x00000001U // .. .. ==> MASK : 0x00000038U VAL : 0x00000008U // .. .. reserved_reg_ddrc_rank0_rd_odt = 0x0 // .. .. ==> 0XF8006048[2:0] = 0x00000000U // .. .. ==> MASK : 0x00000007U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006048, 0x0003F03FU ,0x0003C008U), // .. .. reg_phy_rd_cmd_to_data = 0x0 // .. .. ==> 0XF8006050[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_phy_wr_cmd_to_data = 0x0 // .. .. ==> 0XF8006050[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_phy_rdc_we_to_re_delay = 0x8 // .. .. ==> 0XF8006050[11:8] = 0x00000008U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000800U // .. .. reg_phy_rdc_fifo_rst_disable = 0x0 // .. .. ==> 0XF8006050[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_phy_use_fixed_re = 0x1 // .. .. ==> 0XF8006050[16:16] = 0x00000001U // .. .. ==> MASK : 0x00010000U VAL : 0x00010000U // .. .. reg_phy_rdc_fifo_rst_err_cnt_clr = 0x0 // .. .. ==> 0XF8006050[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_phy_dis_phy_ctrl_rstn = 0x0 // .. .. ==> 0XF8006050[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_phy_clk_stall_level = 0x0 // .. .. ==> 0XF8006050[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. reg_phy_gatelvl_num_of_dq0 = 0x7 // .. .. ==> 0XF8006050[27:24] = 0x00000007U // .. .. ==> MASK : 0x0F000000U VAL : 0x07000000U // .. .. reg_phy_wrlvl_num_of_dq0 = 0x7 // .. .. ==> 0XF8006050[31:28] = 0x00000007U // .. .. ==> MASK : 0xF0000000U VAL : 0x70000000U // .. .. EMIT_MASKWRITE(0XF8006050, 0xFF0F8FFFU ,0x77010800U), // .. .. reg_ddrc_dis_dll_calib = 0x0 // .. .. ==> 0XF8006058[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006058, 0x00010000U ,0x00000000U), // .. .. reg_ddrc_rd_odt_delay = 0x3 // .. .. ==> 0XF800605C[3:0] = 0x00000003U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000003U // .. .. reg_ddrc_wr_odt_delay = 0x0 // .. .. ==> 0XF800605C[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_ddrc_rd_odt_hold = 0x0 // .. .. ==> 0XF800605C[11:8] = 0x00000000U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000000U // .. .. reg_ddrc_wr_odt_hold = 0x5 // .. .. ==> 0XF800605C[15:12] = 0x00000005U // .. .. ==> MASK : 0x0000F000U VAL : 0x00005000U // .. .. EMIT_MASKWRITE(0XF800605C, 0x0000FFFFU ,0x00005003U), // .. .. reg_ddrc_pageclose = 0x0 // .. .. ==> 0XF8006060[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_lpr_num_entries = 0x7 // .. .. ==> 0XF8006060[6:1] = 0x00000007U // .. .. ==> MASK : 0x0000007EU VAL : 0x0000000EU // .. .. reg_ddrc_auto_pre_en = 0x0 // .. .. ==> 0XF8006060[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. reg_ddrc_refresh_update_level = 0x0 // .. .. ==> 0XF8006060[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_ddrc_dis_wc = 0x0 // .. .. ==> 0XF8006060[9:9] = 0x00000000U // .. .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. .. reg_ddrc_dis_collision_page_opt = 0x0 // .. .. ==> 0XF8006060[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_ddrc_selfref_en = 0x0 // .. .. ==> 0XF8006060[12:12] = 0x00000000U // .. .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006060, 0x000017FFU ,0x0000000EU), // .. .. reg_ddrc_go2critical_hysteresis = 0x0 // .. .. ==> 0XF8006064[12:5] = 0x00000000U // .. .. ==> MASK : 0x00001FE0U VAL : 0x00000000U // .. .. reg_arb_go2critical_en = 0x1 // .. .. ==> 0XF8006064[17:17] = 0x00000001U // .. .. ==> MASK : 0x00020000U VAL : 0x00020000U // .. .. EMIT_MASKWRITE(0XF8006064, 0x00021FE0U ,0x00020000U), // .. .. reg_ddrc_wrlvl_ww = 0x41 // .. .. ==> 0XF8006068[7:0] = 0x00000041U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000041U // .. .. reg_ddrc_rdlvl_rr = 0x41 // .. .. ==> 0XF8006068[15:8] = 0x00000041U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00004100U // .. .. reg_ddrc_dfi_t_wlmrd = 0x28 // .. .. ==> 0XF8006068[25:16] = 0x00000028U // .. .. ==> MASK : 0x03FF0000U VAL : 0x00280000U // .. .. EMIT_MASKWRITE(0XF8006068, 0x03FFFFFFU ,0x00284141U), // .. .. dfi_t_ctrlupd_interval_min_x1024 = 0x10 // .. .. ==> 0XF800606C[7:0] = 0x00000010U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000010U // .. .. dfi_t_ctrlupd_interval_max_x1024 = 0x16 // .. .. ==> 0XF800606C[15:8] = 0x00000016U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00001600U // .. .. EMIT_MASKWRITE(0XF800606C, 0x0000FFFFU ,0x00001610U), // .. .. reg_ddrc_dfi_t_ctrl_delay = 0x1 // .. .. ==> 0XF8006078[3:0] = 0x00000001U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000001U // .. .. reg_ddrc_dfi_t_dram_clk_disable = 0x1 // .. .. ==> 0XF8006078[7:4] = 0x00000001U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000010U // .. .. reg_ddrc_dfi_t_dram_clk_enable = 0x1 // .. .. ==> 0XF8006078[11:8] = 0x00000001U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000100U // .. .. reg_ddrc_t_cksre = 0x6 // .. .. ==> 0XF8006078[15:12] = 0x00000006U // .. .. ==> MASK : 0x0000F000U VAL : 0x00006000U // .. .. reg_ddrc_t_cksrx = 0x6 // .. .. ==> 0XF8006078[19:16] = 0x00000006U // .. .. ==> MASK : 0x000F0000U VAL : 0x00060000U // .. .. reg_ddrc_t_ckesr = 0x4 // .. .. ==> 0XF8006078[25:20] = 0x00000004U // .. .. ==> MASK : 0x03F00000U VAL : 0x00400000U // .. .. EMIT_MASKWRITE(0XF8006078, 0x03FFFFFFU ,0x00466111U), // .. .. reg_ddrc_t_ckpde = 0x2 // .. .. ==> 0XF800607C[3:0] = 0x00000002U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000002U // .. .. reg_ddrc_t_ckpdx = 0x2 // .. .. ==> 0XF800607C[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. reg_ddrc_t_ckdpde = 0x2 // .. .. ==> 0XF800607C[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. reg_ddrc_t_ckdpdx = 0x2 // .. .. ==> 0XF800607C[15:12] = 0x00000002U // .. .. ==> MASK : 0x0000F000U VAL : 0x00002000U // .. .. reg_ddrc_t_ckcsx = 0x3 // .. .. ==> 0XF800607C[19:16] = 0x00000003U // .. .. ==> MASK : 0x000F0000U VAL : 0x00030000U // .. .. EMIT_MASKWRITE(0XF800607C, 0x000FFFFFU ,0x00032222U), // .. .. reg_ddrc_dis_auto_zq = 0x0 // .. .. ==> 0XF80060A4[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_ddr3 = 0x1 // .. .. ==> 0XF80060A4[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. reg_ddrc_t_mod = 0x200 // .. .. ==> 0XF80060A4[11:2] = 0x00000200U // .. .. ==> MASK : 0x00000FFCU VAL : 0x00000800U // .. .. reg_ddrc_t_zq_long_nop = 0x200 // .. .. ==> 0XF80060A4[21:12] = 0x00000200U // .. .. ==> MASK : 0x003FF000U VAL : 0x00200000U // .. .. reg_ddrc_t_zq_short_nop = 0x40 // .. .. ==> 0XF80060A4[31:22] = 0x00000040U // .. .. ==> MASK : 0xFFC00000U VAL : 0x10000000U // .. .. EMIT_MASKWRITE(0XF80060A4, 0xFFFFFFFFU ,0x10200802U), // .. .. t_zq_short_interval_x1024 = 0xcb73 // .. .. ==> 0XF80060A8[19:0] = 0x0000CB73U // .. .. ==> MASK : 0x000FFFFFU VAL : 0x0000CB73U // .. .. dram_rstn_x1024 = 0x69 // .. .. ==> 0XF80060A8[27:20] = 0x00000069U // .. .. ==> MASK : 0x0FF00000U VAL : 0x06900000U // .. .. EMIT_MASKWRITE(0XF80060A8, 0x0FFFFFFFU ,0x0690CB73U), // .. .. deeppowerdown_en = 0x0 // .. .. ==> 0XF80060AC[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. deeppowerdown_to_x1024 = 0xff // .. .. ==> 0XF80060AC[8:1] = 0x000000FFU // .. .. ==> MASK : 0x000001FEU VAL : 0x000001FEU // .. .. EMIT_MASKWRITE(0XF80060AC, 0x000001FFU ,0x000001FEU), // .. .. dfi_wrlvl_max_x1024 = 0xfff // .. .. ==> 0XF80060B0[11:0] = 0x00000FFFU // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000FFFU // .. .. dfi_rdlvl_max_x1024 = 0xfff // .. .. ==> 0XF80060B0[23:12] = 0x00000FFFU // .. .. ==> MASK : 0x00FFF000U VAL : 0x00FFF000U // .. .. ddrc_reg_twrlvl_max_error = 0x0 // .. .. ==> 0XF80060B0[24:24] = 0x00000000U // .. .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. .. ddrc_reg_trdlvl_max_error = 0x0 // .. .. ==> 0XF80060B0[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reg_ddrc_dfi_wr_level_en = 0x1 // .. .. ==> 0XF80060B0[26:26] = 0x00000001U // .. .. ==> MASK : 0x04000000U VAL : 0x04000000U // .. .. reg_ddrc_dfi_rd_dqs_gate_level = 0x1 // .. .. ==> 0XF80060B0[27:27] = 0x00000001U // .. .. ==> MASK : 0x08000000U VAL : 0x08000000U // .. .. reg_ddrc_dfi_rd_data_eye_train = 0x1 // .. .. ==> 0XF80060B0[28:28] = 0x00000001U // .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. EMIT_MASKWRITE(0XF80060B0, 0x1FFFFFFFU ,0x1CFFFFFFU), // .. .. reg_ddrc_skip_ocd = 0x1 // .. .. ==> 0XF80060B4[9:9] = 0x00000001U // .. .. ==> MASK : 0x00000200U VAL : 0x00000200U // .. .. EMIT_MASKWRITE(0XF80060B4, 0x00000200U ,0x00000200U), // .. .. reg_ddrc_dfi_t_rddata_en = 0x6 // .. .. ==> 0XF80060B8[4:0] = 0x00000006U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000006U // .. .. reg_ddrc_dfi_t_ctrlup_min = 0x3 // .. .. ==> 0XF80060B8[14:5] = 0x00000003U // .. .. ==> MASK : 0x00007FE0U VAL : 0x00000060U // .. .. reg_ddrc_dfi_t_ctrlup_max = 0x40 // .. .. ==> 0XF80060B8[24:15] = 0x00000040U // .. .. ==> MASK : 0x01FF8000U VAL : 0x00200000U // .. .. EMIT_MASKWRITE(0XF80060B8, 0x01FFFFFFU ,0x00200066U), // .. .. START: RESET ECC ERROR // .. .. Clear_Uncorrectable_DRAM_ECC_error = 1 // .. .. ==> 0XF80060C4[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. Clear_Correctable_DRAM_ECC_error = 1 // .. .. ==> 0XF80060C4[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. EMIT_MASKWRITE(0XF80060C4, 0x00000003U ,0x00000003U), // .. .. FINISH: RESET ECC ERROR // .. .. Clear_Uncorrectable_DRAM_ECC_error = 0x0 // .. .. ==> 0XF80060C4[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. Clear_Correctable_DRAM_ECC_error = 0x0 // .. .. ==> 0XF80060C4[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060C4, 0x00000003U ,0x00000000U), // .. .. CORR_ECC_LOG_VALID = 0x0 // .. .. ==> 0XF80060C8[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. ECC_CORRECTED_BIT_NUM = 0x0 // .. .. ==> 0XF80060C8[7:1] = 0x00000000U // .. .. ==> MASK : 0x000000FEU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060C8, 0x000000FFU ,0x00000000U), // .. .. UNCORR_ECC_LOG_VALID = 0x0 // .. .. ==> 0XF80060DC[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060DC, 0x00000001U ,0x00000000U), // .. .. STAT_NUM_CORR_ERR = 0x0 // .. .. ==> 0XF80060F0[15:8] = 0x00000000U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00000000U // .. .. STAT_NUM_UNCORR_ERR = 0x0 // .. .. ==> 0XF80060F0[7:0] = 0x00000000U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060F0, 0x0000FFFFU ,0x00000000U), // .. .. reg_ddrc_ecc_mode = 0x0 // .. .. ==> 0XF80060F4[2:0] = 0x00000000U // .. .. ==> MASK : 0x00000007U VAL : 0x00000000U // .. .. reg_ddrc_dis_scrub = 0x1 // .. .. ==> 0XF80060F4[3:3] = 0x00000001U // .. .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. .. EMIT_MASKWRITE(0XF80060F4, 0x0000000FU ,0x00000008U), // .. .. reg_phy_dif_on = 0x0 // .. .. ==> 0XF8006114[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_phy_dif_off = 0x0 // .. .. ==> 0XF8006114[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006114, 0x000000FFU ,0x00000000U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006118[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006118[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006118[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006118[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006118, 0x7FFFFFCFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF800611C[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF800611C[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF800611C[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF800611C[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF800611C, 0x7FFFFFCFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006120[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006120[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006120[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006120[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006120, 0x7FFFFFCFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006124[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006124[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006124[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006124[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006124, 0x7FFFFFCFU ,0x40000001U), // .. .. reg_phy_wrlvl_init_ratio = 0x3 // .. .. ==> 0XF800612C[9:0] = 0x00000003U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000003U // .. .. reg_phy_gatelvl_init_ratio = 0xcf // .. .. ==> 0XF800612C[19:10] = 0x000000CFU // .. .. ==> MASK : 0x000FFC00U VAL : 0x00033C00U // .. .. EMIT_MASKWRITE(0XF800612C, 0x000FFFFFU ,0x00033C03U), // .. .. reg_phy_wrlvl_init_ratio = 0x3 // .. .. ==> 0XF8006130[9:0] = 0x00000003U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000003U // .. .. reg_phy_gatelvl_init_ratio = 0xd0 // .. .. ==> 0XF8006130[19:10] = 0x000000D0U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00034000U // .. .. EMIT_MASKWRITE(0XF8006130, 0x000FFFFFU ,0x00034003U), // .. .. reg_phy_wrlvl_init_ratio = 0x0 // .. .. ==> 0XF8006134[9:0] = 0x00000000U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000000U // .. .. reg_phy_gatelvl_init_ratio = 0xbd // .. .. ==> 0XF8006134[19:10] = 0x000000BDU // .. .. ==> MASK : 0x000FFC00U VAL : 0x0002F400U // .. .. EMIT_MASKWRITE(0XF8006134, 0x000FFFFFU ,0x0002F400U), // .. .. reg_phy_wrlvl_init_ratio = 0x0 // .. .. ==> 0XF8006138[9:0] = 0x00000000U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000000U // .. .. reg_phy_gatelvl_init_ratio = 0xc1 // .. .. ==> 0XF8006138[19:10] = 0x000000C1U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00030400U // .. .. EMIT_MASKWRITE(0XF8006138, 0x000FFFFFU ,0x00030400U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006140[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006140[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006140[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006140, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006144[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006144[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006144[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006144, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006148[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006148[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006148[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006148, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF800614C[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF800614C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF800614C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800614C, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x83 // .. .. ==> 0XF8006154[9:0] = 0x00000083U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000083U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006154[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006154[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006154, 0x000FFFFFU ,0x00000083U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x83 // .. .. ==> 0XF8006158[9:0] = 0x00000083U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000083U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006158[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006158[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006158, 0x000FFFFFU ,0x00000083U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x7f // .. .. ==> 0XF800615C[9:0] = 0x0000007FU // .. .. ==> MASK : 0x000003FFU VAL : 0x0000007FU // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF800615C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF800615C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800615C, 0x000FFFFFU ,0x0000007FU), // .. .. reg_phy_wr_dqs_slave_ratio = 0x78 // .. .. ==> 0XF8006160[9:0] = 0x00000078U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000078U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006160[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006160[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006160, 0x000FFFFFU ,0x00000078U), // .. .. reg_phy_fifo_we_slave_ratio = 0x124 // .. .. ==> 0XF8006168[10:0] = 0x00000124U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000124U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006168[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006168[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006168, 0x001FFFFFU ,0x00000124U), // .. .. reg_phy_fifo_we_slave_ratio = 0x125 // .. .. ==> 0XF800616C[10:0] = 0x00000125U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000125U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF800616C[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF800616C[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800616C, 0x001FFFFFU ,0x00000125U), // .. .. reg_phy_fifo_we_slave_ratio = 0x112 // .. .. ==> 0XF8006170[10:0] = 0x00000112U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000112U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006170[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006170[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006170, 0x001FFFFFU ,0x00000112U), // .. .. reg_phy_fifo_we_slave_ratio = 0x116 // .. .. ==> 0XF8006174[10:0] = 0x00000116U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000116U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006174[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006174[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006174, 0x001FFFFFU ,0x00000116U), // .. .. reg_phy_wr_data_slave_ratio = 0xc3 // .. .. ==> 0XF800617C[9:0] = 0x000000C3U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000C3U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF800617C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF800617C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800617C, 0x000FFFFFU ,0x000000C3U), // .. .. reg_phy_wr_data_slave_ratio = 0xc3 // .. .. ==> 0XF8006180[9:0] = 0x000000C3U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000C3U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006180[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006180[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006180, 0x000FFFFFU ,0x000000C3U), // .. .. reg_phy_wr_data_slave_ratio = 0xbf // .. .. ==> 0XF8006184[9:0] = 0x000000BFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000000BFU // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006184[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006184[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006184, 0x000FFFFFU ,0x000000BFU), // .. .. reg_phy_wr_data_slave_ratio = 0xb8 // .. .. ==> 0XF8006188[9:0] = 0x000000B8U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000B8U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006188[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006188[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006188, 0x000FFFFFU ,0x000000B8U), // .. .. reg_phy_bl2 = 0x0 // .. .. ==> 0XF8006190[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_at_spd_atpg = 0x0 // .. .. ==> 0XF8006190[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_bist_enable = 0x0 // .. .. ==> 0XF8006190[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_force_err = 0x0 // .. .. ==> 0XF8006190[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_bist_mode = 0x0 // .. .. ==> 0XF8006190[6:5] = 0x00000000U // .. .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. .. reg_phy_invert_clkout = 0x1 // .. .. ==> 0XF8006190[7:7] = 0x00000001U // .. .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. .. reg_phy_sel_logic = 0x0 // .. .. ==> 0XF8006190[9:9] = 0x00000000U // .. .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_ratio = 0x100 // .. .. ==> 0XF8006190[19:10] = 0x00000100U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00040000U // .. .. reg_phy_ctrl_slave_force = 0x0 // .. .. ==> 0XF8006190[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_delay = 0x0 // .. .. ==> 0XF8006190[27:21] = 0x00000000U // .. .. ==> MASK : 0x0FE00000U VAL : 0x00000000U // .. .. reg_phy_lpddr = 0x0 // .. .. ==> 0XF8006190[29:29] = 0x00000000U // .. .. ==> MASK : 0x20000000U VAL : 0x00000000U // .. .. reg_phy_cmd_latency = 0x0 // .. .. ==> 0XF8006190[30:30] = 0x00000000U // .. .. ==> MASK : 0x40000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006190, 0x6FFFFEFEU ,0x00040080U), // .. .. reg_phy_wr_rl_delay = 0x2 // .. .. ==> 0XF8006194[4:0] = 0x00000002U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000002U // .. .. reg_phy_rd_rl_delay = 0x4 // .. .. ==> 0XF8006194[9:5] = 0x00000004U // .. .. ==> MASK : 0x000003E0U VAL : 0x00000080U // .. .. reg_phy_dll_lock_diff = 0xf // .. .. ==> 0XF8006194[13:10] = 0x0000000FU // .. .. ==> MASK : 0x00003C00U VAL : 0x00003C00U // .. .. reg_phy_use_wr_level = 0x1 // .. .. ==> 0XF8006194[14:14] = 0x00000001U // .. .. ==> MASK : 0x00004000U VAL : 0x00004000U // .. .. reg_phy_use_rd_dqs_gate_level = 0x1 // .. .. ==> 0XF8006194[15:15] = 0x00000001U // .. .. ==> MASK : 0x00008000U VAL : 0x00008000U // .. .. reg_phy_use_rd_data_eye_level = 0x1 // .. .. ==> 0XF8006194[16:16] = 0x00000001U // .. .. ==> MASK : 0x00010000U VAL : 0x00010000U // .. .. reg_phy_dis_calib_rst = 0x0 // .. .. ==> 0XF8006194[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_delay = 0x0 // .. .. ==> 0XF8006194[19:18] = 0x00000000U // .. .. ==> MASK : 0x000C0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006194, 0x000FFFFFU ,0x0001FC82U), // .. .. reg_arb_page_addr_mask = 0x0 // .. .. ==> 0XF8006204[31:0] = 0x00000000U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006204, 0xFFFFFFFFU ,0x00000000U), // .. .. reg_arb_pri_wr_portn = 0x3ff // .. .. ==> 0XF8006208[9:0] = 0x000003FFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000003FFU // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006208[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006208[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006208[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006208, 0x000703FFU ,0x000003FFU), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF800620C[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF800620C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF800620C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF800620C[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800620C, 0x000703FFU ,0x00000200U), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF8006210[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006210[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006210[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006210[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006210, 0x000703FFU ,0x00000200U), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF8006214[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006214[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006214[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006214[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006214, 0x000703FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x3ff // .. .. ==> 0XF8006218[9:0] = 0x000003FFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000003FFU // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006218[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006218[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006218[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x1 // .. .. ==> 0XF8006218[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006218, 0x000F03FFU ,0x000803FFU), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF800621C[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF800621C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF800621C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF800621C[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF800621C[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800621C, 0x000F03FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF8006220[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006220[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006220[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006220[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF8006220[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006220, 0x000F03FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF8006224[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006224[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006224[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006224[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF8006224[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006224, 0x000F03FFU ,0x00000200U), // .. .. reg_ddrc_lpddr2 = 0x0 // .. .. ==> 0XF80062A8[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_derate_enable = 0x0 // .. .. ==> 0XF80062A8[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_ddrc_mr4_margin = 0x0 // .. .. ==> 0XF80062A8[11:4] = 0x00000000U // .. .. ==> MASK : 0x00000FF0U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80062A8, 0x00000FF5U ,0x00000000U), // .. .. reg_ddrc_mr4_read_interval = 0x0 // .. .. ==> 0XF80062AC[31:0] = 0x00000000U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80062AC, 0xFFFFFFFFU ,0x00000000U), // .. .. reg_ddrc_min_stable_clock_x1 = 0x5 // .. .. ==> 0XF80062B0[3:0] = 0x00000005U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000005U // .. .. reg_ddrc_idle_after_reset_x32 = 0x12 // .. .. ==> 0XF80062B0[11:4] = 0x00000012U // .. .. ==> MASK : 0x00000FF0U VAL : 0x00000120U // .. .. reg_ddrc_t_mrw = 0x5 // .. .. ==> 0XF80062B0[21:12] = 0x00000005U // .. .. ==> MASK : 0x003FF000U VAL : 0x00005000U // .. .. EMIT_MASKWRITE(0XF80062B0, 0x003FFFFFU ,0x00005125U), // .. .. reg_ddrc_max_auto_init_x1024 = 0xa8 // .. .. ==> 0XF80062B4[7:0] = 0x000000A8U // .. .. ==> MASK : 0x000000FFU VAL : 0x000000A8U // .. .. reg_ddrc_dev_zqinit_x32 = 0x12 // .. .. ==> 0XF80062B4[17:8] = 0x00000012U // .. .. ==> MASK : 0x0003FF00U VAL : 0x00001200U // .. .. EMIT_MASKWRITE(0XF80062B4, 0x0003FFFFU ,0x000012A8U), // .. .. START: POLL ON DCI STATUS // .. .. DONE = 1 // .. .. ==> 0XF8000B74[13:13] = 0x00000001U // .. .. ==> MASK : 0x00002000U VAL : 0x00002000U // .. .. EMIT_MASKPOLL(0XF8000B74, 0x00002000U), // .. .. FINISH: POLL ON DCI STATUS // .. .. START: UNLOCK DDR // .. .. reg_ddrc_soft_rstb = 0x1 // .. .. ==> 0XF8006000[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_ddrc_powerdown_en = 0x0 // .. .. ==> 0XF8006000[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_data_bus_width = 0x0 // .. .. ==> 0XF8006000[3:2] = 0x00000000U // .. .. ==> MASK : 0x0000000CU VAL : 0x00000000U // .. .. reg_ddrc_burst8_refresh = 0x0 // .. .. ==> 0XF8006000[6:4] = 0x00000000U // .. .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. .. reg_ddrc_rdwr_idle_gap = 1 // .. .. ==> 0XF8006000[13:7] = 0x00000001U // .. .. ==> MASK : 0x00003F80U VAL : 0x00000080U // .. .. reg_ddrc_dis_rd_bypass = 0x0 // .. .. ==> 0XF8006000[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. reg_ddrc_dis_act_bypass = 0x0 // .. .. ==> 0XF8006000[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_ddrc_dis_auto_refresh = 0x0 // .. .. ==> 0XF8006000[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006000, 0x0001FFFFU ,0x00000081U), // .. .. FINISH: UNLOCK DDR // .. .. START: CHECK DDR STATUS // .. .. ddrc_reg_operating_mode = 1 // .. .. ==> 0XF8006054[2:0] = 0x00000001U // .. .. ==> MASK : 0x00000007U VAL : 0x00000001U // .. .. EMIT_MASKPOLL(0XF8006054, 0x00000007U), // .. .. FINISH: CHECK DDR STATUS // .. FINISH: DDR INITIALIZATION // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_mio_init_data_3_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: OCM REMAPPING // .. FINISH: OCM REMAPPING // .. START: DDRIOB SETTINGS // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B40[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B40[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B40[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B40[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCI_TYPE = 0x0 // .. ==> 0XF8000B40[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B40[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B40[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B40[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B40[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B40, 0x00000FFFU ,0x00000600U), // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B44[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B44[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B44[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B44[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCI_TYPE = 0x0 // .. ==> 0XF8000B44[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B44[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B44[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B44[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B44[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B44, 0x00000FFFU ,0x00000600U), // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B48[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x1 // .. ==> 0XF8000B48[2:1] = 0x00000001U // .. ==> MASK : 0x00000006U VAL : 0x00000002U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B48[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B48[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCI_TYPE = 0x3 // .. ==> 0XF8000B48[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B48[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B48[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B48[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B48[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B48, 0x00000FFFU ,0x00000672U), // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B4C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x1 // .. ==> 0XF8000B4C[2:1] = 0x00000001U // .. ==> MASK : 0x00000006U VAL : 0x00000002U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B4C[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B4C[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCI_TYPE = 0x3 // .. ==> 0XF8000B4C[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B4C[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B4C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B4C[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B4C[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B4C, 0x00000FFFU ,0x00000672U), // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B50[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x2 // .. ==> 0XF8000B50[2:1] = 0x00000002U // .. ==> MASK : 0x00000006U VAL : 0x00000004U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B50[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B50[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCI_TYPE = 0x3 // .. ==> 0XF8000B50[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B50[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B50[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B50[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B50[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B50, 0x00000FFFU ,0x00000674U), // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B54[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x2 // .. ==> 0XF8000B54[2:1] = 0x00000002U // .. ==> MASK : 0x00000006U VAL : 0x00000004U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B54[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B54[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCI_TYPE = 0x3 // .. ==> 0XF8000B54[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B54[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B54[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B54[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B54[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B54, 0x00000FFFU ,0x00000674U), // .. reserved_INP_POWER = 0x0 // .. ==> 0XF8000B58[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B58[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE_B = 0x0 // .. ==> 0XF8000B58[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B58[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCI_TYPE = 0x0 // .. ==> 0XF8000B58[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B58[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B58[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B58[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B58[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B58, 0x00000FFFU ,0x00000600U), // .. reserved_DRIVE_P = 0x1c // .. ==> 0XF8000B5C[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. reserved_DRIVE_N = 0xc // .. ==> 0XF8000B5C[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. reserved_SLEW_P = 0x3 // .. ==> 0XF8000B5C[18:14] = 0x00000003U // .. ==> MASK : 0x0007C000U VAL : 0x0000C000U // .. reserved_SLEW_N = 0x3 // .. ==> 0XF8000B5C[23:19] = 0x00000003U // .. ==> MASK : 0x00F80000U VAL : 0x00180000U // .. reserved_GTL = 0x0 // .. ==> 0XF8000B5C[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. reserved_RTERM = 0x0 // .. ==> 0XF8000B5C[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B5C, 0xFFFFFFFFU ,0x0018C61CU), // .. reserved_DRIVE_P = 0x1c // .. ==> 0XF8000B60[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. reserved_DRIVE_N = 0xc // .. ==> 0XF8000B60[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. reserved_SLEW_P = 0x6 // .. ==> 0XF8000B60[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. reserved_SLEW_N = 0x1f // .. ==> 0XF8000B60[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. reserved_GTL = 0x0 // .. ==> 0XF8000B60[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. reserved_RTERM = 0x0 // .. ==> 0XF8000B60[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B60, 0xFFFFFFFFU ,0x00F9861CU), // .. reserved_DRIVE_P = 0x1c // .. ==> 0XF8000B64[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. reserved_DRIVE_N = 0xc // .. ==> 0XF8000B64[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. reserved_SLEW_P = 0x6 // .. ==> 0XF8000B64[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. reserved_SLEW_N = 0x1f // .. ==> 0XF8000B64[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. reserved_GTL = 0x0 // .. ==> 0XF8000B64[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. reserved_RTERM = 0x0 // .. ==> 0XF8000B64[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B64, 0xFFFFFFFFU ,0x00F9861CU), // .. reserved_DRIVE_P = 0x1c // .. ==> 0XF8000B68[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. reserved_DRIVE_N = 0xc // .. ==> 0XF8000B68[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. reserved_SLEW_P = 0x6 // .. ==> 0XF8000B68[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. reserved_SLEW_N = 0x1f // .. ==> 0XF8000B68[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. reserved_GTL = 0x0 // .. ==> 0XF8000B68[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. reserved_RTERM = 0x0 // .. ==> 0XF8000B68[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B68, 0xFFFFFFFFU ,0x00F9861CU), // .. VREF_INT_EN = 0x1 // .. ==> 0XF8000B6C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. VREF_SEL = 0x4 // .. ==> 0XF8000B6C[4:1] = 0x00000004U // .. ==> MASK : 0x0000001EU VAL : 0x00000008U // .. VREF_EXT_EN = 0x0 // .. ==> 0XF8000B6C[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. reserved_VREF_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[8:7] = 0x00000000U // .. ==> MASK : 0x00000180U VAL : 0x00000000U // .. REFIO_EN = 0x1 // .. ==> 0XF8000B6C[9:9] = 0x00000001U // .. ==> MASK : 0x00000200U VAL : 0x00000200U // .. reserved_REFIO_TEST = 0x0 // .. ==> 0XF8000B6C[11:10] = 0x00000000U // .. ==> MASK : 0x00000C00U VAL : 0x00000000U // .. reserved_REFIO_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. reserved_DRST_B_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. reserved_CKE_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[14:14] = 0x00000000U // .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B6C, 0x00007FFFU ,0x00000209U), // .. .. START: ASSERT RESET // .. .. RESET = 1 // .. .. ==> 0XF8000B70[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x00000001U ,0x00000001U), // .. .. FINISH: ASSERT RESET // .. .. START: DEASSERT RESET // .. .. RESET = 0 // .. .. ==> 0XF8000B70[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reserved_VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x00000021U ,0x00000020U), // .. .. FINISH: DEASSERT RESET // .. .. RESET = 0x1 // .. .. ==> 0XF8000B70[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. ENABLE = 0x1 // .. .. ==> 0XF8000B70[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. reserved_VRP_TRI = 0x0 // .. .. ==> 0XF8000B70[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reserved_VRN_TRI = 0x0 // .. .. ==> 0XF8000B70[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reserved_VRP_OUT = 0x0 // .. .. ==> 0XF8000B70[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reserved_VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. NREF_OPT1 = 0x0 // .. .. ==> 0XF8000B70[7:6] = 0x00000000U // .. .. ==> MASK : 0x000000C0U VAL : 0x00000000U // .. .. NREF_OPT2 = 0x0 // .. .. ==> 0XF8000B70[10:8] = 0x00000000U // .. .. ==> MASK : 0x00000700U VAL : 0x00000000U // .. .. NREF_OPT4 = 0x1 // .. .. ==> 0XF8000B70[13:11] = 0x00000001U // .. .. ==> MASK : 0x00003800U VAL : 0x00000800U // .. .. PREF_OPT1 = 0x0 // .. .. ==> 0XF8000B70[15:14] = 0x00000000U // .. .. ==> MASK : 0x0000C000U VAL : 0x00000000U // .. .. PREF_OPT2 = 0x0 // .. .. ==> 0XF8000B70[19:17] = 0x00000000U // .. .. ==> MASK : 0x000E0000U VAL : 0x00000000U // .. .. UPDATE_CONTROL = 0x0 // .. .. ==> 0XF8000B70[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. reserved_INIT_COMPLETE = 0x0 // .. .. ==> 0XF8000B70[21:21] = 0x00000000U // .. .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. .. reserved_TST_CLK = 0x0 // .. .. ==> 0XF8000B70[22:22] = 0x00000000U // .. .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. .. reserved_TST_HLN = 0x0 // .. .. ==> 0XF8000B70[23:23] = 0x00000000U // .. .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. .. reserved_TST_HLP = 0x0 // .. .. ==> 0XF8000B70[24:24] = 0x00000000U // .. .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. .. reserved_TST_RST = 0x0 // .. .. ==> 0XF8000B70[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reserved_INT_DCI_EN = 0x0 // .. .. ==> 0XF8000B70[26:26] = 0x00000000U // .. .. ==> MASK : 0x04000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x07FEFFFFU ,0x00000823U), // .. FINISH: DDRIOB SETTINGS // .. START: MIO PROGRAMMING // .. TRI_ENABLE = 0 // .. ==> 0XF8000700[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000700[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000700[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000700[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000700[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000700[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000700[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000700[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000700[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000700, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000704[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000704[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000704[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000704[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000704[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000704[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000704[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000704[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000704[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000704, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000708[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000708[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000708[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000708[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000708[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000708[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000708[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000708[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000708[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000708, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF800070C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF800070C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800070C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800070C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800070C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800070C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF800070C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800070C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800070C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800070C, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000710[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000710[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000710[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000710[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000710[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000710[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000710[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000710[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000710[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000710, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000714[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000714[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000714[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000714[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000714[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000714[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000714[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000714[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000714[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000714, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000718[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000718[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000718[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000718[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000718[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000718[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000718[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000718[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000718[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000718, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF800071C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800071C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800071C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800071C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800071C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800071C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800071C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800071C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800071C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800071C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000720[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000720[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000720[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000720[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000720[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000720[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000720[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000720[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000720[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000720, 0x00003FFFU ,0x00000700U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000724[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000724[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000724[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000724[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000724[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000724[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000724[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000724[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000724[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000724, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000728[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000728[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000728[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000728[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000728[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000728[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000728[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000728[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000728[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000728, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF800072C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800072C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800072C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800072C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800072C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800072C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800072C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800072C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800072C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800072C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000730[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000730[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000730[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000730[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000730[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000730[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000730[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000730[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000730[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000730, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000734[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000734[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000734[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000734[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000734[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000734[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000734[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000734[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000734[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000734, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000738[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000738[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000738[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000738[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000738[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000738[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000738[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000738[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000738[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000738, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF800073C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800073C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800073C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800073C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800073C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800073C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800073C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800073C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800073C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800073C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000740[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000740[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000740[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000740[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000740[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000740[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000740[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000740[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000740[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000740, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000744[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000744[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000744[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000744[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000744[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000744[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000744[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000744[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000744[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000744, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000748[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000748[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000748[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000748[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000748[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000748[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000748[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000748[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000748[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000748, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF800074C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF800074C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800074C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800074C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800074C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800074C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800074C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800074C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800074C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800074C, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000750[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000750[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000750[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000750[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000750[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000750[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000750[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000750[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000750[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000750, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000754[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000754[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000754[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000754[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000754[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000754[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000754[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000754[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000754[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000754, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000758[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000758[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000758[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000758[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000758[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000758[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000758[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000758[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000758[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000758, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF800075C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF800075C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800075C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800075C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800075C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800075C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800075C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800075C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800075C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800075C, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000760[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000760[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000760[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000760[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000760[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000760[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000760[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000760[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000760[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000760, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000764[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000764[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000764[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000764[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000764[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000764[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000764[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000764[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000764[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000764, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000768[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000768[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000768[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000768[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000768[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000768[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000768[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000768[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000768[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000768, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF800076C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF800076C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800076C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800076C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800076C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800076C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800076C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800076C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800076C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800076C, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000770[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000770[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000770[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000770[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000770[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000770[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000770[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000770[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000770[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000770, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000774[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF8000774[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000774[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000774[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000774[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000774[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000774[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000774[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000774[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000774, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000778[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000778[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000778[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000778[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000778[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000778[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000778[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000778[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000778[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000778, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF800077C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF800077C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800077C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800077C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800077C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800077C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800077C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800077C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800077C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800077C, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000780[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000780[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000780[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000780[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000780[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000780[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000780[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000780[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000780[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000780, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000784[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000784[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000784[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000784[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000784[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000784[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000784[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000784[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000784[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000784, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000788[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000788[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000788[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000788[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000788[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000788[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000788[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000788[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000788[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000788, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF800078C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800078C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800078C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800078C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800078C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800078C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800078C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800078C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800078C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800078C, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000790[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF8000790[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000790[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000790[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000790[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000790[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000790[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000790[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000790[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000790, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000794[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000794[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000794[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000794[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000794[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000794[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000794[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000794[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000794[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000794, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000798[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000798[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000798[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000798[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000798[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000798[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000798[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000798[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000798[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000798, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF800079C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800079C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800079C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800079C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800079C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800079C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800079C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800079C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800079C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800079C, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A0[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A0, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A4[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A4, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A8[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A8[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A8[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A8[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A8[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A8[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A8, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007AC[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007AC[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007AC[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007AC[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007AC[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007AC[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007AC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007AC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007AC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007AC, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007B0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007B0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007B0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007B0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007B0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007B0[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007B0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B0, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007B4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007B4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007B4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007B4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007B4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007B4[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007B4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B4, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007B8[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. Speed = 0 // .. ==> 0XF80007B8[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007B8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B8, 0x00003F01U ,0x00000201U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007BC[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. Speed = 0 // .. ==> 0XF80007BC[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007BC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007BC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007BC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007BC, 0x00003F01U ,0x00000201U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007C0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007C0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 7 // .. ==> 0XF80007C0[7:5] = 0x00000007U // .. ==> MASK : 0x000000E0U VAL : 0x000000E0U // .. Speed = 0 // .. ==> 0XF80007C0[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C0, 0x00003FFFU ,0x000002E0U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007C4[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF80007C4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 7 // .. ==> 0XF80007C4[7:5] = 0x00000007U // .. ==> MASK : 0x000000E0U VAL : 0x000000E0U // .. Speed = 0 // .. ==> 0XF80007C4[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C4, 0x00003FFFU ,0x000002E1U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007C8[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007C8[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C8[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C8[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF80007C8[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF80007C8[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C8, 0x00003FFFU ,0x00000200U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007CC[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007CC[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007CC[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007CC[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF80007CC[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF80007CC[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007CC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007CC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007CC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007CC, 0x00003FFFU ,0x00000200U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007D0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007D0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007D0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007D0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007D0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 0 // .. ==> 0XF80007D0[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007D0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007D0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007D0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007D0, 0x00003FFFU ,0x00000280U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007D4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007D4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007D4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007D4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007D4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 0 // .. ==> 0XF80007D4[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007D4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007D4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007D4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007D4, 0x00003FFFU ,0x00000280U), // .. SDIO0_WP_SEL = 46 // .. ==> 0XF8000830[5:0] = 0x0000002EU // .. ==> MASK : 0x0000003FU VAL : 0x0000002EU // .. SDIO0_CD_SEL = 47 // .. ==> 0XF8000830[21:16] = 0x0000002FU // .. ==> MASK : 0x003F0000U VAL : 0x002F0000U // .. EMIT_MASKWRITE(0XF8000830, 0x003F003FU ,0x002F002EU), // .. FINISH: MIO PROGRAMMING // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_peripherals_init_data_3_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: DDR TERM/IBUF_DISABLE_MODE SETTINGS // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B48[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B48[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B48, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B4C[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B4C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B4C, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B50[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B50[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B50, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B54[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B54[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B54, 0x00000180U ,0x00000180U), // .. FINISH: DDR TERM/IBUF_DISABLE_MODE SETTINGS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // .. START: SRAM/NOR SET OPMODE // .. FINISH: SRAM/NOR SET OPMODE // .. START: UART REGISTERS // .. BDIV = 0x6 // .. ==> 0XE0001034[7:0] = 0x00000006U // .. ==> MASK : 0x000000FFU VAL : 0x00000006U // .. EMIT_MASKWRITE(0XE0001034, 0x000000FFU ,0x00000006U), // .. CD = 0x3e // .. ==> 0XE0001018[15:0] = 0x0000003EU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000003EU // .. EMIT_MASKWRITE(0XE0001018, 0x0000FFFFU ,0x0000003EU), // .. STPBRK = 0x0 // .. ==> 0XE0001000[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. STTBRK = 0x0 // .. ==> 0XE0001000[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. RSTTO = 0x0 // .. ==> 0XE0001000[6:6] = 0x00000000U // .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. TXDIS = 0x0 // .. ==> 0XE0001000[5:5] = 0x00000000U // .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. TXEN = 0x1 // .. ==> 0XE0001000[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. RXDIS = 0x0 // .. ==> 0XE0001000[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. RXEN = 0x1 // .. ==> 0XE0001000[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. TXRES = 0x1 // .. ==> 0XE0001000[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. RXRES = 0x1 // .. ==> 0XE0001000[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. EMIT_MASKWRITE(0XE0001000, 0x000001FFU ,0x00000017U), // .. CHMODE = 0x0 // .. ==> 0XE0001004[9:8] = 0x00000000U // .. ==> MASK : 0x00000300U VAL : 0x00000000U // .. NBSTOP = 0x0 // .. ==> 0XE0001004[7:6] = 0x00000000U // .. ==> MASK : 0x000000C0U VAL : 0x00000000U // .. PAR = 0x4 // .. ==> 0XE0001004[5:3] = 0x00000004U // .. ==> MASK : 0x00000038U VAL : 0x00000020U // .. CHRL = 0x0 // .. ==> 0XE0001004[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. CLKS = 0x0 // .. ==> 0XE0001004[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XE0001004, 0x000003FFU ,0x00000020U), // .. FINISH: UART REGISTERS // .. START: QSPI REGISTERS // .. Holdb_dr = 1 // .. ==> 0XE000D000[19:19] = 0x00000001U // .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. EMIT_MASKWRITE(0XE000D000, 0x00080000U ,0x00080000U), // .. FINISH: QSPI REGISTERS // .. START: PL POWER ON RESET REGISTERS // .. PCFG_POR_CNT_4K = 0 // .. ==> 0XF8007000[29:29] = 0x00000000U // .. ==> MASK : 0x20000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8007000, 0x20000000U ,0x00000000U), // .. FINISH: PL POWER ON RESET REGISTERS // .. START: SMC TIMING CALCULATION REGISTER UPDATE // .. .. START: NAND SET CYCLE // .. .. FINISH: NAND SET CYCLE // .. .. START: OPMODE // .. .. FINISH: OPMODE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: SRAM/NOR CS0 SET CYCLE // .. .. FINISH: SRAM/NOR CS0 SET CYCLE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: NOR CS0 BASE ADDRESS // .. .. FINISH: NOR CS0 BASE ADDRESS // .. .. START: SRAM/NOR CS1 SET CYCLE // .. .. FINISH: SRAM/NOR CS1 SET CYCLE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: NOR CS1 BASE ADDRESS // .. .. FINISH: NOR CS1 BASE ADDRESS // .. .. START: USB RESET // .. .. .. START: USB0 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: USB0 RESET // .. .. .. START: USB1 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: USB1 RESET // .. .. FINISH: USB RESET // .. .. START: ENET RESET // .. .. .. START: ENET0 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: ENET0 RESET // .. .. .. START: ENET1 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: ENET1 RESET // .. .. FINISH: ENET RESET // .. .. START: I2C RESET // .. .. .. START: I2C0 RESET // .. .. .. .. START: DIR MODE GPIO BANK0 // .. .. .. .. FINISH: DIR MODE GPIO BANK0 // .. .. .. .. START: DIR MODE GPIO BANK1 // .. .. .. .. FINISH: DIR MODE GPIO BANK1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: I2C0 RESET // .. .. .. START: I2C1 RESET // .. .. .. .. START: DIR MODE GPIO BANK0 // .. .. .. .. FINISH: DIR MODE GPIO BANK0 // .. .. .. .. START: DIR MODE GPIO BANK1 // .. .. .. .. FINISH: DIR MODE GPIO BANK1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: I2C1 RESET // .. .. FINISH: I2C RESET // .. .. START: NOR CHIP SELECT // .. .. .. START: DIR MODE BANK 0 // .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. FINISH: NOR CHIP SELECT // .. FINISH: SMC TIMING CALCULATION REGISTER UPDATE // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_post_config_3_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: ENABLING LEVEL SHIFTER // .. USER_LVL_INP_EN_0 = 1 // .. ==> 0XF8000900[3:3] = 0x00000001U // .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. USER_LVL_OUT_EN_0 = 1 // .. ==> 0XF8000900[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. USER_LVL_INP_EN_1 = 1 // .. ==> 0XF8000900[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. USER_LVL_OUT_EN_1 = 1 // .. ==> 0XF8000900[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. EMIT_MASKWRITE(0XF8000900, 0x0000000FU ,0x0000000FU), // .. FINISH: ENABLING LEVEL SHIFTER // .. START: FPGA RESETS TO 0 // .. reserved_3 = 0 // .. ==> 0XF8000240[31:25] = 0x00000000U // .. ==> MASK : 0xFE000000U VAL : 0x00000000U // .. reserved_FPGA_ACP_RST = 0 // .. ==> 0XF8000240[24:24] = 0x00000000U // .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. reserved_FPGA_AXDS3_RST = 0 // .. ==> 0XF8000240[23:23] = 0x00000000U // .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. reserved_FPGA_AXDS2_RST = 0 // .. ==> 0XF8000240[22:22] = 0x00000000U // .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. reserved_FPGA_AXDS1_RST = 0 // .. ==> 0XF8000240[21:21] = 0x00000000U // .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. reserved_FPGA_AXDS0_RST = 0 // .. ==> 0XF8000240[20:20] = 0x00000000U // .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. reserved_2 = 0 // .. ==> 0XF8000240[19:18] = 0x00000000U // .. ==> MASK : 0x000C0000U VAL : 0x00000000U // .. reserved_FSSW1_FPGA_RST = 0 // .. ==> 0XF8000240[17:17] = 0x00000000U // .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. reserved_FSSW0_FPGA_RST = 0 // .. ==> 0XF8000240[16:16] = 0x00000000U // .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. reserved_1 = 0 // .. ==> 0XF8000240[15:14] = 0x00000000U // .. ==> MASK : 0x0000C000U VAL : 0x00000000U // .. reserved_FPGA_FMSW1_RST = 0 // .. ==> 0XF8000240[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. reserved_FPGA_FMSW0_RST = 0 // .. ==> 0XF8000240[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. reserved_FPGA_DMA3_RST = 0 // .. ==> 0XF8000240[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. reserved_FPGA_DMA2_RST = 0 // .. ==> 0XF8000240[10:10] = 0x00000000U // .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. reserved_FPGA_DMA1_RST = 0 // .. ==> 0XF8000240[9:9] = 0x00000000U // .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. reserved_FPGA_DMA0_RST = 0 // .. ==> 0XF8000240[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. reserved = 0 // .. ==> 0XF8000240[7:4] = 0x00000000U // .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. FPGA3_OUT_RST = 0 // .. ==> 0XF8000240[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. FPGA2_OUT_RST = 0 // .. ==> 0XF8000240[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. FPGA1_OUT_RST = 0 // .. ==> 0XF8000240[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. FPGA0_OUT_RST = 0 // .. ==> 0XF8000240[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000240, 0xFFFFFFFFU ,0x00000000U), // .. FINISH: FPGA RESETS TO 0 // .. START: AFI REGISTERS // .. .. START: AFI0 REGISTERS // .. .. FINISH: AFI0 REGISTERS // .. .. START: AFI1 REGISTERS // .. .. FINISH: AFI1 REGISTERS // .. .. START: AFI2 REGISTERS // .. .. FINISH: AFI2 REGISTERS // .. .. START: AFI3 REGISTERS // .. .. FINISH: AFI3 REGISTERS // .. .. START: AFI2 SECURE REGISTER // .. .. FINISH: AFI2 SECURE REGISTER // .. FINISH: AFI REGISTERS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_debug_3_0[] = { // START: top // .. START: CROSS TRIGGER CONFIGURATIONS // .. .. START: UNLOCKING CTI REGISTERS // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8898FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8898FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8899FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8899FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8809FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8809FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. FINISH: UNLOCKING CTI REGISTERS // .. .. START: ENABLING CTI MODULES AND CHANNELS // .. .. FINISH: ENABLING CTI MODULES AND CHANNELS // .. .. START: MAPPING CPU0, CPU1 AND FTM EVENTS TO CTM CHANNELS // .. .. FINISH: MAPPING CPU0, CPU1 AND FTM EVENTS TO CTM CHANNELS // .. FINISH: CROSS TRIGGER CONFIGURATIONS // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_pll_init_data_2_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: PLL SLCR REGISTERS // .. .. START: ARM PLL INIT // .. .. PLL_RES = 0x2 // .. .. ==> 0XF8000110[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000110[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0xfa // .. .. ==> 0XF8000110[21:12] = 0x000000FAU // .. .. ==> MASK : 0x003FF000U VAL : 0x000FA000U // .. .. EMIT_MASKWRITE(0XF8000110, 0x003FFFF0U ,0x000FA220U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x28 // .. .. .. ==> 0XF8000100[18:12] = 0x00000028U // .. .. .. ==> MASK : 0x0007F000U VAL : 0x00028000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x0007F000U ,0x00028000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000100[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000100[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000100[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. ARM_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000001U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000100[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. .. SRCSEL = 0x0 // .. .. .. ==> 0XF8000120[5:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. .. DIVISOR = 0x2 // .. .. .. ==> 0XF8000120[13:8] = 0x00000002U // .. .. .. ==> MASK : 0x00003F00U VAL : 0x00000200U // .. .. .. CPU_6OR4XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[24:24] = 0x00000001U // .. .. .. ==> MASK : 0x01000000U VAL : 0x01000000U // .. .. .. CPU_3OR2XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[25:25] = 0x00000001U // .. .. .. ==> MASK : 0x02000000U VAL : 0x02000000U // .. .. .. CPU_2XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[26:26] = 0x00000001U // .. .. .. ==> MASK : 0x04000000U VAL : 0x04000000U // .. .. .. CPU_1XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[27:27] = 0x00000001U // .. .. .. ==> MASK : 0x08000000U VAL : 0x08000000U // .. .. .. CPU_PERI_CLKACT = 0x1 // .. .. .. ==> 0XF8000120[28:28] = 0x00000001U // .. .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. .. EMIT_MASKWRITE(0XF8000120, 0x1F003F30U ,0x1F000200U), // .. .. FINISH: ARM PLL INIT // .. .. START: DDR PLL INIT // .. .. PLL_RES = 0x2 // .. .. ==> 0XF8000114[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000114[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0x12c // .. .. ==> 0XF8000114[21:12] = 0x0000012CU // .. .. ==> MASK : 0x003FF000U VAL : 0x0012C000U // .. .. EMIT_MASKWRITE(0XF8000114, 0x003FFFF0U ,0x0012C220U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x20 // .. .. .. ==> 0XF8000104[18:12] = 0x00000020U // .. .. .. ==> MASK : 0x0007F000U VAL : 0x00020000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x0007F000U ,0x00020000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000104[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000104[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000104[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. DDR_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[1:1] = 0x00000001U // .. .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000002U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000104[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. .. DDR_3XCLKACT = 0x1 // .. .. .. ==> 0XF8000124[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. DDR_2XCLKACT = 0x1 // .. .. .. ==> 0XF8000124[1:1] = 0x00000001U // .. .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. .. DDR_3XCLK_DIVISOR = 0x2 // .. .. .. ==> 0XF8000124[25:20] = 0x00000002U // .. .. .. ==> MASK : 0x03F00000U VAL : 0x00200000U // .. .. .. DDR_2XCLK_DIVISOR = 0x3 // .. .. .. ==> 0XF8000124[31:26] = 0x00000003U // .. .. .. ==> MASK : 0xFC000000U VAL : 0x0C000000U // .. .. .. EMIT_MASKWRITE(0XF8000124, 0xFFF00003U ,0x0C200003U), // .. .. FINISH: DDR PLL INIT // .. .. START: IO PLL INIT // .. .. PLL_RES = 0xc // .. .. ==> 0XF8000118[7:4] = 0x0000000CU // .. .. ==> MASK : 0x000000F0U VAL : 0x000000C0U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000118[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0x145 // .. .. ==> 0XF8000118[21:12] = 0x00000145U // .. .. ==> MASK : 0x003FF000U VAL : 0x00145000U // .. .. EMIT_MASKWRITE(0XF8000118, 0x003FFFF0U ,0x001452C0U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x1e // .. .. .. ==> 0XF8000108[18:12] = 0x0000001EU // .. .. .. ==> MASK : 0x0007F000U VAL : 0x0001E000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x0007F000U ,0x0001E000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000108[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000108[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000108[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. IO_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[2:2] = 0x00000001U // .. .. .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000004U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000108[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. FINISH: IO PLL INIT // .. FINISH: PLL SLCR REGISTERS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_clock_init_data_2_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: CLOCK CONTROL SLCR REGISTERS // .. CLKACT = 0x1 // .. ==> 0XF8000128[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. DIVISOR0 = 0x23 // .. ==> 0XF8000128[13:8] = 0x00000023U // .. ==> MASK : 0x00003F00U VAL : 0x00002300U // .. DIVISOR1 = 0x3 // .. ==> 0XF8000128[25:20] = 0x00000003U // .. ==> MASK : 0x03F00000U VAL : 0x00300000U // .. EMIT_MASKWRITE(0XF8000128, 0x03F03F01U ,0x00302301U), // .. CLKACT = 0x1 // .. ==> 0XF8000138[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF8000138[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000138, 0x00000011U ,0x00000001U), // .. CLKACT = 0x1 // .. ==> 0XF8000140[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF8000140[6:4] = 0x00000000U // .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. DIVISOR = 0x8 // .. ==> 0XF8000140[13:8] = 0x00000008U // .. ==> MASK : 0x00003F00U VAL : 0x00000800U // .. DIVISOR1 = 0x1 // .. ==> 0XF8000140[25:20] = 0x00000001U // .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. EMIT_MASKWRITE(0XF8000140, 0x03F03F71U ,0x00100801U), // .. CLKACT = 0x1 // .. ==> 0XF800014C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF800014C[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x5 // .. ==> 0XF800014C[13:8] = 0x00000005U // .. ==> MASK : 0x00003F00U VAL : 0x00000500U // .. EMIT_MASKWRITE(0XF800014C, 0x00003F31U ,0x00000501U), // .. CLKACT0 = 0x1 // .. ==> 0XF8000150[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. CLKACT1 = 0x0 // .. ==> 0XF8000150[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. SRCSEL = 0x0 // .. ==> 0XF8000150[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x14 // .. ==> 0XF8000150[13:8] = 0x00000014U // .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. EMIT_MASKWRITE(0XF8000150, 0x00003F33U ,0x00001401U), // .. CLKACT0 = 0x0 // .. ==> 0XF8000154[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. CLKACT1 = 0x1 // .. ==> 0XF8000154[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. SRCSEL = 0x0 // .. ==> 0XF8000154[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x14 // .. ==> 0XF8000154[13:8] = 0x00000014U // .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. EMIT_MASKWRITE(0XF8000154, 0x00003F33U ,0x00001402U), // .. .. START: TRACE CLOCK // .. .. FINISH: TRACE CLOCK // .. .. CLKACT = 0x1 // .. .. ==> 0XF8000168[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000168[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR = 0x5 // .. .. ==> 0XF8000168[13:8] = 0x00000005U // .. .. ==> MASK : 0x00003F00U VAL : 0x00000500U // .. .. EMIT_MASKWRITE(0XF8000168, 0x00003F31U ,0x00000501U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000170[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0xa // .. .. ==> 0XF8000170[13:8] = 0x0000000AU // .. .. ==> MASK : 0x00003F00U VAL : 0x00000A00U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000170[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000170, 0x03F03F30U ,0x00100A00U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000180[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x7 // .. .. ==> 0XF8000180[13:8] = 0x00000007U // .. .. ==> MASK : 0x00003F00U VAL : 0x00000700U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000180[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000180, 0x03F03F30U ,0x00100700U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000190[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x14 // .. .. ==> 0XF8000190[13:8] = 0x00000014U // .. .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000190[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000190, 0x03F03F30U ,0x00101400U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF80001A0[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x14 // .. .. ==> 0XF80001A0[13:8] = 0x00000014U // .. .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF80001A0[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF80001A0, 0x03F03F30U ,0x00101400U), // .. .. CLK_621_TRUE = 0x1 // .. .. ==> 0XF80001C4[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. EMIT_MASKWRITE(0XF80001C4, 0x00000001U ,0x00000001U), // .. .. DMA_CPU_2XCLKACT = 0x1 // .. .. ==> 0XF800012C[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. USB0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[2:2] = 0x00000001U // .. .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. .. USB1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[3:3] = 0x00000001U // .. .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. .. GEM0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[6:6] = 0x00000001U // .. .. ==> MASK : 0x00000040U VAL : 0x00000040U // .. .. GEM1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. SDI0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[10:10] = 0x00000001U // .. .. ==> MASK : 0x00000400U VAL : 0x00000400U // .. .. SDI1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. SPI0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. SPI1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. CAN0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. CAN1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. I2C0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[18:18] = 0x00000001U // .. .. ==> MASK : 0x00040000U VAL : 0x00040000U // .. .. I2C1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. UART0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. UART1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[21:21] = 0x00000001U // .. .. ==> MASK : 0x00200000U VAL : 0x00200000U // .. .. GPIO_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[22:22] = 0x00000001U // .. .. ==> MASK : 0x00400000U VAL : 0x00400000U // .. .. LQSPI_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[23:23] = 0x00000001U // .. .. ==> MASK : 0x00800000U VAL : 0x00800000U // .. .. SMC_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[24:24] = 0x00000001U // .. .. ==> MASK : 0x01000000U VAL : 0x01000000U // .. .. EMIT_MASKWRITE(0XF800012C, 0x01FFCCCDU ,0x01EC044DU), // .. FINISH: CLOCK CONTROL SLCR REGISTERS // .. START: THIS SHOULD BE BLANK // .. FINISH: THIS SHOULD BE BLANK // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_ddr_init_data_2_0[] = { // START: top // .. START: DDR INITIALIZATION // .. .. START: LOCK DDR // .. .. reg_ddrc_soft_rstb = 0 // .. .. ==> 0XF8006000[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_powerdown_en = 0x0 // .. .. ==> 0XF8006000[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_data_bus_width = 0x0 // .. .. ==> 0XF8006000[3:2] = 0x00000000U // .. .. ==> MASK : 0x0000000CU VAL : 0x00000000U // .. .. reg_ddrc_burst8_refresh = 0x0 // .. .. ==> 0XF8006000[6:4] = 0x00000000U // .. .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. .. reg_ddrc_rdwr_idle_gap = 0x1 // .. .. ==> 0XF8006000[13:7] = 0x00000001U // .. .. ==> MASK : 0x00003F80U VAL : 0x00000080U // .. .. reg_ddrc_dis_rd_bypass = 0x0 // .. .. ==> 0XF8006000[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. reg_ddrc_dis_act_bypass = 0x0 // .. .. ==> 0XF8006000[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_ddrc_dis_auto_refresh = 0x0 // .. .. ==> 0XF8006000[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006000, 0x0001FFFFU ,0x00000080U), // .. .. FINISH: LOCK DDR // .. .. reg_ddrc_t_rfc_nom_x32 = 0x81 // .. .. ==> 0XF8006004[11:0] = 0x00000081U // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000081U // .. .. reg_ddrc_active_ranks = 0x1 // .. .. ==> 0XF8006004[13:12] = 0x00000001U // .. .. ==> MASK : 0x00003000U VAL : 0x00001000U // .. .. reg_ddrc_addrmap_cs_bit0 = 0x0 // .. .. ==> 0XF8006004[18:14] = 0x00000000U // .. .. ==> MASK : 0x0007C000U VAL : 0x00000000U // .. .. reg_ddrc_wr_odt_block = 0x1 // .. .. ==> 0XF8006004[20:19] = 0x00000001U // .. .. ==> MASK : 0x00180000U VAL : 0x00080000U // .. .. reg_ddrc_diff_rank_rd_2cycle_gap = 0x0 // .. .. ==> 0XF8006004[21:21] = 0x00000000U // .. .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_cs_bit1 = 0x0 // .. .. ==> 0XF8006004[26:22] = 0x00000000U // .. .. ==> MASK : 0x07C00000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_open_bank = 0x0 // .. .. ==> 0XF8006004[27:27] = 0x00000000U // .. .. ==> MASK : 0x08000000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_4bank_ram = 0x0 // .. .. ==> 0XF8006004[28:28] = 0x00000000U // .. .. ==> MASK : 0x10000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006004, 0x1FFFFFFFU ,0x00081081U), // .. .. reg_ddrc_hpr_min_non_critical_x32 = 0xf // .. .. ==> 0XF8006008[10:0] = 0x0000000FU // .. .. ==> MASK : 0x000007FFU VAL : 0x0000000FU // .. .. reg_ddrc_hpr_max_starve_x32 = 0xf // .. .. ==> 0XF8006008[21:11] = 0x0000000FU // .. .. ==> MASK : 0x003FF800U VAL : 0x00007800U // .. .. reg_ddrc_hpr_xact_run_length = 0xf // .. .. ==> 0XF8006008[25:22] = 0x0000000FU // .. .. ==> MASK : 0x03C00000U VAL : 0x03C00000U // .. .. EMIT_MASKWRITE(0XF8006008, 0x03FFFFFFU ,0x03C0780FU), // .. .. reg_ddrc_lpr_min_non_critical_x32 = 0x1 // .. .. ==> 0XF800600C[10:0] = 0x00000001U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000001U // .. .. reg_ddrc_lpr_max_starve_x32 = 0x2 // .. .. ==> 0XF800600C[21:11] = 0x00000002U // .. .. ==> MASK : 0x003FF800U VAL : 0x00001000U // .. .. reg_ddrc_lpr_xact_run_length = 0x8 // .. .. ==> 0XF800600C[25:22] = 0x00000008U // .. .. ==> MASK : 0x03C00000U VAL : 0x02000000U // .. .. EMIT_MASKWRITE(0XF800600C, 0x03FFFFFFU ,0x02001001U), // .. .. reg_ddrc_w_min_non_critical_x32 = 0x1 // .. .. ==> 0XF8006010[10:0] = 0x00000001U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000001U // .. .. reg_ddrc_w_xact_run_length = 0x8 // .. .. ==> 0XF8006010[14:11] = 0x00000008U // .. .. ==> MASK : 0x00007800U VAL : 0x00004000U // .. .. reg_ddrc_w_max_starve_x32 = 0x2 // .. .. ==> 0XF8006010[25:15] = 0x00000002U // .. .. ==> MASK : 0x03FF8000U VAL : 0x00010000U // .. .. EMIT_MASKWRITE(0XF8006010, 0x03FFFFFFU ,0x00014001U), // .. .. reg_ddrc_t_rc = 0x1b // .. .. ==> 0XF8006014[5:0] = 0x0000001BU // .. .. ==> MASK : 0x0000003FU VAL : 0x0000001BU // .. .. reg_ddrc_t_rfc_min = 0x56 // .. .. ==> 0XF8006014[13:6] = 0x00000056U // .. .. ==> MASK : 0x00003FC0U VAL : 0x00001580U // .. .. reg_ddrc_post_selfref_gap_x32 = 0x10 // .. .. ==> 0XF8006014[20:14] = 0x00000010U // .. .. ==> MASK : 0x001FC000U VAL : 0x00040000U // .. .. EMIT_MASKWRITE(0XF8006014, 0x001FFFFFU ,0x0004159BU), // .. .. reg_ddrc_wr2pre = 0x12 // .. .. ==> 0XF8006018[4:0] = 0x00000012U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000012U // .. .. reg_ddrc_powerdown_to_x32 = 0x6 // .. .. ==> 0XF8006018[9:5] = 0x00000006U // .. .. ==> MASK : 0x000003E0U VAL : 0x000000C0U // .. .. reg_ddrc_t_faw = 0x18 // .. .. ==> 0XF8006018[15:10] = 0x00000018U // .. .. ==> MASK : 0x0000FC00U VAL : 0x00006000U // .. .. reg_ddrc_t_ras_max = 0x24 // .. .. ==> 0XF8006018[21:16] = 0x00000024U // .. .. ==> MASK : 0x003F0000U VAL : 0x00240000U // .. .. reg_ddrc_t_ras_min = 0x14 // .. .. ==> 0XF8006018[26:22] = 0x00000014U // .. .. ==> MASK : 0x07C00000U VAL : 0x05000000U // .. .. reg_ddrc_t_cke = 0x4 // .. .. ==> 0XF8006018[31:28] = 0x00000004U // .. .. ==> MASK : 0xF0000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006018, 0xF7FFFFFFU ,0x452460D2U), // .. .. reg_ddrc_write_latency = 0x5 // .. .. ==> 0XF800601C[4:0] = 0x00000005U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000005U // .. .. reg_ddrc_rd2wr = 0x7 // .. .. ==> 0XF800601C[9:5] = 0x00000007U // .. .. ==> MASK : 0x000003E0U VAL : 0x000000E0U // .. .. reg_ddrc_wr2rd = 0xe // .. .. ==> 0XF800601C[14:10] = 0x0000000EU // .. .. ==> MASK : 0x00007C00U VAL : 0x00003800U // .. .. reg_ddrc_t_xp = 0x4 // .. .. ==> 0XF800601C[19:15] = 0x00000004U // .. .. ==> MASK : 0x000F8000U VAL : 0x00020000U // .. .. reg_ddrc_pad_pd = 0x0 // .. .. ==> 0XF800601C[22:20] = 0x00000000U // .. .. ==> MASK : 0x00700000U VAL : 0x00000000U // .. .. reg_ddrc_rd2pre = 0x4 // .. .. ==> 0XF800601C[27:23] = 0x00000004U // .. .. ==> MASK : 0x0F800000U VAL : 0x02000000U // .. .. reg_ddrc_t_rcd = 0x7 // .. .. ==> 0XF800601C[31:28] = 0x00000007U // .. .. ==> MASK : 0xF0000000U VAL : 0x70000000U // .. .. EMIT_MASKWRITE(0XF800601C, 0xFFFFFFFFU ,0x720238E5U), // .. .. reg_ddrc_t_ccd = 0x4 // .. .. ==> 0XF8006020[4:2] = 0x00000004U // .. .. ==> MASK : 0x0000001CU VAL : 0x00000010U // .. .. reg_ddrc_t_rrd = 0x6 // .. .. ==> 0XF8006020[7:5] = 0x00000006U // .. .. ==> MASK : 0x000000E0U VAL : 0x000000C0U // .. .. reg_ddrc_refresh_margin = 0x2 // .. .. ==> 0XF8006020[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. reg_ddrc_t_rp = 0x7 // .. .. ==> 0XF8006020[15:12] = 0x00000007U // .. .. ==> MASK : 0x0000F000U VAL : 0x00007000U // .. .. reg_ddrc_refresh_to_x32 = 0x8 // .. .. ==> 0XF8006020[20:16] = 0x00000008U // .. .. ==> MASK : 0x001F0000U VAL : 0x00080000U // .. .. reg_ddrc_sdram = 0x1 // .. .. ==> 0XF8006020[21:21] = 0x00000001U // .. .. ==> MASK : 0x00200000U VAL : 0x00200000U // .. .. reg_ddrc_mobile = 0x0 // .. .. ==> 0XF8006020[22:22] = 0x00000000U // .. .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. .. reg_ddrc_clock_stop_en = 0x0 // .. .. ==> 0XF8006020[23:23] = 0x00000000U // .. .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. .. reg_ddrc_read_latency = 0x7 // .. .. ==> 0XF8006020[28:24] = 0x00000007U // .. .. ==> MASK : 0x1F000000U VAL : 0x07000000U // .. .. reg_phy_mode_ddr1_ddr2 = 0x1 // .. .. ==> 0XF8006020[29:29] = 0x00000001U // .. .. ==> MASK : 0x20000000U VAL : 0x20000000U // .. .. reg_ddrc_dis_pad_pd = 0x0 // .. .. ==> 0XF8006020[30:30] = 0x00000000U // .. .. ==> MASK : 0x40000000U VAL : 0x00000000U // .. .. reg_ddrc_loopback = 0x0 // .. .. ==> 0XF8006020[31:31] = 0x00000000U // .. .. ==> MASK : 0x80000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006020, 0xFFFFFFFCU ,0x272872D0U), // .. .. reg_ddrc_en_2t_timing_mode = 0x0 // .. .. ==> 0XF8006024[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_prefer_write = 0x0 // .. .. ==> 0XF8006024[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_max_rank_rd = 0xf // .. .. ==> 0XF8006024[5:2] = 0x0000000FU // .. .. ==> MASK : 0x0000003CU VAL : 0x0000003CU // .. .. reg_ddrc_mr_wr = 0x0 // .. .. ==> 0XF8006024[6:6] = 0x00000000U // .. .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. .. reg_ddrc_mr_addr = 0x0 // .. .. ==> 0XF8006024[8:7] = 0x00000000U // .. .. ==> MASK : 0x00000180U VAL : 0x00000000U // .. .. reg_ddrc_mr_data = 0x0 // .. .. ==> 0XF8006024[24:9] = 0x00000000U // .. .. ==> MASK : 0x01FFFE00U VAL : 0x00000000U // .. .. ddrc_reg_mr_wr_busy = 0x0 // .. .. ==> 0XF8006024[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reg_ddrc_mr_type = 0x0 // .. .. ==> 0XF8006024[26:26] = 0x00000000U // .. .. ==> MASK : 0x04000000U VAL : 0x00000000U // .. .. reg_ddrc_mr_rdata_valid = 0x0 // .. .. ==> 0XF8006024[27:27] = 0x00000000U // .. .. ==> MASK : 0x08000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006024, 0x0FFFFFFFU ,0x0000003CU), // .. .. reg_ddrc_final_wait_x32 = 0x7 // .. .. ==> 0XF8006028[6:0] = 0x00000007U // .. .. ==> MASK : 0x0000007FU VAL : 0x00000007U // .. .. reg_ddrc_pre_ocd_x32 = 0x0 // .. .. ==> 0XF8006028[10:7] = 0x00000000U // .. .. ==> MASK : 0x00000780U VAL : 0x00000000U // .. .. reg_ddrc_t_mrd = 0x4 // .. .. ==> 0XF8006028[13:11] = 0x00000004U // .. .. ==> MASK : 0x00003800U VAL : 0x00002000U // .. .. EMIT_MASKWRITE(0XF8006028, 0x00003FFFU ,0x00002007U), // .. .. reg_ddrc_emr2 = 0x8 // .. .. ==> 0XF800602C[15:0] = 0x00000008U // .. .. ==> MASK : 0x0000FFFFU VAL : 0x00000008U // .. .. reg_ddrc_emr3 = 0x0 // .. .. ==> 0XF800602C[31:16] = 0x00000000U // .. .. ==> MASK : 0xFFFF0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800602C, 0xFFFFFFFFU ,0x00000008U), // .. .. reg_ddrc_mr = 0x930 // .. .. ==> 0XF8006030[15:0] = 0x00000930U // .. .. ==> MASK : 0x0000FFFFU VAL : 0x00000930U // .. .. reg_ddrc_emr = 0x4 // .. .. ==> 0XF8006030[31:16] = 0x00000004U // .. .. ==> MASK : 0xFFFF0000U VAL : 0x00040000U // .. .. EMIT_MASKWRITE(0XF8006030, 0xFFFFFFFFU ,0x00040930U), // .. .. reg_ddrc_burst_rdwr = 0x4 // .. .. ==> 0XF8006034[3:0] = 0x00000004U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000004U // .. .. reg_ddrc_pre_cke_x1024 = 0x16d // .. .. ==> 0XF8006034[13:4] = 0x0000016DU // .. .. ==> MASK : 0x00003FF0U VAL : 0x000016D0U // .. .. reg_ddrc_post_cke_x1024 = 0x1 // .. .. ==> 0XF8006034[25:16] = 0x00000001U // .. .. ==> MASK : 0x03FF0000U VAL : 0x00010000U // .. .. reg_ddrc_burstchop = 0x0 // .. .. ==> 0XF8006034[28:28] = 0x00000000U // .. .. ==> MASK : 0x10000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006034, 0x13FF3FFFU ,0x000116D4U), // .. .. reg_ddrc_force_low_pri_n = 1 // .. .. ==> 0XF8006038[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_ddrc_dis_dq = 0x0 // .. .. ==> 0XF8006038[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_debug_mode = 0x0 // .. .. ==> 0XF8006038[6:6] = 0x00000000U // .. .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. .. reg_phy_wr_level_start = 0x0 // .. .. ==> 0XF8006038[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. reg_phy_rd_level_start = 0x0 // .. .. ==> 0XF8006038[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_phy_dq0_wait_t = 0x0 // .. .. ==> 0XF8006038[12:9] = 0x00000000U // .. .. ==> MASK : 0x00001E00U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006038, 0x00001FC3U ,0x00000001U), // .. .. reg_ddrc_addrmap_bank_b0 = 0x7 // .. .. ==> 0XF800603C[3:0] = 0x00000007U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000007U // .. .. reg_ddrc_addrmap_bank_b1 = 0x7 // .. .. ==> 0XF800603C[7:4] = 0x00000007U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000070U // .. .. reg_ddrc_addrmap_bank_b2 = 0x7 // .. .. ==> 0XF800603C[11:8] = 0x00000007U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000700U // .. .. reg_ddrc_addrmap_col_b5 = 0x0 // .. .. ==> 0XF800603C[15:12] = 0x00000000U // .. .. ==> MASK : 0x0000F000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b6 = 0x0 // .. .. ==> 0XF800603C[19:16] = 0x00000000U // .. .. ==> MASK : 0x000F0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800603C, 0x000FFFFFU ,0x00000777U), // .. .. reg_ddrc_addrmap_col_b2 = 0x0 // .. .. ==> 0XF8006040[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b3 = 0x0 // .. .. ==> 0XF8006040[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b4 = 0x0 // .. .. ==> 0XF8006040[11:8] = 0x00000000U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b7 = 0x0 // .. .. ==> 0XF8006040[15:12] = 0x00000000U // .. .. ==> MASK : 0x0000F000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b8 = 0x0 // .. .. ==> 0XF8006040[19:16] = 0x00000000U // .. .. ==> MASK : 0x000F0000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b9 = 0xf // .. .. ==> 0XF8006040[23:20] = 0x0000000FU // .. .. ==> MASK : 0x00F00000U VAL : 0x00F00000U // .. .. reg_ddrc_addrmap_col_b10 = 0xf // .. .. ==> 0XF8006040[27:24] = 0x0000000FU // .. .. ==> MASK : 0x0F000000U VAL : 0x0F000000U // .. .. reg_ddrc_addrmap_col_b11 = 0xf // .. .. ==> 0XF8006040[31:28] = 0x0000000FU // .. .. ==> MASK : 0xF0000000U VAL : 0xF0000000U // .. .. EMIT_MASKWRITE(0XF8006040, 0xFFFFFFFFU ,0xFFF00000U), // .. .. reg_ddrc_addrmap_row_b0 = 0x6 // .. .. ==> 0XF8006044[3:0] = 0x00000006U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000006U // .. .. reg_ddrc_addrmap_row_b1 = 0x6 // .. .. ==> 0XF8006044[7:4] = 0x00000006U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000060U // .. .. reg_ddrc_addrmap_row_b2_11 = 0x6 // .. .. ==> 0XF8006044[11:8] = 0x00000006U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000600U // .. .. reg_ddrc_addrmap_row_b12 = 0x6 // .. .. ==> 0XF8006044[15:12] = 0x00000006U // .. .. ==> MASK : 0x0000F000U VAL : 0x00006000U // .. .. reg_ddrc_addrmap_row_b13 = 0x6 // .. .. ==> 0XF8006044[19:16] = 0x00000006U // .. .. ==> MASK : 0x000F0000U VAL : 0x00060000U // .. .. reg_ddrc_addrmap_row_b14 = 0xf // .. .. ==> 0XF8006044[23:20] = 0x0000000FU // .. .. ==> MASK : 0x00F00000U VAL : 0x00F00000U // .. .. reg_ddrc_addrmap_row_b15 = 0xf // .. .. ==> 0XF8006044[27:24] = 0x0000000FU // .. .. ==> MASK : 0x0F000000U VAL : 0x0F000000U // .. .. EMIT_MASKWRITE(0XF8006044, 0x0FFFFFFFU ,0x0FF66666U), // .. .. reg_ddrc_rank0_rd_odt = 0x0 // .. .. ==> 0XF8006048[2:0] = 0x00000000U // .. .. ==> MASK : 0x00000007U VAL : 0x00000000U // .. .. reg_ddrc_rank0_wr_odt = 0x1 // .. .. ==> 0XF8006048[5:3] = 0x00000001U // .. .. ==> MASK : 0x00000038U VAL : 0x00000008U // .. .. reg_ddrc_rank1_rd_odt = 0x1 // .. .. ==> 0XF8006048[8:6] = 0x00000001U // .. .. ==> MASK : 0x000001C0U VAL : 0x00000040U // .. .. reg_ddrc_rank1_wr_odt = 0x1 // .. .. ==> 0XF8006048[11:9] = 0x00000001U // .. .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. .. reg_phy_rd_local_odt = 0x0 // .. .. ==> 0XF8006048[13:12] = 0x00000000U // .. .. ==> MASK : 0x00003000U VAL : 0x00000000U // .. .. reg_phy_wr_local_odt = 0x3 // .. .. ==> 0XF8006048[15:14] = 0x00000003U // .. .. ==> MASK : 0x0000C000U VAL : 0x0000C000U // .. .. reg_phy_idle_local_odt = 0x3 // .. .. ==> 0XF8006048[17:16] = 0x00000003U // .. .. ==> MASK : 0x00030000U VAL : 0x00030000U // .. .. reg_ddrc_rank2_rd_odt = 0x0 // .. .. ==> 0XF8006048[20:18] = 0x00000000U // .. .. ==> MASK : 0x001C0000U VAL : 0x00000000U // .. .. reg_ddrc_rank2_wr_odt = 0x0 // .. .. ==> 0XF8006048[23:21] = 0x00000000U // .. .. ==> MASK : 0x00E00000U VAL : 0x00000000U // .. .. reg_ddrc_rank3_rd_odt = 0x0 // .. .. ==> 0XF8006048[26:24] = 0x00000000U // .. .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. .. reg_ddrc_rank3_wr_odt = 0x0 // .. .. ==> 0XF8006048[29:27] = 0x00000000U // .. .. ==> MASK : 0x38000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006048, 0x3FFFFFFFU ,0x0003C248U), // .. .. reg_phy_rd_cmd_to_data = 0x0 // .. .. ==> 0XF8006050[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_phy_wr_cmd_to_data = 0x0 // .. .. ==> 0XF8006050[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_phy_rdc_we_to_re_delay = 0x8 // .. .. ==> 0XF8006050[11:8] = 0x00000008U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000800U // .. .. reg_phy_rdc_fifo_rst_disable = 0x0 // .. .. ==> 0XF8006050[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_phy_use_fixed_re = 0x1 // .. .. ==> 0XF8006050[16:16] = 0x00000001U // .. .. ==> MASK : 0x00010000U VAL : 0x00010000U // .. .. reg_phy_rdc_fifo_rst_err_cnt_clr = 0x0 // .. .. ==> 0XF8006050[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_phy_dis_phy_ctrl_rstn = 0x0 // .. .. ==> 0XF8006050[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_phy_clk_stall_level = 0x0 // .. .. ==> 0XF8006050[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. reg_phy_gatelvl_num_of_dq0 = 0x7 // .. .. ==> 0XF8006050[27:24] = 0x00000007U // .. .. ==> MASK : 0x0F000000U VAL : 0x07000000U // .. .. reg_phy_wrlvl_num_of_dq0 = 0x7 // .. .. ==> 0XF8006050[31:28] = 0x00000007U // .. .. ==> MASK : 0xF0000000U VAL : 0x70000000U // .. .. EMIT_MASKWRITE(0XF8006050, 0xFF0F8FFFU ,0x77010800U), // .. .. reg_ddrc_dll_calib_to_min_x1024 = 0x1 // .. .. ==> 0XF8006058[7:0] = 0x00000001U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000001U // .. .. reg_ddrc_dll_calib_to_max_x1024 = 0x1 // .. .. ==> 0XF8006058[15:8] = 0x00000001U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00000100U // .. .. reg_ddrc_dis_dll_calib = 0x0 // .. .. ==> 0XF8006058[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006058, 0x0001FFFFU ,0x00000101U), // .. .. reg_ddrc_rd_odt_delay = 0x3 // .. .. ==> 0XF800605C[3:0] = 0x00000003U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000003U // .. .. reg_ddrc_wr_odt_delay = 0x0 // .. .. ==> 0XF800605C[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_ddrc_rd_odt_hold = 0x0 // .. .. ==> 0XF800605C[11:8] = 0x00000000U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000000U // .. .. reg_ddrc_wr_odt_hold = 0x5 // .. .. ==> 0XF800605C[15:12] = 0x00000005U // .. .. ==> MASK : 0x0000F000U VAL : 0x00005000U // .. .. EMIT_MASKWRITE(0XF800605C, 0x0000FFFFU ,0x00005003U), // .. .. reg_ddrc_pageclose = 0x0 // .. .. ==> 0XF8006060[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_lpr_num_entries = 0x7 // .. .. ==> 0XF8006060[6:1] = 0x00000007U // .. .. ==> MASK : 0x0000007EU VAL : 0x0000000EU // .. .. reg_ddrc_auto_pre_en = 0x0 // .. .. ==> 0XF8006060[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. reg_ddrc_refresh_update_level = 0x0 // .. .. ==> 0XF8006060[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_ddrc_dis_wc = 0x0 // .. .. ==> 0XF8006060[9:9] = 0x00000000U // .. .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. .. reg_ddrc_dis_collision_page_opt = 0x0 // .. .. ==> 0XF8006060[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_ddrc_selfref_en = 0x0 // .. .. ==> 0XF8006060[12:12] = 0x00000000U // .. .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006060, 0x000017FFU ,0x0000000EU), // .. .. reg_ddrc_go2critical_hysteresis = 0x0 // .. .. ==> 0XF8006064[12:5] = 0x00000000U // .. .. ==> MASK : 0x00001FE0U VAL : 0x00000000U // .. .. reg_arb_go2critical_en = 0x1 // .. .. ==> 0XF8006064[17:17] = 0x00000001U // .. .. ==> MASK : 0x00020000U VAL : 0x00020000U // .. .. EMIT_MASKWRITE(0XF8006064, 0x00021FE0U ,0x00020000U), // .. .. reg_ddrc_wrlvl_ww = 0x41 // .. .. ==> 0XF8006068[7:0] = 0x00000041U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000041U // .. .. reg_ddrc_rdlvl_rr = 0x41 // .. .. ==> 0XF8006068[15:8] = 0x00000041U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00004100U // .. .. reg_ddrc_dfi_t_wlmrd = 0x28 // .. .. ==> 0XF8006068[25:16] = 0x00000028U // .. .. ==> MASK : 0x03FF0000U VAL : 0x00280000U // .. .. EMIT_MASKWRITE(0XF8006068, 0x03FFFFFFU ,0x00284141U), // .. .. dfi_t_ctrlupd_interval_min_x1024 = 0x10 // .. .. ==> 0XF800606C[7:0] = 0x00000010U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000010U // .. .. dfi_t_ctrlupd_interval_max_x1024 = 0x16 // .. .. ==> 0XF800606C[15:8] = 0x00000016U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00001600U // .. .. EMIT_MASKWRITE(0XF800606C, 0x0000FFFFU ,0x00001610U), // .. .. reg_ddrc_dfi_t_ctrl_delay = 0x1 // .. .. ==> 0XF8006078[3:0] = 0x00000001U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000001U // .. .. reg_ddrc_dfi_t_dram_clk_disable = 0x1 // .. .. ==> 0XF8006078[7:4] = 0x00000001U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000010U // .. .. reg_ddrc_dfi_t_dram_clk_enable = 0x1 // .. .. ==> 0XF8006078[11:8] = 0x00000001U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000100U // .. .. reg_ddrc_t_cksre = 0x6 // .. .. ==> 0XF8006078[15:12] = 0x00000006U // .. .. ==> MASK : 0x0000F000U VAL : 0x00006000U // .. .. reg_ddrc_t_cksrx = 0x6 // .. .. ==> 0XF8006078[19:16] = 0x00000006U // .. .. ==> MASK : 0x000F0000U VAL : 0x00060000U // .. .. reg_ddrc_t_ckesr = 0x4 // .. .. ==> 0XF8006078[25:20] = 0x00000004U // .. .. ==> MASK : 0x03F00000U VAL : 0x00400000U // .. .. EMIT_MASKWRITE(0XF8006078, 0x03FFFFFFU ,0x00466111U), // .. .. reg_ddrc_t_ckpde = 0x2 // .. .. ==> 0XF800607C[3:0] = 0x00000002U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000002U // .. .. reg_ddrc_t_ckpdx = 0x2 // .. .. ==> 0XF800607C[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. reg_ddrc_t_ckdpde = 0x2 // .. .. ==> 0XF800607C[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. reg_ddrc_t_ckdpdx = 0x2 // .. .. ==> 0XF800607C[15:12] = 0x00000002U // .. .. ==> MASK : 0x0000F000U VAL : 0x00002000U // .. .. reg_ddrc_t_ckcsx = 0x3 // .. .. ==> 0XF800607C[19:16] = 0x00000003U // .. .. ==> MASK : 0x000F0000U VAL : 0x00030000U // .. .. EMIT_MASKWRITE(0XF800607C, 0x000FFFFFU ,0x00032222U), // .. .. refresh_timer0_start_value_x32 = 0x0 // .. .. ==> 0XF80060A0[11:0] = 0x00000000U // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000000U // .. .. refresh_timer1_start_value_x32 = 0x8 // .. .. ==> 0XF80060A0[23:12] = 0x00000008U // .. .. ==> MASK : 0x00FFF000U VAL : 0x00008000U // .. .. EMIT_MASKWRITE(0XF80060A0, 0x00FFFFFFU ,0x00008000U), // .. .. reg_ddrc_dis_auto_zq = 0x0 // .. .. ==> 0XF80060A4[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_ddr3 = 0x1 // .. .. ==> 0XF80060A4[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. reg_ddrc_t_mod = 0x200 // .. .. ==> 0XF80060A4[11:2] = 0x00000200U // .. .. ==> MASK : 0x00000FFCU VAL : 0x00000800U // .. .. reg_ddrc_t_zq_long_nop = 0x200 // .. .. ==> 0XF80060A4[21:12] = 0x00000200U // .. .. ==> MASK : 0x003FF000U VAL : 0x00200000U // .. .. reg_ddrc_t_zq_short_nop = 0x40 // .. .. ==> 0XF80060A4[31:22] = 0x00000040U // .. .. ==> MASK : 0xFFC00000U VAL : 0x10000000U // .. .. EMIT_MASKWRITE(0XF80060A4, 0xFFFFFFFFU ,0x10200802U), // .. .. t_zq_short_interval_x1024 = 0xcb73 // .. .. ==> 0XF80060A8[19:0] = 0x0000CB73U // .. .. ==> MASK : 0x000FFFFFU VAL : 0x0000CB73U // .. .. dram_rstn_x1024 = 0x69 // .. .. ==> 0XF80060A8[27:20] = 0x00000069U // .. .. ==> MASK : 0x0FF00000U VAL : 0x06900000U // .. .. EMIT_MASKWRITE(0XF80060A8, 0x0FFFFFFFU ,0x0690CB73U), // .. .. deeppowerdown_en = 0x0 // .. .. ==> 0XF80060AC[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. deeppowerdown_to_x1024 = 0xff // .. .. ==> 0XF80060AC[8:1] = 0x000000FFU // .. .. ==> MASK : 0x000001FEU VAL : 0x000001FEU // .. .. EMIT_MASKWRITE(0XF80060AC, 0x000001FFU ,0x000001FEU), // .. .. dfi_wrlvl_max_x1024 = 0xfff // .. .. ==> 0XF80060B0[11:0] = 0x00000FFFU // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000FFFU // .. .. dfi_rdlvl_max_x1024 = 0xfff // .. .. ==> 0XF80060B0[23:12] = 0x00000FFFU // .. .. ==> MASK : 0x00FFF000U VAL : 0x00FFF000U // .. .. ddrc_reg_twrlvl_max_error = 0x0 // .. .. ==> 0XF80060B0[24:24] = 0x00000000U // .. .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. .. ddrc_reg_trdlvl_max_error = 0x0 // .. .. ==> 0XF80060B0[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reg_ddrc_dfi_wr_level_en = 0x1 // .. .. ==> 0XF80060B0[26:26] = 0x00000001U // .. .. ==> MASK : 0x04000000U VAL : 0x04000000U // .. .. reg_ddrc_dfi_rd_dqs_gate_level = 0x1 // .. .. ==> 0XF80060B0[27:27] = 0x00000001U // .. .. ==> MASK : 0x08000000U VAL : 0x08000000U // .. .. reg_ddrc_dfi_rd_data_eye_train = 0x1 // .. .. ==> 0XF80060B0[28:28] = 0x00000001U // .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. EMIT_MASKWRITE(0XF80060B0, 0x1FFFFFFFU ,0x1CFFFFFFU), // .. .. reg_ddrc_2t_delay = 0x0 // .. .. ==> 0XF80060B4[8:0] = 0x00000000U // .. .. ==> MASK : 0x000001FFU VAL : 0x00000000U // .. .. reg_ddrc_skip_ocd = 0x1 // .. .. ==> 0XF80060B4[9:9] = 0x00000001U // .. .. ==> MASK : 0x00000200U VAL : 0x00000200U // .. .. reg_ddrc_dis_pre_bypass = 0x0 // .. .. ==> 0XF80060B4[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060B4, 0x000007FFU ,0x00000200U), // .. .. reg_ddrc_dfi_t_rddata_en = 0x6 // .. .. ==> 0XF80060B8[4:0] = 0x00000006U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000006U // .. .. reg_ddrc_dfi_t_ctrlup_min = 0x3 // .. .. ==> 0XF80060B8[14:5] = 0x00000003U // .. .. ==> MASK : 0x00007FE0U VAL : 0x00000060U // .. .. reg_ddrc_dfi_t_ctrlup_max = 0x40 // .. .. ==> 0XF80060B8[24:15] = 0x00000040U // .. .. ==> MASK : 0x01FF8000U VAL : 0x00200000U // .. .. EMIT_MASKWRITE(0XF80060B8, 0x01FFFFFFU ,0x00200066U), // .. .. START: RESET ECC ERROR // .. .. Clear_Uncorrectable_DRAM_ECC_error = 1 // .. .. ==> 0XF80060C4[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. Clear_Correctable_DRAM_ECC_error = 1 // .. .. ==> 0XF80060C4[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. EMIT_MASKWRITE(0XF80060C4, 0x00000003U ,0x00000003U), // .. .. FINISH: RESET ECC ERROR // .. .. Clear_Uncorrectable_DRAM_ECC_error = 0x0 // .. .. ==> 0XF80060C4[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. Clear_Correctable_DRAM_ECC_error = 0x0 // .. .. ==> 0XF80060C4[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060C4, 0x00000003U ,0x00000000U), // .. .. CORR_ECC_LOG_VALID = 0x0 // .. .. ==> 0XF80060C8[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. ECC_CORRECTED_BIT_NUM = 0x0 // .. .. ==> 0XF80060C8[7:1] = 0x00000000U // .. .. ==> MASK : 0x000000FEU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060C8, 0x000000FFU ,0x00000000U), // .. .. UNCORR_ECC_LOG_VALID = 0x0 // .. .. ==> 0XF80060DC[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060DC, 0x00000001U ,0x00000000U), // .. .. STAT_NUM_CORR_ERR = 0x0 // .. .. ==> 0XF80060F0[15:8] = 0x00000000U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00000000U // .. .. STAT_NUM_UNCORR_ERR = 0x0 // .. .. ==> 0XF80060F0[7:0] = 0x00000000U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060F0, 0x0000FFFFU ,0x00000000U), // .. .. reg_ddrc_ecc_mode = 0x0 // .. .. ==> 0XF80060F4[2:0] = 0x00000000U // .. .. ==> MASK : 0x00000007U VAL : 0x00000000U // .. .. reg_ddrc_dis_scrub = 0x1 // .. .. ==> 0XF80060F4[3:3] = 0x00000001U // .. .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. .. EMIT_MASKWRITE(0XF80060F4, 0x0000000FU ,0x00000008U), // .. .. reg_phy_dif_on = 0x0 // .. .. ==> 0XF8006114[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_phy_dif_off = 0x0 // .. .. ==> 0XF8006114[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006114, 0x000000FFU ,0x00000000U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006118[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006118[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006118[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006118[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006118[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006118[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006118, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF800611C[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF800611C[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF800611C[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF800611C[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF800611C[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF800611C[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF800611C, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006120[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006120[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006120[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006120[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006120[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006120[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006120[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006120[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006120[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006120[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006120[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006120[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006120, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006124[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006124[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006124[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006124[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006124[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006124[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006124, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_wrlvl_init_ratio = 0x3 // .. .. ==> 0XF800612C[9:0] = 0x00000003U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000003U // .. .. reg_phy_gatelvl_init_ratio = 0xcf // .. .. ==> 0XF800612C[19:10] = 0x000000CFU // .. .. ==> MASK : 0x000FFC00U VAL : 0x00033C00U // .. .. EMIT_MASKWRITE(0XF800612C, 0x000FFFFFU ,0x00033C03U), // .. .. reg_phy_wrlvl_init_ratio = 0x3 // .. .. ==> 0XF8006130[9:0] = 0x00000003U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000003U // .. .. reg_phy_gatelvl_init_ratio = 0xd0 // .. .. ==> 0XF8006130[19:10] = 0x000000D0U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00034000U // .. .. EMIT_MASKWRITE(0XF8006130, 0x000FFFFFU ,0x00034003U), // .. .. reg_phy_wrlvl_init_ratio = 0x0 // .. .. ==> 0XF8006134[9:0] = 0x00000000U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000000U // .. .. reg_phy_gatelvl_init_ratio = 0xbd // .. .. ==> 0XF8006134[19:10] = 0x000000BDU // .. .. ==> MASK : 0x000FFC00U VAL : 0x0002F400U // .. .. EMIT_MASKWRITE(0XF8006134, 0x000FFFFFU ,0x0002F400U), // .. .. reg_phy_wrlvl_init_ratio = 0x0 // .. .. ==> 0XF8006138[9:0] = 0x00000000U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000000U // .. .. reg_phy_gatelvl_init_ratio = 0xc1 // .. .. ==> 0XF8006138[19:10] = 0x000000C1U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00030400U // .. .. EMIT_MASKWRITE(0XF8006138, 0x000FFFFFU ,0x00030400U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006140[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006140[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006140[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006140, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006144[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006144[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006144[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006144, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006148[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006148[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006148[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006148, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF800614C[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF800614C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF800614C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800614C, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x83 // .. .. ==> 0XF8006154[9:0] = 0x00000083U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000083U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006154[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006154[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006154, 0x000FFFFFU ,0x00000083U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x83 // .. .. ==> 0XF8006158[9:0] = 0x00000083U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000083U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006158[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006158[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006158, 0x000FFFFFU ,0x00000083U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x7f // .. .. ==> 0XF800615C[9:0] = 0x0000007FU // .. .. ==> MASK : 0x000003FFU VAL : 0x0000007FU // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF800615C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF800615C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800615C, 0x000FFFFFU ,0x0000007FU), // .. .. reg_phy_wr_dqs_slave_ratio = 0x78 // .. .. ==> 0XF8006160[9:0] = 0x00000078U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000078U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006160[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006160[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006160, 0x000FFFFFU ,0x00000078U), // .. .. reg_phy_fifo_we_slave_ratio = 0x124 // .. .. ==> 0XF8006168[10:0] = 0x00000124U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000124U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006168[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006168[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006168, 0x001FFFFFU ,0x00000124U), // .. .. reg_phy_fifo_we_slave_ratio = 0x125 // .. .. ==> 0XF800616C[10:0] = 0x00000125U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000125U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF800616C[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF800616C[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800616C, 0x001FFFFFU ,0x00000125U), // .. .. reg_phy_fifo_we_slave_ratio = 0x112 // .. .. ==> 0XF8006170[10:0] = 0x00000112U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000112U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006170[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006170[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006170, 0x001FFFFFU ,0x00000112U), // .. .. reg_phy_fifo_we_slave_ratio = 0x116 // .. .. ==> 0XF8006174[10:0] = 0x00000116U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000116U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006174[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006174[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006174, 0x001FFFFFU ,0x00000116U), // .. .. reg_phy_wr_data_slave_ratio = 0xc3 // .. .. ==> 0XF800617C[9:0] = 0x000000C3U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000C3U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF800617C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF800617C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800617C, 0x000FFFFFU ,0x000000C3U), // .. .. reg_phy_wr_data_slave_ratio = 0xc3 // .. .. ==> 0XF8006180[9:0] = 0x000000C3U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000C3U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006180[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006180[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006180, 0x000FFFFFU ,0x000000C3U), // .. .. reg_phy_wr_data_slave_ratio = 0xbf // .. .. ==> 0XF8006184[9:0] = 0x000000BFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000000BFU // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006184[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006184[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006184, 0x000FFFFFU ,0x000000BFU), // .. .. reg_phy_wr_data_slave_ratio = 0xb8 // .. .. ==> 0XF8006188[9:0] = 0x000000B8U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000B8U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006188[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006188[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006188, 0x000FFFFFU ,0x000000B8U), // .. .. reg_phy_loopback = 0x0 // .. .. ==> 0XF8006190[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_phy_bl2 = 0x0 // .. .. ==> 0XF8006190[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_at_spd_atpg = 0x0 // .. .. ==> 0XF8006190[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_bist_enable = 0x0 // .. .. ==> 0XF8006190[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_force_err = 0x0 // .. .. ==> 0XF8006190[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_bist_mode = 0x0 // .. .. ==> 0XF8006190[6:5] = 0x00000000U // .. .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. .. reg_phy_invert_clkout = 0x1 // .. .. ==> 0XF8006190[7:7] = 0x00000001U // .. .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. .. reg_phy_all_dq_mpr_rd_resp = 0x0 // .. .. ==> 0XF8006190[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_phy_sel_logic = 0x0 // .. .. ==> 0XF8006190[9:9] = 0x00000000U // .. .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_ratio = 0x100 // .. .. ==> 0XF8006190[19:10] = 0x00000100U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00040000U // .. .. reg_phy_ctrl_slave_force = 0x0 // .. .. ==> 0XF8006190[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_delay = 0x0 // .. .. ==> 0XF8006190[27:21] = 0x00000000U // .. .. ==> MASK : 0x0FE00000U VAL : 0x00000000U // .. .. reg_phy_use_rank0_delays = 0x1 // .. .. ==> 0XF8006190[28:28] = 0x00000001U // .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. reg_phy_lpddr = 0x0 // .. .. ==> 0XF8006190[29:29] = 0x00000000U // .. .. ==> MASK : 0x20000000U VAL : 0x00000000U // .. .. reg_phy_cmd_latency = 0x0 // .. .. ==> 0XF8006190[30:30] = 0x00000000U // .. .. ==> MASK : 0x40000000U VAL : 0x00000000U // .. .. reg_phy_int_lpbk = 0x0 // .. .. ==> 0XF8006190[31:31] = 0x00000000U // .. .. ==> MASK : 0x80000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006190, 0xFFFFFFFFU ,0x10040080U), // .. .. reg_phy_wr_rl_delay = 0x2 // .. .. ==> 0XF8006194[4:0] = 0x00000002U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000002U // .. .. reg_phy_rd_rl_delay = 0x4 // .. .. ==> 0XF8006194[9:5] = 0x00000004U // .. .. ==> MASK : 0x000003E0U VAL : 0x00000080U // .. .. reg_phy_dll_lock_diff = 0xf // .. .. ==> 0XF8006194[13:10] = 0x0000000FU // .. .. ==> MASK : 0x00003C00U VAL : 0x00003C00U // .. .. reg_phy_use_wr_level = 0x1 // .. .. ==> 0XF8006194[14:14] = 0x00000001U // .. .. ==> MASK : 0x00004000U VAL : 0x00004000U // .. .. reg_phy_use_rd_dqs_gate_level = 0x1 // .. .. ==> 0XF8006194[15:15] = 0x00000001U // .. .. ==> MASK : 0x00008000U VAL : 0x00008000U // .. .. reg_phy_use_rd_data_eye_level = 0x1 // .. .. ==> 0XF8006194[16:16] = 0x00000001U // .. .. ==> MASK : 0x00010000U VAL : 0x00010000U // .. .. reg_phy_dis_calib_rst = 0x0 // .. .. ==> 0XF8006194[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_delay = 0x0 // .. .. ==> 0XF8006194[19:18] = 0x00000000U // .. .. ==> MASK : 0x000C0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006194, 0x000FFFFFU ,0x0001FC82U), // .. .. reg_arb_page_addr_mask = 0x0 // .. .. ==> 0XF8006204[31:0] = 0x00000000U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006204, 0xFFFFFFFFU ,0x00000000U), // .. .. reg_arb_pri_wr_portn = 0x3ff // .. .. ==> 0XF8006208[9:0] = 0x000003FFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000003FFU // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006208[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006208[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006208[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF8006208[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006208, 0x000F03FFU ,0x000803FFU), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF800620C[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF800620C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF800620C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF800620C[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF800620C[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF800620C, 0x000F03FFU ,0x00080200U), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF8006210[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006210[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006210[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006210[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF8006210[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006210, 0x000F03FFU ,0x00080200U), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF8006214[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006214[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006214[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006214[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF8006214[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006214, 0x000F03FFU ,0x00080200U), // .. .. reg_arb_pri_rd_portn = 0x3ff // .. .. ==> 0XF8006218[9:0] = 0x000003FFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000003FFU // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006218[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006218[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006218[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x1 // .. .. ==> 0XF8006218[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006218, 0x000F03FFU ,0x000803FFU), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF800621C[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF800621C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF800621C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF800621C[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF800621C[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800621C, 0x000F03FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF8006220[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006220[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006220[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006220[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF8006220[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006220, 0x000F03FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF8006224[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006224[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006224[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006224[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF8006224[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006224, 0x000F03FFU ,0x00000200U), // .. .. reg_ddrc_lpddr2 = 0x0 // .. .. ==> 0XF80062A8[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_per_bank_refresh = 0x0 // .. .. ==> 0XF80062A8[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_derate_enable = 0x0 // .. .. ==> 0XF80062A8[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_ddrc_mr4_margin = 0x0 // .. .. ==> 0XF80062A8[11:4] = 0x00000000U // .. .. ==> MASK : 0x00000FF0U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80062A8, 0x00000FF7U ,0x00000000U), // .. .. reg_ddrc_mr4_read_interval = 0x0 // .. .. ==> 0XF80062AC[31:0] = 0x00000000U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80062AC, 0xFFFFFFFFU ,0x00000000U), // .. .. reg_ddrc_min_stable_clock_x1 = 0x5 // .. .. ==> 0XF80062B0[3:0] = 0x00000005U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000005U // .. .. reg_ddrc_idle_after_reset_x32 = 0x12 // .. .. ==> 0XF80062B0[11:4] = 0x00000012U // .. .. ==> MASK : 0x00000FF0U VAL : 0x00000120U // .. .. reg_ddrc_t_mrw = 0x5 // .. .. ==> 0XF80062B0[21:12] = 0x00000005U // .. .. ==> MASK : 0x003FF000U VAL : 0x00005000U // .. .. EMIT_MASKWRITE(0XF80062B0, 0x003FFFFFU ,0x00005125U), // .. .. reg_ddrc_max_auto_init_x1024 = 0xa8 // .. .. ==> 0XF80062B4[7:0] = 0x000000A8U // .. .. ==> MASK : 0x000000FFU VAL : 0x000000A8U // .. .. reg_ddrc_dev_zqinit_x32 = 0x12 // .. .. ==> 0XF80062B4[17:8] = 0x00000012U // .. .. ==> MASK : 0x0003FF00U VAL : 0x00001200U // .. .. EMIT_MASKWRITE(0XF80062B4, 0x0003FFFFU ,0x000012A8U), // .. .. START: POLL ON DCI STATUS // .. .. DONE = 1 // .. .. ==> 0XF8000B74[13:13] = 0x00000001U // .. .. ==> MASK : 0x00002000U VAL : 0x00002000U // .. .. EMIT_MASKPOLL(0XF8000B74, 0x00002000U), // .. .. FINISH: POLL ON DCI STATUS // .. .. START: UNLOCK DDR // .. .. reg_ddrc_soft_rstb = 0x1 // .. .. ==> 0XF8006000[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_ddrc_powerdown_en = 0x0 // .. .. ==> 0XF8006000[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_data_bus_width = 0x0 // .. .. ==> 0XF8006000[3:2] = 0x00000000U // .. .. ==> MASK : 0x0000000CU VAL : 0x00000000U // .. .. reg_ddrc_burst8_refresh = 0x0 // .. .. ==> 0XF8006000[6:4] = 0x00000000U // .. .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. .. reg_ddrc_rdwr_idle_gap = 1 // .. .. ==> 0XF8006000[13:7] = 0x00000001U // .. .. ==> MASK : 0x00003F80U VAL : 0x00000080U // .. .. reg_ddrc_dis_rd_bypass = 0x0 // .. .. ==> 0XF8006000[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. reg_ddrc_dis_act_bypass = 0x0 // .. .. ==> 0XF8006000[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_ddrc_dis_auto_refresh = 0x0 // .. .. ==> 0XF8006000[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006000, 0x0001FFFFU ,0x00000081U), // .. .. FINISH: UNLOCK DDR // .. .. START: CHECK DDR STATUS // .. .. ddrc_reg_operating_mode = 1 // .. .. ==> 0XF8006054[2:0] = 0x00000001U // .. .. ==> MASK : 0x00000007U VAL : 0x00000001U // .. .. EMIT_MASKPOLL(0XF8006054, 0x00000007U), // .. .. FINISH: CHECK DDR STATUS // .. FINISH: DDR INITIALIZATION // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_mio_init_data_2_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: OCM REMAPPING // .. FINISH: OCM REMAPPING // .. START: DDRIOB SETTINGS // .. INP_POWER = 0x0 // .. ==> 0XF8000B40[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B40[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B40[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B40[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCR_TYPE = 0x0 // .. ==> 0XF8000B40[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B40[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B40[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B40[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B40[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B40, 0x00000FFFU ,0x00000600U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B44[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B44[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B44[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B44[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCR_TYPE = 0x0 // .. ==> 0XF8000B44[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B44[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B44[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B44[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B44[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B44, 0x00000FFFU ,0x00000600U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B48[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x1 // .. ==> 0XF8000B48[2:1] = 0x00000001U // .. ==> MASK : 0x00000006U VAL : 0x00000002U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B48[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B48[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B48[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B48[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B48[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B48[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B48[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B48, 0x00000FFFU ,0x00000672U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B4C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x1 // .. ==> 0XF8000B4C[2:1] = 0x00000001U // .. ==> MASK : 0x00000006U VAL : 0x00000002U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B4C[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B4C[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B4C[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B4C[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B4C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B4C[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B4C[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B4C, 0x00000FFFU ,0x00000672U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B50[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x2 // .. ==> 0XF8000B50[2:1] = 0x00000002U // .. ==> MASK : 0x00000006U VAL : 0x00000004U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B50[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B50[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B50[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B50[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B50[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B50[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B50[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B50, 0x00000FFFU ,0x00000674U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B54[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x2 // .. ==> 0XF8000B54[2:1] = 0x00000002U // .. ==> MASK : 0x00000006U VAL : 0x00000004U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B54[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B54[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B54[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B54[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B54[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B54[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B54[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B54, 0x00000FFFU ,0x00000674U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B58[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B58[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B58[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B58[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCR_TYPE = 0x0 // .. ==> 0XF8000B58[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B58[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B58[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B58[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B58[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B58, 0x00000FFFU ,0x00000600U), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B5C[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B5C[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x3 // .. ==> 0XF8000B5C[18:14] = 0x00000003U // .. ==> MASK : 0x0007C000U VAL : 0x0000C000U // .. SLEW_N = 0x3 // .. ==> 0XF8000B5C[23:19] = 0x00000003U // .. ==> MASK : 0x00F80000U VAL : 0x00180000U // .. GTL = 0x0 // .. ==> 0XF8000B5C[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B5C[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B5C, 0xFFFFFFFFU ,0x0018C61CU), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B60[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B60[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x6 // .. ==> 0XF8000B60[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. SLEW_N = 0x1f // .. ==> 0XF8000B60[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. GTL = 0x0 // .. ==> 0XF8000B60[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B60[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B60, 0xFFFFFFFFU ,0x00F9861CU), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B64[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B64[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x6 // .. ==> 0XF8000B64[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. SLEW_N = 0x1f // .. ==> 0XF8000B64[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. GTL = 0x0 // .. ==> 0XF8000B64[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B64[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B64, 0xFFFFFFFFU ,0x00F9861CU), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B68[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B68[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x6 // .. ==> 0XF8000B68[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. SLEW_N = 0x1f // .. ==> 0XF8000B68[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. GTL = 0x0 // .. ==> 0XF8000B68[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B68[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B68, 0xFFFFFFFFU ,0x00F9861CU), // .. VREF_INT_EN = 0x1 // .. ==> 0XF8000B6C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. VREF_SEL = 0x4 // .. ==> 0XF8000B6C[4:1] = 0x00000004U // .. ==> MASK : 0x0000001EU VAL : 0x00000008U // .. VREF_EXT_EN = 0x0 // .. ==> 0XF8000B6C[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. VREF_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[8:7] = 0x00000000U // .. ==> MASK : 0x00000180U VAL : 0x00000000U // .. REFIO_EN = 0x1 // .. ==> 0XF8000B6C[9:9] = 0x00000001U // .. ==> MASK : 0x00000200U VAL : 0x00000200U // .. REFIO_TEST = 0x0 // .. ==> 0XF8000B6C[11:10] = 0x00000000U // .. ==> MASK : 0x00000C00U VAL : 0x00000000U // .. REFIO_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DRST_B_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. CKE_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[14:14] = 0x00000000U // .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B6C, 0x00007FFFU ,0x00000209U), // .. .. START: ASSERT RESET // .. .. RESET = 1 // .. .. ==> 0XF8000B70[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x00000021U ,0x00000021U), // .. .. FINISH: ASSERT RESET // .. .. START: DEASSERT RESET // .. .. RESET = 0 // .. .. ==> 0XF8000B70[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x00000021U ,0x00000020U), // .. .. FINISH: DEASSERT RESET // .. .. RESET = 0x1 // .. .. ==> 0XF8000B70[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. ENABLE = 0x1 // .. .. ==> 0XF8000B70[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. VRP_TRI = 0x0 // .. .. ==> 0XF8000B70[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. VRN_TRI = 0x0 // .. .. ==> 0XF8000B70[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. VRP_OUT = 0x0 // .. .. ==> 0XF8000B70[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. NREF_OPT1 = 0x0 // .. .. ==> 0XF8000B70[7:6] = 0x00000000U // .. .. ==> MASK : 0x000000C0U VAL : 0x00000000U // .. .. NREF_OPT2 = 0x0 // .. .. ==> 0XF8000B70[10:8] = 0x00000000U // .. .. ==> MASK : 0x00000700U VAL : 0x00000000U // .. .. NREF_OPT4 = 0x1 // .. .. ==> 0XF8000B70[13:11] = 0x00000001U // .. .. ==> MASK : 0x00003800U VAL : 0x00000800U // .. .. PREF_OPT1 = 0x0 // .. .. ==> 0XF8000B70[16:14] = 0x00000000U // .. .. ==> MASK : 0x0001C000U VAL : 0x00000000U // .. .. PREF_OPT2 = 0x0 // .. .. ==> 0XF8000B70[19:17] = 0x00000000U // .. .. ==> MASK : 0x000E0000U VAL : 0x00000000U // .. .. UPDATE_CONTROL = 0x0 // .. .. ==> 0XF8000B70[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. INIT_COMPLETE = 0x0 // .. .. ==> 0XF8000B70[21:21] = 0x00000000U // .. .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. .. TST_CLK = 0x0 // .. .. ==> 0XF8000B70[22:22] = 0x00000000U // .. .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. .. TST_HLN = 0x0 // .. .. ==> 0XF8000B70[23:23] = 0x00000000U // .. .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. .. TST_HLP = 0x0 // .. .. ==> 0XF8000B70[24:24] = 0x00000000U // .. .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. .. TST_RST = 0x0 // .. .. ==> 0XF8000B70[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. INT_DCI_EN = 0x0 // .. .. ==> 0XF8000B70[26:26] = 0x00000000U // .. .. ==> MASK : 0x04000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x07FFFFFFU ,0x00000823U), // .. FINISH: DDRIOB SETTINGS // .. START: MIO PROGRAMMING // .. TRI_ENABLE = 0 // .. ==> 0XF8000700[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000700[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000700[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000700[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000700[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000700[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000700[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000700[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000700[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000700, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000704[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000704[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000704[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000704[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000704[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000704[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000704[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000704[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000704[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000704, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000708[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000708[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000708[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000708[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000708[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000708[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000708[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000708[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000708[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000708, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF800070C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF800070C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800070C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800070C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800070C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800070C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF800070C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800070C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800070C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800070C, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000710[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000710[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000710[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000710[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000710[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000710[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000710[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000710[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000710[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000710, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000714[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000714[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000714[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000714[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000714[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000714[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000714[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000714[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000714[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000714, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000718[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000718[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000718[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000718[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000718[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000718[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000718[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000718[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000718[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000718, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF800071C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800071C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800071C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800071C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800071C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800071C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800071C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800071C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800071C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800071C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000720[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000720[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000720[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000720[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000720[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000720[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000720[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000720[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000720[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000720, 0x00003FFFU ,0x00000700U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000724[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000724[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000724[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000724[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000724[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000724[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000724[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000724[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000724[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000724, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000728[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000728[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000728[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000728[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000728[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000728[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000728[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000728[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000728[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000728, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF800072C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800072C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800072C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800072C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800072C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800072C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800072C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800072C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800072C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800072C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000730[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000730[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000730[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000730[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000730[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000730[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000730[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000730[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000730[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000730, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000734[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000734[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000734[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000734[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000734[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000734[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000734[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000734[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000734[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000734, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000738[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000738[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000738[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000738[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000738[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000738[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000738[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000738[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000738[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000738, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF800073C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800073C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800073C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800073C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800073C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800073C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800073C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800073C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800073C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800073C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000740[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000740[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000740[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000740[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000740[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000740[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000740[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000740[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000740[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000740, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000744[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000744[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000744[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000744[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000744[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000744[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000744[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000744[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000744[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000744, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000748[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000748[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000748[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000748[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000748[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000748[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000748[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000748[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000748[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000748, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF800074C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF800074C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800074C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800074C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800074C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800074C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800074C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800074C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800074C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800074C, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000750[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000750[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000750[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000750[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000750[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000750[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000750[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000750[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000750[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000750, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000754[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000754[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000754[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000754[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000754[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000754[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000754[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000754[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000754[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000754, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000758[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000758[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000758[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000758[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000758[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000758[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000758[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000758[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000758[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000758, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF800075C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF800075C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800075C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800075C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800075C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800075C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800075C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800075C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800075C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800075C, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000760[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000760[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000760[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000760[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000760[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000760[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000760[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000760[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000760[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000760, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000764[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000764[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000764[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000764[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000764[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000764[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000764[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000764[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000764[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000764, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000768[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000768[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000768[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000768[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000768[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000768[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000768[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000768[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000768[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000768, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF800076C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF800076C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800076C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800076C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800076C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800076C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800076C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800076C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800076C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800076C, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000770[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000770[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000770[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000770[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000770[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000770[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000770[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000770[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000770[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000770, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000774[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF8000774[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000774[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000774[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000774[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000774[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000774[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000774[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000774[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000774, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000778[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000778[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000778[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000778[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000778[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000778[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000778[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000778[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000778[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000778, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF800077C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF800077C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800077C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800077C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800077C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800077C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800077C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800077C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800077C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800077C, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000780[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000780[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000780[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000780[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000780[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000780[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000780[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000780[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000780[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000780, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000784[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000784[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000784[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000784[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000784[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000784[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000784[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000784[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000784[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000784, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000788[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000788[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000788[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000788[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000788[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000788[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000788[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000788[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000788[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000788, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF800078C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800078C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800078C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800078C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800078C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800078C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800078C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800078C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800078C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800078C, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000790[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF8000790[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000790[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000790[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000790[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000790[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000790[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000790[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000790[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000790, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000794[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000794[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000794[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000794[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000794[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000794[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000794[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000794[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000794[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000794, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000798[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000798[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000798[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000798[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000798[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000798[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000798[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000798[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000798[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000798, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF800079C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800079C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800079C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800079C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800079C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800079C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800079C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800079C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800079C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800079C, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A0[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A0, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A4[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A4, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A8[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A8[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A8[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A8[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A8[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A8[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A8, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007AC[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007AC[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007AC[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007AC[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007AC[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007AC[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007AC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007AC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007AC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007AC, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007B0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007B0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007B0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007B0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007B0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007B0[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007B0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B0, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007B4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007B4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007B4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007B4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007B4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007B4[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007B4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B4, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007B8[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. Speed = 0 // .. ==> 0XF80007B8[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007B8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B8, 0x00003F01U ,0x00000201U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007BC[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. Speed = 0 // .. ==> 0XF80007BC[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007BC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007BC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007BC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007BC, 0x00003F01U ,0x00000201U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007C0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007C0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 7 // .. ==> 0XF80007C0[7:5] = 0x00000007U // .. ==> MASK : 0x000000E0U VAL : 0x000000E0U // .. Speed = 0 // .. ==> 0XF80007C0[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C0, 0x00003FFFU ,0x000002E0U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007C4[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF80007C4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 7 // .. ==> 0XF80007C4[7:5] = 0x00000007U // .. ==> MASK : 0x000000E0U VAL : 0x000000E0U // .. Speed = 0 // .. ==> 0XF80007C4[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C4, 0x00003FFFU ,0x000002E1U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007C8[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007C8[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C8[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C8[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF80007C8[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF80007C8[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C8, 0x00003FFFU ,0x00000200U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007CC[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007CC[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007CC[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007CC[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF80007CC[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF80007CC[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007CC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007CC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007CC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007CC, 0x00003FFFU ,0x00000200U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007D0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007D0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007D0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007D0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007D0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 0 // .. ==> 0XF80007D0[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007D0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007D0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007D0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007D0, 0x00003FFFU ,0x00000280U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007D4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007D4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007D4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007D4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007D4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 0 // .. ==> 0XF80007D4[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007D4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007D4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007D4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007D4, 0x00003FFFU ,0x00000280U), // .. SDIO0_WP_SEL = 46 // .. ==> 0XF8000830[5:0] = 0x0000002EU // .. ==> MASK : 0x0000003FU VAL : 0x0000002EU // .. SDIO0_CD_SEL = 47 // .. ==> 0XF8000830[21:16] = 0x0000002FU // .. ==> MASK : 0x003F0000U VAL : 0x002F0000U // .. EMIT_MASKWRITE(0XF8000830, 0x003F003FU ,0x002F002EU), // .. FINISH: MIO PROGRAMMING // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_peripherals_init_data_2_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: DDR TERM/IBUF_DISABLE_MODE SETTINGS // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B48[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B48[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B48, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B4C[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B4C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B4C, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B50[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B50[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B50, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B54[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B54[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B54, 0x00000180U ,0x00000180U), // .. FINISH: DDR TERM/IBUF_DISABLE_MODE SETTINGS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // .. START: SRAM/NOR SET OPMODE // .. FINISH: SRAM/NOR SET OPMODE // .. START: UART REGISTERS // .. BDIV = 0x6 // .. ==> 0XE0001034[7:0] = 0x00000006U // .. ==> MASK : 0x000000FFU VAL : 0x00000006U // .. EMIT_MASKWRITE(0XE0001034, 0x000000FFU ,0x00000006U), // .. CD = 0x3e // .. ==> 0XE0001018[15:0] = 0x0000003EU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000003EU // .. EMIT_MASKWRITE(0XE0001018, 0x0000FFFFU ,0x0000003EU), // .. STPBRK = 0x0 // .. ==> 0XE0001000[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. STTBRK = 0x0 // .. ==> 0XE0001000[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. RSTTO = 0x0 // .. ==> 0XE0001000[6:6] = 0x00000000U // .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. TXDIS = 0x0 // .. ==> 0XE0001000[5:5] = 0x00000000U // .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. TXEN = 0x1 // .. ==> 0XE0001000[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. RXDIS = 0x0 // .. ==> 0XE0001000[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. RXEN = 0x1 // .. ==> 0XE0001000[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. TXRES = 0x1 // .. ==> 0XE0001000[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. RXRES = 0x1 // .. ==> 0XE0001000[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. EMIT_MASKWRITE(0XE0001000, 0x000001FFU ,0x00000017U), // .. IRMODE = 0x0 // .. ==> 0XE0001004[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. UCLKEN = 0x0 // .. ==> 0XE0001004[10:10] = 0x00000000U // .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. CHMODE = 0x0 // .. ==> 0XE0001004[9:8] = 0x00000000U // .. ==> MASK : 0x00000300U VAL : 0x00000000U // .. NBSTOP = 0x0 // .. ==> 0XE0001004[7:6] = 0x00000000U // .. ==> MASK : 0x000000C0U VAL : 0x00000000U // .. PAR = 0x4 // .. ==> 0XE0001004[5:3] = 0x00000004U // .. ==> MASK : 0x00000038U VAL : 0x00000020U // .. CHRL = 0x0 // .. ==> 0XE0001004[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. CLKS = 0x0 // .. ==> 0XE0001004[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XE0001004, 0x00000FFFU ,0x00000020U), // .. FINISH: UART REGISTERS // .. START: QSPI REGISTERS // .. Holdb_dr = 1 // .. ==> 0XE000D000[19:19] = 0x00000001U // .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. EMIT_MASKWRITE(0XE000D000, 0x00080000U ,0x00080000U), // .. FINISH: QSPI REGISTERS // .. START: PL POWER ON RESET REGISTERS // .. PCFG_POR_CNT_4K = 0 // .. ==> 0XF8007000[29:29] = 0x00000000U // .. ==> MASK : 0x20000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8007000, 0x20000000U ,0x00000000U), // .. FINISH: PL POWER ON RESET REGISTERS // .. START: SMC TIMING CALCULATION REGISTER UPDATE // .. .. START: NAND SET CYCLE // .. .. FINISH: NAND SET CYCLE // .. .. START: OPMODE // .. .. FINISH: OPMODE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: SRAM/NOR CS0 SET CYCLE // .. .. FINISH: SRAM/NOR CS0 SET CYCLE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: NOR CS0 BASE ADDRESS // .. .. FINISH: NOR CS0 BASE ADDRESS // .. .. START: SRAM/NOR CS1 SET CYCLE // .. .. FINISH: SRAM/NOR CS1 SET CYCLE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: NOR CS1 BASE ADDRESS // .. .. FINISH: NOR CS1 BASE ADDRESS // .. .. START: USB RESET // .. .. .. START: USB0 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: USB0 RESET // .. .. .. START: USB1 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: USB1 RESET // .. .. FINISH: USB RESET // .. .. START: ENET RESET // .. .. .. START: ENET0 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: ENET0 RESET // .. .. .. START: ENET1 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: ENET1 RESET // .. .. FINISH: ENET RESET // .. .. START: I2C RESET // .. .. .. START: I2C0 RESET // .. .. .. .. START: DIR MODE GPIO BANK0 // .. .. .. .. FINISH: DIR MODE GPIO BANK0 // .. .. .. .. START: DIR MODE GPIO BANK1 // .. .. .. .. FINISH: DIR MODE GPIO BANK1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: I2C0 RESET // .. .. .. START: I2C1 RESET // .. .. .. .. START: DIR MODE GPIO BANK0 // .. .. .. .. FINISH: DIR MODE GPIO BANK0 // .. .. .. .. START: DIR MODE GPIO BANK1 // .. .. .. .. FINISH: DIR MODE GPIO BANK1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: I2C1 RESET // .. .. FINISH: I2C RESET // .. .. START: NOR CHIP SELECT // .. .. .. START: DIR MODE BANK 0 // .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. FINISH: NOR CHIP SELECT // .. FINISH: SMC TIMING CALCULATION REGISTER UPDATE // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_post_config_2_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: ENABLING LEVEL SHIFTER // .. USER_INP_ICT_EN_0 = 3 // .. ==> 0XF8000900[1:0] = 0x00000003U // .. ==> MASK : 0x00000003U VAL : 0x00000003U // .. USER_INP_ICT_EN_1 = 3 // .. ==> 0XF8000900[3:2] = 0x00000003U // .. ==> MASK : 0x0000000CU VAL : 0x0000000CU // .. EMIT_MASKWRITE(0XF8000900, 0x0000000FU ,0x0000000FU), // .. FINISH: ENABLING LEVEL SHIFTER // .. START: FPGA RESETS TO 0 // .. reserved_3 = 0 // .. ==> 0XF8000240[31:25] = 0x00000000U // .. ==> MASK : 0xFE000000U VAL : 0x00000000U // .. FPGA_ACP_RST = 0 // .. ==> 0XF8000240[24:24] = 0x00000000U // .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. FPGA_AXDS3_RST = 0 // .. ==> 0XF8000240[23:23] = 0x00000000U // .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. FPGA_AXDS2_RST = 0 // .. ==> 0XF8000240[22:22] = 0x00000000U // .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. FPGA_AXDS1_RST = 0 // .. ==> 0XF8000240[21:21] = 0x00000000U // .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. FPGA_AXDS0_RST = 0 // .. ==> 0XF8000240[20:20] = 0x00000000U // .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. reserved_2 = 0 // .. ==> 0XF8000240[19:18] = 0x00000000U // .. ==> MASK : 0x000C0000U VAL : 0x00000000U // .. FSSW1_FPGA_RST = 0 // .. ==> 0XF8000240[17:17] = 0x00000000U // .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. FSSW0_FPGA_RST = 0 // .. ==> 0XF8000240[16:16] = 0x00000000U // .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. reserved_1 = 0 // .. ==> 0XF8000240[15:14] = 0x00000000U // .. ==> MASK : 0x0000C000U VAL : 0x00000000U // .. FPGA_FMSW1_RST = 0 // .. ==> 0XF8000240[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. FPGA_FMSW0_RST = 0 // .. ==> 0XF8000240[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. FPGA_DMA3_RST = 0 // .. ==> 0XF8000240[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. FPGA_DMA2_RST = 0 // .. ==> 0XF8000240[10:10] = 0x00000000U // .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. FPGA_DMA1_RST = 0 // .. ==> 0XF8000240[9:9] = 0x00000000U // .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. FPGA_DMA0_RST = 0 // .. ==> 0XF8000240[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. reserved = 0 // .. ==> 0XF8000240[7:4] = 0x00000000U // .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. FPGA3_OUT_RST = 0 // .. ==> 0XF8000240[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. FPGA2_OUT_RST = 0 // .. ==> 0XF8000240[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. FPGA1_OUT_RST = 0 // .. ==> 0XF8000240[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. FPGA0_OUT_RST = 0 // .. ==> 0XF8000240[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000240, 0xFFFFFFFFU ,0x00000000U), // .. FINISH: FPGA RESETS TO 0 // .. START: AFI REGISTERS // .. .. START: AFI0 REGISTERS // .. .. FINISH: AFI0 REGISTERS // .. .. START: AFI1 REGISTERS // .. .. FINISH: AFI1 REGISTERS // .. .. START: AFI2 REGISTERS // .. .. FINISH: AFI2 REGISTERS // .. .. START: AFI3 REGISTERS // .. .. FINISH: AFI3 REGISTERS // .. FINISH: AFI REGISTERS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_debug_2_0[] = { // START: top // .. START: CROSS TRIGGER CONFIGURATIONS // .. .. START: UNLOCKING CTI REGISTERS // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8898FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8898FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8899FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8899FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8809FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8809FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. FINISH: UNLOCKING CTI REGISTERS // .. .. START: ENABLING CTI MODULES AND CHANNELS // .. .. FINISH: ENABLING CTI MODULES AND CHANNELS // .. .. START: MAPPING CPU0, CPU1 AND FTM EVENTS TO CTM CHANNELS // .. .. FINISH: MAPPING CPU0, CPU1 AND FTM EVENTS TO CTM CHANNELS // .. FINISH: CROSS TRIGGER CONFIGURATIONS // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_pll_init_data_1_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: PLL SLCR REGISTERS // .. .. START: ARM PLL INIT // .. .. PLL_RES = 0x2 // .. .. ==> 0XF8000110[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000110[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0xfa // .. .. ==> 0XF8000110[21:12] = 0x000000FAU // .. .. ==> MASK : 0x003FF000U VAL : 0x000FA000U // .. .. EMIT_MASKWRITE(0XF8000110, 0x003FFFF0U ,0x000FA220U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x28 // .. .. .. ==> 0XF8000100[18:12] = 0x00000028U // .. .. .. ==> MASK : 0x0007F000U VAL : 0x00028000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x0007F000U ,0x00028000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000100[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000100[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000100[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. ARM_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000001U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000100[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000100, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. .. SRCSEL = 0x0 // .. .. .. ==> 0XF8000120[5:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. .. DIVISOR = 0x2 // .. .. .. ==> 0XF8000120[13:8] = 0x00000002U // .. .. .. ==> MASK : 0x00003F00U VAL : 0x00000200U // .. .. .. CPU_6OR4XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[24:24] = 0x00000001U // .. .. .. ==> MASK : 0x01000000U VAL : 0x01000000U // .. .. .. CPU_3OR2XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[25:25] = 0x00000001U // .. .. .. ==> MASK : 0x02000000U VAL : 0x02000000U // .. .. .. CPU_2XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[26:26] = 0x00000001U // .. .. .. ==> MASK : 0x04000000U VAL : 0x04000000U // .. .. .. CPU_1XCLKACT = 0x1 // .. .. .. ==> 0XF8000120[27:27] = 0x00000001U // .. .. .. ==> MASK : 0x08000000U VAL : 0x08000000U // .. .. .. CPU_PERI_CLKACT = 0x1 // .. .. .. ==> 0XF8000120[28:28] = 0x00000001U // .. .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. .. EMIT_MASKWRITE(0XF8000120, 0x1F003F30U ,0x1F000200U), // .. .. FINISH: ARM PLL INIT // .. .. START: DDR PLL INIT // .. .. PLL_RES = 0x2 // .. .. ==> 0XF8000114[7:4] = 0x00000002U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000020U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000114[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0x12c // .. .. ==> 0XF8000114[21:12] = 0x0000012CU // .. .. ==> MASK : 0x003FF000U VAL : 0x0012C000U // .. .. EMIT_MASKWRITE(0XF8000114, 0x003FFFF0U ,0x0012C220U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x20 // .. .. .. ==> 0XF8000104[18:12] = 0x00000020U // .. .. .. ==> MASK : 0x0007F000U VAL : 0x00020000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x0007F000U ,0x00020000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000104[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000104[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000104[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. DDR_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[1:1] = 0x00000001U // .. .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000002U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000104[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000104, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. .. DDR_3XCLKACT = 0x1 // .. .. .. ==> 0XF8000124[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. DDR_2XCLKACT = 0x1 // .. .. .. ==> 0XF8000124[1:1] = 0x00000001U // .. .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. .. DDR_3XCLK_DIVISOR = 0x2 // .. .. .. ==> 0XF8000124[25:20] = 0x00000002U // .. .. .. ==> MASK : 0x03F00000U VAL : 0x00200000U // .. .. .. DDR_2XCLK_DIVISOR = 0x3 // .. .. .. ==> 0XF8000124[31:26] = 0x00000003U // .. .. .. ==> MASK : 0xFC000000U VAL : 0x0C000000U // .. .. .. EMIT_MASKWRITE(0XF8000124, 0xFFF00003U ,0x0C200003U), // .. .. FINISH: DDR PLL INIT // .. .. START: IO PLL INIT // .. .. PLL_RES = 0xc // .. .. ==> 0XF8000118[7:4] = 0x0000000CU // .. .. ==> MASK : 0x000000F0U VAL : 0x000000C0U // .. .. PLL_CP = 0x2 // .. .. ==> 0XF8000118[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. LOCK_CNT = 0x145 // .. .. ==> 0XF8000118[21:12] = 0x00000145U // .. .. ==> MASK : 0x003FF000U VAL : 0x00145000U // .. .. EMIT_MASKWRITE(0XF8000118, 0x003FFFF0U ,0x001452C0U), // .. .. .. START: UPDATE FB_DIV // .. .. .. PLL_FDIV = 0x1e // .. .. .. ==> 0XF8000108[18:12] = 0x0000001EU // .. .. .. ==> MASK : 0x0007F000U VAL : 0x0001E000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x0007F000U ,0x0001E000U), // .. .. .. FINISH: UPDATE FB_DIV // .. .. .. START: BY PASS PLL // .. .. .. PLL_BYPASS_FORCE = 1 // .. .. .. ==> 0XF8000108[4:4] = 0x00000001U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000010U ,0x00000010U), // .. .. .. FINISH: BY PASS PLL // .. .. .. START: ASSERT RESET // .. .. .. PLL_RESET = 1 // .. .. .. ==> 0XF8000108[0:0] = 0x00000001U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000001U ,0x00000001U), // .. .. .. FINISH: ASSERT RESET // .. .. .. START: DEASSERT RESET // .. .. .. PLL_RESET = 0 // .. .. .. ==> 0XF8000108[0:0] = 0x00000000U // .. .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000001U ,0x00000000U), // .. .. .. FINISH: DEASSERT RESET // .. .. .. START: CHECK PLL STATUS // .. .. .. IO_PLL_LOCK = 1 // .. .. .. ==> 0XF800010C[2:2] = 0x00000001U // .. .. .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. .. .. EMIT_MASKPOLL(0XF800010C, 0x00000004U), // .. .. .. FINISH: CHECK PLL STATUS // .. .. .. START: REMOVE PLL BY PASS // .. .. .. PLL_BYPASS_FORCE = 0 // .. .. .. ==> 0XF8000108[4:4] = 0x00000000U // .. .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. .. EMIT_MASKWRITE(0XF8000108, 0x00000010U ,0x00000000U), // .. .. .. FINISH: REMOVE PLL BY PASS // .. .. FINISH: IO PLL INIT // .. FINISH: PLL SLCR REGISTERS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_clock_init_data_1_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: CLOCK CONTROL SLCR REGISTERS // .. CLKACT = 0x1 // .. ==> 0XF8000128[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. DIVISOR0 = 0x23 // .. ==> 0XF8000128[13:8] = 0x00000023U // .. ==> MASK : 0x00003F00U VAL : 0x00002300U // .. DIVISOR1 = 0x3 // .. ==> 0XF8000128[25:20] = 0x00000003U // .. ==> MASK : 0x03F00000U VAL : 0x00300000U // .. EMIT_MASKWRITE(0XF8000128, 0x03F03F01U ,0x00302301U), // .. CLKACT = 0x1 // .. ==> 0XF8000138[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF8000138[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000138, 0x00000011U ,0x00000001U), // .. CLKACT = 0x1 // .. ==> 0XF8000140[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF8000140[6:4] = 0x00000000U // .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. DIVISOR = 0x8 // .. ==> 0XF8000140[13:8] = 0x00000008U // .. ==> MASK : 0x00003F00U VAL : 0x00000800U // .. DIVISOR1 = 0x1 // .. ==> 0XF8000140[25:20] = 0x00000001U // .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. EMIT_MASKWRITE(0XF8000140, 0x03F03F71U ,0x00100801U), // .. CLKACT = 0x1 // .. ==> 0XF800014C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. SRCSEL = 0x0 // .. ==> 0XF800014C[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x5 // .. ==> 0XF800014C[13:8] = 0x00000005U // .. ==> MASK : 0x00003F00U VAL : 0x00000500U // .. EMIT_MASKWRITE(0XF800014C, 0x00003F31U ,0x00000501U), // .. CLKACT0 = 0x1 // .. ==> 0XF8000150[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. CLKACT1 = 0x0 // .. ==> 0XF8000150[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. SRCSEL = 0x0 // .. ==> 0XF8000150[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x14 // .. ==> 0XF8000150[13:8] = 0x00000014U // .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. EMIT_MASKWRITE(0XF8000150, 0x00003F33U ,0x00001401U), // .. CLKACT0 = 0x0 // .. ==> 0XF8000154[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. CLKACT1 = 0x1 // .. ==> 0XF8000154[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. SRCSEL = 0x0 // .. ==> 0XF8000154[5:4] = 0x00000000U // .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. DIVISOR = 0x14 // .. ==> 0XF8000154[13:8] = 0x00000014U // .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. EMIT_MASKWRITE(0XF8000154, 0x00003F33U ,0x00001402U), // .. .. START: TRACE CLOCK // .. .. FINISH: TRACE CLOCK // .. .. CLKACT = 0x1 // .. .. ==> 0XF8000168[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000168[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR = 0x5 // .. .. ==> 0XF8000168[13:8] = 0x00000005U // .. .. ==> MASK : 0x00003F00U VAL : 0x00000500U // .. .. EMIT_MASKWRITE(0XF8000168, 0x00003F31U ,0x00000501U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000170[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0xa // .. .. ==> 0XF8000170[13:8] = 0x0000000AU // .. .. ==> MASK : 0x00003F00U VAL : 0x00000A00U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000170[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000170, 0x03F03F30U ,0x00100A00U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000180[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x7 // .. .. ==> 0XF8000180[13:8] = 0x00000007U // .. .. ==> MASK : 0x00003F00U VAL : 0x00000700U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000180[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000180, 0x03F03F30U ,0x00100700U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF8000190[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x14 // .. .. ==> 0XF8000190[13:8] = 0x00000014U // .. .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF8000190[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF8000190, 0x03F03F30U ,0x00101400U), // .. .. SRCSEL = 0x0 // .. .. ==> 0XF80001A0[5:4] = 0x00000000U // .. .. ==> MASK : 0x00000030U VAL : 0x00000000U // .. .. DIVISOR0 = 0x14 // .. .. ==> 0XF80001A0[13:8] = 0x00000014U // .. .. ==> MASK : 0x00003F00U VAL : 0x00001400U // .. .. DIVISOR1 = 0x1 // .. .. ==> 0XF80001A0[25:20] = 0x00000001U // .. .. ==> MASK : 0x03F00000U VAL : 0x00100000U // .. .. EMIT_MASKWRITE(0XF80001A0, 0x03F03F30U ,0x00101400U), // .. .. CLK_621_TRUE = 0x1 // .. .. ==> 0XF80001C4[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. EMIT_MASKWRITE(0XF80001C4, 0x00000001U ,0x00000001U), // .. .. DMA_CPU_2XCLKACT = 0x1 // .. .. ==> 0XF800012C[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. USB0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[2:2] = 0x00000001U // .. .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. .. USB1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[3:3] = 0x00000001U // .. .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. .. GEM0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[6:6] = 0x00000001U // .. .. ==> MASK : 0x00000040U VAL : 0x00000040U // .. .. GEM1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. SDI0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[10:10] = 0x00000001U // .. .. ==> MASK : 0x00000400U VAL : 0x00000400U // .. .. SDI1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. SPI0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. SPI1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. CAN0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. CAN1_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. I2C0_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[18:18] = 0x00000001U // .. .. ==> MASK : 0x00040000U VAL : 0x00040000U // .. .. I2C1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. UART0_CPU_1XCLKACT = 0x0 // .. .. ==> 0XF800012C[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. UART1_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[21:21] = 0x00000001U // .. .. ==> MASK : 0x00200000U VAL : 0x00200000U // .. .. GPIO_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[22:22] = 0x00000001U // .. .. ==> MASK : 0x00400000U VAL : 0x00400000U // .. .. LQSPI_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[23:23] = 0x00000001U // .. .. ==> MASK : 0x00800000U VAL : 0x00800000U // .. .. SMC_CPU_1XCLKACT = 0x1 // .. .. ==> 0XF800012C[24:24] = 0x00000001U // .. .. ==> MASK : 0x01000000U VAL : 0x01000000U // .. .. EMIT_MASKWRITE(0XF800012C, 0x01FFCCCDU ,0x01EC044DU), // .. FINISH: CLOCK CONTROL SLCR REGISTERS // .. START: THIS SHOULD BE BLANK // .. FINISH: THIS SHOULD BE BLANK // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_ddr_init_data_1_0[] = { // START: top // .. START: DDR INITIALIZATION // .. .. START: LOCK DDR // .. .. reg_ddrc_soft_rstb = 0 // .. .. ==> 0XF8006000[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_powerdown_en = 0x0 // .. .. ==> 0XF8006000[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_data_bus_width = 0x0 // .. .. ==> 0XF8006000[3:2] = 0x00000000U // .. .. ==> MASK : 0x0000000CU VAL : 0x00000000U // .. .. reg_ddrc_burst8_refresh = 0x0 // .. .. ==> 0XF8006000[6:4] = 0x00000000U // .. .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. .. reg_ddrc_rdwr_idle_gap = 0x1 // .. .. ==> 0XF8006000[13:7] = 0x00000001U // .. .. ==> MASK : 0x00003F80U VAL : 0x00000080U // .. .. reg_ddrc_dis_rd_bypass = 0x0 // .. .. ==> 0XF8006000[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. reg_ddrc_dis_act_bypass = 0x0 // .. .. ==> 0XF8006000[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_ddrc_dis_auto_refresh = 0x0 // .. .. ==> 0XF8006000[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006000, 0x0001FFFFU ,0x00000080U), // .. .. FINISH: LOCK DDR // .. .. reg_ddrc_t_rfc_nom_x32 = 0x81 // .. .. ==> 0XF8006004[11:0] = 0x00000081U // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000081U // .. .. reg_ddrc_active_ranks = 0x1 // .. .. ==> 0XF8006004[13:12] = 0x00000001U // .. .. ==> MASK : 0x00003000U VAL : 0x00001000U // .. .. reg_ddrc_addrmap_cs_bit0 = 0x0 // .. .. ==> 0XF8006004[18:14] = 0x00000000U // .. .. ==> MASK : 0x0007C000U VAL : 0x00000000U // .. .. reg_ddrc_wr_odt_block = 0x1 // .. .. ==> 0XF8006004[20:19] = 0x00000001U // .. .. ==> MASK : 0x00180000U VAL : 0x00080000U // .. .. reg_ddrc_diff_rank_rd_2cycle_gap = 0x0 // .. .. ==> 0XF8006004[21:21] = 0x00000000U // .. .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_cs_bit1 = 0x0 // .. .. ==> 0XF8006004[26:22] = 0x00000000U // .. .. ==> MASK : 0x07C00000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_open_bank = 0x0 // .. .. ==> 0XF8006004[27:27] = 0x00000000U // .. .. ==> MASK : 0x08000000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_4bank_ram = 0x0 // .. .. ==> 0XF8006004[28:28] = 0x00000000U // .. .. ==> MASK : 0x10000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006004, 0x1FFFFFFFU ,0x00081081U), // .. .. reg_ddrc_hpr_min_non_critical_x32 = 0xf // .. .. ==> 0XF8006008[10:0] = 0x0000000FU // .. .. ==> MASK : 0x000007FFU VAL : 0x0000000FU // .. .. reg_ddrc_hpr_max_starve_x32 = 0xf // .. .. ==> 0XF8006008[21:11] = 0x0000000FU // .. .. ==> MASK : 0x003FF800U VAL : 0x00007800U // .. .. reg_ddrc_hpr_xact_run_length = 0xf // .. .. ==> 0XF8006008[25:22] = 0x0000000FU // .. .. ==> MASK : 0x03C00000U VAL : 0x03C00000U // .. .. EMIT_MASKWRITE(0XF8006008, 0x03FFFFFFU ,0x03C0780FU), // .. .. reg_ddrc_lpr_min_non_critical_x32 = 0x1 // .. .. ==> 0XF800600C[10:0] = 0x00000001U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000001U // .. .. reg_ddrc_lpr_max_starve_x32 = 0x2 // .. .. ==> 0XF800600C[21:11] = 0x00000002U // .. .. ==> MASK : 0x003FF800U VAL : 0x00001000U // .. .. reg_ddrc_lpr_xact_run_length = 0x8 // .. .. ==> 0XF800600C[25:22] = 0x00000008U // .. .. ==> MASK : 0x03C00000U VAL : 0x02000000U // .. .. EMIT_MASKWRITE(0XF800600C, 0x03FFFFFFU ,0x02001001U), // .. .. reg_ddrc_w_min_non_critical_x32 = 0x1 // .. .. ==> 0XF8006010[10:0] = 0x00000001U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000001U // .. .. reg_ddrc_w_xact_run_length = 0x8 // .. .. ==> 0XF8006010[14:11] = 0x00000008U // .. .. ==> MASK : 0x00007800U VAL : 0x00004000U // .. .. reg_ddrc_w_max_starve_x32 = 0x2 // .. .. ==> 0XF8006010[25:15] = 0x00000002U // .. .. ==> MASK : 0x03FF8000U VAL : 0x00010000U // .. .. EMIT_MASKWRITE(0XF8006010, 0x03FFFFFFU ,0x00014001U), // .. .. reg_ddrc_t_rc = 0x1b // .. .. ==> 0XF8006014[5:0] = 0x0000001BU // .. .. ==> MASK : 0x0000003FU VAL : 0x0000001BU // .. .. reg_ddrc_t_rfc_min = 0x56 // .. .. ==> 0XF8006014[13:6] = 0x00000056U // .. .. ==> MASK : 0x00003FC0U VAL : 0x00001580U // .. .. reg_ddrc_post_selfref_gap_x32 = 0x10 // .. .. ==> 0XF8006014[20:14] = 0x00000010U // .. .. ==> MASK : 0x001FC000U VAL : 0x00040000U // .. .. EMIT_MASKWRITE(0XF8006014, 0x001FFFFFU ,0x0004159BU), // .. .. reg_ddrc_wr2pre = 0x12 // .. .. ==> 0XF8006018[4:0] = 0x00000012U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000012U // .. .. reg_ddrc_powerdown_to_x32 = 0x6 // .. .. ==> 0XF8006018[9:5] = 0x00000006U // .. .. ==> MASK : 0x000003E0U VAL : 0x000000C0U // .. .. reg_ddrc_t_faw = 0x18 // .. .. ==> 0XF8006018[15:10] = 0x00000018U // .. .. ==> MASK : 0x0000FC00U VAL : 0x00006000U // .. .. reg_ddrc_t_ras_max = 0x24 // .. .. ==> 0XF8006018[21:16] = 0x00000024U // .. .. ==> MASK : 0x003F0000U VAL : 0x00240000U // .. .. reg_ddrc_t_ras_min = 0x14 // .. .. ==> 0XF8006018[26:22] = 0x00000014U // .. .. ==> MASK : 0x07C00000U VAL : 0x05000000U // .. .. reg_ddrc_t_cke = 0x4 // .. .. ==> 0XF8006018[31:28] = 0x00000004U // .. .. ==> MASK : 0xF0000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006018, 0xF7FFFFFFU ,0x452460D2U), // .. .. reg_ddrc_write_latency = 0x5 // .. .. ==> 0XF800601C[4:0] = 0x00000005U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000005U // .. .. reg_ddrc_rd2wr = 0x7 // .. .. ==> 0XF800601C[9:5] = 0x00000007U // .. .. ==> MASK : 0x000003E0U VAL : 0x000000E0U // .. .. reg_ddrc_wr2rd = 0xe // .. .. ==> 0XF800601C[14:10] = 0x0000000EU // .. .. ==> MASK : 0x00007C00U VAL : 0x00003800U // .. .. reg_ddrc_t_xp = 0x4 // .. .. ==> 0XF800601C[19:15] = 0x00000004U // .. .. ==> MASK : 0x000F8000U VAL : 0x00020000U // .. .. reg_ddrc_pad_pd = 0x0 // .. .. ==> 0XF800601C[22:20] = 0x00000000U // .. .. ==> MASK : 0x00700000U VAL : 0x00000000U // .. .. reg_ddrc_rd2pre = 0x4 // .. .. ==> 0XF800601C[27:23] = 0x00000004U // .. .. ==> MASK : 0x0F800000U VAL : 0x02000000U // .. .. reg_ddrc_t_rcd = 0x7 // .. .. ==> 0XF800601C[31:28] = 0x00000007U // .. .. ==> MASK : 0xF0000000U VAL : 0x70000000U // .. .. EMIT_MASKWRITE(0XF800601C, 0xFFFFFFFFU ,0x720238E5U), // .. .. reg_ddrc_t_ccd = 0x4 // .. .. ==> 0XF8006020[4:2] = 0x00000004U // .. .. ==> MASK : 0x0000001CU VAL : 0x00000010U // .. .. reg_ddrc_t_rrd = 0x6 // .. .. ==> 0XF8006020[7:5] = 0x00000006U // .. .. ==> MASK : 0x000000E0U VAL : 0x000000C0U // .. .. reg_ddrc_refresh_margin = 0x2 // .. .. ==> 0XF8006020[11:8] = 0x00000002U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000200U // .. .. reg_ddrc_t_rp = 0x7 // .. .. ==> 0XF8006020[15:12] = 0x00000007U // .. .. ==> MASK : 0x0000F000U VAL : 0x00007000U // .. .. reg_ddrc_refresh_to_x32 = 0x8 // .. .. ==> 0XF8006020[20:16] = 0x00000008U // .. .. ==> MASK : 0x001F0000U VAL : 0x00080000U // .. .. reg_ddrc_sdram = 0x1 // .. .. ==> 0XF8006020[21:21] = 0x00000001U // .. .. ==> MASK : 0x00200000U VAL : 0x00200000U // .. .. reg_ddrc_mobile = 0x0 // .. .. ==> 0XF8006020[22:22] = 0x00000000U // .. .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. .. reg_ddrc_clock_stop_en = 0x0 // .. .. ==> 0XF8006020[23:23] = 0x00000000U // .. .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. .. reg_ddrc_read_latency = 0x7 // .. .. ==> 0XF8006020[28:24] = 0x00000007U // .. .. ==> MASK : 0x1F000000U VAL : 0x07000000U // .. .. reg_phy_mode_ddr1_ddr2 = 0x1 // .. .. ==> 0XF8006020[29:29] = 0x00000001U // .. .. ==> MASK : 0x20000000U VAL : 0x20000000U // .. .. reg_ddrc_dis_pad_pd = 0x0 // .. .. ==> 0XF8006020[30:30] = 0x00000000U // .. .. ==> MASK : 0x40000000U VAL : 0x00000000U // .. .. reg_ddrc_loopback = 0x0 // .. .. ==> 0XF8006020[31:31] = 0x00000000U // .. .. ==> MASK : 0x80000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006020, 0xFFFFFFFCU ,0x272872D0U), // .. .. reg_ddrc_en_2t_timing_mode = 0x0 // .. .. ==> 0XF8006024[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_prefer_write = 0x0 // .. .. ==> 0XF8006024[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_max_rank_rd = 0xf // .. .. ==> 0XF8006024[5:2] = 0x0000000FU // .. .. ==> MASK : 0x0000003CU VAL : 0x0000003CU // .. .. reg_ddrc_mr_wr = 0x0 // .. .. ==> 0XF8006024[6:6] = 0x00000000U // .. .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. .. reg_ddrc_mr_addr = 0x0 // .. .. ==> 0XF8006024[8:7] = 0x00000000U // .. .. ==> MASK : 0x00000180U VAL : 0x00000000U // .. .. reg_ddrc_mr_data = 0x0 // .. .. ==> 0XF8006024[24:9] = 0x00000000U // .. .. ==> MASK : 0x01FFFE00U VAL : 0x00000000U // .. .. ddrc_reg_mr_wr_busy = 0x0 // .. .. ==> 0XF8006024[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reg_ddrc_mr_type = 0x0 // .. .. ==> 0XF8006024[26:26] = 0x00000000U // .. .. ==> MASK : 0x04000000U VAL : 0x00000000U // .. .. reg_ddrc_mr_rdata_valid = 0x0 // .. .. ==> 0XF8006024[27:27] = 0x00000000U // .. .. ==> MASK : 0x08000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006024, 0x0FFFFFFFU ,0x0000003CU), // .. .. reg_ddrc_final_wait_x32 = 0x7 // .. .. ==> 0XF8006028[6:0] = 0x00000007U // .. .. ==> MASK : 0x0000007FU VAL : 0x00000007U // .. .. reg_ddrc_pre_ocd_x32 = 0x0 // .. .. ==> 0XF8006028[10:7] = 0x00000000U // .. .. ==> MASK : 0x00000780U VAL : 0x00000000U // .. .. reg_ddrc_t_mrd = 0x4 // .. .. ==> 0XF8006028[13:11] = 0x00000004U // .. .. ==> MASK : 0x00003800U VAL : 0x00002000U // .. .. EMIT_MASKWRITE(0XF8006028, 0x00003FFFU ,0x00002007U), // .. .. reg_ddrc_emr2 = 0x8 // .. .. ==> 0XF800602C[15:0] = 0x00000008U // .. .. ==> MASK : 0x0000FFFFU VAL : 0x00000008U // .. .. reg_ddrc_emr3 = 0x0 // .. .. ==> 0XF800602C[31:16] = 0x00000000U // .. .. ==> MASK : 0xFFFF0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800602C, 0xFFFFFFFFU ,0x00000008U), // .. .. reg_ddrc_mr = 0x930 // .. .. ==> 0XF8006030[15:0] = 0x00000930U // .. .. ==> MASK : 0x0000FFFFU VAL : 0x00000930U // .. .. reg_ddrc_emr = 0x4 // .. .. ==> 0XF8006030[31:16] = 0x00000004U // .. .. ==> MASK : 0xFFFF0000U VAL : 0x00040000U // .. .. EMIT_MASKWRITE(0XF8006030, 0xFFFFFFFFU ,0x00040930U), // .. .. reg_ddrc_burst_rdwr = 0x4 // .. .. ==> 0XF8006034[3:0] = 0x00000004U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000004U // .. .. reg_ddrc_pre_cke_x1024 = 0x16d // .. .. ==> 0XF8006034[13:4] = 0x0000016DU // .. .. ==> MASK : 0x00003FF0U VAL : 0x000016D0U // .. .. reg_ddrc_post_cke_x1024 = 0x1 // .. .. ==> 0XF8006034[25:16] = 0x00000001U // .. .. ==> MASK : 0x03FF0000U VAL : 0x00010000U // .. .. reg_ddrc_burstchop = 0x0 // .. .. ==> 0XF8006034[28:28] = 0x00000000U // .. .. ==> MASK : 0x10000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006034, 0x13FF3FFFU ,0x000116D4U), // .. .. reg_ddrc_force_low_pri_n = 1 // .. .. ==> 0XF8006038[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_ddrc_dis_dq = 0x0 // .. .. ==> 0XF8006038[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_debug_mode = 0x0 // .. .. ==> 0XF8006038[6:6] = 0x00000000U // .. .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. .. reg_phy_wr_level_start = 0x0 // .. .. ==> 0XF8006038[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. reg_phy_rd_level_start = 0x0 // .. .. ==> 0XF8006038[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_phy_dq0_wait_t = 0x0 // .. .. ==> 0XF8006038[12:9] = 0x00000000U // .. .. ==> MASK : 0x00001E00U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006038, 0x00001FC3U ,0x00000001U), // .. .. reg_ddrc_addrmap_bank_b0 = 0x7 // .. .. ==> 0XF800603C[3:0] = 0x00000007U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000007U // .. .. reg_ddrc_addrmap_bank_b1 = 0x7 // .. .. ==> 0XF800603C[7:4] = 0x00000007U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000070U // .. .. reg_ddrc_addrmap_bank_b2 = 0x7 // .. .. ==> 0XF800603C[11:8] = 0x00000007U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000700U // .. .. reg_ddrc_addrmap_col_b5 = 0x0 // .. .. ==> 0XF800603C[15:12] = 0x00000000U // .. .. ==> MASK : 0x0000F000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b6 = 0x0 // .. .. ==> 0XF800603C[19:16] = 0x00000000U // .. .. ==> MASK : 0x000F0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800603C, 0x000FFFFFU ,0x00000777U), // .. .. reg_ddrc_addrmap_col_b2 = 0x0 // .. .. ==> 0XF8006040[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b3 = 0x0 // .. .. ==> 0XF8006040[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b4 = 0x0 // .. .. ==> 0XF8006040[11:8] = 0x00000000U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b7 = 0x0 // .. .. ==> 0XF8006040[15:12] = 0x00000000U // .. .. ==> MASK : 0x0000F000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b8 = 0x0 // .. .. ==> 0XF8006040[19:16] = 0x00000000U // .. .. ==> MASK : 0x000F0000U VAL : 0x00000000U // .. .. reg_ddrc_addrmap_col_b9 = 0xf // .. .. ==> 0XF8006040[23:20] = 0x0000000FU // .. .. ==> MASK : 0x00F00000U VAL : 0x00F00000U // .. .. reg_ddrc_addrmap_col_b10 = 0xf // .. .. ==> 0XF8006040[27:24] = 0x0000000FU // .. .. ==> MASK : 0x0F000000U VAL : 0x0F000000U // .. .. reg_ddrc_addrmap_col_b11 = 0xf // .. .. ==> 0XF8006040[31:28] = 0x0000000FU // .. .. ==> MASK : 0xF0000000U VAL : 0xF0000000U // .. .. EMIT_MASKWRITE(0XF8006040, 0xFFFFFFFFU ,0xFFF00000U), // .. .. reg_ddrc_addrmap_row_b0 = 0x6 // .. .. ==> 0XF8006044[3:0] = 0x00000006U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000006U // .. .. reg_ddrc_addrmap_row_b1 = 0x6 // .. .. ==> 0XF8006044[7:4] = 0x00000006U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000060U // .. .. reg_ddrc_addrmap_row_b2_11 = 0x6 // .. .. ==> 0XF8006044[11:8] = 0x00000006U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000600U // .. .. reg_ddrc_addrmap_row_b12 = 0x6 // .. .. ==> 0XF8006044[15:12] = 0x00000006U // .. .. ==> MASK : 0x0000F000U VAL : 0x00006000U // .. .. reg_ddrc_addrmap_row_b13 = 0x6 // .. .. ==> 0XF8006044[19:16] = 0x00000006U // .. .. ==> MASK : 0x000F0000U VAL : 0x00060000U // .. .. reg_ddrc_addrmap_row_b14 = 0xf // .. .. ==> 0XF8006044[23:20] = 0x0000000FU // .. .. ==> MASK : 0x00F00000U VAL : 0x00F00000U // .. .. reg_ddrc_addrmap_row_b15 = 0xf // .. .. ==> 0XF8006044[27:24] = 0x0000000FU // .. .. ==> MASK : 0x0F000000U VAL : 0x0F000000U // .. .. EMIT_MASKWRITE(0XF8006044, 0x0FFFFFFFU ,0x0FF66666U), // .. .. reg_ddrc_rank0_rd_odt = 0x0 // .. .. ==> 0XF8006048[2:0] = 0x00000000U // .. .. ==> MASK : 0x00000007U VAL : 0x00000000U // .. .. reg_ddrc_rank0_wr_odt = 0x1 // .. .. ==> 0XF8006048[5:3] = 0x00000001U // .. .. ==> MASK : 0x00000038U VAL : 0x00000008U // .. .. reg_ddrc_rank1_rd_odt = 0x1 // .. .. ==> 0XF8006048[8:6] = 0x00000001U // .. .. ==> MASK : 0x000001C0U VAL : 0x00000040U // .. .. reg_ddrc_rank1_wr_odt = 0x1 // .. .. ==> 0XF8006048[11:9] = 0x00000001U // .. .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. .. reg_phy_rd_local_odt = 0x0 // .. .. ==> 0XF8006048[13:12] = 0x00000000U // .. .. ==> MASK : 0x00003000U VAL : 0x00000000U // .. .. reg_phy_wr_local_odt = 0x3 // .. .. ==> 0XF8006048[15:14] = 0x00000003U // .. .. ==> MASK : 0x0000C000U VAL : 0x0000C000U // .. .. reg_phy_idle_local_odt = 0x3 // .. .. ==> 0XF8006048[17:16] = 0x00000003U // .. .. ==> MASK : 0x00030000U VAL : 0x00030000U // .. .. reg_ddrc_rank2_rd_odt = 0x0 // .. .. ==> 0XF8006048[20:18] = 0x00000000U // .. .. ==> MASK : 0x001C0000U VAL : 0x00000000U // .. .. reg_ddrc_rank2_wr_odt = 0x0 // .. .. ==> 0XF8006048[23:21] = 0x00000000U // .. .. ==> MASK : 0x00E00000U VAL : 0x00000000U // .. .. reg_ddrc_rank3_rd_odt = 0x0 // .. .. ==> 0XF8006048[26:24] = 0x00000000U // .. .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. .. reg_ddrc_rank3_wr_odt = 0x0 // .. .. ==> 0XF8006048[29:27] = 0x00000000U // .. .. ==> MASK : 0x38000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006048, 0x3FFFFFFFU ,0x0003C248U), // .. .. reg_phy_rd_cmd_to_data = 0x0 // .. .. ==> 0XF8006050[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_phy_wr_cmd_to_data = 0x0 // .. .. ==> 0XF8006050[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_phy_rdc_we_to_re_delay = 0x8 // .. .. ==> 0XF8006050[11:8] = 0x00000008U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000800U // .. .. reg_phy_rdc_fifo_rst_disable = 0x0 // .. .. ==> 0XF8006050[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_phy_use_fixed_re = 0x1 // .. .. ==> 0XF8006050[16:16] = 0x00000001U // .. .. ==> MASK : 0x00010000U VAL : 0x00010000U // .. .. reg_phy_rdc_fifo_rst_err_cnt_clr = 0x0 // .. .. ==> 0XF8006050[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_phy_dis_phy_ctrl_rstn = 0x0 // .. .. ==> 0XF8006050[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_phy_clk_stall_level = 0x0 // .. .. ==> 0XF8006050[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. reg_phy_gatelvl_num_of_dq0 = 0x7 // .. .. ==> 0XF8006050[27:24] = 0x00000007U // .. .. ==> MASK : 0x0F000000U VAL : 0x07000000U // .. .. reg_phy_wrlvl_num_of_dq0 = 0x7 // .. .. ==> 0XF8006050[31:28] = 0x00000007U // .. .. ==> MASK : 0xF0000000U VAL : 0x70000000U // .. .. EMIT_MASKWRITE(0XF8006050, 0xFF0F8FFFU ,0x77010800U), // .. .. reg_ddrc_dll_calib_to_min_x1024 = 0x1 // .. .. ==> 0XF8006058[7:0] = 0x00000001U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000001U // .. .. reg_ddrc_dll_calib_to_max_x1024 = 0x1 // .. .. ==> 0XF8006058[15:8] = 0x00000001U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00000100U // .. .. reg_ddrc_dis_dll_calib = 0x0 // .. .. ==> 0XF8006058[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006058, 0x0001FFFFU ,0x00000101U), // .. .. reg_ddrc_rd_odt_delay = 0x3 // .. .. ==> 0XF800605C[3:0] = 0x00000003U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000003U // .. .. reg_ddrc_wr_odt_delay = 0x0 // .. .. ==> 0XF800605C[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. reg_ddrc_rd_odt_hold = 0x0 // .. .. ==> 0XF800605C[11:8] = 0x00000000U // .. .. ==> MASK : 0x00000F00U VAL : 0x00000000U // .. .. reg_ddrc_wr_odt_hold = 0x5 // .. .. ==> 0XF800605C[15:12] = 0x00000005U // .. .. ==> MASK : 0x0000F000U VAL : 0x00005000U // .. .. EMIT_MASKWRITE(0XF800605C, 0x0000FFFFU ,0x00005003U), // .. .. reg_ddrc_pageclose = 0x0 // .. .. ==> 0XF8006060[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_lpr_num_entries = 0x7 // .. .. ==> 0XF8006060[6:1] = 0x00000007U // .. .. ==> MASK : 0x0000007EU VAL : 0x0000000EU // .. .. reg_ddrc_auto_pre_en = 0x0 // .. .. ==> 0XF8006060[7:7] = 0x00000000U // .. .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. .. reg_ddrc_refresh_update_level = 0x0 // .. .. ==> 0XF8006060[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_ddrc_dis_wc = 0x0 // .. .. ==> 0XF8006060[9:9] = 0x00000000U // .. .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. .. reg_ddrc_dis_collision_page_opt = 0x0 // .. .. ==> 0XF8006060[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_ddrc_selfref_en = 0x0 // .. .. ==> 0XF8006060[12:12] = 0x00000000U // .. .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006060, 0x000017FFU ,0x0000000EU), // .. .. reg_ddrc_go2critical_hysteresis = 0x0 // .. .. ==> 0XF8006064[12:5] = 0x00000000U // .. .. ==> MASK : 0x00001FE0U VAL : 0x00000000U // .. .. reg_arb_go2critical_en = 0x1 // .. .. ==> 0XF8006064[17:17] = 0x00000001U // .. .. ==> MASK : 0x00020000U VAL : 0x00020000U // .. .. EMIT_MASKWRITE(0XF8006064, 0x00021FE0U ,0x00020000U), // .. .. reg_ddrc_wrlvl_ww = 0x41 // .. .. ==> 0XF8006068[7:0] = 0x00000041U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000041U // .. .. reg_ddrc_rdlvl_rr = 0x41 // .. .. ==> 0XF8006068[15:8] = 0x00000041U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00004100U // .. .. reg_ddrc_dfi_t_wlmrd = 0x28 // .. .. ==> 0XF8006068[25:16] = 0x00000028U // .. .. ==> MASK : 0x03FF0000U VAL : 0x00280000U // .. .. EMIT_MASKWRITE(0XF8006068, 0x03FFFFFFU ,0x00284141U), // .. .. dfi_t_ctrlupd_interval_min_x1024 = 0x10 // .. .. ==> 0XF800606C[7:0] = 0x00000010U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000010U // .. .. dfi_t_ctrlupd_interval_max_x1024 = 0x16 // .. .. ==> 0XF800606C[15:8] = 0x00000016U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00001600U // .. .. EMIT_MASKWRITE(0XF800606C, 0x0000FFFFU ,0x00001610U), // .. .. refresh_timer0_start_value_x32 = 0x0 // .. .. ==> 0XF80060A0[11:0] = 0x00000000U // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000000U // .. .. refresh_timer1_start_value_x32 = 0x8 // .. .. ==> 0XF80060A0[23:12] = 0x00000008U // .. .. ==> MASK : 0x00FFF000U VAL : 0x00008000U // .. .. EMIT_MASKWRITE(0XF80060A0, 0x00FFFFFFU ,0x00008000U), // .. .. reg_ddrc_dis_auto_zq = 0x0 // .. .. ==> 0XF80060A4[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_ddr3 = 0x1 // .. .. ==> 0XF80060A4[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. reg_ddrc_t_mod = 0x200 // .. .. ==> 0XF80060A4[11:2] = 0x00000200U // .. .. ==> MASK : 0x00000FFCU VAL : 0x00000800U // .. .. reg_ddrc_t_zq_long_nop = 0x200 // .. .. ==> 0XF80060A4[21:12] = 0x00000200U // .. .. ==> MASK : 0x003FF000U VAL : 0x00200000U // .. .. reg_ddrc_t_zq_short_nop = 0x40 // .. .. ==> 0XF80060A4[31:22] = 0x00000040U // .. .. ==> MASK : 0xFFC00000U VAL : 0x10000000U // .. .. EMIT_MASKWRITE(0XF80060A4, 0xFFFFFFFFU ,0x10200802U), // .. .. t_zq_short_interval_x1024 = 0xcb73 // .. .. ==> 0XF80060A8[19:0] = 0x0000CB73U // .. .. ==> MASK : 0x000FFFFFU VAL : 0x0000CB73U // .. .. dram_rstn_x1024 = 0x69 // .. .. ==> 0XF80060A8[27:20] = 0x00000069U // .. .. ==> MASK : 0x0FF00000U VAL : 0x06900000U // .. .. EMIT_MASKWRITE(0XF80060A8, 0x0FFFFFFFU ,0x0690CB73U), // .. .. deeppowerdown_en = 0x0 // .. .. ==> 0XF80060AC[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. deeppowerdown_to_x1024 = 0xff // .. .. ==> 0XF80060AC[8:1] = 0x000000FFU // .. .. ==> MASK : 0x000001FEU VAL : 0x000001FEU // .. .. EMIT_MASKWRITE(0XF80060AC, 0x000001FFU ,0x000001FEU), // .. .. dfi_wrlvl_max_x1024 = 0xfff // .. .. ==> 0XF80060B0[11:0] = 0x00000FFFU // .. .. ==> MASK : 0x00000FFFU VAL : 0x00000FFFU // .. .. dfi_rdlvl_max_x1024 = 0xfff // .. .. ==> 0XF80060B0[23:12] = 0x00000FFFU // .. .. ==> MASK : 0x00FFF000U VAL : 0x00FFF000U // .. .. ddrc_reg_twrlvl_max_error = 0x0 // .. .. ==> 0XF80060B0[24:24] = 0x00000000U // .. .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. .. ddrc_reg_trdlvl_max_error = 0x0 // .. .. ==> 0XF80060B0[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. reg_ddrc_dfi_wr_level_en = 0x1 // .. .. ==> 0XF80060B0[26:26] = 0x00000001U // .. .. ==> MASK : 0x04000000U VAL : 0x04000000U // .. .. reg_ddrc_dfi_rd_dqs_gate_level = 0x1 // .. .. ==> 0XF80060B0[27:27] = 0x00000001U // .. .. ==> MASK : 0x08000000U VAL : 0x08000000U // .. .. reg_ddrc_dfi_rd_data_eye_train = 0x1 // .. .. ==> 0XF80060B0[28:28] = 0x00000001U // .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. EMIT_MASKWRITE(0XF80060B0, 0x1FFFFFFFU ,0x1CFFFFFFU), // .. .. reg_ddrc_2t_delay = 0x0 // .. .. ==> 0XF80060B4[8:0] = 0x00000000U // .. .. ==> MASK : 0x000001FFU VAL : 0x00000000U // .. .. reg_ddrc_skip_ocd = 0x1 // .. .. ==> 0XF80060B4[9:9] = 0x00000001U // .. .. ==> MASK : 0x00000200U VAL : 0x00000200U // .. .. reg_ddrc_dis_pre_bypass = 0x0 // .. .. ==> 0XF80060B4[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060B4, 0x000007FFU ,0x00000200U), // .. .. reg_ddrc_dfi_t_rddata_en = 0x6 // .. .. ==> 0XF80060B8[4:0] = 0x00000006U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000006U // .. .. reg_ddrc_dfi_t_ctrlup_min = 0x3 // .. .. ==> 0XF80060B8[14:5] = 0x00000003U // .. .. ==> MASK : 0x00007FE0U VAL : 0x00000060U // .. .. reg_ddrc_dfi_t_ctrlup_max = 0x40 // .. .. ==> 0XF80060B8[24:15] = 0x00000040U // .. .. ==> MASK : 0x01FF8000U VAL : 0x00200000U // .. .. EMIT_MASKWRITE(0XF80060B8, 0x01FFFFFFU ,0x00200066U), // .. .. START: RESET ECC ERROR // .. .. Clear_Uncorrectable_DRAM_ECC_error = 1 // .. .. ==> 0XF80060C4[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. Clear_Correctable_DRAM_ECC_error = 1 // .. .. ==> 0XF80060C4[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. EMIT_MASKWRITE(0XF80060C4, 0x00000003U ,0x00000003U), // .. .. FINISH: RESET ECC ERROR // .. .. Clear_Uncorrectable_DRAM_ECC_error = 0x0 // .. .. ==> 0XF80060C4[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. Clear_Correctable_DRAM_ECC_error = 0x0 // .. .. ==> 0XF80060C4[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060C4, 0x00000003U ,0x00000000U), // .. .. CORR_ECC_LOG_VALID = 0x0 // .. .. ==> 0XF80060C8[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. ECC_CORRECTED_BIT_NUM = 0x0 // .. .. ==> 0XF80060C8[7:1] = 0x00000000U // .. .. ==> MASK : 0x000000FEU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060C8, 0x000000FFU ,0x00000000U), // .. .. UNCORR_ECC_LOG_VALID = 0x0 // .. .. ==> 0XF80060DC[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060DC, 0x00000001U ,0x00000000U), // .. .. STAT_NUM_CORR_ERR = 0x0 // .. .. ==> 0XF80060F0[15:8] = 0x00000000U // .. .. ==> MASK : 0x0000FF00U VAL : 0x00000000U // .. .. STAT_NUM_UNCORR_ERR = 0x0 // .. .. ==> 0XF80060F0[7:0] = 0x00000000U // .. .. ==> MASK : 0x000000FFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80060F0, 0x0000FFFFU ,0x00000000U), // .. .. reg_ddrc_ecc_mode = 0x0 // .. .. ==> 0XF80060F4[2:0] = 0x00000000U // .. .. ==> MASK : 0x00000007U VAL : 0x00000000U // .. .. reg_ddrc_dis_scrub = 0x1 // .. .. ==> 0XF80060F4[3:3] = 0x00000001U // .. .. ==> MASK : 0x00000008U VAL : 0x00000008U // .. .. EMIT_MASKWRITE(0XF80060F4, 0x0000000FU ,0x00000008U), // .. .. reg_phy_dif_on = 0x0 // .. .. ==> 0XF8006114[3:0] = 0x00000000U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000000U // .. .. reg_phy_dif_off = 0x0 // .. .. ==> 0XF8006114[7:4] = 0x00000000U // .. .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006114, 0x000000FFU ,0x00000000U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006118[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006118[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006118[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006118[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006118[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006118[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006118[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006118, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF800611C[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF800611C[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF800611C[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF800611C[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF800611C[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF800611C[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF800611C[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF800611C, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006120[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006120[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006120[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006120[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006120[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006120[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006120[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006120, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_data_slice_in_use = 0x1 // .. .. ==> 0XF8006124[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_phy_rdlvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_gatelvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_wrlvl_inc_mode = 0x0 // .. .. ==> 0XF8006124[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_tx = 0x0 // .. .. ==> 0XF8006124[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_board_lpbk_rx = 0x0 // .. .. ==> 0XF8006124[5:5] = 0x00000000U // .. .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. .. reg_phy_bist_shift_dq = 0x0 // .. .. ==> 0XF8006124[14:6] = 0x00000000U // .. .. ==> MASK : 0x00007FC0U VAL : 0x00000000U // .. .. reg_phy_bist_err_clr = 0x0 // .. .. ==> 0XF8006124[23:15] = 0x00000000U // .. .. ==> MASK : 0x00FF8000U VAL : 0x00000000U // .. .. reg_phy_dq_offset = 0x40 // .. .. ==> 0XF8006124[30:24] = 0x00000040U // .. .. ==> MASK : 0x7F000000U VAL : 0x40000000U // .. .. EMIT_MASKWRITE(0XF8006124, 0x7FFFFFFFU ,0x40000001U), // .. .. reg_phy_wrlvl_init_ratio = 0x3 // .. .. ==> 0XF800612C[9:0] = 0x00000003U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000003U // .. .. reg_phy_gatelvl_init_ratio = 0xcf // .. .. ==> 0XF800612C[19:10] = 0x000000CFU // .. .. ==> MASK : 0x000FFC00U VAL : 0x00033C00U // .. .. EMIT_MASKWRITE(0XF800612C, 0x000FFFFFU ,0x00033C03U), // .. .. reg_phy_wrlvl_init_ratio = 0x3 // .. .. ==> 0XF8006130[9:0] = 0x00000003U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000003U // .. .. reg_phy_gatelvl_init_ratio = 0xd0 // .. .. ==> 0XF8006130[19:10] = 0x000000D0U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00034000U // .. .. EMIT_MASKWRITE(0XF8006130, 0x000FFFFFU ,0x00034003U), // .. .. reg_phy_wrlvl_init_ratio = 0x0 // .. .. ==> 0XF8006134[9:0] = 0x00000000U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000000U // .. .. reg_phy_gatelvl_init_ratio = 0xbd // .. .. ==> 0XF8006134[19:10] = 0x000000BDU // .. .. ==> MASK : 0x000FFC00U VAL : 0x0002F400U // .. .. EMIT_MASKWRITE(0XF8006134, 0x000FFFFFU ,0x0002F400U), // .. .. reg_phy_wrlvl_init_ratio = 0x0 // .. .. ==> 0XF8006138[9:0] = 0x00000000U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000000U // .. .. reg_phy_gatelvl_init_ratio = 0xc1 // .. .. ==> 0XF8006138[19:10] = 0x000000C1U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00030400U // .. .. EMIT_MASKWRITE(0XF8006138, 0x000FFFFFU ,0x00030400U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006140[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006140[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006140[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006140, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006144[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006144[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006144[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006144, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF8006148[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF8006148[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006148[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006148, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_rd_dqs_slave_ratio = 0x35 // .. .. ==> 0XF800614C[9:0] = 0x00000035U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000035U // .. .. reg_phy_rd_dqs_slave_force = 0x0 // .. .. ==> 0XF800614C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_rd_dqs_slave_delay = 0x0 // .. .. ==> 0XF800614C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800614C, 0x000FFFFFU ,0x00000035U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x83 // .. .. ==> 0XF8006154[9:0] = 0x00000083U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000083U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006154[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006154[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006154, 0x000FFFFFU ,0x00000083U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x83 // .. .. ==> 0XF8006158[9:0] = 0x00000083U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000083U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006158[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006158[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006158, 0x000FFFFFU ,0x00000083U), // .. .. reg_phy_wr_dqs_slave_ratio = 0x7f // .. .. ==> 0XF800615C[9:0] = 0x0000007FU // .. .. ==> MASK : 0x000003FFU VAL : 0x0000007FU // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF800615C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF800615C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800615C, 0x000FFFFFU ,0x0000007FU), // .. .. reg_phy_wr_dqs_slave_ratio = 0x78 // .. .. ==> 0XF8006160[9:0] = 0x00000078U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000078U // .. .. reg_phy_wr_dqs_slave_force = 0x0 // .. .. ==> 0XF8006160[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_dqs_slave_delay = 0x0 // .. .. ==> 0XF8006160[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006160, 0x000FFFFFU ,0x00000078U), // .. .. reg_phy_fifo_we_slave_ratio = 0x124 // .. .. ==> 0XF8006168[10:0] = 0x00000124U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000124U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006168[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006168[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006168, 0x001FFFFFU ,0x00000124U), // .. .. reg_phy_fifo_we_slave_ratio = 0x125 // .. .. ==> 0XF800616C[10:0] = 0x00000125U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000125U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF800616C[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF800616C[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800616C, 0x001FFFFFU ,0x00000125U), // .. .. reg_phy_fifo_we_slave_ratio = 0x112 // .. .. ==> 0XF8006170[10:0] = 0x00000112U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000112U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006170[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006170[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006170, 0x001FFFFFU ,0x00000112U), // .. .. reg_phy_fifo_we_slave_ratio = 0x116 // .. .. ==> 0XF8006174[10:0] = 0x00000116U // .. .. ==> MASK : 0x000007FFU VAL : 0x00000116U // .. .. reg_phy_fifo_we_in_force = 0x0 // .. .. ==> 0XF8006174[11:11] = 0x00000000U // .. .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. .. reg_phy_fifo_we_in_delay = 0x0 // .. .. ==> 0XF8006174[20:12] = 0x00000000U // .. .. ==> MASK : 0x001FF000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006174, 0x001FFFFFU ,0x00000116U), // .. .. reg_phy_wr_data_slave_ratio = 0xc3 // .. .. ==> 0XF800617C[9:0] = 0x000000C3U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000C3U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF800617C[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF800617C[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800617C, 0x000FFFFFU ,0x000000C3U), // .. .. reg_phy_wr_data_slave_ratio = 0xc3 // .. .. ==> 0XF8006180[9:0] = 0x000000C3U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000C3U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006180[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006180[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006180, 0x000FFFFFU ,0x000000C3U), // .. .. reg_phy_wr_data_slave_ratio = 0xbf // .. .. ==> 0XF8006184[9:0] = 0x000000BFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000000BFU // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006184[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006184[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006184, 0x000FFFFFU ,0x000000BFU), // .. .. reg_phy_wr_data_slave_ratio = 0xb8 // .. .. ==> 0XF8006188[9:0] = 0x000000B8U // .. .. ==> MASK : 0x000003FFU VAL : 0x000000B8U // .. .. reg_phy_wr_data_slave_force = 0x0 // .. .. ==> 0XF8006188[10:10] = 0x00000000U // .. .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. .. reg_phy_wr_data_slave_delay = 0x0 // .. .. ==> 0XF8006188[19:11] = 0x00000000U // .. .. ==> MASK : 0x000FF800U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006188, 0x000FFFFFU ,0x000000B8U), // .. .. reg_phy_loopback = 0x0 // .. .. ==> 0XF8006190[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_phy_bl2 = 0x0 // .. .. ==> 0XF8006190[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_phy_at_spd_atpg = 0x0 // .. .. ==> 0XF8006190[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_phy_bist_enable = 0x0 // .. .. ==> 0XF8006190[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. reg_phy_bist_force_err = 0x0 // .. .. ==> 0XF8006190[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. reg_phy_bist_mode = 0x0 // .. .. ==> 0XF8006190[6:5] = 0x00000000U // .. .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. .. reg_phy_invert_clkout = 0x1 // .. .. ==> 0XF8006190[7:7] = 0x00000001U // .. .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. .. reg_phy_all_dq_mpr_rd_resp = 0x0 // .. .. ==> 0XF8006190[8:8] = 0x00000000U // .. .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. .. reg_phy_sel_logic = 0x0 // .. .. ==> 0XF8006190[9:9] = 0x00000000U // .. .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_ratio = 0x100 // .. .. ==> 0XF8006190[19:10] = 0x00000100U // .. .. ==> MASK : 0x000FFC00U VAL : 0x00040000U // .. .. reg_phy_ctrl_slave_force = 0x0 // .. .. ==> 0XF8006190[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_delay = 0x0 // .. .. ==> 0XF8006190[27:21] = 0x00000000U // .. .. ==> MASK : 0x0FE00000U VAL : 0x00000000U // .. .. reg_phy_use_rank0_delays = 0x1 // .. .. ==> 0XF8006190[28:28] = 0x00000001U // .. .. ==> MASK : 0x10000000U VAL : 0x10000000U // .. .. reg_phy_lpddr = 0x0 // .. .. ==> 0XF8006190[29:29] = 0x00000000U // .. .. ==> MASK : 0x20000000U VAL : 0x00000000U // .. .. reg_phy_cmd_latency = 0x0 // .. .. ==> 0XF8006190[30:30] = 0x00000000U // .. .. ==> MASK : 0x40000000U VAL : 0x00000000U // .. .. reg_phy_int_lpbk = 0x0 // .. .. ==> 0XF8006190[31:31] = 0x00000000U // .. .. ==> MASK : 0x80000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006190, 0xFFFFFFFFU ,0x10040080U), // .. .. reg_phy_wr_rl_delay = 0x2 // .. .. ==> 0XF8006194[4:0] = 0x00000002U // .. .. ==> MASK : 0x0000001FU VAL : 0x00000002U // .. .. reg_phy_rd_rl_delay = 0x4 // .. .. ==> 0XF8006194[9:5] = 0x00000004U // .. .. ==> MASK : 0x000003E0U VAL : 0x00000080U // .. .. reg_phy_dll_lock_diff = 0xf // .. .. ==> 0XF8006194[13:10] = 0x0000000FU // .. .. ==> MASK : 0x00003C00U VAL : 0x00003C00U // .. .. reg_phy_use_wr_level = 0x1 // .. .. ==> 0XF8006194[14:14] = 0x00000001U // .. .. ==> MASK : 0x00004000U VAL : 0x00004000U // .. .. reg_phy_use_rd_dqs_gate_level = 0x1 // .. .. ==> 0XF8006194[15:15] = 0x00000001U // .. .. ==> MASK : 0x00008000U VAL : 0x00008000U // .. .. reg_phy_use_rd_data_eye_level = 0x1 // .. .. ==> 0XF8006194[16:16] = 0x00000001U // .. .. ==> MASK : 0x00010000U VAL : 0x00010000U // .. .. reg_phy_dis_calib_rst = 0x0 // .. .. ==> 0XF8006194[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_phy_ctrl_slave_delay = 0x0 // .. .. ==> 0XF8006194[19:18] = 0x00000000U // .. .. ==> MASK : 0x000C0000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006194, 0x000FFFFFU ,0x0001FC82U), // .. .. reg_arb_page_addr_mask = 0x0 // .. .. ==> 0XF8006204[31:0] = 0x00000000U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006204, 0xFFFFFFFFU ,0x00000000U), // .. .. reg_arb_pri_wr_portn = 0x3ff // .. .. ==> 0XF8006208[9:0] = 0x000003FFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000003FFU // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006208[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006208[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006208[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF8006208[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006208, 0x000F03FFU ,0x000803FFU), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF800620C[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF800620C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF800620C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF800620C[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF800620C[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF800620C, 0x000F03FFU ,0x00080200U), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF8006210[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006210[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006210[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006210[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF8006210[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006210, 0x000F03FFU ,0x00080200U), // .. .. reg_arb_pri_wr_portn = 0x200 // .. .. ==> 0XF8006214[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_wr_portn = 0x0 // .. .. ==> 0XF8006214[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_wr_portn = 0x0 // .. .. ==> 0XF8006214[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_wr_portn = 0x0 // .. .. ==> 0XF8006214[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_dis_rmw_portn = 0x1 // .. .. ==> 0XF8006214[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006214, 0x000F03FFU ,0x00080200U), // .. .. reg_arb_pri_rd_portn = 0x3ff // .. .. ==> 0XF8006218[9:0] = 0x000003FFU // .. .. ==> MASK : 0x000003FFU VAL : 0x000003FFU // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006218[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006218[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006218[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x1 // .. .. ==> 0XF8006218[19:19] = 0x00000001U // .. .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. .. EMIT_MASKWRITE(0XF8006218, 0x000F03FFU ,0x000803FFU), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF800621C[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF800621C[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF800621C[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF800621C[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF800621C[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF800621C, 0x000F03FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF8006220[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006220[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006220[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006220[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF8006220[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006220, 0x000F03FFU ,0x00000200U), // .. .. reg_arb_pri_rd_portn = 0x200 // .. .. ==> 0XF8006224[9:0] = 0x00000200U // .. .. ==> MASK : 0x000003FFU VAL : 0x00000200U // .. .. reg_arb_disable_aging_rd_portn = 0x0 // .. .. ==> 0XF8006224[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. reg_arb_disable_urgent_rd_portn = 0x0 // .. .. ==> 0XF8006224[17:17] = 0x00000000U // .. .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. .. reg_arb_dis_page_match_rd_portn = 0x0 // .. .. ==> 0XF8006224[18:18] = 0x00000000U // .. .. ==> MASK : 0x00040000U VAL : 0x00000000U // .. .. reg_arb_set_hpr_rd_portn = 0x0 // .. .. ==> 0XF8006224[19:19] = 0x00000000U // .. .. ==> MASK : 0x00080000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006224, 0x000F03FFU ,0x00000200U), // .. .. reg_ddrc_lpddr2 = 0x0 // .. .. ==> 0XF80062A8[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. reg_ddrc_per_bank_refresh = 0x0 // .. .. ==> 0XF80062A8[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_derate_enable = 0x0 // .. .. ==> 0XF80062A8[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. reg_ddrc_mr4_margin = 0x0 // .. .. ==> 0XF80062A8[11:4] = 0x00000000U // .. .. ==> MASK : 0x00000FF0U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80062A8, 0x00000FF7U ,0x00000000U), // .. .. reg_ddrc_mr4_read_interval = 0x0 // .. .. ==> 0XF80062AC[31:0] = 0x00000000U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF80062AC, 0xFFFFFFFFU ,0x00000000U), // .. .. reg_ddrc_min_stable_clock_x1 = 0x5 // .. .. ==> 0XF80062B0[3:0] = 0x00000005U // .. .. ==> MASK : 0x0000000FU VAL : 0x00000005U // .. .. reg_ddrc_idle_after_reset_x32 = 0x12 // .. .. ==> 0XF80062B0[11:4] = 0x00000012U // .. .. ==> MASK : 0x00000FF0U VAL : 0x00000120U // .. .. reg_ddrc_t_mrw = 0x5 // .. .. ==> 0XF80062B0[21:12] = 0x00000005U // .. .. ==> MASK : 0x003FF000U VAL : 0x00005000U // .. .. EMIT_MASKWRITE(0XF80062B0, 0x003FFFFFU ,0x00005125U), // .. .. reg_ddrc_max_auto_init_x1024 = 0xa8 // .. .. ==> 0XF80062B4[7:0] = 0x000000A8U // .. .. ==> MASK : 0x000000FFU VAL : 0x000000A8U // .. .. reg_ddrc_dev_zqinit_x32 = 0x12 // .. .. ==> 0XF80062B4[17:8] = 0x00000012U // .. .. ==> MASK : 0x0003FF00U VAL : 0x00001200U // .. .. EMIT_MASKWRITE(0XF80062B4, 0x0003FFFFU ,0x000012A8U), // .. .. START: POLL ON DCI STATUS // .. .. DONE = 1 // .. .. ==> 0XF8000B74[13:13] = 0x00000001U // .. .. ==> MASK : 0x00002000U VAL : 0x00002000U // .. .. EMIT_MASKPOLL(0XF8000B74, 0x00002000U), // .. .. FINISH: POLL ON DCI STATUS // .. .. START: UNLOCK DDR // .. .. reg_ddrc_soft_rstb = 0x1 // .. .. ==> 0XF8006000[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. reg_ddrc_powerdown_en = 0x0 // .. .. ==> 0XF8006000[1:1] = 0x00000000U // .. .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. .. reg_ddrc_data_bus_width = 0x0 // .. .. ==> 0XF8006000[3:2] = 0x00000000U // .. .. ==> MASK : 0x0000000CU VAL : 0x00000000U // .. .. reg_ddrc_burst8_refresh = 0x0 // .. .. ==> 0XF8006000[6:4] = 0x00000000U // .. .. ==> MASK : 0x00000070U VAL : 0x00000000U // .. .. reg_ddrc_rdwr_idle_gap = 1 // .. .. ==> 0XF8006000[13:7] = 0x00000001U // .. .. ==> MASK : 0x00003F80U VAL : 0x00000080U // .. .. reg_ddrc_dis_rd_bypass = 0x0 // .. .. ==> 0XF8006000[14:14] = 0x00000000U // .. .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. .. reg_ddrc_dis_act_bypass = 0x0 // .. .. ==> 0XF8006000[15:15] = 0x00000000U // .. .. ==> MASK : 0x00008000U VAL : 0x00000000U // .. .. reg_ddrc_dis_auto_refresh = 0x0 // .. .. ==> 0XF8006000[16:16] = 0x00000000U // .. .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8006000, 0x0001FFFFU ,0x00000081U), // .. .. FINISH: UNLOCK DDR // .. .. START: CHECK DDR STATUS // .. .. ddrc_reg_operating_mode = 1 // .. .. ==> 0XF8006054[2:0] = 0x00000001U // .. .. ==> MASK : 0x00000007U VAL : 0x00000001U // .. .. EMIT_MASKPOLL(0XF8006054, 0x00000007U), // .. .. FINISH: CHECK DDR STATUS // .. FINISH: DDR INITIALIZATION // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_mio_init_data_1_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: OCM REMAPPING // .. FINISH: OCM REMAPPING // .. START: DDRIOB SETTINGS // .. INP_POWER = 0x0 // .. ==> 0XF8000B40[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B40[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B40[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B40[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCR_TYPE = 0x0 // .. ==> 0XF8000B40[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B40[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B40[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B40[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B40[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B40, 0x00000FFFU ,0x00000600U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B44[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B44[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B44[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B44[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCR_TYPE = 0x0 // .. ==> 0XF8000B44[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B44[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B44[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B44[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B44[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B44, 0x00000FFFU ,0x00000600U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B48[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x1 // .. ==> 0XF8000B48[2:1] = 0x00000001U // .. ==> MASK : 0x00000006U VAL : 0x00000002U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B48[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B48[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B48[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B48[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B48[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B48[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B48[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B48, 0x00000FFFU ,0x00000672U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B4C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x1 // .. ==> 0XF8000B4C[2:1] = 0x00000001U // .. ==> MASK : 0x00000006U VAL : 0x00000002U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B4C[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B4C[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B4C[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B4C[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B4C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B4C[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B4C[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B4C, 0x00000FFFU ,0x00000672U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B50[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x2 // .. ==> 0XF8000B50[2:1] = 0x00000002U // .. ==> MASK : 0x00000006U VAL : 0x00000004U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B50[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B50[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B50[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B50[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B50[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B50[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B50[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B50, 0x00000FFFU ,0x00000674U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B54[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x2 // .. ==> 0XF8000B54[2:1] = 0x00000002U // .. ==> MASK : 0x00000006U VAL : 0x00000004U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B54[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x1 // .. ==> 0XF8000B54[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. DCR_TYPE = 0x3 // .. ==> 0XF8000B54[6:5] = 0x00000003U // .. ==> MASK : 0x00000060U VAL : 0x00000060U // .. IBUF_DISABLE_MODE = 0 // .. ==> 0XF8000B54[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0 // .. ==> 0XF8000B54[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B54[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B54[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B54, 0x00000FFFU ,0x00000674U), // .. INP_POWER = 0x0 // .. ==> 0XF8000B58[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. INP_TYPE = 0x0 // .. ==> 0XF8000B58[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. DCI_UPDATE = 0x0 // .. ==> 0XF8000B58[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. TERM_EN = 0x0 // .. ==> 0XF8000B58[4:4] = 0x00000000U // .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. DCR_TYPE = 0x0 // .. ==> 0XF8000B58[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. IBUF_DISABLE_MODE = 0x0 // .. ==> 0XF8000B58[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. TERM_DISABLE_MODE = 0x0 // .. ==> 0XF8000B58[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. OUTPUT_EN = 0x3 // .. ==> 0XF8000B58[10:9] = 0x00000003U // .. ==> MASK : 0x00000600U VAL : 0x00000600U // .. PULLUP_EN = 0x0 // .. ==> 0XF8000B58[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B58, 0x00000FFFU ,0x00000600U), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B5C[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B5C[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x3 // .. ==> 0XF8000B5C[18:14] = 0x00000003U // .. ==> MASK : 0x0007C000U VAL : 0x0000C000U // .. SLEW_N = 0x3 // .. ==> 0XF8000B5C[23:19] = 0x00000003U // .. ==> MASK : 0x00F80000U VAL : 0x00180000U // .. GTL = 0x0 // .. ==> 0XF8000B5C[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B5C[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B5C, 0xFFFFFFFFU ,0x0018C61CU), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B60[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B60[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x6 // .. ==> 0XF8000B60[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. SLEW_N = 0x1f // .. ==> 0XF8000B60[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. GTL = 0x0 // .. ==> 0XF8000B60[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B60[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B60, 0xFFFFFFFFU ,0x00F9861CU), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B64[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B64[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x6 // .. ==> 0XF8000B64[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. SLEW_N = 0x1f // .. ==> 0XF8000B64[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. GTL = 0x0 // .. ==> 0XF8000B64[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B64[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B64, 0xFFFFFFFFU ,0x00F9861CU), // .. DRIVE_P = 0x1c // .. ==> 0XF8000B68[6:0] = 0x0000001CU // .. ==> MASK : 0x0000007FU VAL : 0x0000001CU // .. DRIVE_N = 0xc // .. ==> 0XF8000B68[13:7] = 0x0000000CU // .. ==> MASK : 0x00003F80U VAL : 0x00000600U // .. SLEW_P = 0x6 // .. ==> 0XF8000B68[18:14] = 0x00000006U // .. ==> MASK : 0x0007C000U VAL : 0x00018000U // .. SLEW_N = 0x1f // .. ==> 0XF8000B68[23:19] = 0x0000001FU // .. ==> MASK : 0x00F80000U VAL : 0x00F80000U // .. GTL = 0x0 // .. ==> 0XF8000B68[26:24] = 0x00000000U // .. ==> MASK : 0x07000000U VAL : 0x00000000U // .. RTERM = 0x0 // .. ==> 0XF8000B68[31:27] = 0x00000000U // .. ==> MASK : 0xF8000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B68, 0xFFFFFFFFU ,0x00F9861CU), // .. VREF_INT_EN = 0x1 // .. ==> 0XF8000B6C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. VREF_SEL = 0x4 // .. ==> 0XF8000B6C[4:1] = 0x00000004U // .. ==> MASK : 0x0000001EU VAL : 0x00000008U // .. VREF_EXT_EN = 0x0 // .. ==> 0XF8000B6C[6:5] = 0x00000000U // .. ==> MASK : 0x00000060U VAL : 0x00000000U // .. VREF_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[8:7] = 0x00000000U // .. ==> MASK : 0x00000180U VAL : 0x00000000U // .. REFIO_EN = 0x1 // .. ==> 0XF8000B6C[9:9] = 0x00000001U // .. ==> MASK : 0x00000200U VAL : 0x00000200U // .. REFIO_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DRST_B_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. CKE_PULLUP_EN = 0x0 // .. ==> 0XF8000B6C[14:14] = 0x00000000U // .. ==> MASK : 0x00004000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000B6C, 0x000073FFU ,0x00000209U), // .. .. START: ASSERT RESET // .. .. RESET = 1 // .. .. ==> 0XF8000B70[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x00000021U ,0x00000021U), // .. .. FINISH: ASSERT RESET // .. .. START: DEASSERT RESET // .. .. RESET = 0 // .. .. ==> 0XF8000B70[0:0] = 0x00000000U // .. .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. .. VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x00000021U ,0x00000020U), // .. .. FINISH: DEASSERT RESET // .. .. RESET = 0x1 // .. .. ==> 0XF8000B70[0:0] = 0x00000001U // .. .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. .. ENABLE = 0x1 // .. .. ==> 0XF8000B70[1:1] = 0x00000001U // .. .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. .. VRP_TRI = 0x0 // .. .. ==> 0XF8000B70[2:2] = 0x00000000U // .. .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. .. VRN_TRI = 0x0 // .. .. ==> 0XF8000B70[3:3] = 0x00000000U // .. .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. .. VRP_OUT = 0x0 // .. .. ==> 0XF8000B70[4:4] = 0x00000000U // .. .. ==> MASK : 0x00000010U VAL : 0x00000000U // .. .. VRN_OUT = 0x1 // .. .. ==> 0XF8000B70[5:5] = 0x00000001U // .. .. ==> MASK : 0x00000020U VAL : 0x00000020U // .. .. NREF_OPT1 = 0x0 // .. .. ==> 0XF8000B70[7:6] = 0x00000000U // .. .. ==> MASK : 0x000000C0U VAL : 0x00000000U // .. .. NREF_OPT2 = 0x0 // .. .. ==> 0XF8000B70[10:8] = 0x00000000U // .. .. ==> MASK : 0x00000700U VAL : 0x00000000U // .. .. NREF_OPT4 = 0x1 // .. .. ==> 0XF8000B70[13:11] = 0x00000001U // .. .. ==> MASK : 0x00003800U VAL : 0x00000800U // .. .. PREF_OPT1 = 0x0 // .. .. ==> 0XF8000B70[16:14] = 0x00000000U // .. .. ==> MASK : 0x0001C000U VAL : 0x00000000U // .. .. PREF_OPT2 = 0x0 // .. .. ==> 0XF8000B70[19:17] = 0x00000000U // .. .. ==> MASK : 0x000E0000U VAL : 0x00000000U // .. .. UPDATE_CONTROL = 0x0 // .. .. ==> 0XF8000B70[20:20] = 0x00000000U // .. .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. .. INIT_COMPLETE = 0x0 // .. .. ==> 0XF8000B70[21:21] = 0x00000000U // .. .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. .. TST_CLK = 0x0 // .. .. ==> 0XF8000B70[22:22] = 0x00000000U // .. .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. .. TST_HLN = 0x0 // .. .. ==> 0XF8000B70[23:23] = 0x00000000U // .. .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. .. TST_HLP = 0x0 // .. .. ==> 0XF8000B70[24:24] = 0x00000000U // .. .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. .. TST_RST = 0x0 // .. .. ==> 0XF8000B70[25:25] = 0x00000000U // .. .. ==> MASK : 0x02000000U VAL : 0x00000000U // .. .. INT_DCI_EN = 0x0 // .. .. ==> 0XF8000B70[26:26] = 0x00000000U // .. .. ==> MASK : 0x04000000U VAL : 0x00000000U // .. .. EMIT_MASKWRITE(0XF8000B70, 0x07FFFFFFU ,0x00000823U), // .. FINISH: DDRIOB SETTINGS // .. START: MIO PROGRAMMING // .. TRI_ENABLE = 0 // .. ==> 0XF8000700[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000700[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000700[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000700[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000700[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000700[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000700[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000700[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000700[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000700, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000704[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000704[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000704[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000704[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000704[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000704[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000704[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000704[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000704[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000704, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000708[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000708[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000708[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000708[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000708[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000708[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000708[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000708[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000708[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000708, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF800070C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF800070C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800070C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800070C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800070C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800070C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF800070C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800070C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800070C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800070C, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000710[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000710[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000710[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000710[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000710[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000710[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000710[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000710[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000710[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000710, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000714[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000714[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000714[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000714[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000714[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000714[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000714[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000714[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000714[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000714, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000718[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000718[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000718[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000718[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000718[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000718[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000718[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000718[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000718[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000718, 0x00003FFFU ,0x00000702U), // .. TRI_ENABLE = 0 // .. ==> 0XF800071C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800071C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800071C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800071C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800071C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800071C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800071C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800071C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800071C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800071C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000720[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000720[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000720[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000720[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000720[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000720[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 3 // .. ==> 0XF8000720[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000720[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000720[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000720, 0x00003FFFU ,0x00000700U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000724[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000724[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000724[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000724[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000724[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000724[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000724[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000724[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000724[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000724, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000728[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000728[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000728[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000728[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000728[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000728[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000728[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000728[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000728[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000728, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF800072C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800072C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800072C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800072C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800072C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800072C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800072C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800072C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800072C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800072C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000730[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000730[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000730[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000730[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000730[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000730[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000730[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000730[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000730[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000730, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000734[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000734[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000734[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000734[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000734[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000734[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000734[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000734[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000734[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000734, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000738[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000738[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF8000738[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000738[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000738[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF8000738[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF8000738[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF8000738[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000738[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000738, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF800073C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800073C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF800073C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800073C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800073C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF800073C[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 3 // .. ==> 0XF800073C[11:9] = 0x00000003U // .. ==> MASK : 0x00000E00U VAL : 0x00000600U // .. PULLUP = 0 // .. ==> 0XF800073C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800073C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800073C, 0x00003FFFU ,0x00000600U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000740[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000740[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000740[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000740[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000740[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000740[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000740[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000740[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000740[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000740, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000744[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000744[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000744[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000744[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000744[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000744[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000744[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000744[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000744[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000744, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000748[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000748[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000748[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000748[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000748[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000748[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000748[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000748[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000748[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000748, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF800074C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF800074C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800074C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800074C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800074C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800074C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800074C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800074C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800074C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800074C, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000750[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000750[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000750[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000750[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000750[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000750[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000750[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000750[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000750[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000750, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000754[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 1 // .. ==> 0XF8000754[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000754[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000754[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000754[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000754[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000754[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000754[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000754[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000754, 0x00003FFFU ,0x00000302U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000758[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000758[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000758[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000758[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000758[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000758[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000758[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000758[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000758[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000758, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF800075C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF800075C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800075C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800075C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800075C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800075C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800075C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800075C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800075C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800075C, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000760[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000760[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000760[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000760[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000760[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000760[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000760[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000760[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000760[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000760, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000764[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000764[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000764[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000764[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000764[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000764[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000764[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000764[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000764[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000764, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000768[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF8000768[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF8000768[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF8000768[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000768[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000768[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000768[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000768[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000768[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000768, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 1 // .. ==> 0XF800076C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 1 // .. ==> 0XF800076C[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. L1_SEL = 0 // .. ==> 0XF800076C[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF800076C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800076C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800076C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800076C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800076C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800076C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800076C, 0x00003FFFU ,0x00000303U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000770[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000770[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000770[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000770[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000770[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000770[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000770[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000770[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000770[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000770, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000774[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF8000774[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000774[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000774[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000774[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000774[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000774[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000774[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000774[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000774, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000778[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000778[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000778[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000778[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000778[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000778[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000778[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000778[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000778[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000778, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF800077C[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF800077C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800077C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800077C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800077C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800077C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800077C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800077C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800077C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800077C, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000780[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000780[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000780[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000780[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000780[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000780[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000780[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000780[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000780[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000780, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000784[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000784[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000784[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000784[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000784[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000784[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000784[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000784[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000784[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000784, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000788[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000788[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000788[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000788[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000788[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000788[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000788[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000788[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000788[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000788, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF800078C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800078C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800078C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800078C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800078C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800078C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800078C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800078C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800078C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800078C, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 1 // .. ==> 0XF8000790[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF8000790[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000790[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000790[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000790[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000790[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000790[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000790[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000790[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000790, 0x00003FFFU ,0x00000305U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000794[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000794[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000794[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000794[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000794[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000794[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000794[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000794[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000794[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000794, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF8000798[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF8000798[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF8000798[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF8000798[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF8000798[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF8000798[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF8000798[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF8000798[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF8000798[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000798, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF800079C[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF800079C[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 1 // .. ==> 0XF800079C[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. L2_SEL = 0 // .. ==> 0XF800079C[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF800079C[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 1 // .. ==> 0XF800079C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF800079C[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF800079C[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF800079C[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF800079C, 0x00003FFFU ,0x00000304U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A0[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A0, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A4[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A4, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007A8[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007A8[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007A8[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007A8[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007A8[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007A8[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007A8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007A8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007A8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007A8, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007AC[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007AC[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007AC[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007AC[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007AC[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007AC[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007AC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007AC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007AC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007AC, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007B0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007B0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007B0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007B0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007B0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007B0[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007B0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B0, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007B4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007B4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007B4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007B4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007B4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 1 // .. ==> 0XF80007B4[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. IO_Type = 1 // .. ==> 0XF80007B4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B4, 0x00003FFFU ,0x00000380U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007B8[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. Speed = 0 // .. ==> 0XF80007B8[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007B8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007B8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007B8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007B8, 0x00003F01U ,0x00000201U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007BC[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. Speed = 0 // .. ==> 0XF80007BC[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007BC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007BC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007BC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007BC, 0x00003F01U ,0x00000201U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007C0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007C0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 7 // .. ==> 0XF80007C0[7:5] = 0x00000007U // .. ==> MASK : 0x000000E0U VAL : 0x000000E0U // .. Speed = 0 // .. ==> 0XF80007C0[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C0, 0x00003FFFU ,0x000002E0U), // .. TRI_ENABLE = 1 // .. ==> 0XF80007C4[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. L0_SEL = 0 // .. ==> 0XF80007C4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 7 // .. ==> 0XF80007C4[7:5] = 0x00000007U // .. ==> MASK : 0x000000E0U VAL : 0x000000E0U // .. Speed = 0 // .. ==> 0XF80007C4[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C4, 0x00003FFFU ,0x000002E1U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007C8[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007C8[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007C8[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007C8[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF80007C8[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF80007C8[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007C8[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007C8[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007C8[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007C8, 0x00003FFFU ,0x00000200U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007CC[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007CC[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007CC[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007CC[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 0 // .. ==> 0XF80007CC[7:5] = 0x00000000U // .. ==> MASK : 0x000000E0U VAL : 0x00000000U // .. Speed = 0 // .. ==> 0XF80007CC[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007CC[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007CC[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007CC[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007CC, 0x00003FFFU ,0x00000200U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007D0[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007D0[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007D0[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007D0[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007D0[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 0 // .. ==> 0XF80007D0[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007D0[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007D0[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007D0[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007D0, 0x00003FFFU ,0x00000280U), // .. TRI_ENABLE = 0 // .. ==> 0XF80007D4[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. L0_SEL = 0 // .. ==> 0XF80007D4[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. L1_SEL = 0 // .. ==> 0XF80007D4[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. L2_SEL = 0 // .. ==> 0XF80007D4[4:3] = 0x00000000U // .. ==> MASK : 0x00000018U VAL : 0x00000000U // .. L3_SEL = 4 // .. ==> 0XF80007D4[7:5] = 0x00000004U // .. ==> MASK : 0x000000E0U VAL : 0x00000080U // .. Speed = 0 // .. ==> 0XF80007D4[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. IO_Type = 1 // .. ==> 0XF80007D4[11:9] = 0x00000001U // .. ==> MASK : 0x00000E00U VAL : 0x00000200U // .. PULLUP = 0 // .. ==> 0XF80007D4[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. DisableRcvr = 0 // .. ==> 0XF80007D4[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF80007D4, 0x00003FFFU ,0x00000280U), // .. SDIO0_WP_SEL = 46 // .. ==> 0XF8000830[5:0] = 0x0000002EU // .. ==> MASK : 0x0000003FU VAL : 0x0000002EU // .. SDIO0_CD_SEL = 47 // .. ==> 0XF8000830[21:16] = 0x0000002FU // .. ==> MASK : 0x003F0000U VAL : 0x002F0000U // .. EMIT_MASKWRITE(0XF8000830, 0x003F003FU ,0x002F002EU), // .. FINISH: MIO PROGRAMMING // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_peripherals_init_data_1_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: DDR TERM/IBUF_DISABLE_MODE SETTINGS // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B48[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B48[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B48, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B4C[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B4C[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B4C, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B50[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B50[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B50, 0x00000180U ,0x00000180U), // .. IBUF_DISABLE_MODE = 0x1 // .. ==> 0XF8000B54[7:7] = 0x00000001U // .. ==> MASK : 0x00000080U VAL : 0x00000080U // .. TERM_DISABLE_MODE = 0x1 // .. ==> 0XF8000B54[8:8] = 0x00000001U // .. ==> MASK : 0x00000100U VAL : 0x00000100U // .. EMIT_MASKWRITE(0XF8000B54, 0x00000180U ,0x00000180U), // .. FINISH: DDR TERM/IBUF_DISABLE_MODE SETTINGS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // .. START: SRAM/NOR SET OPMODE // .. FINISH: SRAM/NOR SET OPMODE // .. START: UART REGISTERS // .. BDIV = 0x6 // .. ==> 0XE0001034[7:0] = 0x00000006U // .. ==> MASK : 0x000000FFU VAL : 0x00000006U // .. EMIT_MASKWRITE(0XE0001034, 0x000000FFU ,0x00000006U), // .. CD = 0x3e // .. ==> 0XE0001018[15:0] = 0x0000003EU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000003EU // .. EMIT_MASKWRITE(0XE0001018, 0x0000FFFFU ,0x0000003EU), // .. STPBRK = 0x0 // .. ==> 0XE0001000[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. STTBRK = 0x0 // .. ==> 0XE0001000[7:7] = 0x00000000U // .. ==> MASK : 0x00000080U VAL : 0x00000000U // .. RSTTO = 0x0 // .. ==> 0XE0001000[6:6] = 0x00000000U // .. ==> MASK : 0x00000040U VAL : 0x00000000U // .. TXDIS = 0x0 // .. ==> 0XE0001000[5:5] = 0x00000000U // .. ==> MASK : 0x00000020U VAL : 0x00000000U // .. TXEN = 0x1 // .. ==> 0XE0001000[4:4] = 0x00000001U // .. ==> MASK : 0x00000010U VAL : 0x00000010U // .. RXDIS = 0x0 // .. ==> 0XE0001000[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. RXEN = 0x1 // .. ==> 0XE0001000[2:2] = 0x00000001U // .. ==> MASK : 0x00000004U VAL : 0x00000004U // .. TXRES = 0x1 // .. ==> 0XE0001000[1:1] = 0x00000001U // .. ==> MASK : 0x00000002U VAL : 0x00000002U // .. RXRES = 0x1 // .. ==> 0XE0001000[0:0] = 0x00000001U // .. ==> MASK : 0x00000001U VAL : 0x00000001U // .. EMIT_MASKWRITE(0XE0001000, 0x000001FFU ,0x00000017U), // .. IRMODE = 0x0 // .. ==> 0XE0001004[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. UCLKEN = 0x0 // .. ==> 0XE0001004[10:10] = 0x00000000U // .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. CHMODE = 0x0 // .. ==> 0XE0001004[9:8] = 0x00000000U // .. ==> MASK : 0x00000300U VAL : 0x00000000U // .. NBSTOP = 0x0 // .. ==> 0XE0001004[7:6] = 0x00000000U // .. ==> MASK : 0x000000C0U VAL : 0x00000000U // .. PAR = 0x4 // .. ==> 0XE0001004[5:3] = 0x00000004U // .. ==> MASK : 0x00000038U VAL : 0x00000020U // .. CHRL = 0x0 // .. ==> 0XE0001004[2:1] = 0x00000000U // .. ==> MASK : 0x00000006U VAL : 0x00000000U // .. CLKS = 0x0 // .. ==> 0XE0001004[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XE0001004, 0x00000FFFU ,0x00000020U), // .. FINISH: UART REGISTERS // .. START: QSPI REGISTERS // .. Holdb_dr = 1 // .. ==> 0XE000D000[19:19] = 0x00000001U // .. ==> MASK : 0x00080000U VAL : 0x00080000U // .. EMIT_MASKWRITE(0XE000D000, 0x00080000U ,0x00080000U), // .. FINISH: QSPI REGISTERS // .. START: PL POWER ON RESET REGISTERS // .. PCFG_POR_CNT_4K = 0 // .. ==> 0XF8007000[29:29] = 0x00000000U // .. ==> MASK : 0x20000000U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8007000, 0x20000000U ,0x00000000U), // .. FINISH: PL POWER ON RESET REGISTERS // .. START: SMC TIMING CALCULATION REGISTER UPDATE // .. .. START: NAND SET CYCLE // .. .. FINISH: NAND SET CYCLE // .. .. START: OPMODE // .. .. FINISH: OPMODE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: SRAM/NOR CS0 SET CYCLE // .. .. FINISH: SRAM/NOR CS0 SET CYCLE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: NOR CS0 BASE ADDRESS // .. .. FINISH: NOR CS0 BASE ADDRESS // .. .. START: SRAM/NOR CS1 SET CYCLE // .. .. FINISH: SRAM/NOR CS1 SET CYCLE // .. .. START: DIRECT COMMAND // .. .. FINISH: DIRECT COMMAND // .. .. START: NOR CS1 BASE ADDRESS // .. .. FINISH: NOR CS1 BASE ADDRESS // .. .. START: USB RESET // .. .. .. START: USB0 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: USB0 RESET // .. .. .. START: USB1 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: USB1 RESET // .. .. FINISH: USB RESET // .. .. START: ENET RESET // .. .. .. START: ENET0 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: ENET0 RESET // .. .. .. START: ENET1 RESET // .. .. .. .. START: DIR MODE BANK 0 // .. .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. .. START: DIR MODE BANK 1 // .. .. .. .. FINISH: DIR MODE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. .. .. START: OUTPUT ENABLE BANK 1 // .. .. .. .. FINISH: OUTPUT ENABLE BANK 1 // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: ENET1 RESET // .. .. FINISH: ENET RESET // .. .. START: I2C RESET // .. .. .. START: I2C0 RESET // .. .. .. .. START: DIR MODE GPIO BANK0 // .. .. .. .. FINISH: DIR MODE GPIO BANK0 // .. .. .. .. START: DIR MODE GPIO BANK1 // .. .. .. .. FINISH: DIR MODE GPIO BANK1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: I2C0 RESET // .. .. .. START: I2C1 RESET // .. .. .. .. START: DIR MODE GPIO BANK0 // .. .. .. .. FINISH: DIR MODE GPIO BANK0 // .. .. .. .. START: DIR MODE GPIO BANK1 // .. .. .. .. FINISH: DIR MODE GPIO BANK1 // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: OUTPUT ENABLE // .. .. .. .. FINISH: OUTPUT ENABLE // .. .. .. .. START: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW LOW BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW LOW BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW LOW BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW LOW BANK [53:48] // .. .. .. .. START: ADD 1 MS DELAY // .. .. .. .. EMIT_MASKDELAY(0XF8F00200, 1), // .. .. .. .. FINISH: ADD 1 MS DELAY // .. .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. .. START: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. FINISH: MASK_DATA_0_MSW HIGH BANK [31:16] // .. .. .. .. START: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. FINISH: MASK_DATA_1_LSW HIGH BANK [47:32] // .. .. .. .. START: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. .. FINISH: MASK_DATA_1_MSW HIGH BANK [53:48] // .. .. .. FINISH: I2C1 RESET // .. .. FINISH: I2C RESET // .. .. START: NOR CHIP SELECT // .. .. .. START: DIR MODE BANK 0 // .. .. .. FINISH: DIR MODE BANK 0 // .. .. .. START: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. FINISH: MASK_DATA_0_LSW HIGH BANK [15:0] // .. .. .. START: OUTPUT ENABLE BANK 0 // .. .. .. FINISH: OUTPUT ENABLE BANK 0 // .. .. FINISH: NOR CHIP SELECT // .. FINISH: SMC TIMING CALCULATION REGISTER UPDATE // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_post_config_1_0[] = { // START: top // .. START: SLCR SETTINGS // .. UNLOCK_KEY = 0XDF0D // .. ==> 0XF8000008[15:0] = 0x0000DF0DU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000DF0DU // .. EMIT_MASKWRITE(0XF8000008, 0x0000FFFFU ,0x0000DF0DU), // .. FINISH: SLCR SETTINGS // .. START: ENABLING LEVEL SHIFTER // .. USER_INP_ICT_EN_0 = 3 // .. ==> 0XF8000900[1:0] = 0x00000003U // .. ==> MASK : 0x00000003U VAL : 0x00000003U // .. USER_INP_ICT_EN_1 = 3 // .. ==> 0XF8000900[3:2] = 0x00000003U // .. ==> MASK : 0x0000000CU VAL : 0x0000000CU // .. EMIT_MASKWRITE(0XF8000900, 0x0000000FU ,0x0000000FU), // .. FINISH: ENABLING LEVEL SHIFTER // .. START: FPGA RESETS TO 0 // .. reserved_3 = 0 // .. ==> 0XF8000240[31:25] = 0x00000000U // .. ==> MASK : 0xFE000000U VAL : 0x00000000U // .. FPGA_ACP_RST = 0 // .. ==> 0XF8000240[24:24] = 0x00000000U // .. ==> MASK : 0x01000000U VAL : 0x00000000U // .. FPGA_AXDS3_RST = 0 // .. ==> 0XF8000240[23:23] = 0x00000000U // .. ==> MASK : 0x00800000U VAL : 0x00000000U // .. FPGA_AXDS2_RST = 0 // .. ==> 0XF8000240[22:22] = 0x00000000U // .. ==> MASK : 0x00400000U VAL : 0x00000000U // .. FPGA_AXDS1_RST = 0 // .. ==> 0XF8000240[21:21] = 0x00000000U // .. ==> MASK : 0x00200000U VAL : 0x00000000U // .. FPGA_AXDS0_RST = 0 // .. ==> 0XF8000240[20:20] = 0x00000000U // .. ==> MASK : 0x00100000U VAL : 0x00000000U // .. reserved_2 = 0 // .. ==> 0XF8000240[19:18] = 0x00000000U // .. ==> MASK : 0x000C0000U VAL : 0x00000000U // .. FSSW1_FPGA_RST = 0 // .. ==> 0XF8000240[17:17] = 0x00000000U // .. ==> MASK : 0x00020000U VAL : 0x00000000U // .. FSSW0_FPGA_RST = 0 // .. ==> 0XF8000240[16:16] = 0x00000000U // .. ==> MASK : 0x00010000U VAL : 0x00000000U // .. reserved_1 = 0 // .. ==> 0XF8000240[15:14] = 0x00000000U // .. ==> MASK : 0x0000C000U VAL : 0x00000000U // .. FPGA_FMSW1_RST = 0 // .. ==> 0XF8000240[13:13] = 0x00000000U // .. ==> MASK : 0x00002000U VAL : 0x00000000U // .. FPGA_FMSW0_RST = 0 // .. ==> 0XF8000240[12:12] = 0x00000000U // .. ==> MASK : 0x00001000U VAL : 0x00000000U // .. FPGA_DMA3_RST = 0 // .. ==> 0XF8000240[11:11] = 0x00000000U // .. ==> MASK : 0x00000800U VAL : 0x00000000U // .. FPGA_DMA2_RST = 0 // .. ==> 0XF8000240[10:10] = 0x00000000U // .. ==> MASK : 0x00000400U VAL : 0x00000000U // .. FPGA_DMA1_RST = 0 // .. ==> 0XF8000240[9:9] = 0x00000000U // .. ==> MASK : 0x00000200U VAL : 0x00000000U // .. FPGA_DMA0_RST = 0 // .. ==> 0XF8000240[8:8] = 0x00000000U // .. ==> MASK : 0x00000100U VAL : 0x00000000U // .. reserved = 0 // .. ==> 0XF8000240[7:4] = 0x00000000U // .. ==> MASK : 0x000000F0U VAL : 0x00000000U // .. FPGA3_OUT_RST = 0 // .. ==> 0XF8000240[3:3] = 0x00000000U // .. ==> MASK : 0x00000008U VAL : 0x00000000U // .. FPGA2_OUT_RST = 0 // .. ==> 0XF8000240[2:2] = 0x00000000U // .. ==> MASK : 0x00000004U VAL : 0x00000000U // .. FPGA1_OUT_RST = 0 // .. ==> 0XF8000240[1:1] = 0x00000000U // .. ==> MASK : 0x00000002U VAL : 0x00000000U // .. FPGA0_OUT_RST = 0 // .. ==> 0XF8000240[0:0] = 0x00000000U // .. ==> MASK : 0x00000001U VAL : 0x00000000U // .. EMIT_MASKWRITE(0XF8000240, 0xFFFFFFFFU ,0x00000000U), // .. FINISH: FPGA RESETS TO 0 // .. START: AFI REGISTERS // .. .. START: AFI0 REGISTERS // .. .. FINISH: AFI0 REGISTERS // .. .. START: AFI1 REGISTERS // .. .. FINISH: AFI1 REGISTERS // .. .. START: AFI2 REGISTERS // .. .. FINISH: AFI2 REGISTERS // .. .. START: AFI3 REGISTERS // .. .. FINISH: AFI3 REGISTERS // .. FINISH: AFI REGISTERS // .. START: LOCK IT BACK // .. LOCK_KEY = 0X767B // .. ==> 0XF8000004[15:0] = 0x0000767BU // .. ==> MASK : 0x0000FFFFU VAL : 0x0000767BU // .. EMIT_MASKWRITE(0XF8000004, 0x0000FFFFU ,0x0000767BU), // .. FINISH: LOCK IT BACK // FINISH: top // EMIT_EXIT(), // }; unsigned long ps7_debug_1_0[] = { // START: top // .. START: CROSS TRIGGER CONFIGURATIONS // .. .. START: UNLOCKING CTI REGISTERS // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8898FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8898FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8899FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8899FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. KEY = 0XC5ACCE55 // .. .. ==> 0XF8809FB0[31:0] = 0xC5ACCE55U // .. .. ==> MASK : 0xFFFFFFFFU VAL : 0xC5ACCE55U // .. .. EMIT_MASKWRITE(0XF8809FB0, 0xFFFFFFFFU ,0xC5ACCE55U), // .. .. FINISH: UNLOCKING CTI REGISTERS // .. .. START: ENABLING CTI MODULES AND CHANNELS // .. .. FINISH: ENABLING CTI MODULES AND CHANNELS // .. .. START: MAPPING CPU0, CPU1 AND FTM EVENTS TO CTM CHANNELS // .. .. FINISH: MAPPING CPU0, CPU1 AND FTM EVENTS TO CTM CHANNELS // .. FINISH: CROSS TRIGGER CONFIGURATIONS // FINISH: top // EMIT_EXIT(), // }; #include "xil_io.h" #define PS7_MASK_POLL_TIME 100000000 char* getPS7MessageInfo(unsigned key) { char* err_msg = ""; switch (key) { case PS7_INIT_SUCCESS: err_msg = "PS7 initialization successful"; break; case PS7_INIT_CORRUPT: err_msg = "PS7 init Data Corrupted"; break; case PS7_INIT_TIMEOUT: err_msg = "PS7 init mask poll timeout"; break; case PS7_POLL_FAILED_DDR_INIT: err_msg = "Mask Poll failed for DDR Init"; break; case PS7_POLL_FAILED_DMA: err_msg = "Mask Poll failed for PLL Init"; break; case PS7_POLL_FAILED_PLL: err_msg = "Mask Poll failed for DMA done bit"; break; default: err_msg = "Undefined error status"; break; } return err_msg; } unsigned long ps7GetSiliconVersion () { // Read PS version from MCTRL register [31:28] unsigned long mask = 0xF0000000; unsigned long *addr = (unsigned long*) 0XF8007080; unsigned long ps_version = (*addr & mask) >> 28; return ps_version; } void mask_write (unsigned long add , unsigned long mask, unsigned long val ) { volatile unsigned long *addr = (volatile unsigned long*) add; *addr = ( val & mask ) | ( *addr & ~mask); //xil_printf("MaskWrite : 0x%x--> 0x%x \n \r" ,add, *addr); } int mask_poll(unsigned long add , unsigned long mask ) { volatile unsigned long *addr = (volatile unsigned long*) add; int i = 0; while (!(*addr & mask)) { if (i == PS7_MASK_POLL_TIME) { return -1; } i++; } return 1; //xil_printf("MaskPoll : 0x%x --> 0x%x \n \r" , add, *addr); } unsigned long mask_read(unsigned long add , unsigned long mask ) { volatile unsigned long *addr = (volatile unsigned long*) add; unsigned long val = (*addr & mask); //xil_printf("MaskRead : 0x%x --> 0x%x \n \r" , add, val); return val; } int ps7_config(unsigned long * ps7_config_init) { unsigned long *ptr = ps7_config_init; unsigned long opcode; // current instruction .. unsigned long args[16]; // no opcode has so many args ... int numargs; // number of arguments of this instruction int j; // general purpose index volatile unsigned long *addr; // some variable to make code readable unsigned long val,mask; // some variable to make code readable int finish = -1 ; // loop while this is negative ! int i = 0; // Timeout variable while( finish < 0 ) { numargs = ptr[0] & 0xF; opcode = ptr[0] >> 4; for( j = 0 ; j < numargs ; j ++ ) args[j] = ptr[j+1]; ptr += numargs + 1; switch ( opcode ) { case OPCODE_EXIT: finish = PS7_INIT_SUCCESS; break; case OPCODE_CLEAR: addr = (unsigned long*) args[0]; *addr = 0; break; case OPCODE_WRITE: addr = (unsigned long*) args[0]; val = args[1]; *addr = val; break; case OPCODE_MASKWRITE: addr = (unsigned long*) args[0]; mask = args[1]; val = args[2]; *addr = ( val & mask ) | ( *addr & ~mask); break; case OPCODE_MASKPOLL: addr = (unsigned long*) args[0]; mask = args[1]; i = 0; while (!(*addr & mask)) { if (i == PS7_MASK_POLL_TIME) { finish = PS7_INIT_TIMEOUT; break; } i++; } break; case OPCODE_MASKDELAY: addr = (unsigned long*) args[0]; mask = args[1]; int delay = get_number_of_cycles_for_delay(mask); perf_reset_and_start_timer(); while ((*addr < delay)) { } break; default: finish = PS7_INIT_CORRUPT; break; } } return finish; } unsigned long *ps7_mio_init_data = ps7_mio_init_data_3_0; unsigned long *ps7_pll_init_data = ps7_pll_init_data_3_0; unsigned long *ps7_clock_init_data = ps7_clock_init_data_3_0; unsigned long *ps7_ddr_init_data = ps7_ddr_init_data_3_0; unsigned long *ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; int ps7_post_config() { // Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret = -1; if (si_ver == PCW_SILICON_VERSION_1) { ret = ps7_config (ps7_post_config_1_0); if (ret != PS7_INIT_SUCCESS) return ret; } else if (si_ver == PCW_SILICON_VERSION_2) { ret = ps7_config (ps7_post_config_2_0); if (ret != PS7_INIT_SUCCESS) return ret; } else { ret = ps7_config (ps7_post_config_3_0); if (ret != PS7_INIT_SUCCESS) return ret; } return PS7_INIT_SUCCESS; } int ps7_debug() { // Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret = -1; if (si_ver == PCW_SILICON_VERSION_1) { ret = ps7_config (ps7_debug_1_0); if (ret != PS7_INIT_SUCCESS) return ret; } else if (si_ver == PCW_SILICON_VERSION_2) { ret = ps7_config (ps7_debug_2_0); if (ret != PS7_INIT_SUCCESS) return ret; } else { ret = ps7_config (ps7_debug_3_0); if (ret != PS7_INIT_SUCCESS) return ret; } return PS7_INIT_SUCCESS; } int ps7_init() { // Get the PS_VERSION on run time unsigned long si_ver = ps7GetSiliconVersion (); int ret; //int pcw_ver = 0; if (si_ver == PCW_SILICON_VERSION_1) { ps7_mio_init_data = ps7_mio_init_data_1_0; ps7_pll_init_data = ps7_pll_init_data_1_0; ps7_clock_init_data = ps7_clock_init_data_1_0; ps7_ddr_init_data = ps7_ddr_init_data_1_0; ps7_peripherals_init_data = ps7_peripherals_init_data_1_0; //pcw_ver = 1; } else if (si_ver == PCW_SILICON_VERSION_2) { ps7_mio_init_data = ps7_mio_init_data_2_0; ps7_pll_init_data = ps7_pll_init_data_2_0; ps7_clock_init_data = ps7_clock_init_data_2_0; ps7_ddr_init_data = ps7_ddr_init_data_2_0; ps7_peripherals_init_data = ps7_peripherals_init_data_2_0; //pcw_ver = 2; } else { ps7_mio_init_data = ps7_mio_init_data_3_0; ps7_pll_init_data = ps7_pll_init_data_3_0; ps7_clock_init_data = ps7_clock_init_data_3_0; ps7_ddr_init_data = ps7_ddr_init_data_3_0; ps7_peripherals_init_data = ps7_peripherals_init_data_3_0; //pcw_ver = 3; } // MIO init ret = ps7_config (ps7_mio_init_data); if (ret != PS7_INIT_SUCCESS) return ret; // PLL init ret = ps7_config (ps7_pll_init_data); if (ret != PS7_INIT_SUCCESS) return ret; // Clock init ret = ps7_config (ps7_clock_init_data); if (ret != PS7_INIT_SUCCESS) return ret; // DDR init ret = ps7_config (ps7_ddr_init_data); if (ret != PS7_INIT_SUCCESS) return ret; // Peripherals init ret = ps7_config (ps7_peripherals_init_data); if (ret != PS7_INIT_SUCCESS) return ret; //xil_printf ("\n PCW Silicon Version : %d.0", pcw_ver); return PS7_INIT_SUCCESS; } /* For delay calculation using global timer */ /* start timer */ void perf_start_clock(void) { *(volatile unsigned int*)SCU_GLOBAL_TIMER_CONTROL = ((1 << 0) | // Timer Enable (1 << 3) | // Auto-increment (0 << 8) // Pre-scale ); } /* stop timer and reset timer count regs */ void perf_reset_clock(void) { perf_disable_clock(); *(volatile unsigned int*)SCU_GLOBAL_TIMER_COUNT_L32 = 0; *(volatile unsigned int*)SCU_GLOBAL_TIMER_COUNT_U32 = 0; } /* Compute mask for given delay in miliseconds*/ int get_number_of_cycles_for_delay(unsigned int delay) { // GTC is always clocked at 1/2 of the CPU frequency (CPU_3x2x) return (APU_FREQ*delay/(2*1000)); } /* stop timer */ void perf_disable_clock(void) { *(volatile unsigned int*)SCU_GLOBAL_TIMER_CONTROL = 0; } void perf_reset_and_start_timer() { perf_reset_clock(); perf_start_clock(); }