/* * \brief Driver for the Central Security Unit * \author Stefan Kalkowski * \date 2012-11-06 */ /* * Copyright (C) 2012-2017 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. */ #ifndef _SRC__BOOTSTRAP__SPEC__ARM__IMX_CSU_H_ #define _SRC__BOOTSTRAP__SPEC__ARM__IMX_CSU_H_ #include #include namespace Bootstrap { struct Csu; } struct Bootstrap::Csu : Genode::Mmio { template struct Csl : public Register { enum { SECURE = 0x33, UNSECURE = 0xff, }; struct Slave_a : Register::template Bitfield<0, 9> { }; struct Slave_b : Register::template Bitfield<16, 9> { }; }; struct Master : public Register<0x218, 32> { enum { SECURE_UNLOCKED, UNSECURE_UNLOCKED, SECURE_LOCKED, UNSECURE_LOCKED }; struct Esdhc3 : Bitfield<0,2> { }; struct Cortex : Bitfield<2,2> { }; struct Sdma : Bitfield<4,2> { }; struct Gpu : Bitfield<6,2> { }; struct Usb : Bitfield<8,2> { }; struct Pata : Bitfield<10,2> { }; struct Mlb : Bitfield<14,2> { }; struct Rtic : Bitfield<18,2> { }; struct Esdhc4 : Bitfield<20,2> { }; struct Fec : Bitfield<22,2> { }; struct Dap : Bitfield<24,2> { }; struct Esdhc1 : Bitfield<26,2> { }; struct Esdhc2 : Bitfield<28,2> { }; }; struct Alarm_mask : public Register<0x230, 32> { }; struct Irq_ctrl : public Register<0x368, 32> { }; typedef Csl<0x00> Csl00; typedef Csl<0x04> Csl01; typedef Csl<0x08> Csl02; typedef Csl<0x0c> Csl03; typedef Csl<0x10> Csl04; typedef Csl<0x14> Csl05; typedef Csl<0x18> Csl06; typedef Csl<0x1c> Csl07; typedef Csl<0x20> Csl08; typedef Csl<0x24> Csl09; typedef Csl<0x28> Csl10; typedef Csl<0x2c> Csl11; typedef Csl<0x30> Csl12; typedef Csl<0x34> Csl13; typedef Csl<0x38> Csl14; typedef Csl<0x3c> Csl15; typedef Csl<0x40> Csl16; typedef Csl<0x44> Csl17; typedef Csl<0x48> Csl18; typedef Csl<0x4c> Csl19; typedef Csl<0x50> Csl20; typedef Csl<0x54> Csl21; typedef Csl<0x58> Csl22; typedef Csl<0x5c> Csl23; typedef Csl<0x60> Csl24; typedef Csl<0x64> Csl25; typedef Csl<0x68> Csl26; typedef Csl<0x6c> Csl27; typedef Csl<0x70> Csl28; typedef Csl<0x74> Csl29; typedef Csl<0x78> Csl30; typedef Csl<0x7c> Csl31; Csu(Genode::addr_t base, bool secure_uart, bool secure_gpio, bool secure_esdhc, bool secure_i2c) : Genode::Mmio(base) { /* Power (CCM, SRC, DPLLIP1-4, GPC and OWIRE) */ write(Csl00::UNSECURE); /* AHBMAX S0-S2 */ write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); /* AHBMAX M6 */ write(Csl00::UNSECURE); /* Timer (EPIT, GPT) TODO */ write(Csl00::UNSECURE); /* UART 1-5 */ Csl00::access_t uart_csl = secure_uart ? Csl00::SECURE : Csl00::UNSECURE; write(uart_csl); write(uart_csl); write(uart_csl); write(uart_csl); write(uart_csl); /* GPIO */ Csl00::access_t gpio_csl = secure_gpio ? Csl00::SECURE : Csl00::UNSECURE; write(gpio_csl); write(gpio_csl); write(gpio_csl); write(gpio_csl); /* IOMUXC TODO */ write(Csl00::UNSECURE); /* SDMA TODO */ write(Csl00::UNSECURE); /* USB */ write(Csl00::UNSECURE); /* TVE */ write(Csl00::SECURE); /* I2C */ Csl00::access_t i2c_csl = secure_i2c ? Csl00::SECURE : Csl00::UNSECURE; write(i2c_csl); write(i2c_csl); write(i2c_csl); /* IPU */ write(Csl00::SECURE); /* Audio */ write(Csl00::UNSECURE); /* SATA */ write(Csl00::UNSECURE); /* FEC */ write(Csl00::UNSECURE); /* SDHCI 1-4 */ Csl00::access_t esdhc_csl = secure_esdhc ? Csl00::SECURE : Csl00::UNSECURE; write(esdhc_csl); write(esdhc_csl); write(esdhc_csl); write(esdhc_csl); /* SPDIF */ write(Csl00::UNSECURE); /* GPU 2D */ write(Csl00::SECURE); /* GPU 3D */ write(Csl00::SECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); // SRTC write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); // SCC write(Csl00::UNSECURE); write(Csl00::UNSECURE); // RTIC write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::SECURE); //VPU write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); write(Csl00::UNSECURE); /* DMA from graphical subsystem is considered to be secure */ write(Master::SECURE_UNLOCKED); /* all other DMA operations are insecure */ write(Master::UNSECURE_UNLOCKED); write(Master::UNSECURE_UNLOCKED); write(Master::UNSECURE_UNLOCKED); write(Master::UNSECURE_UNLOCKED); write(Master::UNSECURE_UNLOCKED); Master::access_t esdhc_master = secure_esdhc ? Master::SECURE_UNLOCKED : Master::UNSECURE_UNLOCKED; write(esdhc_master); write(esdhc_master); write(esdhc_master); write(esdhc_master); } }; #endif /* _SRC__BOOTSTRAP__SPEC__ARM__IMX_CSU_H_ */