2018-03-02 13:45:39 +03:00
|
|
|
/*
|
|
|
|
* ARM IoT Kit security controller
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018 Linaro Limited
|
|
|
|
* Written by Peter Maydell
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is a model of the security controller which is part of the
|
|
|
|
* Arm IoT Kit and documented in
|
|
|
|
* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
|
|
|
|
*
|
|
|
|
* QEMU interface:
|
|
|
|
* + sysbus MMIO region 0 is the "secure privilege control block" registers
|
|
|
|
* + sysbus MMIO region 1 is the "non-secure privilege control block" registers
|
2018-03-02 13:45:39 +03:00
|
|
|
* + named GPIO output "sec_resp_cfg" indicating whether blocked accesses
|
|
|
|
* should RAZ/WI or bus error
|
2018-03-02 13:45:40 +03:00
|
|
|
* + named GPIO output "nsc_cfg" whose value tracks the NSCCFG register value
|
2018-08-24 15:17:44 +03:00
|
|
|
* + named GPIO output "msc_irq" for the combined IRQ line from the MSCs
|
2018-03-02 13:45:39 +03:00
|
|
|
* Controlling the 2 APB PPCs in the IoTKit:
|
|
|
|
* + named GPIO outputs apb_ppc0_nonsec[0..2] and apb_ppc1_nonsec
|
|
|
|
* + named GPIO outputs apb_ppc0_ap[0..2] and apb_ppc1_ap
|
|
|
|
* + named GPIO outputs apb_ppc{0,1}_irq_enable
|
|
|
|
* + named GPIO outputs apb_ppc{0,1}_irq_clear
|
|
|
|
* + named GPIO inputs apb_ppc{0,1}_irq_status
|
|
|
|
* Controlling each of the 4 expansion APB PPCs which a system using the IoTKit
|
|
|
|
* might provide:
|
|
|
|
* + named GPIO outputs apb_ppcexp{0,1,2,3}_nonsec[0..15]
|
|
|
|
* + named GPIO outputs apb_ppcexp{0,1,2,3}_ap[0..15]
|
|
|
|
* + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_enable
|
|
|
|
* + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_clear
|
|
|
|
* + named GPIO inputs apb_ppcexp{0,1,2,3}_irq_status
|
|
|
|
* Controlling each of the 4 expansion AHB PPCs which a system using the IoTKit
|
|
|
|
* might provide:
|
|
|
|
* + named GPIO outputs ahb_ppcexp{0,1,2,3}_nonsec[0..15]
|
|
|
|
* + named GPIO outputs ahb_ppcexp{0,1,2,3}_ap[0..15]
|
|
|
|
* + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_enable
|
|
|
|
* + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_clear
|
|
|
|
* + named GPIO inputs ahb_ppcexp{0,1,2,3}_irq_status
|
2019-02-01 17:55:42 +03:00
|
|
|
* Controlling the (up to) 4 MPCs in the IoTKit/SSE:
|
|
|
|
* + named GPIO inputs mpc_status[0..3]
|
2018-06-22 15:28:40 +03:00
|
|
|
* Controlling each of the 16 expansion MPCs which a system using the IoTKit
|
|
|
|
* might provide:
|
|
|
|
* + named GPIO inputs mpcexp_status[0..15]
|
2018-08-24 15:17:44 +03:00
|
|
|
* Controlling each of the 16 expansion MSCs which a system using the IoTKit
|
|
|
|
* might provide:
|
|
|
|
* + named GPIO inputs mscexp_status[0..15]
|
|
|
|
* + named GPIO outputs mscexp_clear[0..15]
|
|
|
|
* + named GPIO outputs mscexp_ns[0..15]
|
2018-03-02 13:45:39 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IOTKIT_SECCTL_H
|
|
|
|
#define IOTKIT_SECCTL_H
|
|
|
|
|
|
|
|
#include "hw/sysbus.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2018-03-02 13:45:39 +03:00
|
|
|
|
|
|
|
#define TYPE_IOTKIT_SECCTL "iotkit-secctl"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(IoTKitSecCtl, IOTKIT_SECCTL)
|
2018-03-02 13:45:39 +03:00
|
|
|
|
2018-03-02 13:45:39 +03:00
|
|
|
#define IOTS_APB_PPC0_NUM_PORTS 3
|
|
|
|
#define IOTS_APB_PPC1_NUM_PORTS 1
|
|
|
|
#define IOTS_PPC_NUM_PORTS 16
|
|
|
|
#define IOTS_NUM_APB_PPC 2
|
|
|
|
#define IOTS_NUM_APB_EXP_PPC 4
|
|
|
|
#define IOTS_NUM_AHB_EXP_PPC 4
|
2018-06-22 15:28:40 +03:00
|
|
|
#define IOTS_NUM_EXP_MPC 16
|
2019-02-01 17:55:42 +03:00
|
|
|
#define IOTS_NUM_MPC 4
|
2018-08-24 15:17:44 +03:00
|
|
|
#define IOTS_NUM_EXP_MSC 16
|
2018-03-02 13:45:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* State and IRQ lines relating to a PPC. For the
|
|
|
|
* PPCs in the IoTKit not all the IRQ lines are used.
|
|
|
|
*/
|
|
|
|
typedef struct IoTKitSecCtlPPC {
|
|
|
|
qemu_irq nonsec[IOTS_PPC_NUM_PORTS];
|
|
|
|
qemu_irq ap[IOTS_PPC_NUM_PORTS];
|
|
|
|
qemu_irq irq_enable;
|
|
|
|
qemu_irq irq_clear;
|
|
|
|
|
|
|
|
uint32_t ns;
|
|
|
|
uint32_t sp;
|
|
|
|
uint32_t nsp;
|
|
|
|
|
|
|
|
/* Number of ports actually present */
|
|
|
|
int numports;
|
|
|
|
/* Offset of this PPC's interrupt bits in SECPPCINTSTAT */
|
|
|
|
int irq_bit_offset;
|
|
|
|
IoTKitSecCtl *parent;
|
|
|
|
} IoTKitSecCtlPPC;
|
|
|
|
|
|
|
|
struct IoTKitSecCtl {
|
2018-03-02 13:45:39 +03:00
|
|
|
/*< private >*/
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
2018-03-02 13:45:39 +03:00
|
|
|
qemu_irq sec_resp_cfg;
|
2018-03-02 13:45:40 +03:00
|
|
|
qemu_irq nsc_cfg_irq;
|
2018-03-02 13:45:39 +03:00
|
|
|
|
|
|
|
MemoryRegion s_regs;
|
|
|
|
MemoryRegion ns_regs;
|
2018-03-02 13:45:39 +03:00
|
|
|
|
|
|
|
uint32_t secppcintstat;
|
|
|
|
uint32_t secppcinten;
|
|
|
|
uint32_t secrespcfg;
|
2018-03-02 13:45:40 +03:00
|
|
|
uint32_t nsccfg;
|
|
|
|
uint32_t brginten;
|
2018-06-22 15:28:40 +03:00
|
|
|
uint32_t mpcintstatus;
|
2018-03-02 13:45:39 +03:00
|
|
|
|
2018-08-24 15:17:44 +03:00
|
|
|
uint32_t secmscintstat;
|
|
|
|
uint32_t secmscinten;
|
|
|
|
uint32_t nsmscexp;
|
|
|
|
qemu_irq mscexp_clear[IOTS_NUM_EXP_MSC];
|
|
|
|
qemu_irq mscexp_ns[IOTS_NUM_EXP_MSC];
|
|
|
|
qemu_irq msc_irq;
|
|
|
|
|
2018-03-02 13:45:39 +03:00
|
|
|
IoTKitSecCtlPPC apb[IOTS_NUM_APB_PPC];
|
|
|
|
IoTKitSecCtlPPC apbexp[IOTS_NUM_APB_EXP_PPC];
|
|
|
|
IoTKitSecCtlPPC ahbexp[IOTS_NUM_APB_EXP_PPC];
|
|
|
|
};
|
2018-03-02 13:45:39 +03:00
|
|
|
|
|
|
|
#endif
|