提交 f5e3980f 编写于 作者: A Alan Cox 提交者: Greg Kroah-Hartman

Staging: sep: Create a structure to hold all the current crap spewed about as globals

For now keep the field names matching the variable names
Signed-off-by: NAlan Cox <alan@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 6a107539
#ifndef __SEP_DEV_H__
#define __SEP_DEV_H__
/*
*
* sep_dev.h - Security Processor Device Structures
*
* Copyright(c) 2009 Intel Corporation. All rights reserved.
* Copyright(c) 2009 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Alan Cox alan@linux.intel.com
*
*/
struct sep_device {
/* pointer to pci dev */
struct pci_dev *sep_pci_dev_ptr;
unsigned long io_memory_start_physical_address;
unsigned long io_memory_end_physical_address;
unsigned long io_memory_size;
void *io_memory_start_virtual_address;
/* restricted access region */
unsigned long rar_physical_address;
void *rar_virtual_address;
/* shared memory region */
unsigned long shared_physical_address;
void *shared_virtual_address;
/* firmware regions */
unsigned long cache_physical_address;
unsigned long cache_size;
void *cache_virtual_address;
unsigned long resident_physical_address;
unsigned long resident_size;
void *resident_virtual_address;
/* device interrupt (as retrieved from PCI) */
int sep_irq;
unsigned long rar_region_addr;
/* start address of the access to the SEP registers from driver */
unsigned long reg_base_address;
/* transaction counter that coordinates the transactions between SEP and HOST */
unsigned long host_to_sep_send_counter;
/* counter for the messages from sep */
unsigned long sep_to_host_reply_counter;
/* counter for the number of bytes allocated in the pool for the current
transaction */
unsigned long data_pool_bytes_allocated;
/* array of pointers to the pages that represent input data for the synchronic
DMA action */
struct page **in_page_array;
/* array of pointers to the pages that represent out data for the synchronic
DMA action */
struct page **out_page_array;
/* number of pages in the sep_in_page_array */
unsigned long in_num_pages;
/* number of pages in the sep_out_page_array */
unsigned long out_num_pages;
/* global data for every flow */
struct sep_flow_context_t flows_data_array[SEP_DRIVER_NUM_FLOWS];
/* flag for API mode - 1 -is blocking, 0 is non-blocking */
unsigned long block_mode_flag;
/* pointer to the workqueue that handles the flow done interrupts */
struct workqueue_struct *flow_wq_ptr;
/* address of the shared memory allocated during init for SEP driver */
unsigned long shared_area_addr;
/* the physical address of the shared area */
unsigned long phys_shared_area_addr;
/* Message Shared Area start address - will be allocated during init */
unsigned long message_shared_area_addr;
};
extern struct sep_device *sep_dev;
extern inline void sep_write_reg(struct sep_device *dev, int reg, u32 value)
{
void __iomem *addr = dev->reg_base_address + reg;
writel(value, reg);
}
extern inline u32 sep_read_reg(struct sep_device *dev, int reg)
{
void __iomem *addr = dev->reg_base_address + reg;
return readl(reg);
}
#endif
......@@ -297,7 +297,7 @@ do { \
do { \
unsigned long reg_val; \
do { \
SEP_READ_REGISTER(g_sep_reg_base_address + \
SEP_READ_REGISTER(sep_dev->reg_base_address + \
HW_SRAM_DATA_READY_REG_ADDR, (reg_val)); \
} while (!(reg_val & 0x1)); \
} while (0)
......
......@@ -36,8 +36,6 @@
/* shared variables */
extern int sepDebug;
extern unsigned long g_sep_reg_base_address;
/*
this function loads the ROM code in SEP (needed only in the debug mode on FPGA)
*/
......
......@@ -51,6 +51,7 @@
#include "sep_driver_config.h"
#include "sep_driver_api.h"
#include "sep_driver_ext_api.h"
#include "sep_dev.h"
#if SEP_DRIVER_ARM_DEBUG_MODE
......@@ -91,32 +92,10 @@ static unsigned long CRYS_SEP_ROM[] = {
irqreturn_t sep_inthandler(int irq , void* dev_id);
/* Keep this a single static object for now to keep the conversion easy */
/* io memory (register area) */
static unsigned long io_memory_start_physical_address;
static unsigned long io_memory_end_physical_address;
static unsigned long io_memory_size;
void *io_memory_start_virtual_address;
/* restricted access region */
static unsigned long rar_physical_address;
static void *rar_virtual_address;
/* shared memory region */
static unsigned long shared_physical_address;
static void *shared_virtual_address;
/* firmware regions */
static unsigned long cache_physical_address;
static unsigned long cache_size;
static void *cache_virtual_address;
static unsigned long resident_physical_address;
static unsigned long resident_size;
static void *resident_virtual_address;
/* device interrupt (as retrieved from PCI) */
int sep_irq;
static struct sep_device sep_instance;
struct sep_device *sep_dev = &sep_instance;
/* temporary */
unsigned long jiffies_future;
......@@ -138,7 +117,6 @@ static struct pci_device_id sep_pci_id_tbl[] = {
MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl);
static unsigned long rar_region_addr;
/* field for registering driver to PCI device */
......@@ -148,8 +126,6 @@ static struct pci_driver sep_pci_driver = {
.probe = sep_probe
};
/* pointer to pci dev received during probe */
struct pci_dev *sep_pci_dev_ptr;
/*
This functions locks the area of the resisnd and cache sep code
......@@ -193,18 +169,18 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:rar_virtual is %p\n",
rar_virtual_address);
sep_dev->rar_virtual_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:rar_physical is %08lx\n",
rar_physical_address);
sep_dev->rar_physical_address);
rar_region_addr = (unsigned long)rar_virtual_address;
sep_dev->rar_region_addr = (unsigned long)sep_dev->rar_virtual_address;
cache_physical_address = rar_physical_address;
cache_virtual_address = rar_virtual_address;
sep_dev->cache_physical_address = sep_dev->rar_physical_address;
sep_dev->cache_virtual_address = sep_dev->rar_virtual_address;
/* load cache */
error = request_firmware(&fw, cache_name, &sep_pci_dev_ptr->dev);
error = request_firmware(&fw, cache_name, &sep_dev->sep_pci_dev_ptr->dev);
if (error) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:cant request cache fw\n");
......@@ -218,19 +194,21 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
"SEP Driver:cache data size is %08Zx\n",
fw->size);
memcpy((void *)cache_virtual_address, (void *)fw->data, fw->size);
memcpy((void *)sep_dev->cache_virtual_address, (void *)fw->data, fw->size);
cache_size = fw->size;
sep_dev->cache_size = fw->size;
cache_addr = (unsigned long)cache_virtual_address;
cache_addr = (unsigned long)sep_dev->cache_virtual_address;
release_firmware(fw);
resident_physical_address = cache_physical_address+cache_size;
resident_virtual_address = cache_virtual_address+cache_size;
sep_dev->resident_physical_address = sep_dev->cache_physical_address
+ sep_dev->cache_size;
sep_dev->resident_virtual_address = sep_dev->cache_virtual_address
+ sep_dev->cache_size;
/* load resident */
error = request_firmware(&fw, res_name, &sep_pci_dev_ptr->dev);
error = request_firmware(&fw, res_name, &sep_dev->sep_pci_dev_ptr->dev);
if (error) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:cant request res fw\n");
......@@ -244,20 +222,20 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
"SEP Driver:res data size is %08Zx\n",
fw->size);
memcpy((void *)resident_virtual_address, (void *)fw->data, fw->size);
memcpy((void *)sep_dev->resident_virtual_address, (void *)fw->data, fw->size);
resident_size = fw->size;
sep_dev->resident_size = fw->size;
release_firmware(fw);
resident_addr = (unsigned long)resident_virtual_address;
resident_addr = (unsigned long)sep_dev->resident_virtual_address;
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:resident_addr (physical )is %08lx\n",
resident_physical_address);
sep_dev->resident_physical_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:cache_addr (physical) is %08lx\n",
cache_physical_address);
sep_dev->cache_physical_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:resident_addr (logical )is %08lx\n",
......@@ -267,15 +245,15 @@ int sep_copy_cache_resident_to_area(unsigned long src_cache_addr,
cache_addr);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:resident_size is %08lx\n", resident_size);
"SEP Driver:resident_size is %08lx\n", sep_dev->resident_size);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:cache_size is %08lx\n", cache_size);
"SEP Driver:cache_size is %08lx\n", sep_dev->cache_size);
/* physical addresses */
*dst_new_cache_addr_ptr = cache_physical_address;
*dst_new_resident_addr_ptr = resident_physical_address;
*dst_new_cache_addr_ptr = sep_dev->cache_physical_address;
*dst_new_resident_addr_ptr = sep_dev->resident_physical_address;
end_function:
......@@ -297,23 +275,24 @@ int sep_map_and_alloc_shared_area(unsigned long shared_area_size,
unsigned long *phys_shared_area_addr_ptr)
{
// shared_virtual_address = ioremap_nocache(0xda00000,shared_area_size);
shared_virtual_address = kmalloc(shared_area_size, GFP_KERNEL);
if (!shared_virtual_address) {
sep_dev->shared_virtual_address = kmalloc(shared_area_size, GFP_KERNEL);
if (!sep_dev->shared_virtual_address) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"sep_driver:shared memory kmalloc failed\n");
return -1;
}
shared_physical_address = __pa(shared_virtual_address);
/* FIXME */
sep_dev->shared_physical_address = __pa(sep_dev->shared_virtual_address);
// shared_physical_address = 0xda00000;
*kernel_shared_area_addr_ptr = (unsigned long)shared_virtual_address;
*kernel_shared_area_addr_ptr = (unsigned long)sep_dev->shared_virtual_address;
/* set the physical address of the shared area */
*phys_shared_area_addr_ptr = shared_physical_address;
*phys_shared_area_addr_ptr = sep_dev->shared_physical_address;
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:shared_virtual_address is %p\n",
shared_virtual_address);
sep_dev->shared_virtual_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:shared_region_size is %08lx\n",
shared_area_size);
......@@ -353,11 +332,11 @@ unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address)
virt_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:sh virt to phys p %08lx\n",
shared_physical_address
+ (virt_address - (unsigned long)shared_virtual_address));
sep_dev->shared_physical_address
+ (virt_address - (unsigned long)sep_dev->shared_virtual_address));
return (unsigned long)shared_physical_address +
(virt_address - (unsigned long)shared_virtual_address);
return (unsigned long)sep_dev->shared_physical_address +
(virt_address - (unsigned long)sep_dev->shared_virtual_address);
}
/*
......@@ -368,8 +347,8 @@ unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address)
*/
unsigned long sep_shared_area_phys_to_virt(unsigned long phys_address)
{
return (unsigned long)shared_virtual_address
+ (phys_address - shared_physical_address);
return (unsigned long)sep_dev->shared_virtual_address
+ (phys_address - sep_dev->shared_physical_address);
}
......@@ -399,43 +378,43 @@ static int __devinit sep_probe(struct pci_dev *pdev,
}
/* set the pci dev pointer */
sep_pci_dev_ptr = pdev;
sep_dev->sep_pci_dev_ptr = pdev;
/* get the io memory start address */
io_memory_start_physical_address = pci_resource_start(pdev, 0);
if (!io_memory_start_physical_address) {
sep_dev->io_memory_start_physical_address = pci_resource_start(pdev, 0);
if (!sep_dev->io_memory_start_physical_address) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver error pci resource start\n");
goto end_function;
}
/* get the io memory end address */
io_memory_end_physical_address = pci_resource_end(pdev, 0);
if (!io_memory_end_physical_address) {
sep_dev->io_memory_end_physical_address = pci_resource_end(pdev, 0);
if (!sep_dev->io_memory_end_physical_address) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver error pci resource end\n");
goto end_function;
}
io_memory_size = io_memory_end_physical_address -
io_memory_start_physical_address + 1;
sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address -
sep_dev->io_memory_start_physical_address + 1;
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:io_memory_start_physical_address is %08lx\n",
io_memory_start_physical_address);
sep_dev->io_memory_start_physical_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:io_memory_end_phyaical_address is %08lx\n",
io_memory_end_physical_address);
sep_dev->io_memory_end_physical_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:io_memory_size is %08lx\n",
io_memory_size);
sep_dev->io_memory_size);
io_memory_start_virtual_address =
ioremap_nocache(io_memory_start_physical_address,
io_memory_size);
if (!io_memory_start_virtual_address) {
sep_dev->io_memory_start_virtual_address =
ioremap_nocache(sep_dev->io_memory_start_physical_address,
sep_dev->io_memory_size);
if (!sep_dev->io_memory_start_virtual_address) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver error ioremap of io memory\n");
goto end_function;
......@@ -443,31 +422,31 @@ static int __devinit sep_probe(struct pci_dev *pdev,
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:io_memory_start_virtual_address is %p\n",
io_memory_start_virtual_address);
sep_dev->io_memory_start_virtual_address);
g_sep_reg_base_address = (unsigned long)io_memory_start_virtual_address;
sep_dev->reg_base_address = (unsigned long)sep_dev->io_memory_start_virtual_address;
/* set up system base address and shared memory location */
rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE,
sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE,
GFP_KERNEL);
if (!rar_virtual_address) {
if (!sep_dev->rar_virtual_address) {
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:cant kmalloc rar\n");
goto end_function;
}
rar_physical_address = __pa(rar_virtual_address);
/* FIXME */
sep_dev->rar_physical_address = __pa(sep_dev->rar_virtual_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:rar_physical is %08lx\n",
rar_physical_address);
sep_dev->rar_physical_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver:rar_virtual is %p\n",
rar_virtual_address);
sep_dev->rar_virtual_address);
#if !SEP_DRIVER_POLLING_MODE
......@@ -476,15 +455,16 @@ static int __devinit sep_probe(struct pci_dev *pdev,
"SEP Driver: about to write IMR and ICR REG_ADDR\n");
/* clear ICR register */
SEP_WRITE_REGISTER(g_sep_reg_base_address + HW_HOST_ICR_REG_ADDR,
SEP_WRITE_REGISTER(sep_dev->reg_base_address + HW_HOST_ICR_REG_ADDR,
0xFFFFFFFF);
/* set the IMR register - open only GPR 2 */
SEP_WRITE_REGISTER(g_sep_reg_base_address + HW_HOST_IMR_REG_ADDR,
SEP_WRITE_REGISTER(sep_dev->reg_base_address + HW_HOST_IMR_REG_ADDR,
(~(0x1 << 13)));
/* figure out our irq */
error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *)&sep_irq);
/* FIXME: */
error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *)&sep_dev->sep_irq);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: my irq is %d\n", sep_irq);
......@@ -493,7 +473,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
"SEP Driver: about to call request_irq\n");
/* get the interrupt line */
error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED,
"sep_driver", &g_sep_reg_base_address);
"sep_driver", &sep_dev->reg_base_address);
if (error)
goto end_function;
......@@ -502,7 +482,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
"SEP Driver: about to write IMR REG_ADDR");
/* set the IMR register - open only GPR 2 */
SEP_WRITE_REGISTER(g_sep_reg_base_address + HW_HOST_IMR_REG_ADDR,
SEP_WRITE_REGISTER(sep_dev->reg_base_address + HW_HOST_IMR_REG_ADDR,
(~(0x1 << 13)));
#endif /* SEP_DRIVER_POLLING_MODE */
......@@ -523,7 +503,7 @@ int sep_register_driver_to_device(void)
void sep_load_rom_code()
void sep_load_rom_code(void)
{
#if SEP_DRIVER_ARM_DEBUG_MODE
/* Index variables */
......@@ -541,19 +521,19 @@ void sep_load_rom_code()
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: k is %lu\n", k);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: g_sep_reg_base_address is %p\n",
g_sep_reg_base_address);
"SEP Driver: sep_dev->reg_base_address is %p\n",
sep_dev->reg_base_address);
DEBUG_PRINT_1(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n",
CRYS_SEP_ROM_start_address_offset);
for (i = 0; i < 4; i++) {
/* write bank */
SEP_WRITE_REGISTER(g_sep_reg_base_address
SEP_WRITE_REGISTER(sep_dev->reg_base_address
+ SEP_ROM_BANK_register_offset, i);
for (j = 0; j < CRYS_SEP_ROM_length / 4; j++) {
SEP_WRITE_REGISTER(g_sep_reg_base_address +
SEP_WRITE_REGISTER(sep_dev->reg_base_address +
CRYS_SEP_ROM_start_address_offset + 4*j,
CRYS_SEP_ROM[i * 0x1000 + j]);
......@@ -567,12 +547,12 @@ void sep_load_rom_code()
}
/* reset the SEP*/
SEP_WRITE_REGISTER(g_sep_reg_base_address
SEP_WRITE_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_SW_RST_REG_ADDR, 0x1);
/* poll for SEP ROM boot finish */
do {
SEP_READ_REGISTER(g_sep_reg_base_address
SEP_READ_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_HOST_GPR3_REG_ADDR, regVal);
} while (!regVal);
......@@ -582,21 +562,21 @@ void sep_load_rom_code()
switch (regVal) {
case 0x1:
/* fatal error - read erro status from GPRO */
SEP_READ_REGISTER(g_sep_reg_base_address
SEP_READ_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_HOST_GPR0_REG_ADDR, Error);
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: ROM polling case 1\n");
break;
case 0x2:
/* Boot First Phase ended */
SEP_READ_REGISTER(g_sep_reg_base_address
SEP_READ_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_HOST_GPR0_REG_ADDR, warning);
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: ROM polling case 2\n");
break;
case 0x4:
/* Cold boot ended successfully */
SEP_READ_REGISTER(g_sep_reg_base_address
SEP_READ_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_HOST_GPR0_REG_ADDR, warning);
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: ROM polling case 4\n");
......@@ -604,7 +584,7 @@ void sep_load_rom_code()
break;
case 0x8:
/* Warmboot ended successfully */
SEP_READ_REGISTER(g_sep_reg_base_address
SEP_READ_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_HOST_GPR0_REG_ADDR, warning);
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: ROM polling case 8\n");
......@@ -612,7 +592,7 @@ void sep_load_rom_code()
break;
case 0x10:
/* ColdWarm boot ended successfully */
SEP_READ_REGISTER(g_sep_reg_base_address
SEP_READ_REGISTER(sep_dev->reg_base_address
+ HW_HOST_SEP_HOST_GPR0_REG_ADDR, warning);
DEBUG_PRINT_0(SEP_DEBUG_LEVEL_EXTENDED,
"SEP Driver: ROM polling case 16\n");
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册