Loading drivers/gud/Makefile +0 −3 Original line number Diff line number Diff line Loading @@ -23,9 +23,6 @@ mcKernelApi-objs := MobiCoreKernelApi/main.o \ ccflags-y := -DNDEBUG -I$(GUD_ROOT_FOLDER) ccflags-y += -Wno-declaration-after-statement #Netlink changed arguments number ccflags-y += -DMC_NETLINK_COMPAT_V37 ccflags-$(CONFIG_MOBICORE_DEBUG) += -DDEBUG ccflags-$(CONFIG_MOBICORE_VERBOSE) += -DDEBUG_VERBOSE Loading drivers/gud/MobiCoreDriver/logging.c +6 −4 Original line number Diff line number Diff line /* * Copyright (c) 2013-2014 TRUSTONIC LIMITED * Copyright (c) 2013 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -58,6 +58,7 @@ struct logmsg_struct { uint32_t log_data; /* Value, if any */ }; static bool prev_eol; /* Previous char was a EOL */ static uint16_t prev_source; /* Previous Log source */ static uint32_t log_pos; /* MobiCore log previous position */ static struct mc_trace_buf *log_buf; /* MobiCore log buffer structure */ Loading @@ -73,6 +74,7 @@ static void log_eol(uint16_t source) log_line_len = 0; return; } prev_eol = true; /* MobiCore Userspace */ if (prev_source) dev_info(mcd, "%03x|%s\n", prev_source, log_line); Loading Loading @@ -102,6 +104,7 @@ static void log_char(char ch, uint16_t source) log_line[log_line_len] = ch; log_line[log_line_len + 1] = 0; log_line_len++; prev_eol = false; prev_source = source; } Loading Loading @@ -287,6 +290,7 @@ long mobicore_log_setup(void) log_thread = NULL; log_line = NULL; log_line_len = 0; prev_eol = false; prev_source = 0; thread_err = 0; Loading Loading @@ -326,9 +330,7 @@ long mobicore_log_setup(void) memset(&fc_log, 0, sizeof(fc_log)); fc_log.as_in.cmd = MC_FC_NWD_TRACE; fc_log.as_in.param[0] = (uint32_t)phys_log_buf; #ifdef CONFIG_PHYS_ADDR_T_64BIT fc_log.as_in.param[1] = (uint32_t)(phys_log_buf >> 32); #endif fc_log.as_in.param[1] = (uint32_t)(((uint64_t)phys_log_buf) >> 32); fc_log.as_in.param[2] = log_size; MCDRV_DBG(mcd, "fc_log virt=%p phys=0x%llX", Loading drivers/gud/MobiCoreDriver/main.c +5 −38 Original line number Diff line number Diff line /* * Copyright (c) 2013-2014 TRUSTONIC LIMITED * Copyright (c) 2013 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -220,8 +220,6 @@ bool mc_check_owner_fd(struct mc_instance *instance, int32_t fd) rcu_read_lock(); fp = fcheck_files(current->files, fd); if (fp == NULL) goto out; s = __get_socket(fp); if (s) peer = get_pid_task(s->sk_peer_pid, PIDTYPE_PID); Loading Loading @@ -394,9 +392,7 @@ int mc_get_buffer(struct mc_instance *instance, void *addr = 0; phys_addr_t phys = 0; unsigned int order; #if defined(DEBUG_VERBOSE) unsigned long allocated_size; #endif int ret = 0; if (WARN(!instance, "No instance data available")) Loading @@ -412,9 +408,7 @@ int mc_get_buffer(struct mc_instance *instance, MCDRV_DBG_WARN(mcd, "Buffer size too large"); return -ENOMEM; } #if defined(DEBUG_VERBOSE) allocated_size = (1 << order) * PAGE_SIZE; #endif if (mutex_lock_interruptible(&instance->lock)) return -ERESTARTSYS; Loading Loading @@ -787,41 +781,13 @@ static long mc_fd_user_ioctl(struct file *file, unsigned int cmd, ret = mc_free_buffer(instance, (uint32_t)arg); break; /* 32/64 bit interface compatiblity notice: * mc_ioctl_reg_wsm has been defined with the buffer parameter * as void* which means that the size and layout of the structure * are different between 32 and 64 bit variants. * However our 64 bit Linux driver must be able to service both * 32 and 64 bit clients so we have to allow both IOCTLs. Though * we have a bit of copy paste code we provide maximum backwards * compatiblity */ case MC_IO_REG_WSM:{ struct mc_ioctl_reg_wsm reg; phys_addr_t phys = 0; if (copy_from_user(®, uarg, sizeof(reg))) return -EFAULT; ret = mc_register_wsm_mmu(instance, (void *)(uintptr_t)reg.buffer, reg.len, ®.handle, &phys); reg.table_phys = phys; if (!ret) { if (copy_to_user(uarg, ®, sizeof(reg))) { ret = -EFAULT; mc_unregister_wsm_mmu(instance, reg.handle); } } break; } case MC_COMPAT_REG_WSM:{ struct mc_compat_ioctl_reg_wsm reg; phys_addr_t phys = 0; phys_addr_t phys; if (copy_from_user(®, uarg, sizeof(reg))) return -EFAULT; ret = mc_register_wsm_mmu(instance, (void *)(uintptr_t)reg.buffer, ret = mc_register_wsm_mmu(instance, (void *)reg.buffer, reg.len, ®.handle, &phys); reg.table_phys = phys; Loading Loading @@ -1471,8 +1437,8 @@ free_pm: #ifdef MC_PM_RUNTIME mc_pm_free(); free_isr: #endif free_irq(MC_INTR_SSIQ, &ctx); #endif err_req_irq: mc_fastcall_destroy(); error: Loading Loading @@ -1523,6 +1489,7 @@ bool mc_sleep_ready(void) /* Linux Driver Module Macros */ module_init(mobicore_init); module_exit(mobicore_exit); MODULE_AUTHOR("Giesecke & Devrient GmbH"); MODULE_AUTHOR("Trustonic Limited"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("MobiCore driver"); drivers/gud/MobiCoreDriver/platforms/MSM8960_SURF_STD/platform.h +2 −8 Original line number Diff line number Diff line /* * Copyright (c) 2013-2014 TRUSTONIC LIMITED * Copyright (c) 2013 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading @@ -20,8 +20,6 @@ * Header file the MobiCore Driver Kernel Module, * its internal structures and defines. */ #ifndef _MC_PLATFORM_H_ #define _MC_PLATFORM_H_ Loading Loading @@ -56,11 +54,7 @@ static inline int smc_fastcall(void *fc_generic, size_t size) */ #define MC_VM_UNMAP /* * Perform crypto clock enable/disable */ #ifndef CONFIG_ARCH_MSM8960 /* Perform clock enable/disable */ #define MC_CRYPTO_CLOCK_MANAGEMENT #endif #endif /* _MC_PLATFORM_H_ */ drivers/gud/MobiCoreDriver/pm.c +62 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,57 @@ static struct notifier_block mc_notif_block = { .notifier_call = mc_suspend_notifier, }; #ifdef MC_BL_NOTIFIER static int bl_switcher_notifier_handler(struct notifier_block *this, unsigned long event, void *ptr) { unsigned int mpidr, cpu, cluster; struct mc_mcp_buffer *mcp = ctx->mcp; if (!mcp) return 0; asm volatile ("mrc\tp15, 0, %0, c0, c0, 5" : "=r" (mpidr)); cpu = mpidr & 0x3; cluster = (mpidr >> 8) & 0xf; MCDRV_DBG(mcd, "%s switching!!, cpu: %u, Out=%u", (event == SWITCH_ENTER ? "Before" : "After"), cpu, cluster); if (cpu != 0) return 0; switch (event) { case SWITCH_ENTER: if (!sleep_ready()) { ctx->mcp->flags.sleep_mode.sleep_req = REQ_TO_SLEEP; _nsiq(); /* By this time we should be ready for sleep or we are * in the middle of something important */ if (!sleep_ready()) { dump_sleep_params(&mcp->flags); MCDRV_DBG(mcd, "MobiCore: Don't allow switch!"); ctx->mcp->flags.sleep_mode.sleep_req = 0; return -EPERM; } } break; case SWITCH_EXIT: ctx->mcp->flags.sleep_mode.sleep_req = 0; break; default: MCDRV_DBG(mcd, "MobiCore: Unknown switch event!"); } return 0; } static struct notifier_block switcher_nb = { .notifier_call = bl_switcher_notifier_handler, }; #endif int mc_pm_initialize(struct mc_context *context) { int ret = 0; Loading @@ -136,6 +187,12 @@ int mc_pm_initialize(struct mc_context *context) ret = register_pm_notifier(&mc_notif_block); if (ret) MCDRV_DBG_ERROR(mcd, "device pm register failed"); #ifdef MC_BL_NOTIFIER if (register_bL_swicher_notifier(&switcher_nb)) MCDRV_DBG_ERROR(mcd, "Failed to register to bl_switcher_notifier"); #endif return ret; } Loading @@ -144,6 +201,11 @@ int mc_pm_free(void) int ret = unregister_pm_notifier(&mc_notif_block); if (ret) MCDRV_DBG_ERROR(mcd, "device pm unregister failed"); #ifdef MC_BL_NOTIFIER ret = unregister_bL_swicher_notifier(&switcher_nb); if (ret) MCDRV_DBG_ERROR(mcd, "device bl unregister failed"); #endif return ret; } Loading Loading
drivers/gud/Makefile +0 −3 Original line number Diff line number Diff line Loading @@ -23,9 +23,6 @@ mcKernelApi-objs := MobiCoreKernelApi/main.o \ ccflags-y := -DNDEBUG -I$(GUD_ROOT_FOLDER) ccflags-y += -Wno-declaration-after-statement #Netlink changed arguments number ccflags-y += -DMC_NETLINK_COMPAT_V37 ccflags-$(CONFIG_MOBICORE_DEBUG) += -DDEBUG ccflags-$(CONFIG_MOBICORE_VERBOSE) += -DDEBUG_VERBOSE Loading
drivers/gud/MobiCoreDriver/logging.c +6 −4 Original line number Diff line number Diff line /* * Copyright (c) 2013-2014 TRUSTONIC LIMITED * Copyright (c) 2013 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -58,6 +58,7 @@ struct logmsg_struct { uint32_t log_data; /* Value, if any */ }; static bool prev_eol; /* Previous char was a EOL */ static uint16_t prev_source; /* Previous Log source */ static uint32_t log_pos; /* MobiCore log previous position */ static struct mc_trace_buf *log_buf; /* MobiCore log buffer structure */ Loading @@ -73,6 +74,7 @@ static void log_eol(uint16_t source) log_line_len = 0; return; } prev_eol = true; /* MobiCore Userspace */ if (prev_source) dev_info(mcd, "%03x|%s\n", prev_source, log_line); Loading Loading @@ -102,6 +104,7 @@ static void log_char(char ch, uint16_t source) log_line[log_line_len] = ch; log_line[log_line_len + 1] = 0; log_line_len++; prev_eol = false; prev_source = source; } Loading Loading @@ -287,6 +290,7 @@ long mobicore_log_setup(void) log_thread = NULL; log_line = NULL; log_line_len = 0; prev_eol = false; prev_source = 0; thread_err = 0; Loading Loading @@ -326,9 +330,7 @@ long mobicore_log_setup(void) memset(&fc_log, 0, sizeof(fc_log)); fc_log.as_in.cmd = MC_FC_NWD_TRACE; fc_log.as_in.param[0] = (uint32_t)phys_log_buf; #ifdef CONFIG_PHYS_ADDR_T_64BIT fc_log.as_in.param[1] = (uint32_t)(phys_log_buf >> 32); #endif fc_log.as_in.param[1] = (uint32_t)(((uint64_t)phys_log_buf) >> 32); fc_log.as_in.param[2] = log_size; MCDRV_DBG(mcd, "fc_log virt=%p phys=0x%llX", Loading
drivers/gud/MobiCoreDriver/main.c +5 −38 Original line number Diff line number Diff line /* * Copyright (c) 2013-2014 TRUSTONIC LIMITED * Copyright (c) 2013 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -220,8 +220,6 @@ bool mc_check_owner_fd(struct mc_instance *instance, int32_t fd) rcu_read_lock(); fp = fcheck_files(current->files, fd); if (fp == NULL) goto out; s = __get_socket(fp); if (s) peer = get_pid_task(s->sk_peer_pid, PIDTYPE_PID); Loading Loading @@ -394,9 +392,7 @@ int mc_get_buffer(struct mc_instance *instance, void *addr = 0; phys_addr_t phys = 0; unsigned int order; #if defined(DEBUG_VERBOSE) unsigned long allocated_size; #endif int ret = 0; if (WARN(!instance, "No instance data available")) Loading @@ -412,9 +408,7 @@ int mc_get_buffer(struct mc_instance *instance, MCDRV_DBG_WARN(mcd, "Buffer size too large"); return -ENOMEM; } #if defined(DEBUG_VERBOSE) allocated_size = (1 << order) * PAGE_SIZE; #endif if (mutex_lock_interruptible(&instance->lock)) return -ERESTARTSYS; Loading Loading @@ -787,41 +781,13 @@ static long mc_fd_user_ioctl(struct file *file, unsigned int cmd, ret = mc_free_buffer(instance, (uint32_t)arg); break; /* 32/64 bit interface compatiblity notice: * mc_ioctl_reg_wsm has been defined with the buffer parameter * as void* which means that the size and layout of the structure * are different between 32 and 64 bit variants. * However our 64 bit Linux driver must be able to service both * 32 and 64 bit clients so we have to allow both IOCTLs. Though * we have a bit of copy paste code we provide maximum backwards * compatiblity */ case MC_IO_REG_WSM:{ struct mc_ioctl_reg_wsm reg; phys_addr_t phys = 0; if (copy_from_user(®, uarg, sizeof(reg))) return -EFAULT; ret = mc_register_wsm_mmu(instance, (void *)(uintptr_t)reg.buffer, reg.len, ®.handle, &phys); reg.table_phys = phys; if (!ret) { if (copy_to_user(uarg, ®, sizeof(reg))) { ret = -EFAULT; mc_unregister_wsm_mmu(instance, reg.handle); } } break; } case MC_COMPAT_REG_WSM:{ struct mc_compat_ioctl_reg_wsm reg; phys_addr_t phys = 0; phys_addr_t phys; if (copy_from_user(®, uarg, sizeof(reg))) return -EFAULT; ret = mc_register_wsm_mmu(instance, (void *)(uintptr_t)reg.buffer, ret = mc_register_wsm_mmu(instance, (void *)reg.buffer, reg.len, ®.handle, &phys); reg.table_phys = phys; Loading Loading @@ -1471,8 +1437,8 @@ free_pm: #ifdef MC_PM_RUNTIME mc_pm_free(); free_isr: #endif free_irq(MC_INTR_SSIQ, &ctx); #endif err_req_irq: mc_fastcall_destroy(); error: Loading Loading @@ -1523,6 +1489,7 @@ bool mc_sleep_ready(void) /* Linux Driver Module Macros */ module_init(mobicore_init); module_exit(mobicore_exit); MODULE_AUTHOR("Giesecke & Devrient GmbH"); MODULE_AUTHOR("Trustonic Limited"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("MobiCore driver");
drivers/gud/MobiCoreDriver/platforms/MSM8960_SURF_STD/platform.h +2 −8 Original line number Diff line number Diff line /* * Copyright (c) 2013-2014 TRUSTONIC LIMITED * Copyright (c) 2013 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading @@ -20,8 +20,6 @@ * Header file the MobiCore Driver Kernel Module, * its internal structures and defines. */ #ifndef _MC_PLATFORM_H_ #define _MC_PLATFORM_H_ Loading Loading @@ -56,11 +54,7 @@ static inline int smc_fastcall(void *fc_generic, size_t size) */ #define MC_VM_UNMAP /* * Perform crypto clock enable/disable */ #ifndef CONFIG_ARCH_MSM8960 /* Perform clock enable/disable */ #define MC_CRYPTO_CLOCK_MANAGEMENT #endif #endif /* _MC_PLATFORM_H_ */
drivers/gud/MobiCoreDriver/pm.c +62 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,57 @@ static struct notifier_block mc_notif_block = { .notifier_call = mc_suspend_notifier, }; #ifdef MC_BL_NOTIFIER static int bl_switcher_notifier_handler(struct notifier_block *this, unsigned long event, void *ptr) { unsigned int mpidr, cpu, cluster; struct mc_mcp_buffer *mcp = ctx->mcp; if (!mcp) return 0; asm volatile ("mrc\tp15, 0, %0, c0, c0, 5" : "=r" (mpidr)); cpu = mpidr & 0x3; cluster = (mpidr >> 8) & 0xf; MCDRV_DBG(mcd, "%s switching!!, cpu: %u, Out=%u", (event == SWITCH_ENTER ? "Before" : "After"), cpu, cluster); if (cpu != 0) return 0; switch (event) { case SWITCH_ENTER: if (!sleep_ready()) { ctx->mcp->flags.sleep_mode.sleep_req = REQ_TO_SLEEP; _nsiq(); /* By this time we should be ready for sleep or we are * in the middle of something important */ if (!sleep_ready()) { dump_sleep_params(&mcp->flags); MCDRV_DBG(mcd, "MobiCore: Don't allow switch!"); ctx->mcp->flags.sleep_mode.sleep_req = 0; return -EPERM; } } break; case SWITCH_EXIT: ctx->mcp->flags.sleep_mode.sleep_req = 0; break; default: MCDRV_DBG(mcd, "MobiCore: Unknown switch event!"); } return 0; } static struct notifier_block switcher_nb = { .notifier_call = bl_switcher_notifier_handler, }; #endif int mc_pm_initialize(struct mc_context *context) { int ret = 0; Loading @@ -136,6 +187,12 @@ int mc_pm_initialize(struct mc_context *context) ret = register_pm_notifier(&mc_notif_block); if (ret) MCDRV_DBG_ERROR(mcd, "device pm register failed"); #ifdef MC_BL_NOTIFIER if (register_bL_swicher_notifier(&switcher_nb)) MCDRV_DBG_ERROR(mcd, "Failed to register to bl_switcher_notifier"); #endif return ret; } Loading @@ -144,6 +201,11 @@ int mc_pm_free(void) int ret = unregister_pm_notifier(&mc_notif_block); if (ret) MCDRV_DBG_ERROR(mcd, "device pm unregister failed"); #ifdef MC_BL_NOTIFIER ret = unregister_bL_swicher_notifier(&switcher_nb); if (ret) MCDRV_DBG_ERROR(mcd, "device bl unregister failed"); #endif return ret; } Loading