Loading drivers/gud/Makefile +3 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ 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 +4 −6 Original line number Diff line number Diff line /* * Copyright (c) 2013 TRUSTONIC LIMITED * Copyright (c) 2013-2014 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -58,7 +58,6 @@ 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 @@ -74,7 +73,6 @@ 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 @@ -104,7 +102,6 @@ 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 @@ -290,7 +287,6 @@ 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 @@ -330,7 +326,9 @@ 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; fc_log.as_in.param[1] = (uint32_t)(((uint64_t)phys_log_buf) >> 32); #ifdef CONFIG_PHYS_ADDR_T_64BIT fc_log.as_in.param[1] = (uint32_t)(phys_log_buf >> 32); #endif fc_log.as_in.param[2] = log_size; MCDRV_DBG(mcd, "fc_log virt=%p phys=0x%llX", Loading drivers/gud/MobiCoreDriver/main.c +38 −5 Original line number Diff line number Diff line /* * Copyright (c) 2013 TRUSTONIC LIMITED * Copyright (c) 2013-2014 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -220,6 +220,8 @@ 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 @@ -392,7 +394,9 @@ 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 @@ -408,7 +412,9 @@ 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 @@ -781,13 +787,41 @@ 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; 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; if (copy_from_user(®, uarg, sizeof(reg))) return -EFAULT; ret = mc_register_wsm_mmu(instance, (void *)reg.buffer, ret = mc_register_wsm_mmu(instance, (void *)(uintptr_t)reg.buffer, reg.len, ®.handle, &phys); reg.table_phys = phys; Loading Loading @@ -1437,8 +1471,8 @@ free_pm: #ifdef MC_PM_RUNTIME mc_pm_free(); free_isr: free_irq(MC_INTR_SSIQ, &ctx); #endif free_irq(MC_INTR_SSIQ, &ctx); err_req_irq: mc_fastcall_destroy(); error: Loading Loading @@ -1489,7 +1523,6 @@ 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 +7 −6 Original line number Diff line number Diff line /* * Copyright (c) 2013 TRUSTONIC LIMITED * Copyright (c) 2013-2014 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading @@ -20,6 +20,8 @@ * Header file the MobiCore Driver Kernel Module, * its internal structures and defines. */ #ifndef _MC_PLATFORM_H_ #define _MC_PLATFORM_H_ Loading @@ -31,7 +33,6 @@ /*--------------- Implementation -------------- */ #include <soc/qcom/scm.h> /* from following file */ #define SCM_SVC_MOBICORE 250 #define SCM_CMD_MOBICORE 1 Loading @@ -54,10 +55,10 @@ static inline int smc_fastcall(void *fc_generic, size_t size) */ #define MC_VM_UNMAP /* Enable Power Management for Crypto Engine */ #if defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8226) || \ defined(CONFIG_ARCH_APQ8084) /* Perform clock enable/disable */ /* * Perform crypto clock enable/disable */ #ifndef CONFIG_ARCH_MSM8960 #define MC_CRYPTO_CLOCK_MANAGEMENT #endif Loading drivers/gud/MobiCoreDriver/pm.c +0 −62 Original line number Diff line number Diff line Loading @@ -127,57 +127,6 @@ 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 @@ -187,12 +136,6 @@ 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 @@ -201,11 +144,6 @@ 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 +3 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,9 @@ 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 +4 −6 Original line number Diff line number Diff line /* * Copyright (c) 2013 TRUSTONIC LIMITED * Copyright (c) 2013-2014 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -58,7 +58,6 @@ 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 @@ -74,7 +73,6 @@ 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 @@ -104,7 +102,6 @@ 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 @@ -290,7 +287,6 @@ 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 @@ -330,7 +326,9 @@ 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; fc_log.as_in.param[1] = (uint32_t)(((uint64_t)phys_log_buf) >> 32); #ifdef CONFIG_PHYS_ADDR_T_64BIT fc_log.as_in.param[1] = (uint32_t)(phys_log_buf >> 32); #endif fc_log.as_in.param[2] = log_size; MCDRV_DBG(mcd, "fc_log virt=%p phys=0x%llX", Loading
drivers/gud/MobiCoreDriver/main.c +38 −5 Original line number Diff line number Diff line /* * Copyright (c) 2013 TRUSTONIC LIMITED * Copyright (c) 2013-2014 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading Loading @@ -220,6 +220,8 @@ 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 @@ -392,7 +394,9 @@ 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 @@ -408,7 +412,9 @@ 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 @@ -781,13 +787,41 @@ 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; 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; if (copy_from_user(®, uarg, sizeof(reg))) return -EFAULT; ret = mc_register_wsm_mmu(instance, (void *)reg.buffer, ret = mc_register_wsm_mmu(instance, (void *)(uintptr_t)reg.buffer, reg.len, ®.handle, &phys); reg.table_phys = phys; Loading Loading @@ -1437,8 +1471,8 @@ free_pm: #ifdef MC_PM_RUNTIME mc_pm_free(); free_isr: free_irq(MC_INTR_SSIQ, &ctx); #endif free_irq(MC_INTR_SSIQ, &ctx); err_req_irq: mc_fastcall_destroy(); error: Loading Loading @@ -1489,7 +1523,6 @@ 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 +7 −6 Original line number Diff line number Diff line /* * Copyright (c) 2013 TRUSTONIC LIMITED * Copyright (c) 2013-2014 TRUSTONIC LIMITED * All Rights Reserved. * * This program is free software; you can redistribute it and/or Loading @@ -20,6 +20,8 @@ * Header file the MobiCore Driver Kernel Module, * its internal structures and defines. */ #ifndef _MC_PLATFORM_H_ #define _MC_PLATFORM_H_ Loading @@ -31,7 +33,6 @@ /*--------------- Implementation -------------- */ #include <soc/qcom/scm.h> /* from following file */ #define SCM_SVC_MOBICORE 250 #define SCM_CMD_MOBICORE 1 Loading @@ -54,10 +55,10 @@ static inline int smc_fastcall(void *fc_generic, size_t size) */ #define MC_VM_UNMAP /* Enable Power Management for Crypto Engine */ #if defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8226) || \ defined(CONFIG_ARCH_APQ8084) /* Perform clock enable/disable */ /* * Perform crypto clock enable/disable */ #ifndef CONFIG_ARCH_MSM8960 #define MC_CRYPTO_CLOCK_MANAGEMENT #endif Loading
drivers/gud/MobiCoreDriver/pm.c +0 −62 Original line number Diff line number Diff line Loading @@ -127,57 +127,6 @@ 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 @@ -187,12 +136,6 @@ 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 @@ -201,11 +144,6 @@ 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