void system_disable_jump(void) { disable_jump = 1; #ifdef CONFIG_MPU if (system_is_locked()) { int ret; int enable_mpu = 0; enum system_image_copy_t copy; CPRINTS("MPU type: %08x", mpu_get_type()); /* * Protect RAM from code execution */ ret = mpu_protect_ram(); if (ret == EC_SUCCESS) { enable_mpu = 1; CPRINTS("RAM locked. Exclusion %08x-%08x", &__iram_text_start, &__iram_text_end); } else { CPRINTS("Failed to lock RAM (%d)", ret); } /* * Protect inactive image (ie. RO if running RW, vice versa) * from code execution. */ switch (system_get_image_copy()) { case SYSTEM_IMAGE_RO: ret = mpu_lock_rw_flash(); copy = SYSTEM_IMAGE_RW; break; case SYSTEM_IMAGE_RW: ret = mpu_lock_ro_flash(); copy = SYSTEM_IMAGE_RO; break; default: copy = SYSTEM_IMAGE_UNKNOWN; ret = !EC_SUCCESS; } if (ret == EC_SUCCESS) { enable_mpu = 1; CPRINTS("%s image locked", system_image_copy_t_to_string(copy)); } else { CPRINTS("Failed to lock %s image (%d)", system_image_copy_t_to_string(copy), ret); } if (enable_mpu) mpu_enable(); } else { CPRINTS("System is unlocked. Skip MPU configuration"); } #endif }
int mpu_pre_init(void) { int i; if (mpu_get_type() != 0x00000800) return EC_ERROR_UNIMPLEMENTED; mpu_disable(); for (i = 0; i < 8; ++i) mpu_config_region(i, CONFIG_RAM_BASE, CONFIG_RAM_SIZE, 0, 0); return EC_SUCCESS; }