Lines Matching +full:secure +full:- +full:reg +full:- +full:access

4  * Copyright (c) 2006-2007 CodeSourcery.
16 #include "hw/qdev-properties.h"
17 #include "hw/qdev-clock.h"
20 #include "qemu/error-report.h"
25 #include "target/arm/cpu-features.h"
26 #include "target/arm/cpu-qom.h"
31 /* Get the byte address of the real memory for a bitband access. */
34 return s->base | (offset & 0x1ffffff) >> 5; in bitband_addr()
49 addr = bitband_addr(s, offset) & (-size); in bitband_read()
50 res = address_space_read(&s->source_as, addr, attrs, buf, size); in bitband_read()
55 bitpos = (offset >> 2) & ((size * 8) - 1); in bitband_read()
74 addr = bitband_addr(s, offset) & (-size); in bitband_write()
75 res = address_space_read(&s->source_as, addr, attrs, buf, size); in bitband_write()
80 bitpos = (offset >> 2) & ((size * 8) - 1); in bitband_write()
88 return address_space_write(&s->source_as, addr, attrs, buf, size); in bitband_write()
106 memory_region_init_io(&s->iomem, obj, &bitband_ops, s, in bitband_init()
108 sysbus_init_mmio(dev, &s->iomem); in bitband_init()
115 if (!s->source_memory) { in bitband_realize()
116 error_setg(errp, "source-memory property not set"); in bitband_realize()
120 address_space_init(&s->source_as, s->source_memory, "bitband-source"); in bitband_realize()
139 if (attrs.secure) { in v7m_sysreg_ns_write()
141 attrs.secure = 0; in v7m_sysreg_ns_write()
159 if (attrs.secure) { in v7m_sysreg_ns_read()
161 attrs.secure = 0; in v7m_sysreg_ns_read()
187 /* Direct the access to the correct systick */ in v7m_systick_write()
188 mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); in v7m_systick_write()
200 /* Direct the access to the correct systick */ in v7m_systick_read()
201 mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); in v7m_systick_read()
214 * accesses, and fault for non-privileged accesses.
256 memory_region_init(&s->container, obj, "armv7m-container", UINT64_MAX); in armv7m_instance_init()
258 object_initialize_child(obj, "nvic", &s->nvic, TYPE_NVIC); in armv7m_instance_init()
259 object_property_add_alias(obj, "num-irq", in armv7m_instance_init()
260 OBJECT(&s->nvic), "num-irq"); in armv7m_instance_init()
261 object_property_add_alias(obj, "num-prio-bits", in armv7m_instance_init()
262 OBJECT(&s->nvic), "num-prio-bits"); in armv7m_instance_init()
264 object_initialize_child(obj, "systick-reg-ns", &s->systick[M_REG_NS], in armv7m_instance_init()
267 * We can't initialize the secure systick here, as we don't know in armv7m_instance_init()
271 for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { in armv7m_instance_init()
272 object_initialize_child(obj, "bitband[*]", &s->bitband[i], in armv7m_instance_init()
276 s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0); in armv7m_instance_init()
277 s->cpuclk = qdev_init_clock_in(DEVICE(obj), "cpuclk", NULL, NULL, 0); in armv7m_instance_init()
287 if (!s->board_memory) { in armv7m_realize()
293 if (!clock_has_source(s->cpuclk)) { in armv7m_realize()
298 memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1); in armv7m_realize()
300 s->cpu = ARM_CPU(object_new_with_props(s->cpu_type, OBJECT(s), "cpu", in armv7m_realize()
307 object_property_set_link(OBJECT(s->cpu), "memory", OBJECT(&s->container), in armv7m_realize()
309 if (object_property_find(OBJECT(s->cpu), "idau")) { in armv7m_realize()
310 object_property_set_link(OBJECT(s->cpu), "idau", s->idau, in armv7m_realize()
313 if (object_property_find(OBJECT(s->cpu), "init-svtor")) { in armv7m_realize()
314 if (!object_property_set_uint(OBJECT(s->cpu), "init-svtor", in armv7m_realize()
315 s->init_svtor, errp)) { in armv7m_realize()
319 if (object_property_find(OBJECT(s->cpu), "init-nsvtor")) { in armv7m_realize()
320 if (!object_property_set_uint(OBJECT(s->cpu), "init-nsvtor", in armv7m_realize()
321 s->init_nsvtor, errp)) { in armv7m_realize()
325 if (object_property_find(OBJECT(s->cpu), "vfp")) { in armv7m_realize()
326 if (!object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, errp)) { in armv7m_realize()
330 if (object_property_find(OBJECT(s->cpu), "dsp")) { in armv7m_realize()
331 if (!object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, errp)) { in armv7m_realize()
335 object_property_set_bool(OBJECT(s->cpu), "start-powered-off", in armv7m_realize()
336 s->start_powered_off, &error_abort); in armv7m_realize()
339 * Real M-profile hardware can be configured with a different number of in armv7m_realize()
340 * MPU regions for Secure vs NonSecure. QEMU's CPU implementation doesn't in armv7m_realize()
343 if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && in armv7m_realize()
344 s->mpu_ns_regions != s->mpu_s_regions) { in armv7m_realize()
346 "mpu-ns-regions and mpu-s-regions properties must have the same value"); in armv7m_realize()
349 if (s->mpu_ns_regions != UINT_MAX && in armv7m_realize()
350 object_property_find(OBJECT(s->cpu), "pmsav7-dregion")) { in armv7m_realize()
351 if (!object_property_set_uint(OBJECT(s->cpu), "pmsav7-dregion", in armv7m_realize()
352 s->mpu_ns_regions, errp)) { in armv7m_realize()
361 s->cpu->env.nvic = &s->nvic; in armv7m_realize()
362 s->nvic.cpu = s->cpu; in armv7m_realize()
364 if (!qdev_realize(DEVICE(s->cpu), NULL, errp)) { in armv7m_realize()
369 if (!sysbus_realize(SYS_BUS_DEVICE(&s->nvic), errp)) { in armv7m_realize()
377 qdev_pass_gpios(DEVICE(&s->nvic), dev, NULL); in armv7m_realize()
378 qdev_pass_gpios(DEVICE(&s->nvic), dev, "SYSRESETREQ"); in armv7m_realize()
379 qdev_pass_gpios(DEVICE(&s->nvic), dev, "NMI"); in armv7m_realize()
391 * is to RAZ/WI for privileged access and BusFault for non-privileged in armv7m_realize()
392 * access. in armv7m_realize()
396 * 0x004 - ICTR in armv7m_realize()
397 * 0x010 - 0xff - systick in armv7m_realize()
398 * 0x100..0x7ec - NVIC in armv7m_realize()
399 * 0x7f0..0xcff - Reserved in armv7m_realize()
400 * 0xd00..0xd3c - SCS registers in armv7m_realize()
401 * 0xd40..0xeff - Reserved or Not implemented in armv7m_realize()
402 * 0xf00 - STIR in armv7m_realize()
406 * NonSecure alias SCS; secure accesses to this behave like NS accesses in armv7m_realize()
407 * to the main SCS range, and non-secure accesses (including when in armv7m_realize()
412 * state (attrs.secure == env->v7m.secure). In the v7m_sysreg_ns_ops in armv7m_realize()
413 * wrappers we change attrs.secure to indicate the NS access; so in armv7m_realize()
415 * use attrs.secure; code determining actual behaviour of the system in armv7m_realize()
416 * should use env->v7m.secure. in armv7m_realize()
420 * - default region (for RAZ/WI and BusFault) : -1 in armv7m_realize()
421 * - system register regions (provided by the NVIC) : 0 in armv7m_realize()
422 * - systick : 1 in armv7m_realize()
427 memory_region_init_io(&s->defaultmem, OBJECT(s), &ppb_default_ops, s, in armv7m_realize()
428 "nvic-default", 0x100000); in armv7m_realize()
429 memory_region_add_subregion_overlap(&s->container, 0xe0000000, in armv7m_realize()
430 &s->defaultmem, -1); in armv7m_realize()
433 sbd = SYS_BUS_DEVICE(&s->nvic); in armv7m_realize()
435 qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); in armv7m_realize()
437 memory_region_add_subregion(&s->container, 0xe000e000, in armv7m_realize()
439 if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { in armv7m_realize()
441 memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), in armv7m_realize()
445 memory_region_add_subregion(&s->container, 0xe002e000, in armv7m_realize()
446 &s->sysreg_ns_mem); in armv7m_realize()
454 * an ultimate source, and then it won't correctly auto-select the in armv7m_realize()
457 if (clock_has_source(s->refclk)) { in armv7m_realize()
458 qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "refclk", in armv7m_realize()
459 s->refclk); in armv7m_realize()
461 qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "cpuclk", s->cpuclk); in armv7m_realize()
462 if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) { in armv7m_realize()
465 sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), 0, in armv7m_realize()
466 qdev_get_gpio_in_named(DEVICE(&s->nvic), in armv7m_realize()
467 "systick-trigger", M_REG_NS)); in armv7m_realize()
469 if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) { in armv7m_realize()
471 * We couldn't init the secure systick device in instance_init in armv7m_realize()
475 object_initialize_child(OBJECT(dev), "systick-reg-s", in armv7m_realize()
476 &s->systick[M_REG_S], TYPE_SYSTICK); in armv7m_realize()
477 if (clock_has_source(s->refclk)) { in armv7m_realize()
478 qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "refclk", in armv7m_realize()
479 s->refclk); in armv7m_realize()
481 qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "cpuclk", in armv7m_realize()
482 s->cpuclk); in armv7m_realize()
484 if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), errp)) { in armv7m_realize()
487 sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_S]), 0, in armv7m_realize()
488 qdev_get_gpio_in_named(DEVICE(&s->nvic), in armv7m_realize()
489 "systick-trigger", M_REG_S)); in armv7m_realize()
492 memory_region_init_io(&s->systickmem, OBJECT(s), in armv7m_realize()
496 memory_region_add_subregion_overlap(&s->container, 0xe000e010, in armv7m_realize()
497 &s->systickmem, 1); in armv7m_realize()
498 if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { in armv7m_realize()
499 memory_region_init_io(&s->systick_ns_mem, OBJECT(s), in armv7m_realize()
500 &v7m_sysreg_ns_ops, &s->systickmem, in armv7m_realize()
502 memory_region_add_subregion_overlap(&s->container, 0xe002e010, in armv7m_realize()
503 &s->systick_ns_mem, 1); in armv7m_realize()
507 if (cpu_isar_feature(aa32_ras, s->cpu)) { in armv7m_realize()
508 object_initialize_child(OBJECT(dev), "armv7m-ras", in armv7m_realize()
509 &s->ras, TYPE_ARMV7M_RAS); in armv7m_realize()
510 sbd = SYS_BUS_DEVICE(&s->ras); in armv7m_realize()
514 memory_region_add_subregion_overlap(&s->container, 0xe0005000, in armv7m_realize()
518 for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { in armv7m_realize()
519 if (s->enable_bitband) { in armv7m_realize()
520 Object *obj = OBJECT(&s->bitband[i]); in armv7m_realize()
521 sbd = SYS_BUS_DEVICE(&s->bitband[i]); in armv7m_realize()
527 object_property_set_link(obj, "source-memory", in armv7m_realize()
528 OBJECT(s->board_memory), &error_abort); in armv7m_realize()
533 memory_region_add_subregion(&s->container, bitband_output_addr[i], in armv7m_realize()
536 object_unparent(OBJECT(&s->bitband[i])); in armv7m_realize()
542 DEFINE_PROP_STRING("cpu-type", ARMv7MState, cpu_type),
546 DEFINE_PROP_UINT32("init-svtor", ARMv7MState, init_svtor, 0),
547 DEFINE_PROP_UINT32("init-nsvtor", ARMv7MState, init_nsvtor, 0),
548 DEFINE_PROP_BOOL("enable-bitband", ARMv7MState, enable_bitband, false),
549 DEFINE_PROP_BOOL("start-powered-off", ARMv7MState, start_powered_off,
553 DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX),
554 DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX),
573 dc->realize = armv7m_realize; in armv7m_class_init()
574 dc->vmsd = &vmstate_armv7m; in armv7m_class_init()
602 if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { in armv7m_load_kernel()
625 * A-profile CPUs, we don't need to do anything special in the in armv7m_load_kernel()
628 * way A-profile does it. Note that this means that every M profile in armv7m_load_kernel()
636 DEFINE_PROP_LINK("source-memory", BitBandState, source_memory,
645 dc->realize = bitband_realize; in bitband_class_init()