Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: sep: indent pass

Ok time to indent and get the code in vague shape. No other changes in this
patch.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
d19cf32f 46eb5a13

+1987 -2612
+4 -5
drivers/staging/sep/sep_dev.h
··· 66 66 /* counter for the messages from sep */ 67 67 unsigned long sep_to_host_reply_counter; 68 68 /* counter for the number of bytes allocated in the pool for the current 69 - transaction */ 69 + transaction */ 70 70 unsigned long data_pool_bytes_allocated; 71 71 72 72 /* array of pointers to the pages that represent input data for the synchronic 73 - DMA action */ 73 + DMA action */ 74 74 struct page **in_page_array; 75 75 76 76 /* array of pointers to the pages that represent out data for the synchronic 77 - DMA action */ 77 + DMA action */ 78 78 struct page **out_page_array; 79 79 80 80 /* number of pages in the sep_in_page_array */ ··· 121 121 u32 reg_val; 122 122 do 123 123 reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR); 124 - while(!(reg_val & 1)); 124 + while (!(reg_val & 1)); 125 125 } 126 126 127 127 128 128 #endif 129 -
+191 -210
drivers/staging/sep/sep_driver_api.h
··· 106 106 init command struct 107 107 */ 108 108 struct sep_driver_init_t { 109 - /* start of the 1G of the host memory address that SEP can access */ 110 - unsigned long message_addr; 109 + /* start of the 1G of the host memory address that SEP can access */ 110 + unsigned long message_addr; 111 111 112 - /* start address of resident */ 113 - unsigned long message_size_in_words; 112 + /* start address of resident */ 113 + unsigned long message_size_in_words; 114 114 115 115 }; 116 116 ··· 119 119 realloc cache resident command 120 120 */ 121 121 struct sep_driver_realloc_cache_resident_t { 122 - /* base address */ 123 - unsigned long base_addr; 122 + /* base address */ 123 + unsigned long base_addr; 124 124 125 - /* current cache address */ 126 - unsigned long cache_addr; 125 + /* current cache address */ 126 + unsigned long cache_addr; 127 127 128 - /* cache size in bytes*/ 129 - unsigned long cache_size_in_bytes; 128 + /* cache size in bytes */ 129 + unsigned long cache_size_in_bytes; 130 130 131 - /* current resident address */ 132 - unsigned long resident_addr; 131 + /* current resident address */ 132 + unsigned long resident_addr; 133 133 134 - /* resident size in bytes*/ 135 - unsigned long resident_size_in_bytes; 134 + /* resident size in bytes */ 135 + unsigned long resident_size_in_bytes; 136 136 137 - /* new cache address */ 138 - unsigned long new_cache_addr; 137 + /* new cache address */ 138 + unsigned long new_cache_addr; 139 139 140 - /* new resident address */ 141 - unsigned long new_resident_addr; 140 + /* new resident address */ 141 + unsigned long new_resident_addr; 142 142 143 - /* new resident address */ 144 - unsigned long new_shared_area_addr; 143 + /* new resident address */ 144 + unsigned long new_shared_area_addr; 145 145 146 - /* new base address */ 147 - unsigned long new_base_addr; 146 + /* new base address */ 147 + unsigned long new_base_addr; 148 148 }; 149 149 150 150 /* 151 151 set api mode command struct 152 152 */ 153 153 struct sep_driver_set_api_mode_t { 154 - /* mode to set - 1 - blocking, 0 - non-blocking */ 155 - unsigned long mode; 154 + /* mode to set - 1 - blocking, 0 - non-blocking */ 155 + unsigned long mode; 156 156 }; 157 157 158 158 struct sep_driver_alloc_t { 159 - /* virtual address of allocated space */ 160 - unsigned long offset; 159 + /* virtual address of allocated space */ 160 + unsigned long offset; 161 161 162 - /* physical address of allocated space */ 163 - unsigned long phys_address; 162 + /* physical address of allocated space */ 163 + unsigned long phys_address; 164 164 165 - /* number of bytes to allocate */ 166 - unsigned long num_bytes; 165 + /* number of bytes to allocate */ 166 + unsigned long num_bytes; 167 167 }; 168 168 169 169 /* 170 170 */ 171 171 struct sep_driver_write_t { 172 - /* application space address */ 173 - unsigned long app_address; 172 + /* application space address */ 173 + unsigned long app_address; 174 174 175 - /* address of the data pool */ 176 - unsigned long datapool_address; 175 + /* address of the data pool */ 176 + unsigned long datapool_address; 177 177 178 - /* number of bytes to write */ 179 - unsigned long num_bytes; 178 + /* number of bytes to write */ 179 + unsigned long num_bytes; 180 180 }; 181 181 182 182 /* 183 183 */ 184 184 struct sep_driver_read_t { 185 - /* application space address */ 186 - unsigned long app_address; 185 + /* application space address */ 186 + unsigned long app_address; 187 187 188 - /* address of the data pool */ 189 - unsigned long datapool_address; 188 + /* address of the data pool */ 189 + unsigned long datapool_address; 190 190 191 - /* number of bytes to read */ 192 - unsigned long num_bytes; 191 + /* number of bytes to read */ 192 + unsigned long num_bytes; 193 193 }; 194 194 195 195 /* 196 196 */ 197 197 struct sep_driver_build_sync_table_t { 198 - /* address value of the data in */ 199 - unsigned long app_in_address; 198 + /* address value of the data in */ 199 + unsigned long app_in_address; 200 200 201 - /* size of data in */ 202 - unsigned long data_in_size; 201 + /* size of data in */ 202 + unsigned long data_in_size; 203 203 204 - /* address of the data out */ 205 - unsigned long app_out_address; 204 + /* address of the data out */ 205 + unsigned long app_out_address; 206 206 207 - /* the size of the block of the operation - if needed, 208 - every table will be modulo this parameter */ 209 - unsigned long block_size; 207 + /* the size of the block of the operation - if needed, 208 + every table will be modulo this parameter */ 209 + unsigned long block_size; 210 210 211 - /* the physical address of the first input DMA table */ 212 - unsigned long in_table_address; 211 + /* the physical address of the first input DMA table */ 212 + unsigned long in_table_address; 213 213 214 - /* number of entries in the first input DMA table */ 215 - unsigned long in_table_num_entries; 214 + /* number of entries in the first input DMA table */ 215 + unsigned long in_table_num_entries; 216 216 217 - /* the physical address of the first output DMA table */ 218 - unsigned long out_table_address; 217 + /* the physical address of the first output DMA table */ 218 + unsigned long out_table_address; 219 219 220 - /* number of entries in the first output DMA table */ 221 - unsigned long out_table_num_entries; 220 + /* number of entries in the first output DMA table */ 221 + unsigned long out_table_num_entries; 222 222 223 - /* data in the first input table */ 224 - unsigned long table_data_size; 223 + /* data in the first input table */ 224 + unsigned long table_data_size; 225 225 226 - /* distinct user/kernel layout */ 227 - bool isKernelVirtualAddress; 226 + /* distinct user/kernel layout */ 227 + bool isKernelVirtualAddress; 228 228 229 229 }; 230 230 231 231 /* 232 232 */ 233 233 struct sep_driver_build_flow_table_t { 234 - /* flow type */ 235 - unsigned long flow_type; 234 + /* flow type */ 235 + unsigned long flow_type; 236 236 237 - /* flag for input output */ 238 - unsigned long input_output_flag; 237 + /* flag for input output */ 238 + unsigned long input_output_flag; 239 239 240 - /* address value of the data in */ 241 - unsigned long virt_buff_data_addr; 240 + /* address value of the data in */ 241 + unsigned long virt_buff_data_addr; 242 242 243 - /* size of data in */ 244 - unsigned long num_virtual_buffers; 243 + /* size of data in */ 244 + unsigned long num_virtual_buffers; 245 245 246 - /* the physical address of the first input DMA table */ 247 - unsigned long first_table_addr; 246 + /* the physical address of the first input DMA table */ 247 + unsigned long first_table_addr; 248 248 249 - /* number of entries in the first input DMA table */ 250 - unsigned long first_table_num_entries; 249 + /* number of entries in the first input DMA table */ 250 + unsigned long first_table_num_entries; 251 251 252 - /* data in the first input table */ 253 - unsigned long first_table_data_size; 252 + /* data in the first input table */ 253 + unsigned long first_table_data_size; 254 254 255 - /* distinct user/kernel layout */ 256 - bool isKernelVirtualAddress; 255 + /* distinct user/kernel layout */ 256 + bool isKernelVirtualAddress; 257 257 }; 258 258 259 259 260 260 struct sep_driver_add_flow_table_t { 261 - /* flow id */ 262 - unsigned long flow_id; 261 + /* flow id */ 262 + unsigned long flow_id; 263 263 264 - /* flag for input output */ 265 - unsigned long inputOutputFlag; 264 + /* flag for input output */ 265 + unsigned long inputOutputFlag; 266 266 267 - /* address value of the data in */ 268 - unsigned long virt_buff_data_addr; 267 + /* address value of the data in */ 268 + unsigned long virt_buff_data_addr; 269 269 270 - /* size of data in */ 271 - unsigned long num_virtual_buffers; 270 + /* size of data in */ 271 + unsigned long num_virtual_buffers; 272 272 273 - /* address of the first table */ 274 - unsigned long first_table_addr; 273 + /* address of the first table */ 274 + unsigned long first_table_addr; 275 275 276 - /* number of entries in the first table */ 277 - unsigned long first_table_num_entries; 276 + /* number of entries in the first table */ 277 + unsigned long first_table_num_entries; 278 278 279 - /* data size of the first table */ 280 - unsigned long first_table_data_size; 279 + /* data size of the first table */ 280 + unsigned long first_table_data_size; 281 281 282 - /* distinct user/kernel layout */ 283 - bool isKernelVirtualAddress; 282 + /* distinct user/kernel layout */ 283 + bool isKernelVirtualAddress; 284 284 285 285 }; 286 286 ··· 288 288 command struct for set flow id 289 289 */ 290 290 struct sep_driver_set_flow_id_t { 291 - /* flow id to set */ 292 - unsigned long flow_id; 291 + /* flow id to set */ 292 + unsigned long flow_id; 293 293 }; 294 294 295 295 296 296 /* command struct for add tables message */ 297 297 struct sep_driver_add_message_t { 298 - /* flow id to set */ 299 - unsigned long flow_id; 298 + /* flow id to set */ 299 + unsigned long flow_id; 300 300 301 - /* message size in bytes */ 302 - unsigned long message_size_in_bytes; 301 + /* message size in bytes */ 302 + unsigned long message_size_in_bytes; 303 303 304 - /* address of the message */ 305 - unsigned long message_address; 304 + /* address of the message */ 305 + unsigned long message_address; 306 306 }; 307 307 308 308 /* command struct for static pool addresses */ 309 309 struct sep_driver_static_pool_addr_t { 310 - /* physical address of the static pool */ 311 - unsigned long physical_static_address; 310 + /* physical address of the static pool */ 311 + unsigned long physical_static_address; 312 312 313 - /* virtual address of the static pool */ 314 - unsigned long virtual_static_address; 313 + /* virtual address of the static pool */ 314 + unsigned long virtual_static_address; 315 315 }; 316 316 317 317 /* command struct for getiing offset of the physical address from 318 318 the start of the mapped area */ 319 319 struct sep_driver_get_mapped_offset_t { 320 - /* physical address of the static pool */ 321 - unsigned long physical_address; 320 + /* physical address of the static pool */ 321 + unsigned long physical_address; 322 322 323 - /* virtual address of the static pool */ 324 - unsigned long offset; 323 + /* virtual address of the static pool */ 324 + unsigned long offset; 325 325 }; 326 326 327 327 /* command struct for getting time value and address */ 328 328 struct sep_driver_get_time_t { 329 - /* physical address of stored time */ 330 - unsigned long time_physical_address; 329 + /* physical address of stored time */ 330 + unsigned long time_physical_address; 331 331 332 - /* value of the stored time */ 333 - unsigned long time_value; 332 + /* value of the stored time */ 333 + unsigned long time_value; 334 334 }; 335 335 336 336 ··· 338 338 structure that represent one entry in the DMA LLI table 339 339 */ 340 340 struct sep_lli_entry_t { 341 - /* physical address */ 342 - unsigned long physical_address; 341 + /* physical address */ 342 + unsigned long physical_address; 343 343 344 - /* block size */ 345 - unsigned long block_size; 344 + /* block size */ 345 + unsigned long block_size; 346 346 }; 347 347 348 348 /* 349 349 structure that reperesents data needed for lli table construction 350 350 */ 351 351 struct sep_lli_prepare_table_data_t { 352 - /* pointer to the memory where the first lli entry to be built */ 353 - struct sep_lli_entry_t *lli_entry_ptr; 352 + /* pointer to the memory where the first lli entry to be built */ 353 + struct sep_lli_entry_t *lli_entry_ptr; 354 354 355 - /* pointer to the array of lli entries from which the table is to be built */ 356 - struct sep_lli_entry_t *lli_array_ptr; 355 + /* pointer to the array of lli entries from which the table is to be built */ 356 + struct sep_lli_entry_t *lli_array_ptr; 357 357 358 - /* number of elements in lli array */ 359 - int lli_array_size; 358 + /* number of elements in lli array */ 359 + int lli_array_size; 360 360 361 - /* number of entries in the created table */ 362 - int num_table_entries; 361 + /* number of entries in the created table */ 362 + int num_table_entries; 363 363 364 - /* number of array entries processed during table creation */ 365 - int num_array_entries_processed; 364 + /* number of array entries processed during table creation */ 365 + int num_array_entries_processed; 366 366 367 - /* the totatl data size in the created table */ 368 - int lli_table_total_data_size; 367 + /* the totatl data size in the created table */ 368 + int lli_table_total_data_size; 369 369 }; 370 370 371 371 /* ··· 373 373 to show what table looks like 374 374 */ 375 375 struct sep_lli_table_t { 376 - /* number of pages mapped in this tables. If 0 - means that the table 377 - is not defined (used as a valid flag)*/ 378 - unsigned long num_pages; 379 - /* 380 - pointer to array of page pointers that represent the mapping of the 381 - virtual buffer defined by the table to the physical memory. If this 382 - pointer is NULL, it means that the table is not defined 383 - (used as a valid flag) 384 - */ 385 - struct page **table_page_array_ptr; 376 + /* number of pages mapped in this tables. If 0 - means that the table 377 + is not defined (used as a valid flag) */ 378 + unsigned long num_pages; 379 + /* 380 + pointer to array of page pointers that represent the mapping of the 381 + virtual buffer defined by the table to the physical memory. If this 382 + pointer is NULL, it means that the table is not defined 383 + (used as a valid flag) 384 + */ 385 + struct page **table_page_array_ptr; 386 386 387 - /* maximum flow entries in table */ 388 - struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE]; 387 + /* maximum flow entries in table */ 388 + struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE]; 389 389 }; 390 390 391 391 ··· 393 393 structure for keeping the mapping of the virtual buffer into physical pages 394 394 */ 395 395 struct sep_flow_buffer_data { 396 - /* pointer to the array of page structs pointers to the pages of the 397 - virtual buffer */ 398 - struct page **page_array_ptr; 396 + /* pointer to the array of page structs pointers to the pages of the 397 + virtual buffer */ 398 + struct page **page_array_ptr; 399 399 400 - /* number of pages taken by the virtual buffer */ 401 - unsigned long num_pages; 400 + /* number of pages taken by the virtual buffer */ 401 + unsigned long num_pages; 402 402 403 - /* this flag signals if this page_array is the last one among many that were 404 - sent in one setting to SEP */ 405 - unsigned long last_page_array_flag; 403 + /* this flag signals if this page_array is the last one among many that were 404 + sent in one setting to SEP */ 405 + unsigned long last_page_array_flag; 406 406 }; 407 407 408 408 /* 409 409 struct that keeps all the data for one flow 410 410 */ 411 411 struct sep_flow_context_t { 412 - /* 413 - work struct for handling the flow done interrupt in the workqueue 414 - this structure must be in the first place, since it will be used 415 - forcasting to the containing flow context 416 - */ 417 - struct work_struct flow_wq; 412 + /* 413 + work struct for handling the flow done interrupt in the workqueue 414 + this structure must be in the first place, since it will be used 415 + forcasting to the containing flow context 416 + */ 417 + struct work_struct flow_wq; 418 418 419 - /* flow id */ 420 - unsigned long flow_id; 419 + /* flow id */ 420 + unsigned long flow_id; 421 421 422 - /* additional input tables exists */ 423 - unsigned long input_tables_flag; 422 + /* additional input tables exists */ 423 + unsigned long input_tables_flag; 424 424 425 - /* additional output tables exists */ 426 - unsigned long output_tables_flag; 425 + /* additional output tables exists */ 426 + unsigned long output_tables_flag; 427 427 428 - /* data of the first input file */ 429 - struct sep_lli_entry_t first_input_table; 428 + /* data of the first input file */ 429 + struct sep_lli_entry_t first_input_table; 430 430 431 - /* data of the first output table */ 432 - struct sep_lli_entry_t first_output_table; 431 + /* data of the first output table */ 432 + struct sep_lli_entry_t first_output_table; 433 433 434 - /* last input table data */ 435 - struct sep_lli_entry_t last_input_table; 434 + /* last input table data */ 435 + struct sep_lli_entry_t last_input_table; 436 436 437 - /* last output table data */ 438 - struct sep_lli_entry_t last_output_table; 437 + /* last output table data */ 438 + struct sep_lli_entry_t last_output_table; 439 439 440 - /* first list of table */ 441 - struct sep_lli_entry_t input_tables_in_process; 440 + /* first list of table */ 441 + struct sep_lli_entry_t input_tables_in_process; 442 442 443 - /* output table in process (in sep) */ 444 - struct sep_lli_entry_t output_tables_in_process; 443 + /* output table in process (in sep) */ 444 + struct sep_lli_entry_t output_tables_in_process; 445 445 446 - /* size of messages in bytes */ 447 - unsigned long message_size_in_bytes; 446 + /* size of messages in bytes */ 447 + unsigned long message_size_in_bytes; 448 448 449 - /* message */ 450 - unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES]; 449 + /* message */ 450 + unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES]; 451 451 }; 452 452 453 453 ··· 478 478 This function releases all the application virtual 479 479 buffer physical pages, that were previously locked 480 480 */ 481 - int sep_free_dma_pages(struct page **page_array_ptr, 482 - unsigned long num_pages, 483 - unsigned long dirtyFlag); 481 + int sep_free_dma_pages(struct page **page_array_ptr, unsigned long num_pages, unsigned long dirtyFlag); 484 482 485 483 /* 486 484 This function creates the input and output dma tables for 487 485 symmetric operations (AES/DES) according to the block size 488 486 from LLI arays 489 487 */ 490 - int sep_construct_dma_tables_from_lli( 491 - struct sep_lli_entry_t *lli_in_array, 492 - unsigned long sep_in_lli_entries, 493 - struct sep_lli_entry_t *lli_out_array, 494 - unsigned long sep_out_lli_entries, 495 - unsigned long block_size, 496 - unsigned long *lli_table_in_ptr, 497 - unsigned long *lli_table_out_ptr, 498 - unsigned long *in_num_entries_ptr, 499 - unsigned long *out_num_entries_ptr, 500 - unsigned long *table_data_size_ptr); 488 + int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, 489 + unsigned long sep_in_lli_entries, 490 + struct sep_lli_entry_t *lli_out_array, 491 + unsigned long sep_out_lli_entries, 492 + unsigned long block_size, unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr); 501 493 502 494 /* 503 495 This function builds input and output DMA tables for synhronic symmetric 504 496 operations (AES, DES) It also checks that each table is of the modular 505 497 block size 506 498 */ 507 - int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, 508 - unsigned long app_virt_out_addr, 509 - unsigned long data_size, 510 - unsigned long block_size, 511 - unsigned long *lli_table_in_ptr, 512 - unsigned long *lli_table_out_ptr, 513 - unsigned long *in_num_entries_ptr, 514 - unsigned long *out_num_entries_ptr, 515 - unsigned long *table_data_size_ptr, 516 - bool isKernelVirtualAddress); 499 + int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, 500 + unsigned long app_virt_out_addr, 501 + unsigned long data_size, 502 + unsigned long block_size, 503 + unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress); 517 504 518 505 /* 519 506 This function prepares only input DMA table for synhronic symmetric 520 507 operations (HASH) 521 508 */ 522 - int sep_prepare_input_dma_table(unsigned long app_virt_addr, 523 - unsigned long data_size, 524 - unsigned long block_size, 525 - unsigned long *lli_table_ptr, 526 - unsigned long *num_entries_ptr, 527 - unsigned long *table_data_size_ptr, 528 - bool isKernelVirtualAddress); 509 + int sep_prepare_input_dma_table(unsigned long app_virt_addr, unsigned long data_size, unsigned long block_size, unsigned long *lli_table_ptr, unsigned long *num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress); 529 510 530 511 /* this functions frees all the resources that were allocated for the building 531 512 of the LLI DMA tables */
+3 -12
drivers/staging/sep/sep_driver_ext_api.h
··· 51 51 destination memory, which is external to Linux VM and is given as physical 52 52 address 53 53 */ 54 - int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, 55 - unsigned long cache_size_in_bytes, 56 - unsigned long src_resident_addr, 57 - unsigned long resident_size_in_bytes, 58 - unsigned long *dst_new_cache_addr_ptr, 59 - unsigned long *dst_new_resident_addr_ptr); 54 + int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, unsigned long cache_size_in_bytes, unsigned long src_resident_addr, unsigned long resident_size_in_bytes, unsigned long *dst_new_cache_addr_ptr, unsigned long *dst_new_resident_addr_ptr); 60 55 61 56 /* 62 57 This functions maps and allocates the shared area on the external ··· 60 65 address of the mapped and allocated shared area, and 61 66 phys_shared_area_addr_ptr - the physical address of the shared area 62 67 */ 63 - int sep_map_and_alloc_shared_area(unsigned long shared_area_size, 64 - unsigned long *kernel_shared_area_addr_ptr, 65 - unsigned long *phys_shared_area_addr_ptr); 68 + int sep_map_and_alloc_shared_area(unsigned long shared_area_size, unsigned long *kernel_shared_area_addr_ptr, unsigned long *phys_shared_area_addr_ptr); 66 69 67 70 /* 68 71 This functions unmaps and deallocates the shared area on the external ··· 69 76 mapped and allocated shared area,phys_shared_area_addr_ptr - the physical 70 77 address of the shared area 71 78 */ 72 - void sep_unmap_and_free_shared_area(unsigned long shared_area_size, 73 - unsigned long kernel_shared_area_addr, 74 - unsigned long phys_shared_area_addr); 79 + void sep_unmap_and_free_shared_area(unsigned long shared_area_size, unsigned long kernel_shared_area_addr, unsigned long phys_shared_area_addr); 75 80 76 81 77 82 /*
+1 -1
drivers/staging/sep/sep_driver_hw_defs.h
··· 229 229 #define HW_CLR_SRAM_BUSY_REG_REG_ADDR 0x0F0CUL 230 230 #define HW_CC_SRAM_BASE_ADDRESS 0x5800UL 231 231 232 - #endif /* ifndef HW_DEFS */ 232 + #endif /* ifndef HW_DEFS */
+83 -180
drivers/staging/sep/sep_ext_with_pci_driver.c
··· 85 85 86 86 /* 2M size */ 87 87 88 - #endif /* SEP_DRIVER_ARM_DEBUG_MODE */ 88 + #endif /* SEP_DRIVER_ARM_DEBUG_MODE */ 89 89 90 90 #define BASE_ADDRESS_FOR_SYSTEM 0xfffc0000 91 91 #define SEP_RAR_IO_MEM_REGION_SIZE 0x40000 92 92 93 - irqreturn_t sep_inthandler(int irq , void* dev_id); 93 + irqreturn_t sep_inthandler(int irq, void *dev_id); 94 94 95 95 /* Keep this a single static object for now to keep the conversion easy */ 96 96 ··· 107 107 /* 108 108 function that is activated on the succesfull probe of the SEP device 109 109 */ 110 - static int __devinit sep_probe(struct pci_dev *pdev, 111 - const struct pci_device_id *ent); 110 + static int __devinit sep_probe(struct pci_dev *pdev, const struct pci_device_id *ent); 112 111 113 112 static struct pci_device_id sep_pci_id_tbl[] = { 114 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c) }, 115 - { 0 } 113 + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080c)}, 114 + {0} 116 115 }; 117 116 118 117 MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl); ··· 140 141 destination memory, which is external to Linux VM and is given as 141 142 physical address 142 143 */ 143 - int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, 144 - unsigned long cache_size_in_bytes, 145 - unsigned long src_resident_addr, 146 - unsigned long resident_size_in_bytes, 147 - unsigned long *dst_new_cache_addr_ptr, 148 - unsigned long *dst_new_resident_addr_ptr) 144 + int sep_copy_cache_resident_to_area(unsigned long src_cache_addr, unsigned long cache_size_in_bytes, unsigned long src_resident_addr, unsigned long resident_size_in_bytes, unsigned long *dst_new_cache_addr_ptr, unsigned long *dst_new_resident_addr_ptr) 149 145 { 150 146 /* resident address in user space */ 151 147 unsigned long resident_addr; ··· 151 157 const struct firmware *fw; 152 158 153 159 char *cache_name = "cache.image.bin"; 154 - char *res_name = "resident.image.bin"; 160 + char *res_name = "resident.image.bin"; 155 161 156 162 /* error */ 157 163 int error; ··· 161 167 -------------------------------------*/ 162 168 error = 0; 163 169 164 - edbg( 165 - "SEP Driver:rar_virtual is %p\n", 166 - sep_dev->rar_virtual_address); 167 - edbg( 168 - "SEP Driver:rar_physical is %08lx\n", 169 - sep_dev->rar_physical_address); 170 + edbg("SEP Driver:rar_virtual is %p\n", sep_dev->rar_virtual_address); 171 + edbg("SEP Driver:rar_physical is %08lx\n", sep_dev->rar_physical_address); 170 172 171 - sep_dev->rar_region_addr = (unsigned long)sep_dev->rar_virtual_address; 173 + sep_dev->rar_region_addr = (unsigned long) sep_dev->rar_virtual_address; 172 174 173 175 sep_dev->cache_physical_address = sep_dev->rar_physical_address; 174 176 sep_dev->cache_virtual_address = sep_dev->rar_virtual_address; ··· 172 182 /* load cache */ 173 183 error = request_firmware(&fw, cache_name, &sep_dev->sep_pci_dev_ptr->dev); 174 184 if (error) { 175 - edbg( 176 - "SEP Driver:cant request cache fw\n"); 185 + edbg("SEP Driver:cant request cache fw\n"); 177 186 goto end_function; 178 187 } 179 188 180 - edbg( 181 - "SEP Driver:cache data loc is %p\n", 182 - (void *)fw->data); 183 - edbg( 184 - "SEP Driver:cache data size is %08Zx\n", 185 - fw->size); 189 + edbg("SEP Driver:cache data loc is %p\n", (void *) fw->data); 190 + edbg("SEP Driver:cache data size is %08Zx\n", fw->size); 186 191 187 - memcpy((void *)sep_dev->cache_virtual_address, (void *)fw->data, fw->size); 192 + memcpy((void *) sep_dev->cache_virtual_address, (void *) fw->data, fw->size); 188 193 189 194 sep_dev->cache_size = fw->size; 190 195 191 - cache_addr = (unsigned long)sep_dev->cache_virtual_address; 196 + cache_addr = (unsigned long) sep_dev->cache_virtual_address; 192 197 193 198 release_firmware(fw); 194 199 195 - sep_dev->resident_physical_address = sep_dev->cache_physical_address 196 - + sep_dev->cache_size; 197 - sep_dev->resident_virtual_address = sep_dev->cache_virtual_address 198 - + sep_dev->cache_size; 200 + sep_dev->resident_physical_address = sep_dev->cache_physical_address + sep_dev->cache_size; 201 + sep_dev->resident_virtual_address = sep_dev->cache_virtual_address + sep_dev->cache_size; 199 202 200 203 /* load resident */ 201 204 error = request_firmware(&fw, res_name, &sep_dev->sep_pci_dev_ptr->dev); 202 205 if (error) { 203 - edbg( 204 - "SEP Driver:cant request res fw\n"); 206 + edbg("SEP Driver:cant request res fw\n"); 205 207 goto end_function; 206 208 } 207 209 208 - edbg( 209 - "SEP Driver:res data loc is %p\n", 210 - (void *)fw->data); 211 - edbg( 212 - "SEP Driver:res data size is %08Zx\n", 213 - fw->size); 210 + edbg("SEP Driver:res data loc is %p\n", (void *) fw->data); 211 + edbg("SEP Driver:res data size is %08Zx\n", fw->size); 214 212 215 - memcpy((void *)sep_dev->resident_virtual_address, (void *)fw->data, fw->size); 213 + memcpy((void *) sep_dev->resident_virtual_address, (void *) fw->data, fw->size); 216 214 217 215 sep_dev->resident_size = fw->size; 218 216 219 217 release_firmware(fw); 220 218 221 - resident_addr = (unsigned long)sep_dev->resident_virtual_address; 219 + resident_addr = (unsigned long) sep_dev->resident_virtual_address; 222 220 223 - edbg( 224 - "SEP Driver:resident_addr (physical )is %08lx\n", 225 - sep_dev->resident_physical_address); 226 - edbg( 227 - "SEP Driver:cache_addr (physical) is %08lx\n", 228 - sep_dev->cache_physical_address); 221 + edbg("SEP Driver:resident_addr (physical )is %08lx\n", sep_dev->resident_physical_address); 222 + edbg("SEP Driver:cache_addr (physical) is %08lx\n", sep_dev->cache_physical_address); 229 223 230 - edbg( 231 - "SEP Driver:resident_addr (logical )is %08lx\n", 232 - resident_addr); 233 - edbg( 234 - "SEP Driver:cache_addr (logical) is %08lx\n", 235 - cache_addr); 224 + edbg("SEP Driver:resident_addr (logical )is %08lx\n", resident_addr); 225 + edbg("SEP Driver:cache_addr (logical) is %08lx\n", cache_addr); 236 226 237 - edbg( 238 - "SEP Driver:resident_size is %08lx\n", sep_dev->resident_size); 239 - edbg( 240 - "SEP Driver:cache_size is %08lx\n", sep_dev->cache_size); 227 + edbg("SEP Driver:resident_size is %08lx\n", sep_dev->resident_size); 228 + edbg("SEP Driver:cache_size is %08lx\n", sep_dev->cache_size); 241 229 242 230 243 231 ··· 223 255 *dst_new_cache_addr_ptr = sep_dev->cache_physical_address; 224 256 *dst_new_resident_addr_ptr = sep_dev->resident_physical_address; 225 257 226 - end_function: 258 + end_function: 227 259 228 260 return error; 229 261 } ··· 238 270 shared area, and phys_shared_area_addr_ptr 239 271 - the physical address of the shared area 240 272 */ 241 - int sep_map_and_alloc_shared_area(unsigned long shared_area_size, 242 - unsigned long *kernel_shared_area_addr_ptr, 243 - unsigned long *phys_shared_area_addr_ptr) 273 + int sep_map_and_alloc_shared_area(unsigned long shared_area_size, unsigned long *kernel_shared_area_addr_ptr, unsigned long *phys_shared_area_addr_ptr) 244 274 { 245 275 // shared_virtual_address = ioremap_nocache(0xda00000,shared_area_size); 246 276 sep_dev->shared_virtual_address = kmalloc(shared_area_size, GFP_KERNEL); 247 277 if (!sep_dev->shared_virtual_address) { 248 - edbg( 249 - "sep_driver:shared memory kmalloc failed\n"); 278 + edbg("sep_driver:shared memory kmalloc failed\n"); 250 279 return -1; 251 280 } 252 281 ··· 251 286 sep_dev->shared_physical_address = __pa(sep_dev->shared_virtual_address); 252 287 // shared_physical_address = 0xda00000; 253 288 254 - *kernel_shared_area_addr_ptr = (unsigned long)sep_dev->shared_virtual_address; 289 + *kernel_shared_area_addr_ptr = (unsigned long) sep_dev->shared_virtual_address; 255 290 /* set the physical address of the shared area */ 256 291 *phys_shared_area_addr_ptr = sep_dev->shared_physical_address; 257 292 258 - edbg( 259 - "SEP Driver:shared_virtual_address is %p\n", 260 - sep_dev->shared_virtual_address); 261 - edbg( 262 - "SEP Driver:shared_region_size is %08lx\n", 263 - shared_area_size); 264 - edbg( 265 - "SEP Driver:shared_physical_addr is %08lx\n", 266 - *phys_shared_area_addr_ptr); 293 + edbg("SEP Driver:shared_virtual_address is %p\n", sep_dev->shared_virtual_address); 294 + edbg("SEP Driver:shared_region_size is %08lx\n", shared_area_size); 295 + edbg("SEP Driver:shared_physical_addr is %08lx\n", *phys_shared_area_addr_ptr); 267 296 268 297 return 0; 269 298 } ··· 270 311 shared area,phys_shared_area_addr_ptr - the physical address of 271 312 the shared area 272 313 */ 273 - void sep_unmap_and_free_shared_area(unsigned long shared_area_size, 274 - unsigned long kernel_shared_area_addr, 275 - unsigned long phys_shared_area_addr) 314 + void sep_unmap_and_free_shared_area(unsigned long shared_area_size, unsigned long kernel_shared_area_addr, unsigned long phys_shared_area_addr) 276 315 { 277 - kfree((void *)kernel_shared_area_addr); 316 + kfree((void *) kernel_shared_area_addr); 278 317 return; 279 318 } 280 319 ··· 284 327 */ 285 328 unsigned long sep_shared_area_virt_to_phys(unsigned long virt_address) 286 329 { 287 - edbg( 288 - "SEP Driver:sh virt to phys v %08lx\n", 289 - virt_address); 290 - edbg( 291 - "SEP Driver:sh virt to phys p %08lx\n", 292 - sep_dev->shared_physical_address 293 - + (virt_address - (unsigned long)sep_dev->shared_virtual_address)); 330 + edbg("SEP Driver:sh virt to phys v %08lx\n", virt_address); 331 + edbg("SEP Driver:sh virt to phys p %08lx\n", sep_dev->shared_physical_address + (virt_address - (unsigned long) sep_dev->shared_virtual_address)); 294 332 295 - return (unsigned long)sep_dev->shared_physical_address + 296 - (virt_address - (unsigned long)sep_dev->shared_virtual_address); 333 + return (unsigned long) sep_dev->shared_physical_address + (virt_address - (unsigned long) sep_dev->shared_virtual_address); 297 334 } 298 335 299 336 /* ··· 298 347 */ 299 348 unsigned long sep_shared_area_phys_to_virt(unsigned long phys_address) 300 349 { 301 - return (unsigned long)sep_dev->shared_virtual_address 302 - + (phys_address - sep_dev->shared_physical_address); 350 + return (unsigned long) sep_dev->shared_virtual_address + (phys_address - sep_dev->shared_physical_address); 303 351 } 304 352 305 353 306 354 /* 307 355 function that is activaed on the succesfull probe of the SEP device 308 356 */ 309 - static int __devinit sep_probe(struct pci_dev *pdev, 310 - const struct pci_device_id *ent) 357 + static int __devinit sep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 311 358 { 312 359 /* error */ 313 360 int error; ··· 314 365 CODE 315 366 ---------------------------*/ 316 367 317 - edbg( 318 - "Sep pci probe starting\n"); 368 + edbg("Sep pci probe starting\n"); 319 369 error = 0; 320 370 321 371 /* enable the device */ 322 372 error = pci_enable_device(pdev); 323 373 if (error) { 324 - edbg( 325 - "error enabling pci device\n"); 374 + edbg("error enabling pci device\n"); 326 375 goto end_function; 327 376 } 328 377 ··· 330 383 /* get the io memory start address */ 331 384 sep_dev->io_memory_start_physical_address = pci_resource_start(pdev, 0); 332 385 if (!sep_dev->io_memory_start_physical_address) { 333 - edbg( 334 - "SEP Driver error pci resource start\n"); 386 + edbg("SEP Driver error pci resource start\n"); 335 387 goto end_function; 336 388 } 337 389 338 390 /* get the io memory end address */ 339 391 sep_dev->io_memory_end_physical_address = pci_resource_end(pdev, 0); 340 392 if (!sep_dev->io_memory_end_physical_address) { 341 - edbg( 342 - "SEP Driver error pci resource end\n"); 393 + edbg("SEP Driver error pci resource end\n"); 343 394 goto end_function; 344 395 } 345 396 346 - sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address - 347 - sep_dev->io_memory_start_physical_address + 1; 397 + sep_dev->io_memory_size = sep_dev->io_memory_end_physical_address - sep_dev->io_memory_start_physical_address + 1; 348 398 349 - edbg( 350 - "SEP Driver:io_memory_start_physical_address is %08lx\n", 351 - sep_dev->io_memory_start_physical_address); 399 + edbg("SEP Driver:io_memory_start_physical_address is %08lx\n", sep_dev->io_memory_start_physical_address); 352 400 353 - edbg( 354 - "SEP Driver:io_memory_end_phyaical_address is %08lx\n", 355 - sep_dev->io_memory_end_physical_address); 401 + edbg("SEP Driver:io_memory_end_phyaical_address is %08lx\n", sep_dev->io_memory_end_physical_address); 356 402 357 - edbg( 358 - "SEP Driver:io_memory_size is %08lx\n", 359 - sep_dev->io_memory_size); 403 + edbg("SEP Driver:io_memory_size is %08lx\n", sep_dev->io_memory_size); 360 404 361 - sep_dev->io_memory_start_virtual_address = 362 - ioremap_nocache(sep_dev->io_memory_start_physical_address, 363 - sep_dev->io_memory_size); 405 + sep_dev->io_memory_start_virtual_address = ioremap_nocache(sep_dev->io_memory_start_physical_address, sep_dev->io_memory_size); 364 406 if (!sep_dev->io_memory_start_virtual_address) { 365 - edbg( 366 - "SEP Driver error ioremap of io memory\n"); 407 + edbg("SEP Driver error ioremap of io memory\n"); 367 408 goto end_function; 368 409 } 369 410 370 - edbg( 371 - "SEP Driver:io_memory_start_virtual_address is %p\n", 372 - sep_dev->io_memory_start_virtual_address); 411 + edbg("SEP Driver:io_memory_start_virtual_address is %p\n", sep_dev->io_memory_start_virtual_address); 373 412 374 - sep_dev->reg_base_address = (void __iomem *)sep_dev->io_memory_start_virtual_address; 413 + sep_dev->reg_base_address = (void __iomem *) sep_dev->io_memory_start_virtual_address; 375 414 376 415 377 416 /* set up system base address and shared memory location */ 378 417 379 - sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE, 380 - GFP_KERNEL); 418 + sep_dev->rar_virtual_address = kmalloc(2 * SEP_RAR_IO_MEM_REGION_SIZE, GFP_KERNEL); 381 419 382 420 if (!sep_dev->rar_virtual_address) { 383 - edbg( 384 - "SEP Driver:cant kmalloc rar\n"); 421 + edbg("SEP Driver:cant kmalloc rar\n"); 385 422 goto end_function; 386 - } 423 + } 387 424 /* FIXME */ 388 425 sep_dev->rar_physical_address = __pa(sep_dev->rar_virtual_address); 389 426 390 - edbg( 391 - "SEP Driver:rar_physical is %08lx\n", 392 - sep_dev->rar_physical_address); 427 + edbg("SEP Driver:rar_physical is %08lx\n", sep_dev->rar_physical_address); 393 428 394 - edbg( 395 - "SEP Driver:rar_virtual is %p\n", 396 - sep_dev->rar_virtual_address); 429 + edbg("SEP Driver:rar_virtual is %p\n", sep_dev->rar_virtual_address); 397 430 398 431 399 432 #if !SEP_DRIVER_POLLING_MODE 400 433 401 - edbg( 402 - "SEP Driver: about to write IMR and ICR REG_ADDR\n"); 434 + edbg("SEP Driver: about to write IMR and ICR REG_ADDR\n"); 403 435 404 436 /* clear ICR register */ 405 - sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, 406 - 0xFFFFFFFF); 437 + sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, 0xFFFFFFFF); 407 438 408 439 /* set the IMR register - open only GPR 2 */ 409 - sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 410 - (~(0x1 << 13))); 440 + sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13))); 411 441 412 442 /* figure out our irq */ 413 443 /* FIXME: */ 414 - error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *)&sep_dev->sep_irq); 444 + error = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, (u8 *) & sep_dev->sep_irq); 415 445 416 - edbg( 417 - "SEP Driver: my irq is %d\n", sep_irq); 446 + edbg("SEP Driver: my irq is %d\n", sep_irq); 418 447 419 - edbg( 420 - "SEP Driver: about to call request_irq\n"); 448 + edbg("SEP Driver: about to call request_irq\n"); 421 449 /* get the interrupt line */ 422 - error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED, 423 - "sep_driver", &sep_dev->reg_base_address); 450 + error = request_irq(sep_irq, sep_inthandler, IRQF_SHARED, "sep_driver", &sep_dev->reg_base_address); 424 451 if (error) 425 452 goto end_function; 426 453 427 454 goto end_function; 428 - edbg( 429 - "SEP Driver: about to write IMR REG_ADDR"); 455 + edbg("SEP Driver: about to write IMR REG_ADDR"); 430 456 431 457 /* set the IMR register - open only GPR 2 */ 432 - sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 433 - (~(0x1 << 13))); 458 + sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13))); 434 459 435 - #endif /* SEP_DRIVER_POLLING_MODE */ 460 + #endif /* SEP_DRIVER_POLLING_MODE */ 436 461 437 - end_function: 462 + end_function: 438 463 439 464 return error; 440 465 } ··· 434 515 /* Loading ROM from SEP_ROM_image.h file */ 435 516 k = sizeof(CRYS_SEP_ROM); 436 517 437 - edbg( 438 - "SEP Driver: DX_CC_TST_SepRomLoader start\n"); 518 + edbg("SEP Driver: DX_CC_TST_SepRomLoader start\n"); 439 519 440 - edbg( 441 - "SEP Driver: k is %lu\n", k); 442 - edbg( 443 - "SEP Driver: sep_dev->reg_base_address is %p\n", 444 - sep_dev->reg_base_address); 445 - edbg( 446 - "SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n", 447 - CRYS_SEP_ROM_start_address_offset); 520 + edbg("SEP Driver: k is %lu\n", k); 521 + edbg("SEP Driver: sep_dev->reg_base_address is %p\n", sep_dev->reg_base_address); 522 + edbg("SEP Driver: CRYS_SEP_ROM_start_address_offset is %p\n", CRYS_SEP_ROM_start_address_offset); 448 523 449 524 for (i = 0; i < 4; i++) { 450 525 /* write bank */ 451 526 sep_write_reg(sep_dev, SEP_ROM_BANK_register_offset, i); 452 527 453 528 for (j = 0; j < CRYS_SEP_ROM_length / 4; j++) { 454 - sep_write_reg(sep_dev, 455 - CRYS_SEP_ROM_start_address_offset + 4*j, 456 - CRYS_SEP_ROM[i * 0x1000 + j]); 529 + sep_write_reg(sep_dev, CRYS_SEP_ROM_start_address_offset + 4 * j, CRYS_SEP_ROM[i * 0x1000 + j]); 457 530 458 531 k = k - 4; 459 532 ··· 456 545 } 457 546 } 458 547 459 - /* reset the SEP*/ 548 + /* reset the SEP */ 460 549 sep_write_reg(sep_dev, HW_HOST_SEP_SW_RST_REG_ADDR, 0x1); 461 550 462 551 /* poll for SEP ROM boot finish */ ··· 464 553 retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); 465 554 } while (!regVal); 466 555 467 - edbg( 468 - "SEP Driver: ROM polling ended\n"); 556 + edbg("SEP Driver: ROM polling ended\n"); 469 557 470 558 switch (regVal) { 471 559 case 0x1: 472 560 /* fatal error - read erro status from GPRO */ 473 561 Error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 474 - edbg( 475 - "SEP Driver: ROM polling case 1\n"); 562 + edbg("SEP Driver: ROM polling case 1\n"); 476 563 break; 477 564 case 0x2: 478 565 /* Boot First Phase ended */ 479 566 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 480 - edbg( 481 - "SEP Driver: ROM polling case 2\n"); 567 + edbg("SEP Driver: ROM polling case 2\n"); 482 568 break; 483 569 case 0x4: 484 570 /* Cold boot ended successfully */ 485 571 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 486 - edbg( 487 - "SEP Driver: ROM polling case 4\n"); 572 + edbg("SEP Driver: ROM polling case 4\n"); 488 573 Error = 0; 489 574 break; 490 575 case 0x8: 491 576 /* Warmboot ended successfully */ 492 577 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 493 - edbg( 494 - "SEP Driver: ROM polling case 8\n"); 578 + edbg("SEP Driver: ROM polling case 8\n"); 495 579 Error = 0; 496 580 break; 497 581 case 0x10: 498 582 /* ColdWarm boot ended successfully */ 499 583 warning = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 500 - edbg( 501 - "SEP Driver: ROM polling case 16\n"); 584 + edbg("SEP Driver: ROM polling case 16\n"); 502 585 Error = 0; 503 586 break; 504 587 case 0x20: 505 - edbg( 506 - "SEP Driver: ROM polling case 32\n"); 588 + edbg("SEP Driver: ROM polling case 32\n"); 507 589 break; 508 590 } 509 591 510 592 #endif 511 593 } 512 -
+1705 -2204
drivers/staging/sep/sep_main_mod.c
··· 72 72 MODULE_PARM_DESC(sepDebug, "Flag to enable SEP debug messages"); 73 73 74 74 /* major and minor device numbers */ 75 - static dev_t g_sep_device_number; 75 + static dev_t g_sep_device_number; 76 76 77 77 /* the files operations structure of the driver */ 78 - static struct file_operations g_sep_fops; 78 + static struct file_operations g_sep_fops; 79 79 80 80 /* cdev struct of the driver */ 81 - static struct cdev g_sep_cdev; 81 + static struct cdev g_sep_cdev; 82 82 83 83 /* 84 84 mutex for the access to the internals of the sep driver ··· 103 103 /* 104 104 this function registers the driver to the file system 105 105 */ 106 - static int sep_register_driver_to_fs(void); 106 + static int sep_register_driver_to_fs(void); 107 107 108 108 /* 109 109 this function unregisters driver from fs ··· 115 115 table from this array the condition is that either the table is full 116 116 (all etnries are entered), or there are no more entries in the lli array 117 117 */ 118 - static unsigned long sep_calculate_lli_table_max_size( 119 - struct sep_lli_entry_t *lli_in_array_ptr, 120 - unsigned long num_array_entries); 118 + static unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries); 121 119 /* 122 120 this functions builds ont lli table from the lli_array according to the 123 121 given size of data 124 122 */ 125 - static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, 126 - struct sep_lli_entry_t *lli_table_ptr, 127 - unsigned long *num_processed_entries_ptr, 128 - unsigned long *num_table_entries_ptr, 129 - unsigned long table_data_size); 123 + static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, struct sep_lli_entry_t *lli_table_ptr, unsigned long *num_processed_entries_ptr, unsigned long *num_table_entries_ptr, unsigned long table_data_size); 130 124 131 125 /* 132 126 this function goes over the list of the print created tables and prints 133 127 all the data 134 128 */ 135 - static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, 136 - unsigned long num_table_entries, 137 - unsigned long table_data_size); 129 + static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, unsigned long num_table_entries, unsigned long table_data_size); 138 130 139 131 140 132 ··· 211 219 static int sep_set_api_mode_handler(unsigned long arg); 212 220 213 221 /* handler for flow done interrupt */ 214 - static void sep_flow_done_handler(struct work_struct *work); 222 + static void sep_flow_done_handler(struct work_struct *work); 215 223 216 224 /* 217 225 This function locks all the physical pages of the kernel virtual buffer 218 226 and construct a basic lli array, where each entry holds the physical 219 227 page address and the size that application data holds in this physical pages 220 228 */ 221 - static int sep_lock_kernel_pages(unsigned long kernel_virt_addr, 222 - unsigned long data_size, 223 - unsigned long *num_pages_ptr, 224 - struct sep_lli_entry_t **lli_array_ptr, 225 - struct page ***page_array_ptr); 229 + static int sep_lock_kernel_pages(unsigned long kernel_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr); 226 230 227 231 /* 228 232 This function creates one DMA table for flow and returns its data, 229 233 and pointer to its info entry 230 234 */ 231 - static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr, 232 - unsigned long virt_buff_size, 233 - struct sep_lli_entry_t *table_data, 234 - struct sep_lli_entry_t **info_entry_ptr, 235 - struct sep_flow_context_t *flow_data_ptr, 236 - bool isKernelVirtualAddress); 235 + static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr, unsigned long virt_buff_size, struct sep_lli_entry_t *table_data, struct sep_lli_entry_t **info_entry_ptr, struct sep_flow_context_t *flow_data_ptr, bool isKernelVirtualAddress); 237 236 238 237 /* 239 238 This function creates a list of tables for flow and returns the data for the 240 239 first and last tables of the list 241 240 */ 242 - static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, 243 - unsigned long first_buff_addr, 244 - struct sep_flow_context_t *flow_data_ptr, 245 - struct sep_lli_entry_t *first_table_data_ptr, 246 - struct sep_lli_entry_t *last_table_data_ptr, 247 - bool isKernelVirtualAddress); 241 + static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, 242 + unsigned long first_buff_addr, struct sep_flow_context_t *flow_data_ptr, struct sep_lli_entry_t *first_table_data_ptr, struct sep_lli_entry_t *last_table_data_ptr, bool isKernelVirtualAddress); 248 243 249 244 /* 250 245 this function find a space for the new flow dma table 251 246 */ 252 - static int sep_find_free_flow_dma_table_space( 253 - unsigned long **table_address_ptr); 247 + static int sep_find_free_flow_dma_table_space(unsigned long **table_address_ptr); 254 248 255 249 /* 256 250 this function goes over all the flow tables connected to the given table and 257 251 deallocate them 258 252 */ 259 - static void sep_deallocated_flow_tables( 260 - struct sep_lli_entry_t *first_table_ptr); 253 + static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr); 261 254 262 255 /* 263 256 This function handler the set flow id command ··· 253 276 This function returns pointer to the flow data structure 254 277 that conatins the given id 255 278 */ 256 - static int sep_find_flow_context(unsigned long flow_id, 257 - struct sep_flow_context_t **flow_data_ptr); 279 + static int sep_find_flow_context(unsigned long flow_id, struct sep_flow_context_t **flow_data_ptr); 258 280 259 281 260 282 /* ··· 276 300 /* 277 301 calculates time and sets it at the predefined address 278 302 */ 279 - static int sep_set_time(unsigned long *address_ptr, 280 - unsigned long *time_in_sec_ptr); 303 + static int sep_set_time(unsigned long *address_ptr, unsigned long *time_in_sec_ptr); 281 304 282 305 /* 283 306 PATCH for configuring the DMA to single burst instead of multi-burst ··· 289 314 array, where each entry holds the physical page address 290 315 and the size that application data holds in this physical pages 291 316 */ 292 - static int sep_lock_user_pages(unsigned long app_virt_addr, 293 - unsigned long data_size, 294 - unsigned long *num_pages_ptr, 295 - struct sep_lli_entry_t **lli_array_ptr, 296 - struct page ***page_array_ptr); 317 + static int sep_lock_user_pages(unsigned long app_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr); 297 318 298 319 /*--------------------------------------------- 299 320 FUNCTIONS ··· 300 329 */ 301 330 int sep_lock() 302 331 { 303 - mutex_lock(&sep_mutex); 332 + mutex_lock(&sep_mutex); 304 333 305 - return 0; 334 + return 0; 306 335 } 307 336 308 337 /* ··· 310 339 */ 311 340 void sep_unlock() 312 341 { 313 - /* release mutex */ 314 - mutex_unlock(&sep_mutex); 342 + /* release mutex */ 343 + mutex_unlock(&sep_mutex); 315 344 } 316 345 317 346 /* 318 347 this function returns the address of the message shared area 319 348 */ 320 - void sep_map_shared_area(unsigned long *mappedAddr_ptr) 349 + void sep_map_shared_area(unsigned long *mappedAddr_ptr) 321 350 { 322 - *mappedAddr_ptr = sep_dev->shared_area_addr; 351 + *mappedAddr_ptr = sep_dev->shared_area_addr; 323 352 } 324 353 325 354 /* ··· 327 356 */ 328 357 void sep_send_msg_rdy_cmd() 329 358 { 330 - sep_send_command_handler(); 359 + sep_send_command_handler(); 331 360 } 332 361 333 362 /* this functions frees all the resources that were allocated for the building 334 363 of the LLI DMA tables */ 335 364 void sep_free_dma_resources() 336 365 { 337 - sep_free_dma_table_data_handler(); 366 + sep_free_dma_table_data_handler(); 338 367 } 339 368 340 369 /* poll(suspend), until reply from sep */ 341 370 void sep_driver_poll() 342 371 { 343 - unsigned long retVal = 0; 372 + unsigned long retVal = 0; 344 373 345 374 #ifdef SEP_DRIVER_POLLING_MODE 346 375 347 - while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF)) 348 - retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); 376 + while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF)) 377 + retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); 349 378 350 - sep_dev->sep_to_host_reply_counter++; 379 + sep_dev->sep_to_host_reply_counter++; 351 380 #else 352 - /* poll, until reply from sep */ 353 - wait_event(g_sep_event, 354 - (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter)); 381 + /* poll, until reply from sep */ 382 + wait_event(g_sep_event, (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter)); 355 383 356 384 #endif 357 385 } ··· 361 391 ------------------------------------------------------------------------*/ 362 392 static int sep_open(struct inode *inode_ptr, struct file *file_ptr) 363 393 { 364 - /* return value */ 365 - int error; 394 + /* return value */ 395 + int error; 366 396 367 397 /*----------------- 368 398 CODE 369 399 ---------------------*/ 370 400 371 - dbg("SEP Driver:--------> open start\n"); 401 + dbg("SEP Driver:--------> open start\n"); 372 402 373 - error = 0; 403 + error = 0; 374 404 375 - /* check the blocking mode */ 376 - if (sep_dev->block_mode_flag) 377 - /* lock mutex */ 378 - mutex_lock(&sep_mutex); 379 - else 380 - error = mutex_trylock(&sep_mutex); 405 + /* check the blocking mode */ 406 + if (sep_dev->block_mode_flag) 407 + /* lock mutex */ 408 + mutex_lock(&sep_mutex); 409 + else 410 + error = mutex_trylock(&sep_mutex); 381 411 382 - /* check the error */ 383 - if (error) { 384 - edbg( 385 - "SEP Driver: down_interruptible failed\n"); 412 + /* check the error */ 413 + if (error) { 414 + edbg("SEP Driver: down_interruptible failed\n"); 386 415 387 - goto end_function; 388 - } 416 + goto end_function; 417 + } 389 418 390 - /* release data pool allocations */ 391 - sep_dev->data_pool_bytes_allocated = 0; 419 + /* release data pool allocations */ 420 + sep_dev->data_pool_bytes_allocated = 0; 392 421 393 - end_function: 422 + end_function: 394 423 395 - dbg("SEP Driver:<-------- open end\n"); 424 + dbg("SEP Driver:<-------- open end\n"); 396 425 397 - return error; 426 + return error; 398 427 } 399 428 400 429 ··· 408 439 CODE 409 440 ---------------------*/ 410 441 411 - dbg("----------->SEP Driver: sep_release start\n"); 442 + dbg("----------->SEP Driver: sep_release start\n"); 412 443 413 - #if 0/*!SEP_DRIVER_POLLING_MODE*/ 414 - /* close IMR */ 415 - sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF); 444 + #if 0 /*!SEP_DRIVER_POLLING_MODE */ 445 + /* close IMR */ 446 + sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF); 416 447 417 - /* release IRQ line */ 418 - free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address); 448 + /* release IRQ line */ 449 + free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address); 419 450 420 451 #endif 421 452 422 - /* unlock the sep mutex */ 423 - mutex_unlock(&sep_mutex); 453 + /* unlock the sep mutex */ 454 + mutex_unlock(&sep_mutex); 424 455 425 - dbg("SEP Driver:<-------- sep_release end\n"); 456 + dbg("SEP Driver:<-------- sep_release end\n"); 426 457 427 - return 0; 458 + return 0; 428 459 } 429 460 430 461 ··· 433 464 /*--------------------------------------------------------------- 434 465 map function - this functions maps the message shared area 435 466 -----------------------------------------------------------------*/ 436 - static int sep_mmap(struct file *filp, struct vm_area_struct *vma) 467 + static int sep_mmap(struct file *filp, struct vm_area_struct *vma) 437 468 { 438 - /* physical addr */ 439 - unsigned long phys_addr; 469 + /* physical addr */ 470 + unsigned long phys_addr; 440 471 441 472 /*----------------------- 442 473 CODE 443 474 -------------------------*/ 444 475 445 - dbg("-------->SEP Driver: mmap start\n"); 476 + dbg("-------->SEP Driver: mmap start\n"); 446 477 447 - /* check that the size of the mapped range is as the size of the message 448 - shared area */ 449 - if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) { 450 - edbg( 451 - "SEP Driver mmap requested size is more than allowed\n"); 452 - printk(KERN_WARNING "SEP Driver mmap requested size is more \ 478 + /* check that the size of the mapped range is as the size of the message 479 + shared area */ 480 + if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) { 481 + edbg("SEP Driver mmap requested size is more than allowed\n"); 482 + printk(KERN_WARNING "SEP Driver mmap requested size is more \ 453 483 than allowed\n"); 454 - printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", 455 - vma->vm_end); 456 - printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", 457 - vma->vm_start); 458 - return -EAGAIN; 459 - } 484 + printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", vma->vm_end); 485 + printk(KERN_WARNING "SEP Driver vma->vm_end is %08lx\n", vma->vm_start); 486 + return -EAGAIN; 487 + } 460 488 461 - edbg( 462 - "SEP Driver:g_message_shared_area_addr is %08lx\n", 463 - sep_dev->message_shared_area_addr); 489 + edbg("SEP Driver:g_message_shared_area_addr is %08lx\n", sep_dev->message_shared_area_addr); 464 490 465 - /* get physical address */ 466 - phys_addr = sep_dev->phys_shared_area_addr; 491 + /* get physical address */ 492 + phys_addr = sep_dev->phys_shared_area_addr; 467 493 468 - edbg( "SEP Driver: phys_addr is %08lx\n", 469 - phys_addr); 494 + edbg("SEP Driver: phys_addr is %08lx\n", phys_addr); 470 495 471 - if (remap_pfn_range(vma, 472 - vma->vm_start, 473 - phys_addr >> PAGE_SHIFT, 474 - vma->vm_end - vma->vm_start, 475 - vma->vm_page_prot)) { 476 - edbg( 477 - "SEP Driver remap_page_range failed\n"); 478 - printk(KERN_WARNING "SEP Driver remap_page_range failed\n"); 479 - return -EAGAIN; 480 - } 496 + if (remap_pfn_range(vma, vma->vm_start, phys_addr >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot)) { 497 + edbg("SEP Driver remap_page_range failed\n"); 498 + printk(KERN_WARNING "SEP Driver remap_page_range failed\n"); 499 + return -EAGAIN; 500 + } 481 501 482 - dbg("SEP Driver:<-------- mmap end\n"); 502 + dbg("SEP Driver:<-------- mmap end\n"); 483 503 484 - return 0; 504 + return 0; 485 505 } 486 506 487 507 488 508 /*----------------------------------------------- 489 509 poll function 490 510 *----------------------------------------------*/ 491 - static unsigned int sep_poll(struct file *filp, poll_table *wait) 511 + static unsigned int sep_poll(struct file *filp, poll_table * wait) 492 512 { 493 - unsigned long count; 513 + unsigned long count; 494 514 495 - unsigned int mask = 0; 515 + unsigned int mask = 0; 496 516 497 - /* flow id */ 498 - unsigned long retVal = 0; 517 + /* flow id */ 518 + unsigned long retVal = 0; 499 519 500 520 /*---------------------------------------------- 501 521 CODE 502 522 -------------------------------------------------*/ 503 523 504 - dbg("---------->SEP Driver poll: start\n"); 524 + dbg("---------->SEP Driver poll: start\n"); 505 525 506 526 507 527 #if SEP_DRIVER_POLLING_MODE 508 528 509 - while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF)) { 510 - retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); 529 + while (sep_dev->host_to_sep_send_counter != (retVal & 0x7FFFFFFF)) { 530 + retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); 511 531 512 - for (count = 0; count < 10 * 4; count += 4) 513 - edbg("Poll Debug Word %lu of the message is %lu\n", count, 514 - *((unsigned long *)(sep_dev->shared_area_addr + 515 - SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + count))); 516 - } 532 + for (count = 0; count < 10 * 4; count += 4) 533 + edbg("Poll Debug Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + count))); 534 + } 517 535 518 - sep_dev->sep_to_host_reply_counter++; 536 + sep_dev->sep_to_host_reply_counter++; 519 537 #else 520 - /* add the event to the polling wait table */ 521 - poll_wait(filp, &g_sep_event, wait); 538 + /* add the event to the polling wait table */ 539 + poll_wait(filp, &g_sep_event, wait); 522 540 523 541 #endif 524 542 525 - edbg( 526 - "sep_dev->host_to_sep_send_counter is %lu\n", 527 - sep_dev->host_to_sep_send_counter); 528 - edbg( 529 - "sep_dev->sep_to_host_reply_counter is %lu\n", 530 - sep_dev->sep_to_host_reply_counter); 543 + edbg("sep_dev->host_to_sep_send_counter is %lu\n", sep_dev->host_to_sep_send_counter); 544 + edbg("sep_dev->sep_to_host_reply_counter is %lu\n", sep_dev->sep_to_host_reply_counter); 531 545 532 - /* check if the data is ready */ 533 - if (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter) { 534 - for (count = 0; count < 12 * 4; count += 4) 535 - edbg("Sep Mesg Word %lu of the message is %lu\n", count, 536 - *((unsigned long *)(sep_dev->shared_area_addr + count))); 546 + /* check if the data is ready */ 547 + if (sep_dev->host_to_sep_send_counter == sep_dev->sep_to_host_reply_counter) { 548 + for (count = 0; count < 12 * 4; count += 4) 549 + edbg("Sep Mesg Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count))); 537 550 538 - for (count = 0; count < 10 * 4; count += 4) 539 - edbg("Debug Data Word %lu of the message is %lu\n", count, 540 - *((unsigned long *)(sep_dev->shared_area_addr + 0x1800 + count))); 551 + for (count = 0; count < 10 * 4; count += 4) 552 + edbg("Debug Data Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + 0x1800 + count))); 541 553 542 - retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); 543 - edbg( "retVal is %lu\n", retVal); 544 - /* check if the this is sep reply or request */ 545 - if (retVal >> 31) { 546 - edbg( 547 - "SEP Driver: sep request in\n"); 548 - /* request */ 549 - mask |= POLLOUT | POLLWRNORM; 550 - } else { 551 - edbg( "SEP Driver: sep reply in\n"); 552 - mask |= POLLIN | POLLRDNORM; 554 + retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR2_REG_ADDR); 555 + edbg("retVal is %lu\n", retVal); 556 + /* check if the this is sep reply or request */ 557 + if (retVal >> 31) { 558 + edbg("SEP Driver: sep request in\n"); 559 + /* request */ 560 + mask |= POLLOUT | POLLWRNORM; 561 + } else { 562 + edbg("SEP Driver: sep reply in\n"); 563 + mask |= POLLIN | POLLRDNORM; 564 + } 553 565 } 554 - } 555 566 556 - dbg("SEP Driver:<-------- poll exit\n"); 557 - return mask; 567 + dbg("SEP Driver:<-------- poll exit\n"); 568 + return mask; 558 569 } 559 570 560 571 561 - static int sep_ioctl(struct inode *inode, 562 - struct file *filp, 563 - unsigned int cmd, 564 - unsigned long arg) 572 + static int sep_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) 565 573 { 566 574 567 - /* error */ 568 - int error; 575 + /* error */ 576 + int error; 569 577 570 578 /*------------------------ 571 579 CODE 572 580 ------------------------*/ 573 - error = 0; 581 + error = 0; 574 582 575 - dbg("------------>SEP Driver: ioctl start\n"); 583 + dbg("------------>SEP Driver: ioctl start\n"); 576 584 577 - edbg("SEP Driver: cmd is %x\n", cmd); 585 + edbg("SEP Driver: cmd is %x\n", cmd); 578 586 579 - /* check that the command is for sep device */ 580 - if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) 581 - error = -ENOTTY; 587 + /* check that the command is for sep device */ 588 + if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) 589 + error = -ENOTTY; 582 590 583 591 switch (cmd) { 584 592 case SEP_IOCSENDSEPCOMMAND: 585 593 586 - /* send command to SEP */ 587 - sep_send_command_handler(); 594 + /* send command to SEP */ 595 + sep_send_command_handler(); 588 596 589 - edbg( 590 - "SEP Driver: after sep_send_command_handler\n"); 597 + edbg("SEP Driver: after sep_send_command_handler\n"); 591 598 592 - break; 599 + break; 593 600 594 601 case SEP_IOCSENDSEPRPLYCOMMAND: 595 602 596 - /* send reply command to SEP */ 597 - sep_send_reply_command_handler(); 603 + /* send reply command to SEP */ 604 + sep_send_reply_command_handler(); 598 605 599 - break; 606 + break; 600 607 601 608 case SEP_IOCALLOCDATAPOLL: 602 609 603 - /* allocate data pool */ 604 - error = sep_allocate_data_pool_memory_handler(arg); 610 + /* allocate data pool */ 611 + error = sep_allocate_data_pool_memory_handler(arg); 605 612 606 - break; 613 + break; 607 614 608 615 case SEP_IOCWRITEDATAPOLL: 609 616 610 - /* write data into memory pool */ 611 - error = sep_write_into_data_pool_handler(arg); 617 + /* write data into memory pool */ 618 + error = sep_write_into_data_pool_handler(arg); 612 619 613 - break; 620 + break; 614 621 615 622 case SEP_IOCREADDATAPOLL: 616 623 617 - /* read data from data pool into application memory */ 618 - error = sep_read_from_data_pool_handler(arg); 624 + /* read data from data pool into application memory */ 625 + error = sep_read_from_data_pool_handler(arg); 619 626 620 - break; 627 + break; 621 628 622 629 case SEP_IOCCREATESYMDMATABLE: 623 630 624 - /* create dma table for synhronic operation */ 625 - error = sep_create_sync_dma_tables_handler(arg); 631 + /* create dma table for synhronic operation */ 632 + error = sep_create_sync_dma_tables_handler(arg); 626 633 627 - break; 634 + break; 628 635 629 636 case SEP_IOCCREATEFLOWDMATABLE: 630 637 631 - /* create flow dma tables */ 632 - error = sep_create_flow_dma_tables_handler(arg); 638 + /* create flow dma tables */ 639 + error = sep_create_flow_dma_tables_handler(arg); 633 640 634 - break; 641 + break; 635 642 636 643 case SEP_IOCFREEDMATABLEDATA: 637 644 638 - /* free the pages */ 639 - error = sep_free_dma_table_data_handler(); 645 + /* free the pages */ 646 + error = sep_free_dma_table_data_handler(); 640 647 641 - break; 648 + break; 642 649 643 650 case SEP_IOCSETFLOWID: 644 651 645 - /* set flow id */ 646 - error = sep_set_flow_id_handler(arg); 652 + /* set flow id */ 653 + error = sep_set_flow_id_handler(arg); 647 654 648 - break; 655 + break; 649 656 650 657 case SEP_IOCADDFLOWTABLE: 651 658 652 - /* add tables to the dynamic flow */ 653 - error = sep_add_flow_tables_handler(arg); 659 + /* add tables to the dynamic flow */ 660 + error = sep_add_flow_tables_handler(arg); 654 661 655 - break; 662 + break; 656 663 657 664 case SEP_IOCADDFLOWMESSAGE: 658 665 659 - /* add message of add tables to flow */ 660 - error = sep_add_flow_tables_message_handler(arg); 666 + /* add message of add tables to flow */ 667 + error = sep_add_flow_tables_message_handler(arg); 661 668 662 - break; 669 + break; 663 670 664 671 case SEP_IOCSEPSTART: 665 672 666 - /* start command to sep */ 667 - error = sep_start_handler(); 668 - break; 673 + /* start command to sep */ 674 + error = sep_start_handler(); 675 + break; 669 676 670 677 case SEP_IOCSEPINIT: 671 678 672 - /* init command to sep */ 673 - error = sep_init_handler(arg); 674 - break; 679 + /* init command to sep */ 680 + error = sep_init_handler(arg); 681 + break; 675 682 676 683 case SEP_IOCSETAPIMODE: 677 684 678 - /* set non- blocking mode */ 679 - error = sep_set_api_mode_handler(arg); 685 + /* set non- blocking mode */ 686 + error = sep_set_api_mode_handler(arg); 680 687 681 - break; 688 + break; 682 689 683 690 case SEP_IOCGETSTATICPOOLADDR: 684 691 ··· 665 720 666 721 case SEP_IOCENDTRANSACTION: 667 722 668 - error = sep_end_transaction_handler(arg); 723 + error = sep_end_transaction_handler(arg); 669 724 670 725 break; 671 726 672 727 case SEP_IOCREALLOCCACHERES: 673 728 674 - error = sep_realloc_cache_resident_handler(arg); 729 + error = sep_realloc_cache_resident_handler(arg); 675 730 676 - break; 731 + break; 677 732 678 733 case SEP_IOCGETMAPPEDADDROFFSET: 679 734 680 - error = sep_get_physical_mapped_offset_handler(arg); 735 + error = sep_get_physical_mapped_offset_handler(arg); 681 736 682 - break; 737 + break; 683 738 case SEP_IOCGETIME: 684 739 685 - error = sep_get_time_handler(arg); 740 + error = sep_get_time_handler(arg); 686 741 687 - break; 742 + break; 688 743 689 744 default: 690 - error = -ENOTTY; 691 - break; 692 - } 745 + error = -ENOTTY; 746 + break; 747 + } 693 748 694 - dbg("SEP Driver:<-------- ioctl end\n"); 749 + dbg("SEP Driver:<-------- ioctl end\n"); 695 750 696 - return error; 751 + return error; 697 752 } 698 753 699 754 700 755 /* 701 756 this function registers the driver to the file system 702 757 */ 703 - static int sep_register_driver_to_fs(void) 758 + static int sep_register_driver_to_fs(void) 704 759 { 705 - /* return value */ 706 - int ret_val; 760 + /* return value */ 761 + int ret_val; 707 762 708 763 /*--------------------- 709 764 CODE 710 765 -----------------------*/ 711 766 712 - ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver"); 713 - if (ret_val) { 714 - edbg( 715 - "sep_driver:major number allocation failed, retval is %d\n", ret_val); 767 + ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver"); 768 + if (ret_val) { 769 + edbg("sep_driver:major number allocation failed, retval is %d\n", ret_val); 770 + goto end_function; 771 + } 772 + 773 + /* set the files operations structure */ 774 + g_sep_fops.owner = THIS_MODULE; 775 + g_sep_fops.ioctl = sep_ioctl; 776 + g_sep_fops.poll = sep_poll; 777 + g_sep_fops.open = sep_open; 778 + g_sep_fops.release = sep_release; 779 + g_sep_fops.mmap = sep_mmap; 780 + 781 + /* init cdev */ 782 + cdev_init(&g_sep_cdev, &g_sep_fops); 783 + g_sep_cdev.owner = THIS_MODULE; 784 + 785 + /* register the driver with the kernel */ 786 + ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1); 787 + 788 + if (ret_val) { 789 + edbg("sep_driver:cdev_add failed, retval is %d\n", ret_val); 790 + goto end_function_unregister_devnum; 791 + } 792 + 716 793 goto end_function; 717 - } 718 794 719 - /* set the files operations structure */ 720 - g_sep_fops.owner = THIS_MODULE; 721 - g_sep_fops.ioctl = sep_ioctl; 722 - g_sep_fops.poll = sep_poll; 723 - g_sep_fops.open = sep_open; 724 - g_sep_fops.release = sep_release; 725 - g_sep_fops.mmap = sep_mmap; 795 + end_function_unregister_devnum: 726 796 727 - /* init cdev */ 728 - cdev_init(&g_sep_cdev, &g_sep_fops); 729 - g_sep_cdev.owner = THIS_MODULE; 797 + /* unregister dev numbers */ 798 + unregister_chrdev_region(g_sep_device_number, 1); 730 799 731 - /* register the driver with the kernel */ 732 - ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1); 800 + end_function: 733 801 734 - if (ret_val) { 735 - edbg( 736 - "sep_driver:cdev_add failed, retval is %d\n", 737 - ret_val); 738 - goto end_function_unregister_devnum; 739 - } 740 - 741 - goto end_function; 742 - 743 - end_function_unregister_devnum: 744 - 745 - /* unregister dev numbers */ 746 - unregister_chrdev_region(g_sep_device_number, 1); 747 - 748 - end_function: 749 - 750 - return ret_val; 802 + return ret_val; 751 803 } 752 804 753 805 /* ··· 756 814 CODE 757 815 ---------------------*/ 758 816 759 - cdev_del(&g_sep_cdev); 817 + cdev_del(&g_sep_cdev); 760 818 761 - /* unregister dev numbers */ 762 - unregister_chrdev_region(g_sep_device_number, 1); 819 + /* unregister dev numbers */ 820 + unregister_chrdev_region(g_sep_device_number, 1); 763 821 } 764 822 765 823 /*-------------------------------------------------------------- ··· 767 825 ----------------------------------------------------------------*/ 768 826 static int __init sep_init(void) 769 827 { 770 - /* return value */ 771 - int ret_val; 828 + /* return value */ 829 + int ret_val; 772 830 773 - /* counter */ 774 - int counter; 831 + /* counter */ 832 + int counter; 775 833 776 - /* size to of memory for allocation */ 777 - int size; 834 + /* size to of memory for allocation */ 835 + int size; 778 836 779 837 /*------------------------ 780 838 CODE 781 839 ------------------------*/ 782 840 783 - dbg("SEP Driver:-------->Init start\n"); 784 - edbg("sep->shared_area_addr = %lx\n", 785 - (unsigned long)&sep_dev->shared_area_addr); 841 + dbg("SEP Driver:-------->Init start\n"); 842 + edbg("sep->shared_area_addr = %lx\n", (unsigned long) &sep_dev->shared_area_addr); 786 843 787 - ret_val = 0; 844 + ret_val = 0; 788 845 789 846 /* transaction counter that coordinates the transactions between SEP 790 847 and HOST */ 791 - sep_dev->host_to_sep_send_counter = 0; 848 + sep_dev->host_to_sep_send_counter = 0; 792 849 793 850 /* counter for the messages from sep */ 794 - sep_dev->sep_to_host_reply_counter = 0; 851 + sep_dev->sep_to_host_reply_counter = 0; 795 852 796 853 /* counter for the number of bytes allocated in the pool 797 854 for the current transaction */ 798 - sep_dev->data_pool_bytes_allocated = 0; 855 + sep_dev->data_pool_bytes_allocated = 0; 799 856 800 - /* set the starting mode to blocking */ 801 - sep_dev->block_mode_flag = 1; 857 + /* set the starting mode to blocking */ 858 + sep_dev->block_mode_flag = 1; 802 859 803 860 804 - ret_val = sep_register_driver_to_device(); 805 - if (ret_val) { 806 - edbg( 807 - "sep_driver:sep_driver_to_device failed, ret_val is %d\n", 808 - ret_val); 809 - goto end_function_unregister_from_fs; 810 - } 861 + ret_val = sep_register_driver_to_device(); 862 + if (ret_val) { 863 + edbg("sep_driver:sep_driver_to_device failed, ret_val is %d\n", ret_val); 864 + goto end_function_unregister_from_fs; 865 + } 811 866 812 - /* calculate the total size for allocation */ 813 - size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + 814 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + 815 - SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES + 816 - SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES + 817 - SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES + 818 - SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES; 867 + /* calculate the total size for allocation */ 868 + size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + 869 + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES + SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES; 819 870 820 871 821 872 822 - /* allocate the shared area */ 823 - if (sep_map_and_alloc_shared_area(size, 824 - &sep_dev->shared_area_addr, 825 - &sep_dev->phys_shared_area_addr)) { 826 - ret_val = -ENOMEM; 827 - /* allocation failed */ 828 - goto end_function_unmap_io_memory; 829 - } 873 + /* allocate the shared area */ 874 + if (sep_map_and_alloc_shared_area(size, &sep_dev->shared_area_addr, &sep_dev->phys_shared_area_addr)) { 875 + ret_val = -ENOMEM; 876 + /* allocation failed */ 877 + goto end_function_unmap_io_memory; 878 + } 830 879 831 - /* now set the memory regions */ 832 - sep_dev->message_shared_area_addr = sep_dev->shared_area_addr; 880 + /* now set the memory regions */ 881 + sep_dev->message_shared_area_addr = sep_dev->shared_area_addr; 833 882 834 - edbg( 835 - "SEP Driver: g_message_shared_area_addr is %08lx\n", 836 - sep_dev->message_shared_area_addr); 883 + edbg("SEP Driver: g_message_shared_area_addr is %08lx\n", sep_dev->message_shared_area_addr); 837 884 838 885 #if (SEP_DRIVER_RECONFIG_MESSAGE_AREA == 1) 839 886 840 - /* send the new SHARED MESSAGE AREA to the SEP */ 841 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR1_REG_ADDR, 842 - sep_dev->phys_shared_area_addr); 887 + /* send the new SHARED MESSAGE AREA to the SEP */ 888 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep_dev->phys_shared_area_addr); 843 889 844 - /* poll for SEP response */ 845 - retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR); 846 - while (retVal != 0xffffffff && retVal != sep_dev->phys_shared_area_addr) 890 + /* poll for SEP response */ 847 891 retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR); 892 + while (retVal != 0xffffffff && retVal != sep_dev->phys_shared_area_addr) 893 + retVal = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR1_REG_ADDR); 848 894 849 - /* check the return value (register) */ 850 - if (retVal != sep_dev->phys_shared_area_addr) { 851 - ret_val = -ENOMEM; 852 - goto end_function_deallocate_message_area; 853 - } 854 - 895 + /* check the return value (register) */ 896 + if (retVal != sep_dev->phys_shared_area_addr) { 897 + ret_val = -ENOMEM; 898 + goto end_function_deallocate_message_area; 899 + } 855 900 #endif 856 901 857 - /* init the flow contextes */ 858 - for (counter = 0; counter < SEP_DRIVER_NUM_FLOWS; counter++) 859 - sep_dev->flows_data_array[counter].flow_id = SEP_FREE_FLOW_ID; 902 + /* init the flow contextes */ 903 + for (counter = 0; counter < SEP_DRIVER_NUM_FLOWS; counter++) 904 + sep_dev->flows_data_array[counter].flow_id = SEP_FREE_FLOW_ID; 860 905 861 - sep_dev->flow_wq_ptr = create_singlethread_workqueue("sepflowwq"); 862 - if (sep_dev->flow_wq_ptr == 0) { 863 - ret_val = -ENOMEM; 864 - edbg( 865 - "sep_driver:flow queue creation failed\n"); 866 - goto end_function_deallocate_sep_shared_area; 867 - } 906 + sep_dev->flow_wq_ptr = create_singlethread_workqueue("sepflowwq"); 907 + if (sep_dev->flow_wq_ptr == 0) { 908 + ret_val = -ENOMEM; 909 + edbg("sep_driver:flow queue creation failed\n"); 910 + goto end_function_deallocate_sep_shared_area; 911 + } 868 912 869 - edbg( 870 - "SEP Driver: create flow workqueue \n"); 913 + edbg("SEP Driver: create flow workqueue \n"); 871 914 872 - /* register driver to fs */ 873 - ret_val = sep_register_driver_to_fs(); 874 - if (ret_val) 875 - goto end_function_deallocate_sep_shared_area; 915 + /* register driver to fs */ 916 + ret_val = sep_register_driver_to_fs(); 917 + if (ret_val) 918 + goto end_function_deallocate_sep_shared_area; 876 919 877 - /* load the rom code */ 878 - sep_load_rom_code(); 920 + /* load the rom code */ 921 + sep_load_rom_code(); 879 922 880 - goto end_function; 923 + goto end_function; 881 924 882 - end_function_unregister_from_fs: 925 + end_function_unregister_from_fs: 883 926 884 - /* unregister from fs */ 885 - sep_unregister_driver_from_fs(); 927 + /* unregister from fs */ 928 + sep_unregister_driver_from_fs(); 886 929 887 - end_function_deallocate_sep_shared_area: 930 + end_function_deallocate_sep_shared_area: 888 931 889 - /* de-allocate shared area */ 890 - sep_unmap_and_free_shared_area(size, 891 - sep_dev->shared_area_addr, 892 - sep_dev->phys_shared_area_addr); 932 + /* de-allocate shared area */ 933 + sep_unmap_and_free_shared_area(size, sep_dev->shared_area_addr, sep_dev->phys_shared_area_addr); 893 934 894 - end_function_unmap_io_memory: 935 + end_function_unmap_io_memory: 895 936 896 - iounmap((void *)sep_dev->reg_base_address); 937 + iounmap((void *) sep_dev->reg_base_address); 897 938 898 - /* release io memory region */ 899 - release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE); 939 + /* release io memory region */ 940 + release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE); 900 941 901 - end_function: 942 + end_function: 902 943 903 - dbg("SEP Driver:<-------- Init end\n"); 944 + dbg("SEP Driver:<-------- Init end\n"); 904 945 905 - return ret_val; 946 + return ret_val; 906 947 } 907 948 908 949 ··· 896 971 --------------------------------------------------------------*/ 897 972 static void __exit sep_exit(void) 898 973 { 899 - /* size */ 900 - int size; 974 + /* size */ 975 + int size; 901 976 902 977 /*----------------------------- 903 978 CODE 904 979 --------------------------------*/ 905 980 906 - dbg("SEP Driver:--------> Exit start\n"); 981 + dbg("SEP Driver:--------> Exit start\n"); 907 982 908 - /* unregister from fs */ 909 - sep_unregister_driver_from_fs(); 983 + /* unregister from fs */ 984 + sep_unregister_driver_from_fs(); 910 985 911 - /* calculate the total size for de-allocation */ 912 - size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + 913 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + 914 - SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES + 915 - SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES + 916 - SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES + 917 - SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES; 986 + /* calculate the total size for de-allocation */ 987 + size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES + 988 + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES + SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES + SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES; 918 989 919 990 920 - /* free shared area */ 921 - sep_unmap_and_free_shared_area(size, 922 - sep_dev->shared_area_addr, 923 - sep_dev->phys_shared_area_addr); 991 + /* free shared area */ 992 + sep_unmap_and_free_shared_area(size, sep_dev->shared_area_addr, sep_dev->phys_shared_area_addr); 924 993 925 - edbg( 926 - "SEP Driver: free pages SEP SHARED AREA \n"); 994 + edbg("SEP Driver: free pages SEP SHARED AREA \n"); 927 995 928 - iounmap((void *)sep_dev->reg_base_address); 996 + iounmap((void *) sep_dev->reg_base_address); 929 997 930 - edbg( "SEP Driver: iounmap \n"); 998 + edbg("SEP Driver: iounmap \n"); 931 999 932 - /* release io memory region */ 933 - release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE); 1000 + /* release io memory region */ 1001 + release_mem_region(SEP_IO_MEM_REGION_START_ADDRESS, SEP_IO_MEM_REGION_SIZE); 934 1002 935 - edbg( "SEP Driver: release_mem_region \n"); 1003 + edbg("SEP Driver: release_mem_region \n"); 936 1004 937 - dbg("SEP Driver:<-------- Exit end\n"); 1005 + dbg("SEP Driver:<-------- Exit end\n"); 938 1006 } 939 1007 940 1008 ··· 936 1018 */ 937 1019 irqreturn_t sep_inthandler(int irq, void *dev_id) 938 1020 { 939 - /* int error */ 940 - irqreturn_t int_error; 1021 + /* int error */ 1022 + irqreturn_t int_error; 941 1023 942 - /* error */ 943 - unsigned long error; 1024 + /* error */ 1025 + unsigned long error; 944 1026 945 - /* reg value */ 946 - unsigned long reg_val; 1027 + /* reg value */ 1028 + unsigned long reg_val; 947 1029 948 - /* flow id */ 949 - unsigned long flow_id; 1030 + /* flow id */ 1031 + unsigned long flow_id; 950 1032 951 - /* flow context */ 952 - struct sep_flow_context_t *flow_context_ptr; 1033 + /* flow context */ 1034 + struct sep_flow_context_t *flow_context_ptr; 953 1035 954 1036 /*----------------------------- 955 1037 CODE 956 1038 -----------------------------*/ 957 1039 958 - int_error = IRQ_HANDLED; 1040 + int_error = IRQ_HANDLED; 959 1041 960 - /* read the IRR register to check if this is SEP interrupt */ 961 - reg_val = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR); 962 - edbg( "SEP Interrupt - reg is %08lx\n", 963 - reg_val); 1042 + /* read the IRR register to check if this is SEP interrupt */ 1043 + reg_val = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR); 1044 + edbg("SEP Interrupt - reg is %08lx\n", reg_val); 964 1045 965 - /* check if this is the flow interrupt */ 966 - if (0/*reg_val & (0x1 << 11)*/) { 967 - /* read GPRO to find out the which flow is done */ 968 - flow_id = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR); 1046 + /* check if this is the flow interrupt */ 1047 + if (0 /*reg_val & (0x1 << 11) */ ) { 1048 + /* read GPRO to find out the which flow is done */ 1049 + flow_id = sep_read_reg(sep_dev, HW_HOST_IRR_REG_ADDR); 969 1050 970 - /* find the contex of the flow */ 971 - error = sep_find_flow_context(flow_id >> 28, &flow_context_ptr); 972 - if (error) 973 - goto end_function_with_error; 1051 + /* find the contex of the flow */ 1052 + error = sep_find_flow_context(flow_id >> 28, &flow_context_ptr); 1053 + if (error) 1054 + goto end_function_with_error; 974 1055 975 - INIT_WORK(&flow_context_ptr->flow_wq, sep_flow_done_handler); 1056 + INIT_WORK(&flow_context_ptr->flow_wq, sep_flow_done_handler); 976 1057 977 - /* queue the work */ 978 - queue_work(sep_dev->flow_wq_ptr, &flow_context_ptr->flow_wq); 1058 + /* queue the work */ 1059 + queue_work(sep_dev->flow_wq_ptr, &flow_context_ptr->flow_wq); 979 1060 980 - } else { 981 - /* check if this is reply interrupt from SEP */ 982 - if (reg_val & (0x1 << 13)) { 983 - /* update the counter of reply messages */ 984 - sep_dev->sep_to_host_reply_counter++; 985 - 986 - /* wake up the waiting process */ 987 - wake_up(&g_sep_event); 988 1061 } else { 989 - int_error = IRQ_NONE; 990 - goto end_function; 1062 + /* check if this is reply interrupt from SEP */ 1063 + if (reg_val & (0x1 << 13)) { 1064 + /* update the counter of reply messages */ 1065 + sep_dev->sep_to_host_reply_counter++; 1066 + 1067 + /* wake up the waiting process */ 1068 + wake_up(&g_sep_event); 1069 + } else { 1070 + int_error = IRQ_NONE; 1071 + goto end_function; 1072 + } 991 1073 } 992 - } 993 1074 994 - end_function_with_error: 1075 + end_function_with_error: 995 1076 996 - /* clear the interrupt */ 997 - sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, reg_val); 1077 + /* clear the interrupt */ 1078 + sep_write_reg(sep_dev, HW_HOST_ICR_REG_ADDR, reg_val); 998 1079 999 - end_function: 1080 + end_function: 1000 1081 1001 - return int_error; 1082 + return int_error; 1002 1083 } 1003 1084 1004 1085 ··· 1005 1088 This function prepares only input DMA table for synhronic symmetric 1006 1089 operations (HASH) 1007 1090 */ 1008 - int sep_prepare_input_dma_table(unsigned long app_virt_addr, 1009 - unsigned long data_size, 1010 - unsigned long block_size, 1011 - unsigned long *lli_table_ptr, 1012 - unsigned long *num_entries_ptr, 1013 - unsigned long *table_data_size_ptr, 1014 - bool isKernelVirtualAddress) 1015 - 1091 + int sep_prepare_input_dma_table(unsigned long app_virt_addr, unsigned long data_size, unsigned long block_size, unsigned long *lli_table_ptr, unsigned long *num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress) 1016 1092 { 1017 - /* pointer to the info entry of the table - the last entry */ 1018 - struct sep_lli_entry_t *info_entry_ptr; 1093 + /* pointer to the info entry of the table - the last entry */ 1094 + struct sep_lli_entry_t *info_entry_ptr; 1019 1095 1020 - /* array of pointers ot page */ 1021 - struct sep_lli_entry_t *lli_array_ptr; 1096 + /* array of pointers ot page */ 1097 + struct sep_lli_entry_t *lli_array_ptr; 1022 1098 1023 - /* points to the first entry to be processed in the lli_in_array */ 1024 - unsigned long current_entry; 1099 + /* points to the first entry to be processed in the lli_in_array */ 1100 + unsigned long current_entry; 1025 1101 1026 - /* num entries in the virtual buffer */ 1027 - unsigned long sep_lli_entries; 1102 + /* num entries in the virtual buffer */ 1103 + unsigned long sep_lli_entries; 1028 1104 1029 - /* lli table pointer */ 1030 - struct sep_lli_entry_t *in_lli_table_ptr; 1105 + /* lli table pointer */ 1106 + struct sep_lli_entry_t *in_lli_table_ptr; 1031 1107 1032 - /* the total data in one table */ 1033 - unsigned long table_data_size; 1108 + /* the total data in one table */ 1109 + unsigned long table_data_size; 1034 1110 1035 - /* number of entries in lli table */ 1036 - unsigned long num_entries_in_table; 1111 + /* number of entries in lli table */ 1112 + unsigned long num_entries_in_table; 1037 1113 1038 - /* next table address */ 1039 - unsigned long lli_table_alloc_addr; 1114 + /* next table address */ 1115 + unsigned long lli_table_alloc_addr; 1040 1116 1041 - /* result */ 1042 - unsigned long result; 1117 + /* result */ 1118 + unsigned long result; 1043 1119 1044 1120 /*------------------------ 1045 1121 CODE 1046 1122 --------------------------*/ 1047 1123 1048 - dbg("SEP Driver:--------> sep_prepare_input_dma_table start\n"); 1124 + dbg("SEP Driver:--------> sep_prepare_input_dma_table start\n"); 1049 1125 1050 - edbg( "SEP Driver:data_size is %lu\n", data_size); 1051 - edbg( "SEP Driver:block_size is %lu\n", block_size); 1126 + edbg("SEP Driver:data_size is %lu\n", data_size); 1127 + edbg("SEP Driver:block_size is %lu\n", block_size); 1052 1128 1053 - /* initialize the pages pointers */ 1054 - sep_dev->in_page_array = 0; 1055 - sep_dev->in_num_pages = 0; 1129 + /* initialize the pages pointers */ 1130 + sep_dev->in_page_array = 0; 1131 + sep_dev->in_num_pages = 0; 1056 1132 1057 - if (data_size == 0) { 1058 - /* special case - created 2 entries table with zero data */ 1059 - in_lli_table_ptr = (struct sep_lli_entry_t *)(sep_dev->shared_area_addr + 1060 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES); 1061 - in_lli_table_ptr->physical_address = sep_dev->shared_area_addr + 1062 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1063 - in_lli_table_ptr->block_size = 0; 1133 + if (data_size == 0) { 1134 + /* special case - created 2 entries table with zero data */ 1135 + in_lli_table_ptr = (struct sep_lli_entry_t *) (sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES); 1136 + in_lli_table_ptr->physical_address = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1137 + in_lli_table_ptr->block_size = 0; 1064 1138 1065 - in_lli_table_ptr++; 1066 - in_lli_table_ptr->physical_address = 0xFFFFFFFF; 1067 - in_lli_table_ptr->block_size = 0; 1139 + in_lli_table_ptr++; 1140 + in_lli_table_ptr->physical_address = 0xFFFFFFFF; 1141 + in_lli_table_ptr->block_size = 0; 1068 1142 1069 - *lli_table_ptr = sep_dev->phys_shared_area_addr + 1070 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1071 - *num_entries_ptr = 2; 1072 - *table_data_size_ptr = 0; 1143 + *lli_table_ptr = sep_dev->phys_shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1144 + *num_entries_ptr = 2; 1145 + *table_data_size_ptr = 0; 1073 1146 1074 - goto end_function; 1075 - } 1076 - 1077 - /* check if the pages are in Kernel Virtual Address layout */ 1078 - if (isKernelVirtualAddress == true) 1079 - /* lock the pages of the kernel buffer and translate them to pages */ 1080 - result = sep_lock_kernel_pages(app_virt_addr, 1081 - data_size, 1082 - &sep_dev->in_num_pages, 1083 - &lli_array_ptr, 1084 - &sep_dev->in_page_array); 1085 - else 1086 - /* lock the pages of the user buffer and translate them to pages */ 1087 - result = sep_lock_user_pages(app_virt_addr, 1088 - data_size, 1089 - &sep_dev->in_num_pages, 1090 - &lli_array_ptr, 1091 - &sep_dev->in_page_array); 1092 - 1093 - if (result) 1094 - return result; 1095 - 1096 - edbg( 1097 - "SEP Driver:output sep_dev->in_num_pages is %lu\n", 1098 - sep_dev->in_num_pages); 1099 - 1100 - current_entry = 0; 1101 - info_entry_ptr = 0; 1102 - sep_lli_entries = sep_dev->in_num_pages; 1103 - 1104 - /* initiate to point after the message area */ 1105 - lli_table_alloc_addr = sep_dev->shared_area_addr + 1106 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1107 - 1108 - /* loop till all the entries in in array are not processed */ 1109 - while (current_entry < sep_lli_entries) { 1110 - /* set the new input and output tables */ 1111 - in_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr; 1112 - 1113 - lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * 1114 - SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP; 1115 - 1116 - /* calculate the maximum size of data for input table */ 1117 - table_data_size = sep_calculate_lli_table_max_size( 1118 - &lli_array_ptr[current_entry], 1119 - (sep_lli_entries - current_entry)); 1120 - 1121 - /* now calculate the table size so that it will be module block size */ 1122 - table_data_size = (table_data_size / block_size) * block_size; 1123 - 1124 - edbg( 1125 - "SEP Driver:output table_data_size is %lu\n", 1126 - table_data_size); 1127 - 1128 - /* construct input lli table */ 1129 - sep_build_lli_table(&lli_array_ptr[current_entry], 1130 - in_lli_table_ptr, 1131 - &current_entry, 1132 - &num_entries_in_table, 1133 - table_data_size); 1134 - 1135 - if (info_entry_ptr == 0) { 1136 - /* set the output parameters to physical addresses */ 1137 - *lli_table_ptr = sep_shared_area_virt_to_phys( 1138 - (unsigned long)in_lli_table_ptr); 1139 - *num_entries_ptr = num_entries_in_table; 1140 - *table_data_size_ptr = table_data_size; 1141 - 1142 - edbg( 1143 - "SEP Driver:output lli_table_in_ptr is %08lx\n", 1144 - *lli_table_ptr); 1145 - } else { 1146 - /* update the info entry of the previous in table */ 1147 - info_entry_ptr->physical_address = sep_shared_area_virt_to_phys( 1148 - (unsigned long)in_lli_table_ptr); 1149 - info_entry_ptr->block_size = ((num_entries_in_table) << 24) | 1150 - (table_data_size); 1147 + goto end_function; 1151 1148 } 1152 1149 1153 - /* save the pointer to the info entry of the current tables */ 1154 - info_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1; 1155 - } 1150 + /* check if the pages are in Kernel Virtual Address layout */ 1151 + if (isKernelVirtualAddress == true) 1152 + /* lock the pages of the kernel buffer and translate them to pages */ 1153 + result = sep_lock_kernel_pages(app_virt_addr, data_size, &sep_dev->in_num_pages, &lli_array_ptr, &sep_dev->in_page_array); 1154 + else 1155 + /* lock the pages of the user buffer and translate them to pages */ 1156 + result = sep_lock_user_pages(app_virt_addr, data_size, &sep_dev->in_num_pages, &lli_array_ptr, &sep_dev->in_page_array); 1156 1157 1157 - /* print input tables */ 1158 - sep_debug_print_lli_tables((struct sep_lli_entry_t *) 1159 - sep_shared_area_phys_to_virt(*lli_table_ptr), 1160 - *num_entries_ptr, 1161 - *table_data_size_ptr); 1158 + if (result) 1159 + return result; 1162 1160 1163 - /* the array of the pages */ 1164 - kfree(lli_array_ptr); 1161 + edbg("SEP Driver:output sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages); 1165 1162 1166 - end_function: 1163 + current_entry = 0; 1164 + info_entry_ptr = 0; 1165 + sep_lli_entries = sep_dev->in_num_pages; 1167 1166 1168 - dbg("SEP Driver:<-------- sep_prepare_input_dma_table end\n"); 1167 + /* initiate to point after the message area */ 1168 + lli_table_alloc_addr = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1169 1169 1170 - return 0; 1170 + /* loop till all the entries in in array are not processed */ 1171 + while (current_entry < sep_lli_entries) { 1172 + /* set the new input and output tables */ 1173 + in_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr; 1174 + 1175 + lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP; 1176 + 1177 + /* calculate the maximum size of data for input table */ 1178 + table_data_size = sep_calculate_lli_table_max_size(&lli_array_ptr[current_entry], (sep_lli_entries - current_entry)); 1179 + 1180 + /* now calculate the table size so that it will be module block size */ 1181 + table_data_size = (table_data_size / block_size) * block_size; 1182 + 1183 + edbg("SEP Driver:output table_data_size is %lu\n", table_data_size); 1184 + 1185 + /* construct input lli table */ 1186 + sep_build_lli_table(&lli_array_ptr[current_entry], in_lli_table_ptr, &current_entry, &num_entries_in_table, table_data_size); 1187 + 1188 + if (info_entry_ptr == 0) { 1189 + /* set the output parameters to physical addresses */ 1190 + *lli_table_ptr = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr); 1191 + *num_entries_ptr = num_entries_in_table; 1192 + *table_data_size_ptr = table_data_size; 1193 + 1194 + edbg("SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_ptr); 1195 + } else { 1196 + /* update the info entry of the previous in table */ 1197 + info_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr); 1198 + info_entry_ptr->block_size = ((num_entries_in_table) << 24) | (table_data_size); 1199 + } 1200 + 1201 + /* save the pointer to the info entry of the current tables */ 1202 + info_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1; 1203 + } 1204 + 1205 + /* print input tables */ 1206 + sep_debug_print_lli_tables((struct sep_lli_entry_t *) 1207 + sep_shared_area_phys_to_virt(*lli_table_ptr), *num_entries_ptr, *table_data_size_ptr); 1208 + 1209 + /* the array of the pages */ 1210 + kfree(lli_array_ptr); 1211 + 1212 + end_function: 1213 + 1214 + dbg("SEP Driver:<-------- sep_prepare_input_dma_table end\n"); 1215 + 1216 + return 0; 1171 1217 1172 1218 } 1173 1219 ··· 1139 1259 symmetric operations (AES, DES). It also checks that each table 1140 1260 is of the modular block size 1141 1261 */ 1142 - int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, 1143 - unsigned long app_virt_out_addr, 1144 - unsigned long data_size, 1145 - unsigned long block_size, 1146 - unsigned long *lli_table_in_ptr, 1147 - unsigned long *lli_table_out_ptr, 1148 - unsigned long *in_num_entries_ptr, 1149 - unsigned long *out_num_entries_ptr, 1150 - unsigned long *table_data_size_ptr, 1151 - bool isKernelVirtualAddress) 1152 - 1262 + int sep_prepare_input_output_dma_table(unsigned long app_virt_in_addr, 1263 + unsigned long app_virt_out_addr, 1264 + unsigned long data_size, 1265 + unsigned long block_size, 1266 + unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr, bool isKernelVirtualAddress) 1153 1267 { 1154 - /* array of pointers of page */ 1155 - struct sep_lli_entry_t *lli_in_array; 1268 + /* array of pointers of page */ 1269 + struct sep_lli_entry_t *lli_in_array; 1156 1270 1157 - /* array of pointers of page */ 1158 - struct sep_lli_entry_t *lli_out_array; 1271 + /* array of pointers of page */ 1272 + struct sep_lli_entry_t *lli_out_array; 1159 1273 1160 - /* result */ 1161 - int result; 1274 + /* result */ 1275 + int result; 1162 1276 1163 1277 1164 1278 /*------------------------ 1165 1279 CODE 1166 1280 --------------------------*/ 1167 1281 1168 - dbg("SEP Driver:--------> sep_prepare_input_output_dma_table start\n"); 1282 + dbg("SEP Driver:--------> sep_prepare_input_output_dma_table start\n"); 1169 1283 1170 - result = 0; 1284 + result = 0; 1171 1285 1172 - /* initialize the pages pointers */ 1173 - sep_dev->in_page_array = 0; 1174 - sep_dev->out_page_array = 0; 1286 + /* initialize the pages pointers */ 1287 + sep_dev->in_page_array = 0; 1288 + sep_dev->out_page_array = 0; 1175 1289 1176 - /* check if the pages are in Kernel Virtual Address layout */ 1177 - if (isKernelVirtualAddress == true) { 1178 - /* lock the pages of the kernel buffer and translate them to pages */ 1179 - result = sep_lock_kernel_pages(app_virt_in_addr, 1180 - data_size, 1181 - &sep_dev->in_num_pages, 1182 - &lli_in_array, 1183 - &sep_dev->in_page_array); 1184 - if (result) { 1185 - edbg( 1186 - "SEP Driver: sep_lock_kernel_pages for input virtual buffer failed\n"); 1187 - goto end_function; 1290 + /* check if the pages are in Kernel Virtual Address layout */ 1291 + if (isKernelVirtualAddress == true) { 1292 + /* lock the pages of the kernel buffer and translate them to pages */ 1293 + result = sep_lock_kernel_pages(app_virt_in_addr, data_size, &sep_dev->in_num_pages, &lli_in_array, &sep_dev->in_page_array); 1294 + if (result) { 1295 + edbg("SEP Driver: sep_lock_kernel_pages for input virtual buffer failed\n"); 1296 + goto end_function; 1297 + } 1298 + } else { 1299 + /* lock the pages of the user buffer and translate them to pages */ 1300 + result = sep_lock_user_pages(app_virt_in_addr, data_size, &sep_dev->in_num_pages, &lli_in_array, &sep_dev->in_page_array); 1301 + if (result) { 1302 + edbg("SEP Driver: sep_lock_user_pages for input virtual buffer failed\n"); 1303 + goto end_function; 1304 + } 1188 1305 } 1189 - } else { 1190 - /* lock the pages of the user buffer and translate them to pages */ 1191 - result = sep_lock_user_pages(app_virt_in_addr, 1192 - data_size, 1193 - &sep_dev->in_num_pages, 1194 - &lli_in_array, 1195 - &sep_dev->in_page_array); 1196 - if (result) { 1197 - edbg( 1198 - "SEP Driver: sep_lock_user_pages for input virtual buffer failed\n"); 1199 - goto end_function; 1306 + 1307 + if (isKernelVirtualAddress == true) { 1308 + result = sep_lock_kernel_pages(app_virt_out_addr, data_size, &sep_dev->out_num_pages, &lli_out_array, &sep_dev->out_page_array); 1309 + if (result) { 1310 + edbg("SEP Driver: sep_lock_kernel_pages for output virtual buffer failed\n"); 1311 + goto end_function_with_error1; 1312 + } 1313 + } else { 1314 + result = sep_lock_user_pages(app_virt_out_addr, data_size, &sep_dev->out_num_pages, &lli_out_array, &sep_dev->out_page_array); 1315 + if (result) { 1316 + edbg("SEP Driver: sep_lock_user_pages for output virtual buffer failed\n"); 1317 + goto end_function_with_error1; 1318 + } 1200 1319 } 1201 - } 1202 1320 1203 - if (isKernelVirtualAddress == true) { 1204 - result = sep_lock_kernel_pages(app_virt_out_addr, 1205 - data_size, 1206 - &sep_dev->out_num_pages, 1207 - &lli_out_array, 1208 - &sep_dev->out_page_array); 1321 + 1322 + edbg("sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages); 1323 + edbg("sep_dev->out_num_pages is %lu\n", sep_dev->out_num_pages); 1324 + edbg("SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n", SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP); 1325 + 1326 + 1327 + /* call the fucntion that creates table from the lli arrays */ 1328 + result = sep_construct_dma_tables_from_lli(lli_in_array, sep_dev->in_num_pages, lli_out_array, sep_dev->out_num_pages, block_size, lli_table_in_ptr, lli_table_out_ptr, in_num_entries_ptr, out_num_entries_ptr, table_data_size_ptr); 1209 1329 if (result) { 1210 - edbg( 1211 - "SEP Driver: sep_lock_kernel_pages for output virtual buffer failed\n"); 1212 - goto end_function_with_error1; 1330 + edbg("SEP Driver: sep_construct_dma_tables_from_lli failed\n"); 1331 + goto end_function_with_error2; 1213 1332 } 1214 - } else { 1215 - result = sep_lock_user_pages(app_virt_out_addr, 1216 - data_size, 1217 - &sep_dev->out_num_pages, 1218 - &lli_out_array, 1219 - &sep_dev->out_page_array); 1220 - if (result) { 1221 - edbg( 1222 - "SEP Driver: sep_lock_user_pages for output virtual buffer failed\n"); 1223 - goto end_function_with_error1; 1224 - } 1225 - } 1333 + 1334 + /* fall through - free the lli entry arrays */ 1335 + 1336 + dbg("in_num_entries_ptr is %08lx\n", *in_num_entries_ptr); 1337 + dbg("out_num_entries_ptr is %08lx\n", *out_num_entries_ptr); 1338 + dbg("table_data_size_ptr is %08lx\n", *table_data_size_ptr); 1226 1339 1227 1340 1228 - edbg( 1229 - "sep_dev->in_num_pages is %lu\n", sep_dev->in_num_pages); 1230 - edbg( 1231 - "sep_dev->out_num_pages is %lu\n", sep_dev->out_num_pages); 1232 - edbg( 1233 - "SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n", 1234 - SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP); 1341 + end_function_with_error2: 1235 1342 1343 + kfree(lli_out_array); 1236 1344 1237 - /* call the fucntion that creates table from the lli arrays */ 1238 - result = sep_construct_dma_tables_from_lli(lli_in_array, 1239 - sep_dev->in_num_pages, 1240 - lli_out_array, 1241 - sep_dev->out_num_pages, 1242 - block_size, 1243 - lli_table_in_ptr, 1244 - lli_table_out_ptr, 1245 - in_num_entries_ptr, 1246 - out_num_entries_ptr, 1247 - table_data_size_ptr); 1248 - if (result) { 1249 - edbg( 1250 - "SEP Driver: sep_construct_dma_tables_from_lli failed\n"); 1251 - goto end_function_with_error2; 1252 - } 1345 + end_function_with_error1: 1253 1346 1254 - /* fall through - free the lli entry arrays */ 1347 + kfree(lli_in_array); 1255 1348 1256 - dbg("in_num_entries_ptr is %08lx\n", 1257 - *in_num_entries_ptr); 1258 - dbg("out_num_entries_ptr is %08lx\n", 1259 - *out_num_entries_ptr); 1260 - dbg("table_data_size_ptr is %08lx\n", 1261 - *table_data_size_ptr); 1349 + end_function: 1262 1350 1351 + dbg("SEP Driver:<-------- sep_prepare_input_output_dma_table end result = %d\n", (int) result); 1263 1352 1264 - end_function_with_error2: 1265 - 1266 - kfree(lli_out_array); 1267 - 1268 - end_function_with_error1: 1269 - 1270 - kfree(lli_in_array); 1271 - 1272 - end_function: 1273 - 1274 - dbg("SEP Driver:<-------- sep_prepare_input_output_dma_table end result = %d\n", (int)result); 1275 - 1276 - return result; 1353 + return result; 1277 1354 1278 1355 } 1279 1356 ··· 1239 1402 This function creates the input and output dma tables for 1240 1403 symmetric operations (AES/DES) according to the block size from LLI arays 1241 1404 */ 1242 - int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, 1243 - unsigned long sep_in_lli_entries, 1244 - struct sep_lli_entry_t *lli_out_array, 1245 - unsigned long sep_out_lli_entries, 1246 - unsigned long block_size, 1247 - unsigned long *lli_table_in_ptr, 1248 - unsigned long *lli_table_out_ptr, 1249 - unsigned long *in_num_entries_ptr, 1250 - unsigned long *out_num_entries_ptr, 1251 - unsigned long *table_data_size_ptr) 1405 + int sep_construct_dma_tables_from_lli(struct sep_lli_entry_t *lli_in_array, 1406 + unsigned long sep_in_lli_entries, 1407 + struct sep_lli_entry_t *lli_out_array, 1408 + unsigned long sep_out_lli_entries, 1409 + unsigned long block_size, unsigned long *lli_table_in_ptr, unsigned long *lli_table_out_ptr, unsigned long *in_num_entries_ptr, unsigned long *out_num_entries_ptr, unsigned long *table_data_size_ptr) 1252 1410 { 1253 - /* points to the area where next lli table can be allocated */ 1254 - unsigned long lli_table_alloc_addr; 1411 + /* points to the area where next lli table can be allocated */ 1412 + unsigned long lli_table_alloc_addr; 1255 1413 1256 - /* input lli table */ 1257 - struct sep_lli_entry_t *in_lli_table_ptr; 1414 + /* input lli table */ 1415 + struct sep_lli_entry_t *in_lli_table_ptr; 1258 1416 1259 - /* output lli table */ 1260 - struct sep_lli_entry_t *out_lli_table_ptr; 1417 + /* output lli table */ 1418 + struct sep_lli_entry_t *out_lli_table_ptr; 1261 1419 1262 - /* pointer to the info entry of the table - the last entry */ 1263 - struct sep_lli_entry_t *info_in_entry_ptr; 1420 + /* pointer to the info entry of the table - the last entry */ 1421 + struct sep_lli_entry_t *info_in_entry_ptr; 1264 1422 1265 - /* pointer to the info entry of the table - the last entry */ 1266 - struct sep_lli_entry_t *info_out_entry_ptr; 1423 + /* pointer to the info entry of the table - the last entry */ 1424 + struct sep_lli_entry_t *info_out_entry_ptr; 1267 1425 1268 - /* points to the first entry to be processed in the lli_in_array */ 1269 - unsigned long current_in_entry; 1426 + /* points to the first entry to be processed in the lli_in_array */ 1427 + unsigned long current_in_entry; 1270 1428 1271 - /* points to the first entry to be processed in the lli_out_array */ 1272 - unsigned long current_out_entry; 1429 + /* points to the first entry to be processed in the lli_out_array */ 1430 + unsigned long current_out_entry; 1273 1431 1274 - /* max size of the input table */ 1275 - unsigned long in_table_data_size; 1432 + /* max size of the input table */ 1433 + unsigned long in_table_data_size; 1276 1434 1277 - /* max size of the output table */ 1278 - unsigned long out_table_data_size; 1435 + /* max size of the output table */ 1436 + unsigned long out_table_data_size; 1279 1437 1280 - /* flag te signifies if this is the first tables build from the arrays */ 1281 - unsigned long first_table_flag; 1438 + /* flag te signifies if this is the first tables build from the arrays */ 1439 + unsigned long first_table_flag; 1282 1440 1283 - /* the data size that should be in table */ 1284 - unsigned long table_data_size; 1441 + /* the data size that should be in table */ 1442 + unsigned long table_data_size; 1285 1443 1286 - /* number of etnries in the input table */ 1287 - unsigned long num_entries_in_table; 1444 + /* number of etnries in the input table */ 1445 + unsigned long num_entries_in_table; 1288 1446 1289 - /* number of etnries in the output table */ 1290 - unsigned long num_entries_out_table; 1447 + /* number of etnries in the output table */ 1448 + unsigned long num_entries_out_table; 1291 1449 1292 1450 /*--------------------- 1293 1451 CODE 1294 1452 ------------------------*/ 1295 1453 1296 - dbg("SEP Driver:--------> sep_construct_dma_tables_from_lli start\n"); 1454 + dbg("SEP Driver:--------> sep_construct_dma_tables_from_lli start\n"); 1297 1455 1298 - /* initiate to pint after the message area */ 1299 - lli_table_alloc_addr = sep_dev->shared_area_addr + 1300 - SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1456 + /* initiate to pint after the message area */ 1457 + lli_table_alloc_addr = sep_dev->shared_area_addr + SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES; 1301 1458 1302 - current_in_entry = 0; 1303 - current_out_entry = 0; 1304 - first_table_flag = 1; 1305 - info_in_entry_ptr = 0; 1306 - info_out_entry_ptr = 0; 1459 + current_in_entry = 0; 1460 + current_out_entry = 0; 1461 + first_table_flag = 1; 1462 + info_in_entry_ptr = 0; 1463 + info_out_entry_ptr = 0; 1307 1464 1308 - /* loop till all the entries in in array are not processed */ 1309 - while (current_in_entry < sep_in_lli_entries) { 1310 - /* set the new input and output tables */ 1311 - in_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr; 1465 + /* loop till all the entries in in array are not processed */ 1466 + while (current_in_entry < sep_in_lli_entries) { 1467 + /* set the new input and output tables */ 1468 + in_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr; 1312 1469 1313 - lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * 1314 - SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP; 1470 + lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP; 1315 1471 1316 - /* set the first output tables */ 1317 - out_lli_table_ptr = (struct sep_lli_entry_t *)lli_table_alloc_addr; 1472 + /* set the first output tables */ 1473 + out_lli_table_ptr = (struct sep_lli_entry_t *) lli_table_alloc_addr; 1318 1474 1319 - lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * 1320 - SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP; 1475 + lli_table_alloc_addr += sizeof(struct sep_lli_entry_t) * SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP; 1321 1476 1322 - /* calculate the maximum size of data for input table */ 1323 - in_table_data_size = 1324 - sep_calculate_lli_table_max_size( 1325 - &lli_in_array[current_in_entry], 1326 - (sep_in_lli_entries - current_in_entry)); 1477 + /* calculate the maximum size of data for input table */ 1478 + in_table_data_size = sep_calculate_lli_table_max_size(&lli_in_array[current_in_entry], (sep_in_lli_entries - current_in_entry)); 1327 1479 1328 - /* calculate the maximum size of data for output table */ 1329 - out_table_data_size = 1330 - sep_calculate_lli_table_max_size( 1331 - &lli_out_array[current_out_entry], 1332 - (sep_out_lli_entries - current_out_entry)); 1480 + /* calculate the maximum size of data for output table */ 1481 + out_table_data_size = sep_calculate_lli_table_max_size(&lli_out_array[current_out_entry], (sep_out_lli_entries - current_out_entry)); 1333 1482 1334 - edbg( 1335 - "SEP Driver:in_table_data_size is %lu\n", in_table_data_size); 1336 - edbg( 1337 - "SEP Driver:out_table_data_size is %lu\n", out_table_data_size); 1483 + edbg("SEP Driver:in_table_data_size is %lu\n", in_table_data_size); 1484 + edbg("SEP Driver:out_table_data_size is %lu\n", out_table_data_size); 1338 1485 1339 - /* check where the data is smallest */ 1340 - table_data_size = in_table_data_size; 1341 - if (table_data_size > out_table_data_size) 1342 - table_data_size = out_table_data_size; 1486 + /* check where the data is smallest */ 1487 + table_data_size = in_table_data_size; 1488 + if (table_data_size > out_table_data_size) 1489 + table_data_size = out_table_data_size; 1343 1490 1344 - /* now calculate the table size so that it will be module block size */ 1345 - table_data_size = (table_data_size / block_size) * block_size; 1491 + /* now calculate the table size so that it will be module block size */ 1492 + table_data_size = (table_data_size / block_size) * block_size; 1346 1493 1347 - dbg("SEP Driver:table_data_size is %lu\n", table_data_size); 1494 + dbg("SEP Driver:table_data_size is %lu\n", table_data_size); 1348 1495 1349 - /* construct input lli table */ 1350 - sep_build_lli_table(&lli_in_array[current_in_entry], 1351 - in_lli_table_ptr, 1352 - &current_in_entry, 1353 - &num_entries_in_table, 1354 - table_data_size); 1496 + /* construct input lli table */ 1497 + sep_build_lli_table(&lli_in_array[current_in_entry], in_lli_table_ptr, &current_in_entry, &num_entries_in_table, table_data_size); 1355 1498 1356 - /* construct output lli table */ 1357 - sep_build_lli_table(&lli_out_array[current_out_entry], 1358 - out_lli_table_ptr, 1359 - &current_out_entry, 1360 - &num_entries_out_table, 1361 - table_data_size); 1499 + /* construct output lli table */ 1500 + sep_build_lli_table(&lli_out_array[current_out_entry], out_lli_table_ptr, &current_out_entry, &num_entries_out_table, table_data_size); 1362 1501 1363 - /* if info entry is null - this is the first table built */ 1364 - if (info_in_entry_ptr == 0) { 1365 - /* set the output parameters to physical addresses */ 1366 - *lli_table_in_ptr = 1367 - sep_shared_area_virt_to_phys((unsigned long)in_lli_table_ptr); 1368 - *in_num_entries_ptr = num_entries_in_table; 1369 - *lli_table_out_ptr = 1370 - sep_shared_area_virt_to_phys((unsigned long)out_lli_table_ptr); 1371 - *out_num_entries_ptr = num_entries_out_table; 1372 - *table_data_size_ptr = table_data_size; 1502 + /* if info entry is null - this is the first table built */ 1503 + if (info_in_entry_ptr == 0) { 1504 + /* set the output parameters to physical addresses */ 1505 + *lli_table_in_ptr = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr); 1506 + *in_num_entries_ptr = num_entries_in_table; 1507 + *lli_table_out_ptr = sep_shared_area_virt_to_phys((unsigned long) out_lli_table_ptr); 1508 + *out_num_entries_ptr = num_entries_out_table; 1509 + *table_data_size_ptr = table_data_size; 1373 1510 1374 - edbg( 1375 - "SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_in_ptr); 1376 - edbg( 1377 - "SEP Driver:output lli_table_out_ptr is %08lx\n", *lli_table_out_ptr); 1378 - } else { 1379 - /* update the info entry of the previous in table */ 1380 - info_in_entry_ptr->physical_address = 1381 - sep_shared_area_virt_to_phys((unsigned long)in_lli_table_ptr); 1382 - info_in_entry_ptr->block_size = 1383 - ((num_entries_in_table) << 24) | (table_data_size); 1511 + edbg("SEP Driver:output lli_table_in_ptr is %08lx\n", *lli_table_in_ptr); 1512 + edbg("SEP Driver:output lli_table_out_ptr is %08lx\n", *lli_table_out_ptr); 1513 + } else { 1514 + /* update the info entry of the previous in table */ 1515 + info_in_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) in_lli_table_ptr); 1516 + info_in_entry_ptr->block_size = ((num_entries_in_table) << 24) | (table_data_size); 1384 1517 1385 - /* update the info entry of the previous in table */ 1386 - info_out_entry_ptr->physical_address = 1387 - sep_shared_area_virt_to_phys((unsigned long)out_lli_table_ptr); 1388 - info_out_entry_ptr->block_size = 1389 - ((num_entries_out_table) << 24) | (table_data_size); 1518 + /* update the info entry of the previous in table */ 1519 + info_out_entry_ptr->physical_address = sep_shared_area_virt_to_phys((unsigned long) out_lli_table_ptr); 1520 + info_out_entry_ptr->block_size = ((num_entries_out_table) << 24) | (table_data_size); 1521 + } 1522 + 1523 + /* save the pointer to the info entry of the current tables */ 1524 + info_in_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1; 1525 + info_out_entry_ptr = out_lli_table_ptr + num_entries_out_table - 1; 1526 + 1527 + edbg("SEP Driver:output num_entries_out_table is %lu\n", (unsigned long) num_entries_out_table); 1528 + edbg("SEP Driver:output info_in_entry_ptr is %lu\n", (unsigned long) info_in_entry_ptr); 1529 + edbg("SEP Driver:output info_out_entry_ptr is %lu\n", (unsigned long) info_out_entry_ptr); 1390 1530 } 1391 1531 1392 - /* save the pointer to the info entry of the current tables */ 1393 - info_in_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1; 1394 - info_out_entry_ptr = out_lli_table_ptr + num_entries_out_table - 1; 1532 + /* print input tables */ 1533 + sep_debug_print_lli_tables((struct sep_lli_entry_t *) 1534 + sep_shared_area_phys_to_virt(*lli_table_in_ptr), *in_num_entries_ptr, *table_data_size_ptr); 1395 1535 1396 - edbg( 1397 - "SEP Driver:output num_entries_out_table is %lu\n", 1398 - (unsigned long)num_entries_out_table); 1399 - edbg( 1400 - "SEP Driver:output info_in_entry_ptr is %lu\n", 1401 - (unsigned long)info_in_entry_ptr); 1402 - edbg( 1403 - "SEP Driver:output info_out_entry_ptr is %lu\n", 1404 - (unsigned long)info_out_entry_ptr); 1405 - } 1536 + /* print output tables */ 1537 + sep_debug_print_lli_tables((struct sep_lli_entry_t *) 1538 + sep_shared_area_phys_to_virt(*lli_table_out_ptr), *out_num_entries_ptr, *table_data_size_ptr); 1406 1539 1407 - /* print input tables */ 1408 - sep_debug_print_lli_tables( 1409 - (struct sep_lli_entry_t *) 1410 - sep_shared_area_phys_to_virt(*lli_table_in_ptr), 1411 - *in_num_entries_ptr, 1412 - *table_data_size_ptr); 1540 + dbg("SEP Driver:<-------- sep_construct_dma_tables_from_lli end\n"); 1413 1541 1414 - /* print output tables */ 1415 - sep_debug_print_lli_tables( 1416 - (struct sep_lli_entry_t *) 1417 - sep_shared_area_phys_to_virt(*lli_table_out_ptr), 1418 - *out_num_entries_ptr, 1419 - *table_data_size_ptr); 1420 - 1421 - dbg("SEP Driver:<-------- sep_construct_dma_tables_from_lli end\n"); 1422 - 1423 - return 0; 1542 + return 0; 1424 1543 } 1425 1544 1426 1545 /* ··· 1384 1591 table from this array the condition is that either the table is full 1385 1592 (all etnries are entered), or there are no more entries in the lli array 1386 1593 */ 1387 - unsigned long sep_calculate_lli_table_max_size( 1388 - struct sep_lli_entry_t *lli_in_array_ptr, 1389 - unsigned long num_array_entries) 1594 + unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries) 1390 1595 { 1391 - /* table data size */ 1392 - unsigned long table_data_size; 1596 + /* table data size */ 1597 + unsigned long table_data_size; 1393 1598 1394 - /* counter */ 1395 - unsigned long counter; 1599 + /* counter */ 1600 + unsigned long counter; 1396 1601 1397 1602 /*--------------------- 1398 1603 CODE 1399 1604 ----------------------*/ 1400 1605 1401 - table_data_size = 0; 1606 + table_data_size = 0; 1402 1607 1403 - /* calculate the data in the out lli table if till we fill the whole 1404 - table or till the data has ended */ 1405 - for (counter = 0; 1406 - (counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) && 1407 - (counter < num_array_entries); counter++) 1408 - table_data_size += lli_in_array_ptr[counter].block_size; 1608 + /* calculate the data in the out lli table if till we fill the whole 1609 + table or till the data has ended */ 1610 + for (counter = 0; (counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) && (counter < num_array_entries); counter++) 1611 + table_data_size += lli_in_array_ptr[counter].block_size; 1409 1612 1410 - return table_data_size; 1613 + return table_data_size; 1411 1614 } 1412 1615 1413 1616 /* 1414 1617 this functions builds ont lli table from the lli_array according to 1415 1618 the given size of data 1416 1619 */ 1417 - static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, 1418 - struct sep_lli_entry_t *lli_table_ptr, 1419 - unsigned long *num_processed_entries_ptr, 1420 - unsigned long *num_table_entries_ptr, 1421 - unsigned long table_data_size) 1620 + static void sep_build_lli_table(struct sep_lli_entry_t *lli_array_ptr, struct sep_lli_entry_t *lli_table_ptr, unsigned long *num_processed_entries_ptr, unsigned long *num_table_entries_ptr, unsigned long table_data_size) 1422 1621 { 1423 - /* current table data size */ 1424 - unsigned long curr_table_data_size; 1622 + /* current table data size */ 1623 + unsigned long curr_table_data_size; 1425 1624 1426 - /* counter of lli array entry */ 1427 - unsigned long array_counter; 1625 + /* counter of lli array entry */ 1626 + unsigned long array_counter; 1428 1627 1429 1628 /*----------------------- 1430 1629 CODE 1431 1630 ---------------------------*/ 1432 1631 1433 - dbg("SEP Driver:--------> sep_build_lli_table start\n"); 1632 + dbg("SEP Driver:--------> sep_build_lli_table start\n"); 1434 1633 1435 - /* init currrent table data size and lli array entry counter */ 1436 - curr_table_data_size = 0; 1437 - array_counter = 0; 1438 - *num_table_entries_ptr = 1; 1634 + /* init currrent table data size and lli array entry counter */ 1635 + curr_table_data_size = 0; 1636 + array_counter = 0; 1637 + *num_table_entries_ptr = 1; 1439 1638 1440 - edbg( 1441 - "SEP Driver:table_data_size is %lu\n", 1442 - table_data_size); 1639 + edbg("SEP Driver:table_data_size is %lu\n", table_data_size); 1443 1640 1444 - /* fill the table till table size reaches the needed amount */ 1445 - while (curr_table_data_size < table_data_size) { 1446 - /* update the number of entries in table */ 1447 - (*num_table_entries_ptr)++; 1641 + /* fill the table till table size reaches the needed amount */ 1642 + while (curr_table_data_size < table_data_size) { 1643 + /* update the number of entries in table */ 1644 + (*num_table_entries_ptr)++; 1448 1645 1449 - lli_table_ptr->physical_address = 1450 - lli_array_ptr[array_counter].physical_address; 1451 - lli_table_ptr->block_size = lli_array_ptr[array_counter].block_size; 1452 - curr_table_data_size += lli_table_ptr->block_size; 1646 + lli_table_ptr->physical_address = lli_array_ptr[array_counter].physical_address; 1647 + lli_table_ptr->block_size = lli_array_ptr[array_counter].block_size; 1648 + curr_table_data_size += lli_table_ptr->block_size; 1453 1649 1454 - edbg( 1455 - "SEP Driver:lli_table_ptr is %08lx\n", 1456 - (unsigned long)lli_table_ptr); 1457 - edbg( 1458 - "SEP Driver:lli_table_ptr->physical_address is %08lx\n", 1459 - lli_table_ptr->physical_address); 1460 - edbg( 1461 - "SEP Driver:lli_table_ptr->block_size is %lu\n", 1462 - lli_table_ptr->block_size); 1650 + edbg("SEP Driver:lli_table_ptr is %08lx\n", (unsigned long) lli_table_ptr); 1651 + edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address); 1652 + edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size); 1463 1653 1464 - /* check for overflow of the table data */ 1465 - if (curr_table_data_size > table_data_size) { 1466 - edbg( 1467 - "SEP Driver:curr_table_data_size > table_data_size\n"); 1654 + /* check for overflow of the table data */ 1655 + if (curr_table_data_size > table_data_size) { 1656 + edbg("SEP Driver:curr_table_data_size > table_data_size\n"); 1468 1657 1469 - /* update the size of block in the table */ 1470 - lli_table_ptr->block_size -= (curr_table_data_size - table_data_size); 1658 + /* update the size of block in the table */ 1659 + lli_table_ptr->block_size -= (curr_table_data_size - table_data_size); 1471 1660 1472 - /* update the physical address in the lli array */ 1473 - lli_array_ptr[array_counter].physical_address += 1474 - lli_table_ptr->block_size; 1661 + /* update the physical address in the lli array */ 1662 + lli_array_ptr[array_counter].physical_address += lli_table_ptr->block_size; 1475 1663 1476 - /* update the block size left in the lli array */ 1477 - lli_array_ptr[array_counter].block_size = 1478 - (curr_table_data_size - table_data_size); 1479 - } else 1480 - /* advance to the next entry in the lli_array */ 1481 - array_counter++; 1664 + /* update the block size left in the lli array */ 1665 + lli_array_ptr[array_counter].block_size = (curr_table_data_size - table_data_size); 1666 + } else 1667 + /* advance to the next entry in the lli_array */ 1668 + array_counter++; 1482 1669 1483 - edbg( 1484 - "SEP Driver:lli_table_ptr->physical_address is %08lx\n", 1485 - lli_table_ptr->physical_address); 1486 - edbg( 1487 - "SEP Driver:lli_table_ptr->block_size is %lu\n", 1488 - lli_table_ptr->block_size); 1670 + edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address); 1671 + edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size); 1489 1672 1490 - /* move to the next entry in table */ 1491 - lli_table_ptr++; 1492 - } 1673 + /* move to the next entry in table */ 1674 + lli_table_ptr++; 1675 + } 1493 1676 1494 - /* set the info entry to default */ 1495 - lli_table_ptr->physical_address = 0xffffffff; 1496 - lli_table_ptr->block_size = 0; 1677 + /* set the info entry to default */ 1678 + lli_table_ptr->physical_address = 0xffffffff; 1679 + lli_table_ptr->block_size = 0; 1497 1680 1498 - edbg( 1499 - "SEP Driver:lli_table_ptr is %08lx\n", 1500 - (unsigned long)lli_table_ptr); 1501 - edbg( 1502 - "SEP Driver:lli_table_ptr->physical_address is %08lx\n", 1503 - lli_table_ptr->physical_address); 1504 - edbg( 1505 - "SEP Driver:lli_table_ptr->block_size is %lu\n", 1506 - lli_table_ptr->block_size); 1681 + edbg("SEP Driver:lli_table_ptr is %08lx\n", (unsigned long) lli_table_ptr); 1682 + edbg("SEP Driver:lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address); 1683 + edbg("SEP Driver:lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size); 1507 1684 1508 1685 1509 - /* set the output parameter */ 1510 - *num_processed_entries_ptr += array_counter; 1686 + /* set the output parameter */ 1687 + *num_processed_entries_ptr += array_counter; 1511 1688 1512 - edbg( 1513 - "SEP Driver:*num_processed_entries_ptr is %lu\n", 1514 - *num_processed_entries_ptr); 1689 + edbg("SEP Driver:*num_processed_entries_ptr is %lu\n", *num_processed_entries_ptr); 1515 1690 1516 1691 1517 - dbg("SEP Driver:<-------- sep_build_lli_table end\n"); 1692 + dbg("SEP Driver:<-------- sep_build_lli_table end\n"); 1518 1693 1519 - return; 1694 + return; 1520 1695 } 1521 1696 1522 1697 /* 1523 1698 this function goes over the list of the print created tables and 1524 1699 prints all the data 1525 1700 */ 1526 - static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, 1527 - unsigned long num_table_entries, 1528 - unsigned long table_data_size) 1701 + static void sep_debug_print_lli_tables(struct sep_lli_entry_t *lli_table_ptr, unsigned long num_table_entries, unsigned long table_data_size) 1529 1702 { 1530 - unsigned long table_count; 1703 + unsigned long table_count; 1531 1704 1532 - unsigned long entries_count; 1705 + unsigned long entries_count; 1533 1706 /*----------------------------- 1534 1707 CODE 1535 1708 -------------------------------*/ 1536 1709 1537 - dbg("SEP Driver:--------> sep_debug_print_lli_tables start\n"); 1710 + dbg("SEP Driver:--------> sep_debug_print_lli_tables start\n"); 1538 1711 1539 - table_count = 1; 1540 - while ((unsigned long)lli_table_ptr != 0xffffffff) { 1541 - edbg("SEP Driver: lli table %08lx, table_data_size is %lu\n", 1542 - table_count, table_data_size); 1543 - edbg("SEP Driver: num_table_entries is %lu\n", num_table_entries); 1712 + table_count = 1; 1713 + while ((unsigned long) lli_table_ptr != 0xffffffff) { 1714 + edbg("SEP Driver: lli table %08lx, table_data_size is %lu\n", table_count, table_data_size); 1715 + edbg("SEP Driver: num_table_entries is %lu\n", num_table_entries); 1544 1716 1545 - /* print entries of the table (without info entry) */ 1546 - for (entries_count = 0; 1547 - entries_count < num_table_entries; 1548 - entries_count++, lli_table_ptr++) { 1549 - edbg("SEP Driver:lli_table_ptr address is %08lx\n", 1550 - (unsigned long)lli_table_ptr); 1551 - edbg("SEP Driver:phys address is %08lx block size is %lu\n", 1552 - lli_table_ptr->physical_address, lli_table_ptr->block_size); 1717 + /* print entries of the table (without info entry) */ 1718 + for (entries_count = 0; entries_count < num_table_entries; entries_count++, lli_table_ptr++) { 1719 + edbg("SEP Driver:lli_table_ptr address is %08lx\n", (unsigned long) lli_table_ptr); 1720 + edbg("SEP Driver:phys address is %08lx block size is %lu\n", lli_table_ptr->physical_address, lli_table_ptr->block_size); 1721 + } 1722 + 1723 + /* point to the info entry */ 1724 + lli_table_ptr--; 1725 + 1726 + edbg("SEP Driver:phys lli_table_ptr->block_size is %lu\n", lli_table_ptr->block_size); 1727 + edbg("SEP Driver:phys lli_table_ptr->physical_address is %08lx\n", lli_table_ptr->physical_address); 1728 + 1729 + 1730 + table_data_size = lli_table_ptr->block_size & 0xffffff; 1731 + num_table_entries = (lli_table_ptr->block_size >> 24) & 0xff; 1732 + lli_table_ptr = (struct sep_lli_entry_t *) 1733 + (lli_table_ptr->physical_address); 1734 + 1735 + edbg("SEP Driver:phys table_data_size is %lu num_table_entries is %lu lli_table_ptr is%lu\n", table_data_size, num_table_entries, (unsigned long) lli_table_ptr); 1736 + 1737 + if ((unsigned long) lli_table_ptr != 0xffffffff) 1738 + lli_table_ptr = (struct sep_lli_entry_t *) sep_shared_area_phys_to_virt((unsigned long) lli_table_ptr); 1739 + 1740 + table_count++; 1553 1741 } 1554 1742 1555 - /* point to the info entry */ 1556 - lli_table_ptr--; 1557 - 1558 - edbg( 1559 - "SEP Driver:phys lli_table_ptr->block_size is %lu\n", 1560 - lli_table_ptr->block_size); 1561 - edbg( 1562 - "SEP Driver:phys lli_table_ptr->physical_address is %08lx\n", 1563 - lli_table_ptr->physical_address); 1564 - 1565 - 1566 - table_data_size = lli_table_ptr->block_size & 0xffffff; 1567 - num_table_entries = (lli_table_ptr->block_size >> 24) & 0xff; 1568 - lli_table_ptr = (struct sep_lli_entry_t *) 1569 - (lli_table_ptr->physical_address); 1570 - 1571 - edbg("SEP Driver:phys table_data_size is %lu num_table_entries is %lu lli_table_ptr is%lu\n", 1572 - table_data_size, num_table_entries, (unsigned long)lli_table_ptr); 1573 - 1574 - if ((unsigned long)lli_table_ptr != 0xffffffff) 1575 - lli_table_ptr = (struct sep_lli_entry_t *)sep_shared_area_phys_to_virt( 1576 - (unsigned long)lli_table_ptr); 1577 - 1578 - table_count++; 1579 - } 1580 - 1581 - dbg("SEP Driver:<-------- sep_debug_print_lli_tables end\n"); 1743 + dbg("SEP Driver:<-------- sep_debug_print_lli_tables end\n"); 1582 1744 } 1583 1745 1584 1746 ··· 1542 1794 and construct a basic lli array, where each entry holds the physical page 1543 1795 address and the size that application data holds in this physical pages 1544 1796 */ 1545 - int sep_lock_user_pages(unsigned long app_virt_addr, 1546 - unsigned long data_size, 1547 - unsigned long *num_pages_ptr, 1548 - struct sep_lli_entry_t **lli_array_ptr, 1549 - struct page ***page_array_ptr) 1550 - 1797 + int sep_lock_user_pages(unsigned long app_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr) 1551 1798 { 1552 - /* error */ 1553 - int error; 1799 + /* error */ 1800 + int error; 1554 1801 1555 - /* the the page of the end address of the user space buffer */ 1556 - unsigned long end_page; 1802 + /* the the page of the end address of the user space buffer */ 1803 + unsigned long end_page; 1557 1804 1558 - /* the page of the start address of the user space buffer */ 1559 - unsigned long start_page; 1805 + /* the page of the start address of the user space buffer */ 1806 + unsigned long start_page; 1560 1807 1561 - /* the range in pages */ 1562 - unsigned long num_pages; 1808 + /* the range in pages */ 1809 + unsigned long num_pages; 1563 1810 1564 - /* array of pointers ot page */ 1565 - struct page **page_array; 1811 + /* array of pointers ot page */ 1812 + struct page **page_array; 1566 1813 1567 - /* array of lli */ 1568 - struct sep_lli_entry_t *lli_array; 1814 + /* array of lli */ 1815 + struct sep_lli_entry_t *lli_array; 1569 1816 1570 - /* count */ 1571 - unsigned long count; 1817 + /* count */ 1818 + unsigned long count; 1572 1819 1573 - /* result */ 1574 - int result; 1820 + /* result */ 1821 + int result; 1575 1822 1576 1823 /*------------------------ 1577 1824 CODE 1578 1825 --------------------------*/ 1579 1826 1580 - dbg("SEP Driver:--------> sep_lock_user_pages start\n"); 1827 + dbg("SEP Driver:--------> sep_lock_user_pages start\n"); 1581 1828 1582 - error = 0; 1829 + error = 0; 1583 1830 1584 - /* set start and end pages and num pages */ 1585 - end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT; 1586 - start_page = app_virt_addr >> PAGE_SHIFT; 1587 - num_pages = end_page - start_page + 1; 1831 + /* set start and end pages and num pages */ 1832 + end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT; 1833 + start_page = app_virt_addr >> PAGE_SHIFT; 1834 + num_pages = end_page - start_page + 1; 1588 1835 1589 - edbg( 1590 - "SEP Driver: app_virt_addr is %08lx\n", 1591 - app_virt_addr); 1592 - edbg( 1593 - "SEP Driver: data_size is %lu\n", 1594 - data_size); 1595 - edbg( 1596 - "SEP Driver: start_page is %lu\n", 1597 - start_page); 1598 - edbg( 1599 - "SEP Driver: end_page is %lu\n", 1600 - end_page); 1601 - edbg( 1602 - "SEP Driver: num_pages is %lu\n", 1603 - num_pages); 1836 + edbg("SEP Driver: app_virt_addr is %08lx\n", app_virt_addr); 1837 + edbg("SEP Driver: data_size is %lu\n", data_size); 1838 + edbg("SEP Driver: start_page is %lu\n", start_page); 1839 + edbg("SEP Driver: end_page is %lu\n", end_page); 1840 + edbg("SEP Driver: num_pages is %lu\n", num_pages); 1604 1841 1605 - /* allocate array of pages structure pointers */ 1606 - page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC); 1607 - if (!page_array) { 1608 - edbg( 1609 - "SEP Driver: kmalloc for page_array failed\n"); 1842 + /* allocate array of pages structure pointers */ 1843 + page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC); 1844 + if (!page_array) { 1845 + edbg("SEP Driver: kmalloc for page_array failed\n"); 1610 1846 1611 - error = -ENOMEM; 1612 - goto end_function; 1613 - } 1614 - 1615 - lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC); 1616 - if (!lli_array) { 1617 - edbg( 1618 - "SEP Driver: kmalloc for lli_array failed\n"); 1619 - 1620 - error = -ENOMEM; 1621 - goto end_function_with_error1; 1622 - } 1623 - 1624 - /* convert the application virtual address into a set of physical */ 1625 - down_read(&current->mm->mmap_sem); 1626 - result = get_user_pages(current, current->mm, app_virt_addr, num_pages, 1, 0, 1627 - page_array, 1628 - 0); 1629 - up_read(&current->mm->mmap_sem); 1630 - 1631 - /* check the number of pages locked - if not all then exit with error */ 1632 - if (result != num_pages) { 1633 - dbg("SEP Driver: not all pages locked by get_user_pages\n"); 1634 - 1635 - error = -ENOMEM; 1636 - goto end_function_with_error2; 1637 - } 1638 - 1639 - /* flush the cache */ 1640 - for (count = 0; count < num_pages; count++) 1641 - flush_dcache_page(page_array[count]); 1642 - 1643 - /* set the start address of the first page - app data may start not at 1644 - the beginning of the page */ 1645 - lli_array[0].physical_address = ( 1646 - (unsigned long)page_to_phys(page_array[0])) + 1647 - (app_virt_addr & (~PAGE_MASK)) ; 1648 - 1649 - /* check that not all the data is in the first page only */ 1650 - if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size) 1651 - lli_array[0].block_size = data_size; 1652 - else 1653 - lli_array[0].block_size = PAGE_SIZE - (app_virt_addr & (~PAGE_MASK)); 1654 - 1655 - /* debug print */ 1656 - dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", 1657 - lli_array[0].physical_address, 1658 - lli_array[0].block_size); 1659 - 1660 - /* go from the second page to the prev before last */ 1661 - for (count = 1; count < (num_pages - 1); count++) { 1662 - lli_array[count].physical_address = 1663 - (unsigned long)page_to_phys(page_array[count]); 1664 - lli_array[count].block_size = PAGE_SIZE; 1665 - 1666 - edbg( 1667 - "lli_array[%lu].physical_address is %08lx, \ 1668 - lli_array[%lu].block_size is %lu\n", 1669 - count, lli_array[count].physical_address, 1670 - count, 1671 - lli_array[count].block_size); 1672 - } 1673 - 1674 - /* if more then 1 pages locked - then update for the last page size needed */ 1675 - if (num_pages > 1) { 1676 - /* update the address of the last page */ 1677 - lli_array[count].physical_address = 1678 - (unsigned long)page_to_phys(page_array[count]); 1679 - 1680 - /* set the size of the last page */ 1681 - lli_array[count].block_size = (app_virt_addr + data_size) & 1682 - (~PAGE_MASK); 1683 - 1684 - if (lli_array[count].block_size == 0) { 1685 - dbg("app_virt_addr is %08lx\n", app_virt_addr); 1686 - dbg("data_size is %lu\n", data_size); 1687 - while (1); 1847 + error = -ENOMEM; 1848 + goto end_function; 1688 1849 } 1689 - edbg( 1690 - "lli_array[%lu].physical_address is %08lx, \ 1691 - lli_array[%lu].block_size is %lu\n", 1692 - count, lli_array[count].physical_address, 1693 - count, 1694 - lli_array[count].block_size); 1695 - } 1696 1850 1697 - /* set output params */ 1698 - *lli_array_ptr = lli_array; 1699 - *num_pages_ptr = num_pages; 1700 - *page_array_ptr = page_array; 1851 + lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC); 1852 + if (!lli_array) { 1853 + edbg("SEP Driver: kmalloc for lli_array failed\n"); 1701 1854 1702 - goto end_function; 1855 + error = -ENOMEM; 1856 + goto end_function_with_error1; 1857 + } 1703 1858 1704 - end_function_with_error2: 1859 + /* convert the application virtual address into a set of physical */ 1860 + down_read(&current->mm->mmap_sem); 1861 + result = get_user_pages(current, current->mm, app_virt_addr, num_pages, 1, 0, page_array, 0); 1862 + up_read(&current->mm->mmap_sem); 1705 1863 1706 - /* release the cache */ 1707 - for (count = 0; count < num_pages; count++) 1708 - page_cache_release(page_array[count]); 1864 + /* check the number of pages locked - if not all then exit with error */ 1865 + if (result != num_pages) { 1866 + dbg("SEP Driver: not all pages locked by get_user_pages\n"); 1709 1867 1710 - /* free lli array */ 1711 - kfree(lli_array); 1868 + error = -ENOMEM; 1869 + goto end_function_with_error2; 1870 + } 1712 1871 1713 - end_function_with_error1: 1872 + /* flush the cache */ 1873 + for (count = 0; count < num_pages; count++) 1874 + flush_dcache_page(page_array[count]); 1714 1875 1715 - /* free page array */ 1716 - kfree(page_array); 1876 + /* set the start address of the first page - app data may start not at 1877 + the beginning of the page */ 1878 + lli_array[0].physical_address = ((unsigned long) page_to_phys(page_array[0])) + (app_virt_addr & (~PAGE_MASK)); 1717 1879 1718 - end_function: 1880 + /* check that not all the data is in the first page only */ 1881 + if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size) 1882 + lli_array[0].block_size = data_size; 1883 + else 1884 + lli_array[0].block_size = PAGE_SIZE - (app_virt_addr & (~PAGE_MASK)); 1719 1885 1720 - dbg("SEP Driver:<-------- sep_lock_user_pages end\n"); 1886 + /* debug print */ 1887 + dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", lli_array[0].physical_address, lli_array[0].block_size); 1721 1888 1722 - return 0; 1889 + /* go from the second page to the prev before last */ 1890 + for (count = 1; count < (num_pages - 1); count++) { 1891 + lli_array[count].physical_address = (unsigned long) page_to_phys(page_array[count]); 1892 + lli_array[count].block_size = PAGE_SIZE; 1893 + 1894 + edbg("lli_array[%lu].physical_address is %08lx, \ 1895 + lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size); 1896 + } 1897 + 1898 + /* if more then 1 pages locked - then update for the last page size needed */ 1899 + if (num_pages > 1) { 1900 + /* update the address of the last page */ 1901 + lli_array[count].physical_address = (unsigned long) page_to_phys(page_array[count]); 1902 + 1903 + /* set the size of the last page */ 1904 + lli_array[count].block_size = (app_virt_addr + data_size) & (~PAGE_MASK); 1905 + 1906 + if (lli_array[count].block_size == 0) { 1907 + dbg("app_virt_addr is %08lx\n", app_virt_addr); 1908 + dbg("data_size is %lu\n", data_size); 1909 + while (1); 1910 + } 1911 + edbg("lli_array[%lu].physical_address is %08lx, \ 1912 + lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size); 1913 + } 1914 + 1915 + /* set output params */ 1916 + *lli_array_ptr = lli_array; 1917 + *num_pages_ptr = num_pages; 1918 + *page_array_ptr = page_array; 1919 + 1920 + goto end_function; 1921 + 1922 + end_function_with_error2: 1923 + 1924 + /* release the cache */ 1925 + for (count = 0; count < num_pages; count++) 1926 + page_cache_release(page_array[count]); 1927 + 1928 + /* free lli array */ 1929 + kfree(lli_array); 1930 + 1931 + end_function_with_error1: 1932 + 1933 + /* free page array */ 1934 + kfree(page_array); 1935 + 1936 + end_function: 1937 + 1938 + dbg("SEP Driver:<-------- sep_lock_user_pages end\n"); 1939 + 1940 + return 0; 1723 1941 } 1724 1942 1725 1943 /* ··· 1693 1979 and construct a basic lli array, where each entry holds the physical 1694 1980 page address and the size that application data holds in this physical pages 1695 1981 */ 1696 - int sep_lock_kernel_pages(unsigned long kernel_virt_addr, 1697 - unsigned long data_size, 1698 - unsigned long *num_pages_ptr, 1699 - struct sep_lli_entry_t **lli_array_ptr, 1700 - struct page ***page_array_ptr) 1701 - 1982 + int sep_lock_kernel_pages(unsigned long kernel_virt_addr, unsigned long data_size, unsigned long *num_pages_ptr, struct sep_lli_entry_t **lli_array_ptr, struct page ***page_array_ptr) 1702 1983 { 1703 - /* error */ 1704 - int error; 1984 + /* error */ 1985 + int error; 1705 1986 1706 - /* the the page of the end address of the user space buffer */ 1707 - unsigned long end_page; 1987 + /* the the page of the end address of the user space buffer */ 1988 + unsigned long end_page; 1708 1989 1709 - /* the page of the start address of the user space buffer */ 1710 - unsigned long start_page; 1990 + /* the page of the start address of the user space buffer */ 1991 + unsigned long start_page; 1711 1992 1712 - /* the range in pages */ 1713 - unsigned long num_pages; 1993 + /* the range in pages */ 1994 + unsigned long num_pages; 1714 1995 1715 - /* array of lli */ 1716 - struct sep_lli_entry_t *lli_array; 1996 + /* array of lli */ 1997 + struct sep_lli_entry_t *lli_array; 1717 1998 1718 - /* next kernel address to map */ 1719 - unsigned long next_kernel_address; 1999 + /* next kernel address to map */ 2000 + unsigned long next_kernel_address; 1720 2001 1721 - /* count */ 1722 - unsigned long count; 2002 + /* count */ 2003 + unsigned long count; 1723 2004 1724 2005 1725 2006 /*------------------------ 1726 2007 CODE 1727 2008 --------------------------*/ 1728 2009 1729 - dbg("SEP Driver:--------> sep_lock_kernel_pages start\n"); 2010 + dbg("SEP Driver:--------> sep_lock_kernel_pages start\n"); 1730 2011 1731 - error = 0; 2012 + error = 0; 1732 2013 1733 - /* set start and end pages and num pages */ 1734 - end_page = (kernel_virt_addr + data_size - 1) >> PAGE_SHIFT; 1735 - start_page = kernel_virt_addr >> PAGE_SHIFT; 1736 - num_pages = end_page - start_page + 1; 2014 + /* set start and end pages and num pages */ 2015 + end_page = (kernel_virt_addr + data_size - 1) >> PAGE_SHIFT; 2016 + start_page = kernel_virt_addr >> PAGE_SHIFT; 2017 + num_pages = end_page - start_page + 1; 1737 2018 1738 - edbg( 1739 - "SEP Driver: kernel_virt_addr is %08lx\n", 1740 - kernel_virt_addr); 1741 - edbg( 1742 - "SEP Driver: data_size is %lu\n", 1743 - data_size); 1744 - edbg( 1745 - "SEP Driver: start_page is %lx\n", 1746 - start_page); 1747 - edbg( 1748 - "SEP Driver: end_page is %lx\n", 1749 - end_page); 1750 - edbg( 1751 - "SEP Driver: num_pages is %lu\n", 1752 - num_pages); 2019 + edbg("SEP Driver: kernel_virt_addr is %08lx\n", kernel_virt_addr); 2020 + edbg("SEP Driver: data_size is %lu\n", data_size); 2021 + edbg("SEP Driver: start_page is %lx\n", start_page); 2022 + edbg("SEP Driver: end_page is %lx\n", end_page); 2023 + edbg("SEP Driver: num_pages is %lu\n", num_pages); 1753 2024 1754 - lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC); 1755 - if (!lli_array) { 1756 - edbg( 1757 - "SEP Driver: kmalloc for lli_array failed\n"); 2025 + lli_array = kmalloc(sizeof(struct sep_lli_entry_t) * num_pages, GFP_ATOMIC); 2026 + if (!lli_array) { 2027 + edbg("SEP Driver: kmalloc for lli_array failed\n"); 1758 2028 1759 - error = -ENOMEM; 1760 - goto end_function; 1761 - } 1762 - 1763 - /* set the start address of the first page - app data may start not at 1764 - the beginning of the page */ 1765 - lli_array[0].physical_address = 1766 - (unsigned long)virt_to_phys((unsigned long *)kernel_virt_addr); 1767 - 1768 - /* check that not all the data is in the first page only */ 1769 - if ((PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK))) >= data_size) 1770 - lli_array[0].block_size = data_size; 1771 - else 1772 - lli_array[0].block_size = 1773 - PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK)); 1774 - 1775 - /* debug print */ 1776 - dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", 1777 - lli_array[0].physical_address, 1778 - lli_array[0].block_size); 1779 - 1780 - /* advance the address to the start of the next page */ 1781 - next_kernel_address = (kernel_virt_addr & PAGE_MASK) + PAGE_SIZE; 1782 - 1783 - /* go from the second page to the prev before last */ 1784 - for (count = 1; count < (num_pages - 1); count++) { 1785 - lli_array[count].physical_address = 1786 - (unsigned long)virt_to_phys((unsigned long *)next_kernel_address); 1787 - lli_array[count].block_size = PAGE_SIZE; 1788 - 1789 - edbg( 1790 - "lli_array[%lu].physical_address is %08lx, \ 1791 - lli_array[%lu].block_size is %lu\n", 1792 - count, lli_array[count].physical_address, count, 1793 - lli_array[count].block_size); 1794 - 1795 - next_kernel_address += PAGE_SIZE; 1796 - } 1797 - 1798 - /* if more then 1 pages locked - then update for the last page size needed */ 1799 - if (num_pages > 1) { 1800 - /* update the address of the last page */ 1801 - lli_array[count].physical_address = 1802 - (unsigned long)virt_to_phys((unsigned long *)next_kernel_address); 1803 - 1804 - /* set the size of the last page */ 1805 - lli_array[count].block_size = 1806 - (kernel_virt_addr + data_size) & (~PAGE_MASK); 1807 - 1808 - if (lli_array[count].block_size == 0) { 1809 - dbg("app_virt_addr is %08lx\n", 1810 - kernel_virt_addr); 1811 - dbg("data_size is %lu\n", data_size); 1812 - while (1); 2029 + error = -ENOMEM; 2030 + goto end_function; 1813 2031 } 1814 2032 1815 - edbg( 1816 - "lli_array[%lu].physical_address is %08lx, \ 1817 - lli_array[%lu].block_size is %lu\n", 1818 - count, lli_array[count].physical_address, 1819 - count, 1820 - lli_array[count].block_size); 1821 - } 2033 + /* set the start address of the first page - app data may start not at 2034 + the beginning of the page */ 2035 + lli_array[0].physical_address = (unsigned long) virt_to_phys((unsigned long *) kernel_virt_addr); 1822 2036 1823 - /* set output params */ 1824 - *lli_array_ptr = lli_array; 1825 - *num_pages_ptr = num_pages; 1826 - *page_array_ptr = 0; 2037 + /* check that not all the data is in the first page only */ 2038 + if ((PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK))) >= data_size) 2039 + lli_array[0].block_size = data_size; 2040 + else 2041 + lli_array[0].block_size = PAGE_SIZE - (kernel_virt_addr & (~PAGE_MASK)); 2042 + 2043 + /* debug print */ 2044 + dbg("lli_array[0].physical_address is %08lx, lli_array[0].block_size is %lu\n", lli_array[0].physical_address, lli_array[0].block_size); 2045 + 2046 + /* advance the address to the start of the next page */ 2047 + next_kernel_address = (kernel_virt_addr & PAGE_MASK) + PAGE_SIZE; 2048 + 2049 + /* go from the second page to the prev before last */ 2050 + for (count = 1; count < (num_pages - 1); count++) { 2051 + lli_array[count].physical_address = (unsigned long) virt_to_phys((unsigned long *) next_kernel_address); 2052 + lli_array[count].block_size = PAGE_SIZE; 2053 + 2054 + edbg("lli_array[%lu].physical_address is %08lx, \ 2055 + lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size); 2056 + 2057 + next_kernel_address += PAGE_SIZE; 2058 + } 2059 + 2060 + /* if more then 1 pages locked - then update for the last page size needed */ 2061 + if (num_pages > 1) { 2062 + /* update the address of the last page */ 2063 + lli_array[count].physical_address = (unsigned long) virt_to_phys((unsigned long *) next_kernel_address); 2064 + 2065 + /* set the size of the last page */ 2066 + lli_array[count].block_size = (kernel_virt_addr + data_size) & (~PAGE_MASK); 2067 + 2068 + if (lli_array[count].block_size == 0) { 2069 + dbg("app_virt_addr is %08lx\n", kernel_virt_addr); 2070 + dbg("data_size is %lu\n", data_size); 2071 + while (1); 2072 + } 2073 + 2074 + edbg("lli_array[%lu].physical_address is %08lx, \ 2075 + lli_array[%lu].block_size is %lu\n", count, lli_array[count].physical_address, count, lli_array[count].block_size); 2076 + } 2077 + 2078 + /* set output params */ 2079 + *lli_array_ptr = lli_array; 2080 + *num_pages_ptr = num_pages; 2081 + *page_array_ptr = 0; 1827 2082 1828 2083 1829 - end_function: 2084 + end_function: 1830 2085 1831 - dbg("SEP Driver:<-------- sep_lock_kernel_pages end\n"); 2086 + dbg("SEP Driver:<-------- sep_lock_kernel_pages end\n"); 1832 2087 1833 - return 0; 2088 + return 0; 1834 2089 } 1835 2090 1836 2091 /* 1837 2092 This function releases all the application virtual buffer physical pages, 1838 2093 that were previously locked 1839 2094 */ 1840 - int sep_free_dma_pages(struct page **page_array_ptr, 1841 - unsigned long num_pages, 1842 - unsigned long dirtyFlag) 2095 + int sep_free_dma_pages(struct page **page_array_ptr, unsigned long num_pages, unsigned long dirtyFlag) 1843 2096 { 1844 - /* count */ 1845 - unsigned long count; 2097 + /* count */ 2098 + unsigned long count; 1846 2099 1847 2100 /*------------------- 1848 2101 CODE 1849 2102 ---------------------*/ 1850 2103 1851 - if (dirtyFlag) { 1852 - for (count = 0; count < num_pages; count++) { 1853 - /* the out array was written, therefore the data was changed */ 1854 - if (!PageReserved(page_array_ptr[count])) 1855 - SetPageDirty(page_array_ptr[count]); 1856 - page_cache_release(page_array_ptr[count]); 2104 + if (dirtyFlag) { 2105 + for (count = 0; count < num_pages; count++) { 2106 + /* the out array was written, therefore the data was changed */ 2107 + if (!PageReserved(page_array_ptr[count])) 2108 + SetPageDirty(page_array_ptr[count]); 2109 + page_cache_release(page_array_ptr[count]); 2110 + } 2111 + } else { 2112 + /* free in pages - the data was only read, therefore no update was done 2113 + on those pages */ 2114 + for (count = 0; count < num_pages; count++) 2115 + page_cache_release(page_array_ptr[count]); 1857 2116 } 1858 - } else { 1859 - /* free in pages - the data was only read, therefore no update was done 1860 - on those pages */ 1861 - for (count = 0; count < num_pages; count++) 1862 - page_cache_release(page_array_ptr[count]); 1863 - } 1864 2117 1865 - if (page_array_ptr) 1866 - /* free the array */ 1867 - kfree(page_array_ptr); 2118 + if (page_array_ptr) 2119 + /* free the array */ 2120 + kfree(page_array_ptr); 1868 2121 1869 - return 0; 2122 + return 0; 1870 2123 } 1871 2124 1872 2125 /* ··· 1843 2162 static void sep_send_command_handler() 1844 2163 { 1845 2164 1846 - unsigned long count; 2165 + unsigned long count; 1847 2166 1848 - dbg("SEP Driver:--------> sep_send_command_handler start\n"); 2167 + dbg("SEP Driver:--------> sep_send_command_handler start\n"); 1849 2168 1850 - sep_set_time(0, 0); 2169 + sep_set_time(0, 0); 1851 2170 1852 - /* flash cache */ 1853 - flush_cache_all(); 2171 + /* flash cache */ 2172 + flush_cache_all(); 1854 2173 1855 - for (count = 0; count < 12 * 4; count += 4) 1856 - edbg("Word %lu of the message is %lu\n", count, 1857 - *((unsigned long *)(sep_dev->shared_area_addr + count))); 2174 + for (count = 0; count < 12 * 4; count += 4) 2175 + edbg("Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count))); 1858 2176 1859 - /* update counter */ 1860 - sep_dev->host_to_sep_send_counter++; 2177 + /* update counter */ 2178 + sep_dev->host_to_sep_send_counter++; 1861 2179 1862 - /* send interrupt to SEP */ 1863 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2); 2180 + /* send interrupt to SEP */ 2181 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2); 1864 2182 1865 - dbg("SEP Driver:<-------- sep_send_command_handler end\n"); 2183 + dbg("SEP Driver:<-------- sep_send_command_handler end\n"); 1866 2184 1867 - return; 2185 + return; 1868 2186 } 1869 2187 1870 2188 /* ··· 1872 2192 */ 1873 2193 static void sep_send_reply_command_handler() 1874 2194 { 1875 - unsigned long count; 2195 + unsigned long count; 1876 2196 1877 - dbg("SEP Driver:--------> sep_send_reply_command_handler start\n"); 2197 + dbg("SEP Driver:--------> sep_send_reply_command_handler start\n"); 1878 2198 1879 - /* flash cache */ 1880 - flush_cache_all(); 2199 + /* flash cache */ 2200 + flush_cache_all(); 1881 2201 1882 - for (count = 0; count < 12 * 4; count += 4) 1883 - edbg("Word %lu of the message is %lu\n", count, 1884 - *((unsigned long *)(sep_dev->shared_area_addr + count))); 2202 + for (count = 0; count < 12 * 4; count += 4) 2203 + edbg("Word %lu of the message is %lu\n", count, *((unsigned long *) (sep_dev->shared_area_addr + count))); 1885 2204 1886 2205 1887 - /* update counter */ 1888 - sep_dev->host_to_sep_send_counter++; 2206 + /* update counter */ 2207 + sep_dev->host_to_sep_send_counter++; 1889 2208 1890 - /* send the interrupt to SEP */ 1891 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 1892 - sep_dev->host_to_sep_send_counter); 2209 + /* send the interrupt to SEP */ 2210 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, sep_dev->host_to_sep_send_counter); 1893 2211 1894 - /* update both counters */ 1895 - sep_dev->host_to_sep_send_counter++; 2212 + /* update both counters */ 2213 + sep_dev->host_to_sep_send_counter++; 1896 2214 1897 - sep_dev->sep_to_host_reply_counter++; 2215 + sep_dev->sep_to_host_reply_counter++; 1898 2216 1899 - dbg("SEP Driver:<-------- sep_send_reply_command_handler end\n"); 2217 + dbg("SEP Driver:<-------- sep_send_reply_command_handler end\n"); 1900 2218 1901 - return; 2219 + return; 1902 2220 } 1903 2221 1904 2222 ··· 1910 2232 */ 1911 2233 static int sep_allocate_data_pool_memory_handler(unsigned long arg) 1912 2234 { 1913 - /* error */ 1914 - int error; 2235 + /* error */ 2236 + int error; 1915 2237 1916 - /* command paramaters */ 1917 - struct sep_driver_alloc_t command_args; 2238 + /* command paramaters */ 2239 + struct sep_driver_alloc_t command_args; 1918 2240 1919 2241 /*------------------------- 1920 2242 CODE 1921 2243 ----------------------------*/ 1922 2244 1923 - dbg("SEP Driver:--------> sep_allocate_data_pool_memory_handler start\n"); 2245 + dbg("SEP Driver:--------> sep_allocate_data_pool_memory_handler start\n"); 1924 2246 1925 2247 1926 - error = copy_from_user(&command_args, 1927 - (void *)arg, 1928 - sizeof(struct sep_driver_alloc_t)); 1929 - if (error) 1930 - goto end_function; 2248 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_alloc_t)); 2249 + if (error) 2250 + goto end_function; 1931 2251 1932 - /* allocate memory */ 1933 - if ( 1934 - (sep_dev->data_pool_bytes_allocated + command_args.num_bytes) > 1935 - SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) { 1936 - error = -ENOTTY; 1937 - goto end_function; 1938 - } 2252 + /* allocate memory */ 2253 + if ((sep_dev->data_pool_bytes_allocated + command_args.num_bytes) > SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) { 2254 + error = -ENOTTY; 2255 + goto end_function; 2256 + } 1939 2257 1940 - /* set the virtual and physical address */ 1941 - command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + 1942 - sep_dev->data_pool_bytes_allocated; 1943 - command_args.phys_address = sep_dev->phys_shared_area_addr + 1944 - SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + 1945 - sep_dev->data_pool_bytes_allocated; 2258 + /* set the virtual and physical address */ 2259 + command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + sep_dev->data_pool_bytes_allocated; 2260 + command_args.phys_address = sep_dev->phys_shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + sep_dev->data_pool_bytes_allocated; 1946 2261 1947 - /* write the memory back to the user space */ 1948 - error = copy_to_user((void *)arg, 1949 - (void *)&command_args, 1950 - sizeof(struct sep_driver_alloc_t)); 1951 - if (error) 1952 - goto end_function; 2262 + /* write the memory back to the user space */ 2263 + error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_alloc_t)); 2264 + if (error) 2265 + goto end_function; 1953 2266 1954 - /* set the allocation */ 1955 - sep_dev->data_pool_bytes_allocated += command_args.num_bytes; 2267 + /* set the allocation */ 2268 + sep_dev->data_pool_bytes_allocated += command_args.num_bytes; 1956 2269 1957 - end_function: 2270 + end_function: 1958 2271 1959 - dbg("SEP Driver:<-------- sep_allocate_data_pool_memory_handler end\n"); 2272 + dbg("SEP Driver:<-------- sep_allocate_data_pool_memory_handler end\n"); 1960 2273 1961 - return error; 2274 + return error; 1962 2275 } 1963 2276 1964 2277 /* ··· 1957 2288 */ 1958 2289 static int sep_write_into_data_pool_handler(unsigned long arg) 1959 2290 { 1960 - /* error */ 1961 - int error; 2291 + /* error */ 2292 + int error; 1962 2293 1963 - /* virtual address */ 1964 - unsigned long virt_address; 2294 + /* virtual address */ 2295 + unsigned long virt_address; 1965 2296 1966 - /* application in address */ 1967 - unsigned long app_in_address; 2297 + /* application in address */ 2298 + unsigned long app_in_address; 1968 2299 1969 - /* number of bytes */ 1970 - unsigned long num_bytes; 2300 + /* number of bytes */ 2301 + unsigned long num_bytes; 1971 2302 1972 - /* address of the data pool */ 1973 - unsigned long data_pool_area_addr; 2303 + /* address of the data pool */ 2304 + unsigned long data_pool_area_addr; 1974 2305 1975 2306 /*-------------------------- 1976 2307 CODE 1977 2308 -----------------------------*/ 1978 2309 1979 - dbg("SEP Driver:--------> sep_write_into_data_pool_handler start\n"); 2310 + dbg("SEP Driver:--------> sep_write_into_data_pool_handler start\n"); 1980 2311 1981 - /* get the application address */ 1982 - error = get_user(app_in_address, 1983 - &(((struct sep_driver_write_t *)arg)->app_address)); 1984 - if (error) 1985 - goto end_function; 2312 + /* get the application address */ 2313 + error = get_user(app_in_address, &(((struct sep_driver_write_t *) arg)->app_address)); 2314 + if (error) 2315 + goto end_function; 1986 2316 1987 - /* get the virtual kernel address address */ 1988 - error = get_user(virt_address, 1989 - &(((struct sep_driver_write_t *)arg)->datapool_address)); 1990 - if (error) 1991 - goto end_function; 2317 + /* get the virtual kernel address address */ 2318 + error = get_user(virt_address, &(((struct sep_driver_write_t *) arg)->datapool_address)); 2319 + if (error) 2320 + goto end_function; 1992 2321 1993 - /* get the number of bytes */ 1994 - error = get_user(num_bytes, &(((struct sep_driver_write_t *)arg)->num_bytes)); 1995 - if (error) 1996 - goto end_function; 2322 + /* get the number of bytes */ 2323 + error = get_user(num_bytes, &(((struct sep_driver_write_t *) arg)->num_bytes)); 2324 + if (error) 2325 + goto end_function; 1997 2326 1998 - /* calculate the start of the data pool */ 1999 - data_pool_area_addr = sep_dev->shared_area_addr + 2000 - SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES; 2327 + /* calculate the start of the data pool */ 2328 + data_pool_area_addr = sep_dev->shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES; 2001 2329 2002 2330 2003 - /* check that the range of the virtual kernel address is correct */ 2004 - if ((virt_address < data_pool_area_addr) || 2005 - (virt_address > (data_pool_area_addr + 2006 - SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) { 2007 - error = -ENOTTY; 2008 - goto end_function; 2009 - } 2331 + /* check that the range of the virtual kernel address is correct */ 2332 + if ((virt_address < data_pool_area_addr) || (virt_address > (data_pool_area_addr + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) { 2333 + error = -ENOTTY; 2334 + goto end_function; 2335 + } 2010 2336 2011 - /* copy the application data */ 2012 - error = copy_from_user((void *)virt_address, 2013 - (void *)app_in_address, 2014 - num_bytes); 2337 + /* copy the application data */ 2338 + error = copy_from_user((void *) virt_address, (void *) app_in_address, num_bytes); 2015 2339 2016 - end_function: 2340 + end_function: 2017 2341 2018 - dbg("SEP Driver:<-------- sep_write_into_data_pool_handler end\n"); 2342 + dbg("SEP Driver:<-------- sep_write_into_data_pool_handler end\n"); 2019 2343 2020 - return error; 2344 + return error; 2021 2345 } 2022 2346 2023 2347 /* ··· 2018 2356 */ 2019 2357 static int sep_read_from_data_pool_handler(unsigned long arg) 2020 2358 { 2021 - /* error */ 2022 - int error; 2359 + /* error */ 2360 + int error; 2023 2361 2024 - /* virtual address of dest application buffer */ 2025 - unsigned long app_out_address; 2362 + /* virtual address of dest application buffer */ 2363 + unsigned long app_out_address; 2026 2364 2027 - /* virtual address of the data pool */ 2028 - unsigned long virt_address; 2365 + /* virtual address of the data pool */ 2366 + unsigned long virt_address; 2029 2367 2030 - /* number bytes */ 2031 - unsigned long num_bytes; 2368 + /* number bytes */ 2369 + unsigned long num_bytes; 2032 2370 2033 - /* address of the data pool */ 2034 - unsigned long data_pool_area_addr; 2371 + /* address of the data pool */ 2372 + unsigned long data_pool_area_addr; 2035 2373 2036 2374 /*------------------------ 2037 2375 CODE 2038 2376 -----------------------------*/ 2039 2377 2040 - dbg("SEP Driver:--------> sep_read_from_data_pool_handler start\n"); 2378 + dbg("SEP Driver:--------> sep_read_from_data_pool_handler start\n"); 2041 2379 2042 - /* get the application address */ 2043 - error = get_user(app_out_address, 2044 - &(((struct sep_driver_write_t *)arg)->app_address)); 2045 - if (error) 2046 - goto end_function; 2380 + /* get the application address */ 2381 + error = get_user(app_out_address, &(((struct sep_driver_write_t *) arg)->app_address)); 2382 + if (error) 2383 + goto end_function; 2047 2384 2048 - /* get the virtual kernel address address */ 2049 - error = get_user(virt_address, 2050 - &(((struct sep_driver_write_t *)arg)->datapool_address)); 2051 - if (error) 2052 - goto end_function; 2385 + /* get the virtual kernel address address */ 2386 + error = get_user(virt_address, &(((struct sep_driver_write_t *) arg)->datapool_address)); 2387 + if (error) 2388 + goto end_function; 2053 2389 2054 - /* get the number of bytes */ 2055 - error = get_user(num_bytes, &(((struct sep_driver_write_t *)arg)->num_bytes)); 2056 - if (error) 2057 - goto end_function; 2390 + /* get the number of bytes */ 2391 + error = get_user(num_bytes, &(((struct sep_driver_write_t *) arg)->num_bytes)); 2392 + if (error) 2393 + goto end_function; 2058 2394 2059 - /* calculate the start of the data pool */ 2060 - data_pool_area_addr = sep_dev->shared_area_addr + 2061 - SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES; 2395 + /* calculate the start of the data pool */ 2396 + data_pool_area_addr = sep_dev->shared_area_addr + SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES; 2062 2397 2063 - /* check that the range of the virtual kernel address is correct */ 2064 - if ((virt_address < data_pool_area_addr) || 2065 - (virt_address > (data_pool_area_addr + 2066 - SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) { 2067 - error = -ENOTTY; 2068 - goto end_function; 2069 - } 2398 + /* check that the range of the virtual kernel address is correct */ 2399 + if ((virt_address < data_pool_area_addr) || (virt_address > (data_pool_area_addr + SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES))) { 2400 + error = -ENOTTY; 2401 + goto end_function; 2402 + } 2070 2403 2071 - /* copy the application data */ 2072 - error = copy_to_user((void *)app_out_address, (void *)virt_address, 2073 - num_bytes); 2404 + /* copy the application data */ 2405 + error = copy_to_user((void *) app_out_address, (void *) virt_address, num_bytes); 2074 2406 2075 - end_function: 2407 + end_function: 2076 2408 2077 - dbg("SEP Driver:<-------- sep_read_from_data_pool_handler end\n"); 2409 + dbg("SEP Driver:<-------- sep_read_from_data_pool_handler end\n"); 2078 2410 2079 - return error; 2411 + return error; 2080 2412 } 2081 2413 2082 2414 ··· 2080 2424 */ 2081 2425 static int sep_create_sync_dma_tables_handler(unsigned long arg) 2082 2426 { 2083 - /* error */ 2084 - int error; 2427 + /* error */ 2428 + int error; 2085 2429 2086 - /* command arguments */ 2087 - struct sep_driver_build_sync_table_t command_args; 2430 + /* command arguments */ 2431 + struct sep_driver_build_sync_table_t command_args; 2088 2432 2089 2433 /*------------------------ 2090 2434 CODE 2091 2435 --------------------------*/ 2092 2436 2093 - dbg("SEP Driver:--------> sep_create_sync_dma_tables_handler start\n"); 2437 + dbg("SEP Driver:--------> sep_create_sync_dma_tables_handler start\n"); 2094 2438 2095 - error = copy_from_user(&command_args, 2096 - (void *)arg, 2097 - sizeof(struct sep_driver_build_sync_table_t)); 2098 - if (error) 2099 - goto end_function; 2439 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_sync_table_t)); 2440 + if (error) 2441 + goto end_function; 2100 2442 2101 - edbg( 2102 - "app_in_address is %08lx\n", 2103 - command_args.app_in_address); 2104 - edbg( 2105 - "app_out_address is %08lx\n", 2106 - command_args.app_out_address); 2107 - edbg( 2108 - "data_size is %lu\n", 2109 - command_args.data_in_size); 2110 - edbg( 2111 - "block_size is %lu\n", 2112 - command_args.block_size); 2443 + edbg("app_in_address is %08lx\n", command_args.app_in_address); 2444 + edbg("app_out_address is %08lx\n", command_args.app_out_address); 2445 + edbg("data_size is %lu\n", command_args.data_in_size); 2446 + edbg("block_size is %lu\n", command_args.block_size); 2113 2447 2114 2448 2115 - /* check if we need to build only input table or input/output */ 2116 - if (command_args.app_out_address) 2117 - /* prepare input and output tables */ 2118 - error = sep_prepare_input_output_dma_table(command_args.app_in_address, 2119 - command_args.app_out_address, 2120 - command_args.data_in_size, 2121 - command_args.block_size, 2122 - &command_args.in_table_address, 2123 - &command_args.out_table_address, 2124 - &command_args.in_table_num_entries, 2125 - &command_args.out_table_num_entries, 2126 - &command_args.table_data_size, 2127 - command_args.isKernelVirtualAddress); 2128 - else 2129 - /* prepare input tables */ 2130 - error = sep_prepare_input_dma_table(command_args.app_in_address, 2131 - command_args.data_in_size, 2132 - command_args.block_size, 2133 - &command_args.in_table_address, 2134 - &command_args.in_table_num_entries, 2135 - &command_args.table_data_size, 2136 - command_args.isKernelVirtualAddress); 2449 + /* check if we need to build only input table or input/output */ 2450 + if (command_args.app_out_address) 2451 + /* prepare input and output tables */ 2452 + error = sep_prepare_input_output_dma_table(command_args.app_in_address, 2453 + command_args.app_out_address, 2454 + command_args.data_in_size, 2455 + command_args.block_size, 2456 + &command_args.in_table_address, 2457 + &command_args.out_table_address, &command_args.in_table_num_entries, &command_args.out_table_num_entries, &command_args.table_data_size, command_args.isKernelVirtualAddress); 2458 + else 2459 + /* prepare input tables */ 2460 + error = sep_prepare_input_dma_table(command_args.app_in_address, 2461 + command_args.data_in_size, command_args.block_size, &command_args.in_table_address, &command_args.in_table_num_entries, &command_args.table_data_size, command_args.isKernelVirtualAddress); 2137 2462 2138 - if (error) 2139 - goto end_function; 2463 + if (error) 2464 + goto end_function; 2140 2465 2141 - /* copy to user */ 2142 - error = copy_to_user((void *)arg, 2143 - (void *)&command_args, 2144 - sizeof(struct sep_driver_build_sync_table_t)); 2466 + /* copy to user */ 2467 + error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_build_sync_table_t)); 2145 2468 2146 - end_function: 2469 + end_function: 2147 2470 2148 - dbg("SEP Driver:<-------- sep_create_sync_dma_tables_handler end\n"); 2471 + dbg("SEP Driver:<-------- sep_create_sync_dma_tables_handler end\n"); 2149 2472 2150 - return error; 2473 + return error; 2151 2474 } 2152 2475 2153 2476 /* ··· 2138 2503 CODE 2139 2504 -----------------------------*/ 2140 2505 2141 - dbg("SEP Driver:--------> sep_free_dma_table_data_handler start\n"); 2506 + dbg("SEP Driver:--------> sep_free_dma_table_data_handler start\n"); 2142 2507 2143 - /* free input pages array */ 2144 - sep_free_dma_pages(sep_dev->in_page_array, 2145 - sep_dev->in_num_pages, 2146 - 0); 2508 + /* free input pages array */ 2509 + sep_free_dma_pages(sep_dev->in_page_array, sep_dev->in_num_pages, 0); 2147 2510 2148 - /* free output pages array if needed */ 2149 - if (sep_dev->out_page_array) 2150 - sep_free_dma_pages(sep_dev->out_page_array, 2151 - sep_dev->out_num_pages, 2152 - 1); 2511 + /* free output pages array if needed */ 2512 + if (sep_dev->out_page_array) 2513 + sep_free_dma_pages(sep_dev->out_page_array, sep_dev->out_num_pages, 1); 2153 2514 2154 - /* reset all the values */ 2155 - sep_dev->in_page_array = 0; 2156 - sep_dev->out_page_array = 0; 2157 - sep_dev->in_num_pages = 0; 2158 - sep_dev->out_num_pages = 0; 2515 + /* reset all the values */ 2516 + sep_dev->in_page_array = 0; 2517 + sep_dev->out_page_array = 0; 2518 + sep_dev->in_num_pages = 0; 2519 + sep_dev->out_num_pages = 0; 2159 2520 2160 2521 2161 - dbg("SEP Driver:<-------- sep_free_dma_table_data_handler end\n"); 2522 + dbg("SEP Driver:<-------- sep_free_dma_table_data_handler end\n"); 2162 2523 2163 - return 0; 2524 + return 0; 2164 2525 } 2165 2526 2166 2527 /* ··· 2164 2533 */ 2165 2534 static int sep_create_flow_dma_tables_handler(unsigned long arg) 2166 2535 { 2167 - /* error */ 2168 - int error; 2536 + /* error */ 2537 + int error; 2169 2538 2170 - /* command arguments */ 2171 - struct sep_driver_build_flow_table_t command_args; 2539 + /* command arguments */ 2540 + struct sep_driver_build_flow_table_t command_args; 2172 2541 2173 - /* first table - output */ 2174 - struct sep_lli_entry_t first_table_data; 2542 + /* first table - output */ 2543 + struct sep_lli_entry_t first_table_data; 2175 2544 2176 - /* dma table data */ 2177 - struct sep_lli_entry_t last_table_data; 2545 + /* dma table data */ 2546 + struct sep_lli_entry_t last_table_data; 2178 2547 2179 - /* pointer to the info entry of the previuos DMA table */ 2180 - struct sep_lli_entry_t *prev_info_entry_ptr; 2548 + /* pointer to the info entry of the previuos DMA table */ 2549 + struct sep_lli_entry_t *prev_info_entry_ptr; 2181 2550 2182 - /* pointer to the flow data strucutre */ 2183 - struct sep_flow_context_t *flow_context_ptr; 2551 + /* pointer to the flow data strucutre */ 2552 + struct sep_flow_context_t *flow_context_ptr; 2184 2553 2185 2554 /*------------------------ 2186 2555 CODE 2187 2556 --------------------------*/ 2188 2557 2189 - dbg("SEP Driver:--------> sep_create_flow_dma_tables_handler start\n"); 2558 + dbg("SEP Driver:--------> sep_create_flow_dma_tables_handler start\n"); 2190 2559 2191 - /* init variables */ 2192 - prev_info_entry_ptr = 0; 2193 - first_table_data.physical_address = 0xffffffff; 2560 + /* init variables */ 2561 + prev_info_entry_ptr = 0; 2562 + first_table_data.physical_address = 0xffffffff; 2194 2563 2195 - /* find the free structure for flow data */ 2196 - error = sep_find_flow_context(SEP_FREE_FLOW_ID, &flow_context_ptr); 2197 - if (error) 2564 + /* find the free structure for flow data */ 2565 + error = sep_find_flow_context(SEP_FREE_FLOW_ID, &flow_context_ptr); 2566 + if (error) 2567 + goto end_function; 2568 + 2569 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_build_flow_table_t)); 2570 + if (error) 2571 + goto end_function; 2572 + 2573 + /* create flow tables */ 2574 + error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, command_args.virt_buff_data_addr, flow_context_ptr, &first_table_data, &last_table_data, command_args.isKernelVirtualAddress); 2575 + if (error) 2576 + goto end_function_with_error; 2577 + 2578 + /* check if flow is static */ 2579 + if (!command_args.flow_type) 2580 + /* point the info entry of the last to the info entry of the first */ 2581 + last_table_data = first_table_data; 2582 + 2583 + /* set output params */ 2584 + command_args.first_table_addr = first_table_data.physical_address; 2585 + command_args.first_table_num_entries = ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK); 2586 + command_args.first_table_data_size = (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK); 2587 + 2588 + /* send the parameters to user application */ 2589 + error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_build_flow_table_t)); 2590 + if (error) 2591 + goto end_function_with_error; 2592 + 2593 + /* all the flow created - update the flow entry with temp id */ 2594 + flow_context_ptr->flow_id = SEP_TEMP_FLOW_ID; 2595 + 2596 + /* set the processing tables data in the context */ 2597 + if (command_args.input_output_flag == SEP_DRIVER_IN_FLAG) 2598 + flow_context_ptr->input_tables_in_process = first_table_data; 2599 + else 2600 + flow_context_ptr->output_tables_in_process = first_table_data; 2601 + 2198 2602 goto end_function; 2199 2603 2200 - error = copy_from_user(&command_args, 2201 - (void *)arg, 2202 - sizeof(struct sep_driver_build_flow_table_t)); 2203 - if (error) 2204 - goto end_function; 2604 + end_function_with_error: 2205 2605 2206 - /* create flow tables */ 2207 - error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, 2208 - command_args.virt_buff_data_addr, 2209 - flow_context_ptr, 2210 - &first_table_data, 2211 - &last_table_data, 2212 - command_args.isKernelVirtualAddress); 2213 - if (error) 2214 - goto end_function_with_error; 2606 + /* free the allocated tables */ 2607 + sep_deallocated_flow_tables(&first_table_data); 2215 2608 2216 - /* check if flow is static */ 2217 - if (!command_args.flow_type) 2218 - /* point the info entry of the last to the info entry of the first */ 2219 - last_table_data = first_table_data; 2609 + end_function: 2220 2610 2221 - /* set output params */ 2222 - command_args.first_table_addr = first_table_data.physical_address; 2223 - command_args.first_table_num_entries = 2224 - ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & 2225 - SEP_NUM_ENTRIES_MASK); 2226 - command_args.first_table_data_size = 2227 - (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK); 2611 + dbg("SEP Driver:<-------- sep_create_flow_dma_tables_handler end\n"); 2228 2612 2229 - /* send the parameters to user application */ 2230 - error = copy_to_user((void *)arg, 2231 - &command_args, 2232 - sizeof(struct sep_driver_build_flow_table_t)); 2233 - if (error) 2234 - goto end_function_with_error; 2235 - 2236 - /* all the flow created - update the flow entry with temp id */ 2237 - flow_context_ptr->flow_id = SEP_TEMP_FLOW_ID; 2238 - 2239 - /* set the processing tables data in the context */ 2240 - if (command_args.input_output_flag == SEP_DRIVER_IN_FLAG) 2241 - flow_context_ptr->input_tables_in_process = first_table_data; 2242 - else 2243 - flow_context_ptr->output_tables_in_process = first_table_data; 2244 - 2245 - goto end_function; 2246 - 2247 - end_function_with_error: 2248 - 2249 - /* free the allocated tables */ 2250 - sep_deallocated_flow_tables(&first_table_data); 2251 - 2252 - end_function: 2253 - 2254 - dbg("SEP Driver:<-------- sep_create_flow_dma_tables_handler end\n"); 2255 - 2256 - return error; 2613 + return error; 2257 2614 2258 2615 } 2259 2616 ··· 2250 2631 */ 2251 2632 static int sep_add_flow_tables_handler(unsigned long arg) 2252 2633 { 2253 - /* error */ 2254 - int error; 2634 + /* error */ 2635 + int error; 2255 2636 2256 - /* number of entries */ 2257 - unsigned long num_entries; 2637 + /* number of entries */ 2638 + unsigned long num_entries; 2258 2639 2259 - /* command arguments */ 2260 - struct sep_driver_add_flow_table_t command_args; 2640 + /* command arguments */ 2641 + struct sep_driver_add_flow_table_t command_args; 2261 2642 2262 - /* pointer to the flow data strucutre */ 2263 - struct sep_flow_context_t *flow_context_ptr; 2643 + /* pointer to the flow data strucutre */ 2644 + struct sep_flow_context_t *flow_context_ptr; 2264 2645 2265 - /* first dma table data */ 2266 - struct sep_lli_entry_t first_table_data; 2646 + /* first dma table data */ 2647 + struct sep_lli_entry_t first_table_data; 2267 2648 2268 - /* last dma table data */ 2269 - struct sep_lli_entry_t last_table_data; 2649 + /* last dma table data */ 2650 + struct sep_lli_entry_t last_table_data; 2270 2651 2271 - /* pointer to the info entry of the current DMA table */ 2272 - struct sep_lli_entry_t *info_entry_ptr; 2652 + /* pointer to the info entry of the current DMA table */ 2653 + struct sep_lli_entry_t *info_entry_ptr; 2273 2654 2274 2655 /*-------------------------- 2275 2656 CODE 2276 2657 ----------------------------*/ 2277 2658 2278 - dbg("SEP Driver:--------> sep_add_flow_tables_handler start\n"); 2659 + dbg("SEP Driver:--------> sep_add_flow_tables_handler start\n"); 2279 2660 2280 - /* get input parameters */ 2281 - error = copy_from_user(&command_args, 2282 - (void *)arg, 2283 - sizeof(struct sep_driver_add_flow_table_t)); 2284 - if (error) 2285 - goto end_function; 2661 + /* get input parameters */ 2662 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_add_flow_table_t)); 2663 + if (error) 2664 + goto end_function; 2286 2665 2287 - /* find the flow structure for the flow id */ 2288 - error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr); 2289 - if (error) 2290 - goto end_function; 2666 + /* find the flow structure for the flow id */ 2667 + error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr); 2668 + if (error) 2669 + goto end_function; 2291 2670 2292 - /* prepare the flow dma tables */ 2293 - error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, 2294 - command_args.virt_buff_data_addr, 2295 - flow_context_ptr, 2296 - &first_table_data, 2297 - &last_table_data, 2298 - command_args.isKernelVirtualAddress); 2299 - if (error) 2300 - goto end_function_with_error; 2671 + /* prepare the flow dma tables */ 2672 + error = sep_prepare_flow_dma_tables(command_args.num_virtual_buffers, command_args.virt_buff_data_addr, flow_context_ptr, &first_table_data, &last_table_data, command_args.isKernelVirtualAddress); 2673 + if (error) 2674 + goto end_function_with_error; 2301 2675 2302 - /* now check if there is already an existing add table for this flow */ 2303 - if (command_args.inputOutputFlag == SEP_DRIVER_IN_FLAG) { 2304 - /* this buffer was for input buffers */ 2305 - if (flow_context_ptr->input_tables_flag) { 2306 - /* add table already exists - add the new tables to the end 2307 - of the previous */ 2308 - num_entries = (flow_context_ptr->last_input_table.block_size >> 2309 - SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK; 2676 + /* now check if there is already an existing add table for this flow */ 2677 + if (command_args.inputOutputFlag == SEP_DRIVER_IN_FLAG) { 2678 + /* this buffer was for input buffers */ 2679 + if (flow_context_ptr->input_tables_flag) { 2680 + /* add table already exists - add the new tables to the end 2681 + of the previous */ 2682 + num_entries = (flow_context_ptr->last_input_table.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK; 2310 2683 2311 - info_entry_ptr = 2312 - (struct sep_lli_entry_t *) 2313 - (flow_context_ptr->last_input_table.physical_address + 2314 - (sizeof(struct sep_lli_entry_t) * (num_entries - 1))); 2684 + info_entry_ptr = (struct sep_lli_entry_t *) 2685 + (flow_context_ptr->last_input_table.physical_address + (sizeof(struct sep_lli_entry_t) * (num_entries - 1))); 2315 2686 2316 - /* connect to list of tables */ 2317 - *info_entry_ptr = first_table_data; 2687 + /* connect to list of tables */ 2688 + *info_entry_ptr = first_table_data; 2318 2689 2319 - /* set the first table data */ 2320 - first_table_data = flow_context_ptr->first_input_table; 2321 - } else { 2322 - /* set the input flag */ 2323 - flow_context_ptr->input_tables_flag = 1; 2690 + /* set the first table data */ 2691 + first_table_data = flow_context_ptr->first_input_table; 2692 + } else { 2693 + /* set the input flag */ 2694 + flow_context_ptr->input_tables_flag = 1; 2324 2695 2325 - /* set the first table data */ 2326 - flow_context_ptr->first_input_table = first_table_data; 2696 + /* set the first table data */ 2697 + flow_context_ptr->first_input_table = first_table_data; 2698 + } 2699 + /* set the last table data */ 2700 + flow_context_ptr->last_input_table = last_table_data; 2701 + } else { /* this is output tables */ 2702 + 2703 + /* this buffer was for input buffers */ 2704 + if (flow_context_ptr->output_tables_flag) { 2705 + /* add table already exists - add the new tables to 2706 + the end of the previous */ 2707 + num_entries = (flow_context_ptr->last_output_table.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK; 2708 + 2709 + info_entry_ptr = (struct sep_lli_entry_t *) 2710 + (flow_context_ptr->last_output_table.physical_address + (sizeof(struct sep_lli_entry_t) * (num_entries - 1))); 2711 + 2712 + /* connect to list of tables */ 2713 + *info_entry_ptr = first_table_data; 2714 + 2715 + /* set the first table data */ 2716 + first_table_data = flow_context_ptr->first_output_table; 2717 + } else { 2718 + /* set the input flag */ 2719 + flow_context_ptr->output_tables_flag = 1; 2720 + 2721 + /* set the first table data */ 2722 + flow_context_ptr->first_output_table = first_table_data; 2723 + } 2724 + /* set the last table data */ 2725 + flow_context_ptr->last_output_table = last_table_data; 2327 2726 } 2328 - /* set the last table data */ 2329 - flow_context_ptr->last_input_table = last_table_data; 2330 - } else /* this is output tables */ { 2331 - /* this buffer was for input buffers */ 2332 - if (flow_context_ptr->output_tables_flag) { 2333 - /* add table already exists - add the new tables to 2334 - the end of the previous */ 2335 - num_entries = (flow_context_ptr->last_output_table.block_size >> 2336 - SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK; 2337 2727 2338 - info_entry_ptr = 2339 - (struct sep_lli_entry_t *) 2340 - (flow_context_ptr->last_output_table.physical_address + 2341 - (sizeof(struct sep_lli_entry_t) * (num_entries - 1))); 2728 + /* set output params */ 2729 + command_args.first_table_addr = first_table_data.physical_address; 2730 + command_args.first_table_num_entries = ((first_table_data.block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK); 2731 + command_args.first_table_data_size = (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK); 2342 2732 2343 - /* connect to list of tables */ 2344 - *info_entry_ptr = first_table_data; 2733 + /* send the parameters to user application */ 2734 + error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_add_flow_table_t)); 2735 + if (error) 2736 + goto end_function_with_error; 2345 2737 2346 - /* set the first table data */ 2347 - first_table_data = flow_context_ptr->first_output_table; 2348 - } else { 2349 - /* set the input flag */ 2350 - flow_context_ptr->output_tables_flag = 1; 2738 + end_function_with_error: 2351 2739 2352 - /* set the first table data */ 2353 - flow_context_ptr->first_output_table = first_table_data; 2354 - } 2355 - /* set the last table data */ 2356 - flow_context_ptr->last_output_table = last_table_data; 2357 - } 2740 + /* free the allocated tables */ 2741 + sep_deallocated_flow_tables(&first_table_data); 2358 2742 2359 - /* set output params */ 2360 - command_args.first_table_addr = first_table_data.physical_address; 2361 - command_args.first_table_num_entries = ((first_table_data.block_size >> 2362 - SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK); 2363 - command_args.first_table_data_size = 2364 - (first_table_data.block_size & SEP_TABLE_DATA_SIZE_MASK); 2743 + end_function: 2365 2744 2366 - /* send the parameters to user application */ 2367 - error = copy_to_user((void *)arg, 2368 - &command_args, 2369 - sizeof(struct sep_driver_add_flow_table_t)); 2370 - if (error) 2371 - goto end_function_with_error; 2745 + dbg("SEP Driver:<-------- sep_add_flow_tables_handler end\n"); 2372 2746 2373 - end_function_with_error: 2374 - 2375 - /* free the allocated tables */ 2376 - sep_deallocated_flow_tables(&first_table_data); 2377 - 2378 - end_function: 2379 - 2380 - dbg("SEP Driver:<-------- sep_add_flow_tables_handler end\n"); 2381 - 2382 - return error; 2747 + return error; 2383 2748 } 2384 2749 2385 2750 /* ··· 2371 2768 */ 2372 2769 static int sep_add_flow_tables_message_handler(unsigned long arg) 2373 2770 { 2374 - /* error */ 2375 - int error; 2771 + /* error */ 2772 + int error; 2376 2773 2377 - /* arguments */ 2378 - struct sep_driver_add_message_t command_args; 2774 + /* arguments */ 2775 + struct sep_driver_add_message_t command_args; 2379 2776 2380 - /* flow context */ 2381 - struct sep_flow_context_t *flow_context_ptr; 2777 + /* flow context */ 2778 + struct sep_flow_context_t *flow_context_ptr; 2382 2779 2383 2780 /*---------------------------- 2384 2781 CODE 2385 2782 ------------------------------*/ 2386 2783 2387 - dbg("SEP Driver:--------> sep_add_flow_tables_message_handler start\n"); 2784 + dbg("SEP Driver:--------> sep_add_flow_tables_message_handler start\n"); 2388 2785 2389 - error = copy_from_user(&command_args, 2390 - (void *)arg, 2391 - sizeof(struct sep_driver_add_message_t)); 2392 - if (error) 2393 - goto end_function; 2786 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_add_message_t)); 2787 + if (error) 2788 + goto end_function; 2394 2789 2395 - /* check input */ 2396 - if (command_args.message_size_in_bytes > 2397 - SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES) { 2398 - error = -ENOMEM; 2399 - goto end_function; 2400 - } 2790 + /* check input */ 2791 + if (command_args.message_size_in_bytes > SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES) { 2792 + error = -ENOMEM; 2793 + goto end_function; 2794 + } 2401 2795 2402 - /* find the flow context */ 2403 - error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr); 2404 - if (error) 2405 - goto end_function; 2796 + /* find the flow context */ 2797 + error = sep_find_flow_context(command_args.flow_id, &flow_context_ptr); 2798 + if (error) 2799 + goto end_function; 2406 2800 2407 - /* copy the message into context */ 2408 - flow_context_ptr->message_size_in_bytes = command_args.message_size_in_bytes; 2801 + /* copy the message into context */ 2802 + flow_context_ptr->message_size_in_bytes = command_args.message_size_in_bytes; 2409 2803 2410 - error = copy_from_user(flow_context_ptr->message, 2411 - (void *)command_args.message_address, 2412 - command_args.message_size_in_bytes); 2804 + error = copy_from_user(flow_context_ptr->message, (void *) command_args.message_address, command_args.message_size_in_bytes); 2413 2805 2414 2806 2415 - end_function: 2807 + end_function: 2416 2808 2417 - dbg("SEP Driver:<-------- sep_add_flow_tables_message_handler end\n"); 2809 + dbg("SEP Driver:<-------- sep_add_flow_tables_message_handler end\n"); 2418 2810 2419 - return error; 2811 + return error; 2420 2812 } 2421 2813 2422 2814 ··· 2420 2822 */ 2421 2823 static int sep_get_static_pool_addr_handler(unsigned long arg) 2422 2824 { 2423 - /* error */ 2424 - int error; 2825 + /* error */ 2826 + int error; 2425 2827 2426 - /* command arguments */ 2427 - struct sep_driver_static_pool_addr_t command_args; 2828 + /* command arguments */ 2829 + struct sep_driver_static_pool_addr_t command_args; 2428 2830 2429 2831 /*----------------------------- 2430 2832 CODE 2431 2833 ------------------------------*/ 2432 2834 2433 - dbg("SEP Driver:--------> sep_get_static_pool_addr_handler start\n"); 2835 + dbg("SEP Driver:--------> sep_get_static_pool_addr_handler start\n"); 2434 2836 2435 - /*prepare the output parameters in the struct */ 2436 - command_args.physical_static_address = sep_dev->phys_shared_area_addr + 2437 - SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES; 2438 - command_args.virtual_static_address = sep_dev->shared_area_addr + 2439 - SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES; 2837 + /*prepare the output parameters in the struct */ 2838 + command_args.physical_static_address = sep_dev->phys_shared_area_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES; 2839 + command_args.virtual_static_address = sep_dev->shared_area_addr + SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES; 2440 2840 2441 - edbg("SEP Driver:physical_static_address is %08lx, virtual_static_address %08lx\n", 2442 - command_args.physical_static_address, 2443 - command_args.virtual_static_address); 2841 + edbg("SEP Driver:physical_static_address is %08lx, virtual_static_address %08lx\n", command_args.physical_static_address, command_args.virtual_static_address); 2444 2842 2445 - /* send the parameters to user application */ 2446 - error = copy_to_user((void *)arg, 2447 - &command_args, 2448 - sizeof(struct sep_driver_static_pool_addr_t)); 2449 - if (error) 2450 - goto end_function; 2843 + /* send the parameters to user application */ 2844 + error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_static_pool_addr_t)); 2845 + if (error) 2846 + goto end_function; 2451 2847 2452 - end_function: 2848 + end_function: 2453 2849 2454 - dbg("SEP Driver:<-------- sep_get_static_pool_addr_handler end\n"); 2850 + dbg("SEP Driver:<-------- sep_get_static_pool_addr_handler end\n"); 2455 2851 2456 - return error; 2852 + return error; 2457 2853 } 2458 2854 2459 2855 /* ··· 2456 2864 */ 2457 2865 static int sep_get_physical_mapped_offset_handler(unsigned long arg) 2458 2866 { 2459 - /* error */ 2460 - int error; 2867 + /* error */ 2868 + int error; 2461 2869 2462 - /* command arguments */ 2463 - struct sep_driver_get_mapped_offset_t command_args; 2870 + /* command arguments */ 2871 + struct sep_driver_get_mapped_offset_t command_args; 2464 2872 2465 2873 /*----------------------------- 2466 2874 CODE 2467 2875 ------------------------------*/ 2468 2876 2469 - dbg("SEP Driver:--------> sep_get_physical_mapped_offset_handler start\n"); 2877 + dbg("SEP Driver:--------> sep_get_physical_mapped_offset_handler start\n"); 2470 2878 2471 - error = copy_from_user(&command_args, 2472 - (void *)arg, 2473 - sizeof(struct sep_driver_get_mapped_offset_t)); 2474 - if (error) 2475 - goto end_function; 2879 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_get_mapped_offset_t)); 2880 + if (error) 2881 + goto end_function; 2476 2882 2477 - if (command_args.physical_address < sep_dev->phys_shared_area_addr) { 2478 - error = -ENOTTY; 2479 - goto end_function; 2480 - } 2883 + if (command_args.physical_address < sep_dev->phys_shared_area_addr) { 2884 + error = -ENOTTY; 2885 + goto end_function; 2886 + } 2481 2887 2482 - /*prepare the output parameters in the struct */ 2483 - command_args.offset = command_args.physical_address - 2484 - sep_dev->phys_shared_area_addr; 2888 + /*prepare the output parameters in the struct */ 2889 + command_args.offset = command_args.physical_address - sep_dev->phys_shared_area_addr; 2485 2890 2486 - edbg("SEP Driver:physical_address is %08lx, offset is %lu\n", 2487 - command_args.physical_address, 2488 - command_args.offset); 2891 + edbg("SEP Driver:physical_address is %08lx, offset is %lu\n", command_args.physical_address, command_args.offset); 2489 2892 2490 - /* send the parameters to user application */ 2491 - error = copy_to_user((void *)arg, 2492 - &command_args, 2493 - sizeof(struct sep_driver_get_mapped_offset_t)); 2494 - if (error) 2495 - goto end_function; 2893 + /* send the parameters to user application */ 2894 + error = copy_to_user((void *) arg, &command_args, sizeof(struct sep_driver_get_mapped_offset_t)); 2895 + if (error) 2896 + goto end_function; 2496 2897 2497 - end_function: 2898 + end_function: 2498 2899 2499 - dbg("SEP Driver:<-------- sep_get_physical_mapped_offset_handler end\n"); 2900 + dbg("SEP Driver:<-------- sep_get_physical_mapped_offset_handler end\n"); 2500 2901 2501 - return error; 2902 + return error; 2502 2903 } 2503 2904 2504 2905 ··· 2500 2915 */ 2501 2916 static int sep_start_handler(void) 2502 2917 { 2503 - /* reg val */ 2504 - unsigned long reg_val; 2918 + /* reg val */ 2919 + unsigned long reg_val; 2505 2920 2506 - /* error */ 2507 - unsigned long error; 2921 + /* error */ 2922 + unsigned long error; 2508 2923 2509 2924 /*----------------------------- 2510 2925 CODE 2511 2926 ------------------------------*/ 2512 2927 2513 - dbg("SEP Driver:--------> sep_start_handler start\n"); 2928 + dbg("SEP Driver:--------> sep_start_handler start\n"); 2514 2929 2515 - error = 0; 2930 + error = 0; 2516 2931 2517 - /* wait in polling for message from SEP */ 2518 - do { 2519 - reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); 2520 - } while (!reg_val); 2932 + /* wait in polling for message from SEP */ 2933 + do { 2934 + reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); 2935 + } while (!reg_val); 2521 2936 2522 - /* check the value */ 2523 - if (reg_val == 0x1) { 2524 - /* fatal error - read erro status from GPRO */ 2525 - error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 2526 - goto end_function; 2527 - } 2937 + /* check the value */ 2938 + if (reg_val == 0x1) { 2939 + /* fatal error - read erro status from GPRO */ 2940 + error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 2941 + goto end_function; 2942 + } 2528 2943 2529 - end_function: 2944 + end_function: 2530 2945 2531 - dbg("SEP Driver:<-------- sep_start_handler end\n"); 2946 + dbg("SEP Driver:<-------- sep_start_handler end\n"); 2532 2947 2533 - return error; 2948 + return error; 2534 2949 } 2535 2950 2536 2951 /* ··· 2538 2953 */ 2539 2954 static int sep_init_handler(unsigned long arg) 2540 2955 { 2541 - /* word from message */ 2542 - unsigned long message_word; 2956 + /* word from message */ 2957 + unsigned long message_word; 2543 2958 2544 - /* message ptr */ 2545 - unsigned long *message_ptr; 2959 + /* message ptr */ 2960 + unsigned long *message_ptr; 2546 2961 2547 - /* command arguments */ 2548 - struct sep_driver_init_t command_args; 2962 + /* command arguments */ 2963 + struct sep_driver_init_t command_args; 2549 2964 2550 - /* counter */ 2551 - unsigned long counter; 2965 + /* counter */ 2966 + unsigned long counter; 2552 2967 2553 - /* error */ 2554 - unsigned long error; 2968 + /* error */ 2969 + unsigned long error; 2555 2970 2556 - /* reg val */ 2557 - unsigned long reg_val; 2971 + /* reg val */ 2972 + unsigned long reg_val; 2558 2973 2559 2974 /*------------------- 2560 2975 CODE 2561 2976 ---------------------*/ 2562 2977 2563 - dbg("SEP Driver:--------> sep_init_handler start\n"); 2978 + dbg("SEP Driver:--------> sep_init_handler start\n"); 2564 2979 2565 - error = 0; 2980 + error = 0; 2566 2981 2567 - error = copy_from_user(&command_args, (void *)arg, 2568 - sizeof(struct sep_driver_init_t)); 2982 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_init_t)); 2569 2983 2570 - dbg("SEP Driver:--------> sep_init_handler - finished copy_from_user \n"); 2984 + dbg("SEP Driver:--------> sep_init_handler - finished copy_from_user \n"); 2571 2985 2572 - if (error) 2573 - goto end_function; 2986 + if (error) 2987 + goto end_function; 2574 2988 2575 - /* PATCH - configure the DMA to single -burst instead of multi-burst */ 2576 - /*sep_configure_dma_burst();*/ 2989 + /* PATCH - configure the DMA to single -burst instead of multi-burst */ 2990 + /*sep_configure_dma_burst(); */ 2577 2991 2578 - dbg("SEP Driver:--------> sep_init_handler - finished sep_configure_dma_burst \n"); 2992 + dbg("SEP Driver:--------> sep_init_handler - finished sep_configure_dma_burst \n"); 2579 2993 2580 - message_ptr = (unsigned long *)command_args.message_addr; 2994 + message_ptr = (unsigned long *) command_args.message_addr; 2581 2995 2582 - /* set the base address of the SRAM */ 2583 - sep_write_reg(sep_dev, HW_SRAM_ADDR_REG_ADDR, HW_CC_SRAM_BASE_ADDRESS); 2996 + /* set the base address of the SRAM */ 2997 + sep_write_reg(sep_dev, HW_SRAM_ADDR_REG_ADDR, HW_CC_SRAM_BASE_ADDRESS); 2584 2998 2585 - for (counter = 0 ; 2586 - counter < command_args.message_size_in_words; 2587 - counter++, message_ptr++) { 2588 - get_user(message_word, message_ptr); 2999 + for (counter = 0; counter < command_args.message_size_in_words; counter++, message_ptr++) { 3000 + get_user(message_word, message_ptr); 2589 3001 2590 - /* write data to SRAM */ 2591 - sep_write_reg(sep_dev, HW_SRAM_DATA_REG_ADDR, 2592 - message_word); 3002 + /* write data to SRAM */ 3003 + sep_write_reg(sep_dev, HW_SRAM_DATA_REG_ADDR, message_word); 2593 3004 2594 - edbg( 2595 - "SEP Driver:message_word is %lu\n", 2596 - message_word); 3005 + edbg("SEP Driver:message_word is %lu\n", message_word); 2597 3006 2598 3007 /* wait for write complete */ 2599 - sep_wait_sram_write(sep_dev); 2600 - } 3008 + sep_wait_sram_write(sep_dev); 3009 + } 2601 3010 2602 - dbg("SEP Driver:--------> sep_init_handler - finished getting messages from user space\n"); 3011 + dbg("SEP Driver:--------> sep_init_handler - finished getting messages from user space\n"); 2603 3012 2604 - /* signal SEP */ 2605 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 2606 - 0x1); 3013 + /* signal SEP */ 3014 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x1); 2607 3015 2608 - do { 2609 - reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); 2610 - } while (!(reg_val & 0xFFFFFFFD)); 3016 + do { 3017 + reg_val = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR3_REG_ADDR); 3018 + } while (!(reg_val & 0xFFFFFFFD)); 2611 3019 2612 - dbg("SEP Driver:--------> sep_init_handler - finished waiting for reg_val & 0xFFFFFFFD \n"); 3020 + dbg("SEP Driver:--------> sep_init_handler - finished waiting for reg_val & 0xFFFFFFFD \n"); 2613 3021 2614 - /* check the value */ 2615 - if (reg_val == 0x1) { 2616 - edbg( 2617 - "SEP Driver:init failed\n"); 3022 + /* check the value */ 3023 + if (reg_val == 0x1) { 3024 + edbg("SEP Driver:init failed\n"); 2618 3025 2619 - error = sep_read_reg(sep_dev, 0x8060); 2620 - edbg( 2621 - "SEP Driver:sw monitor is %lu\n", 2622 - error); 3026 + error = sep_read_reg(sep_dev, 0x8060); 3027 + edbg("SEP Driver:sw monitor is %lu\n", error); 2623 3028 2624 - /* fatal error - read erro status from GPRO */ 2625 - error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 2626 - edbg( 2627 - "SEP Driver:error is %lu\n", error); 2628 - goto end_function; 2629 - } 3029 + /* fatal error - read erro status from GPRO */ 3030 + error = sep_read_reg(sep_dev, HW_HOST_SEP_HOST_GPR0_REG_ADDR); 3031 + edbg("SEP Driver:error is %lu\n", error); 3032 + goto end_function; 3033 + } 2630 3034 2631 - end_function: 3035 + end_function: 2632 3036 2633 - dbg("SEP Driver:<-------- sep_init_handler end\n"); 3037 + dbg("SEP Driver:<-------- sep_init_handler end\n"); 2634 3038 2635 - return error; 3039 + return error; 2636 3040 2637 3041 } 2638 3042 ··· 2630 3056 */ 2631 3057 static int sep_realloc_cache_resident_handler(unsigned long arg) 2632 3058 { 2633 - /* error */ 2634 - int error; 3059 + /* error */ 3060 + int error; 2635 3061 2636 - /* physical cache addr */ 2637 - unsigned long phys_cache_address; 3062 + /* physical cache addr */ 3063 + unsigned long phys_cache_address; 2638 3064 2639 - /* physical resident addr */ 2640 - unsigned long phys_resident_address; 3065 + /* physical resident addr */ 3066 + unsigned long phys_resident_address; 2641 3067 2642 - /* command arguments */ 2643 - struct sep_driver_realloc_cache_resident_t command_args; 3068 + /* command arguments */ 3069 + struct sep_driver_realloc_cache_resident_t command_args; 2644 3070 2645 3071 /*------------------ 2646 3072 CODE 2647 3073 ---------------------*/ 2648 3074 2649 - /* copy the data */ 2650 - error = copy_from_user(&command_args, 2651 - (void *)arg, 2652 - sizeof(struct sep_driver_realloc_cache_resident_t)); 2653 - if (error) 2654 - goto end_function; 3075 + /* copy the data */ 3076 + error = copy_from_user(&command_args, (void *) arg, sizeof(struct sep_driver_realloc_cache_resident_t)); 3077 + if (error) 3078 + goto end_function; 2655 3079 2656 - /* copy cache and resident to the their intended locations */ 2657 - error = sep_copy_cache_resident_to_area(command_args.cache_addr, 2658 - command_args.cache_size_in_bytes, 2659 - command_args.resident_addr, 2660 - command_args.resident_size_in_bytes, 2661 - &phys_cache_address, 2662 - &phys_resident_address); 2663 - if (error) 2664 - goto end_function; 3080 + /* copy cache and resident to the their intended locations */ 3081 + error = sep_copy_cache_resident_to_area(command_args.cache_addr, command_args.cache_size_in_bytes, command_args.resident_addr, command_args.resident_size_in_bytes, &phys_cache_address, &phys_resident_address); 3082 + if (error) 3083 + goto end_function; 2665 3084 2666 - /* lock the area (if needed) */ 2667 - sep_lock_cache_resident_area(); 3085 + /* lock the area (if needed) */ 3086 + sep_lock_cache_resident_area(); 2668 3087 2669 - command_args.new_base_addr = sep_dev->phys_shared_area_addr; 3088 + command_args.new_base_addr = sep_dev->phys_shared_area_addr; 2670 3089 2671 - /* find the new base address according to the lowest address between 2672 - cache, resident and shared area */ 2673 - if (phys_resident_address < command_args.new_base_addr) 2674 - command_args.new_base_addr = phys_resident_address; 2675 - if (phys_cache_address < command_args.new_base_addr) 2676 - command_args.new_base_addr = phys_cache_address; 3090 + /* find the new base address according to the lowest address between 3091 + cache, resident and shared area */ 3092 + if (phys_resident_address < command_args.new_base_addr) 3093 + command_args.new_base_addr = phys_resident_address; 3094 + if (phys_cache_address < command_args.new_base_addr) 3095 + command_args.new_base_addr = phys_cache_address; 2677 3096 2678 - /* set the return parameters */ 2679 - command_args.new_cache_addr = phys_cache_address; 2680 - command_args.new_resident_addr = phys_resident_address; 3097 + /* set the return parameters */ 3098 + command_args.new_cache_addr = phys_cache_address; 3099 + command_args.new_resident_addr = phys_resident_address; 2681 3100 2682 3101 2683 - /* set the new shared area */ 2684 - command_args.new_shared_area_addr = sep_dev->phys_shared_area_addr; 3102 + /* set the new shared area */ 3103 + command_args.new_shared_area_addr = sep_dev->phys_shared_area_addr; 2685 3104 2686 - edbg( 2687 - "SEP Driver:command_args.new_shared_area_addr is %08lx\n", 2688 - command_args.new_shared_area_addr); 2689 - edbg( 2690 - "SEP Driver:command_args.new_base_addr is %08lx\n", 2691 - command_args.new_base_addr); 2692 - edbg( 2693 - "SEP Driver:command_args.new_resident_addr is %08lx\n", 2694 - command_args.new_resident_addr); 2695 - edbg( 2696 - "SEP Driver:command_args.new_cache_addr is %08lx\n", 2697 - command_args.new_cache_addr); 3105 + edbg("SEP Driver:command_args.new_shared_area_addr is %08lx\n", command_args.new_shared_area_addr); 3106 + edbg("SEP Driver:command_args.new_base_addr is %08lx\n", command_args.new_base_addr); 3107 + edbg("SEP Driver:command_args.new_resident_addr is %08lx\n", command_args.new_resident_addr); 3108 + edbg("SEP Driver:command_args.new_cache_addr is %08lx\n", command_args.new_cache_addr); 2698 3109 2699 - /* return to user */ 2700 - error = copy_to_user((void *)arg, 2701 - (void *)&command_args, 2702 - sizeof(struct sep_driver_realloc_cache_resident_t)); 3110 + /* return to user */ 3111 + error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_realloc_cache_resident_t)); 2703 3112 2704 - end_function: 3113 + end_function: 2705 3114 2706 - return error; 3115 + return error; 2707 3116 } 2708 3117 2709 3118 /* ··· 2694 3137 */ 2695 3138 static int sep_get_time_handler(unsigned long arg) 2696 3139 { 2697 - /* error */ 2698 - int error; 3140 + /* error */ 3141 + int error; 2699 3142 2700 - /* command arguments */ 2701 - struct sep_driver_get_time_t command_args; 3143 + /* command arguments */ 3144 + struct sep_driver_get_time_t command_args; 2702 3145 2703 3146 /*------------------------ 2704 3147 CODE 2705 3148 --------------------------*/ 2706 3149 2707 - error = sep_set_time(&command_args.time_physical_address, 2708 - &command_args.time_value); 3150 + error = sep_set_time(&command_args.time_physical_address, &command_args.time_value); 2709 3151 2710 - /* return to user */ 2711 - error = copy_to_user((void *)arg, 2712 - (void *)&command_args, 2713 - sizeof(struct sep_driver_get_time_t)); 3152 + /* return to user */ 3153 + error = copy_to_user((void *) arg, (void *) &command_args, sizeof(struct sep_driver_get_time_t)); 2714 3154 2715 - return error; 3155 + return error; 2716 3156 2717 3157 } 2718 3158 ··· 2718 3164 */ 2719 3165 static int sep_set_api_mode_handler(unsigned long arg) 2720 3166 { 2721 - /* error */ 2722 - int error; 3167 + /* error */ 3168 + int error; 2723 3169 2724 - /* flag */ 2725 - unsigned long mode_flag; 3170 + /* flag */ 3171 + unsigned long mode_flag; 2726 3172 2727 3173 /*---------------------------- 2728 3174 CODE 2729 3175 -----------------------------*/ 2730 3176 2731 - dbg("SEP Driver:--------> sep_set_api_mode_handler start\n"); 3177 + dbg("SEP Driver:--------> sep_set_api_mode_handler start\n"); 2732 3178 2733 - error = get_user( 2734 - mode_flag, &(((struct sep_driver_set_api_mode_t *)arg)->mode)); 2735 - if (error) 2736 - goto end_function; 3179 + error = get_user(mode_flag, &(((struct sep_driver_set_api_mode_t *) arg)->mode)); 3180 + if (error) 3181 + goto end_function; 2737 3182 2738 - /* set the global flag */ 2739 - sep_dev->block_mode_flag = mode_flag; 3183 + /* set the global flag */ 3184 + sep_dev->block_mode_flag = mode_flag; 2740 3185 2741 3186 2742 - end_function: 3187 + end_function: 2743 3188 2744 - dbg("SEP Driver:<-------- sep_set_api_mode_handler end\n"); 3189 + dbg("SEP Driver:<-------- sep_set_api_mode_handler end\n"); 2745 3190 2746 - return error; 3191 + return error; 2747 3192 } 2748 3193 2749 3194 /* ··· 2754 3201 CODE 2755 3202 -----------------------------*/ 2756 3203 2757 - dbg("SEP Driver:--------> sep_end_transaction_handler start\n"); 3204 + dbg("SEP Driver:--------> sep_end_transaction_handler start\n"); 2758 3205 2759 - #if 0/*!SEP_DRIVER_POLLING_MODE*/ 2760 - /* close IMR */ 2761 - sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF); 3206 + #if 0 /*!SEP_DRIVER_POLLING_MODE */ 3207 + /* close IMR */ 3208 + sep_write_reg(sep_dev, HW_HOST_IMR_REG_ADDR, 0x7FFF); 2762 3209 2763 - /* release IRQ line */ 2764 - free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address); 3210 + /* release IRQ line */ 3211 + free_irq(SEP_DIRVER_IRQ_NUM, &sep_dev->reg_base_address); 2765 3212 2766 - /* lock the sep mutex */ 2767 - mutex_unlock(&sep_mutex); 3213 + /* lock the sep mutex */ 3214 + mutex_unlock(&sep_mutex); 2768 3215 #endif 2769 3216 2770 - dbg("SEP Driver:<-------- sep_end_transaction_handler end\n"); 3217 + dbg("SEP Driver:<-------- sep_end_transaction_handler end\n"); 2771 3218 2772 - return 0; 3219 + return 0; 2773 3220 } 2774 3221 2775 3222 /* handler for flow done interrupt */ 2776 - static void sep_flow_done_handler(struct work_struct *work) 3223 + static void sep_flow_done_handler(struct work_struct *work) 2777 3224 { 2778 - /* flow context_ptr */ 2779 - struct sep_flow_context_t *flow_data_ptr; 3225 + /* flow context_ptr */ 3226 + struct sep_flow_context_t *flow_data_ptr; 2780 3227 /*------------------------- 2781 3228 CODE 2782 3229 ---------------------------*/ 2783 3230 2784 - /* obtain the mutex */ 2785 - mutex_lock(&sep_mutex); 3231 + /* obtain the mutex */ 3232 + mutex_lock(&sep_mutex); 2786 3233 2787 - /* get the pointer to context */ 2788 - flow_data_ptr = (struct sep_flow_context_t *)work; 3234 + /* get the pointer to context */ 3235 + flow_data_ptr = (struct sep_flow_context_t *) work; 2789 3236 2790 - /* free all the current input tables in sep */ 2791 - sep_deallocated_flow_tables(&flow_data_ptr->input_tables_in_process); 3237 + /* free all the current input tables in sep */ 3238 + sep_deallocated_flow_tables(&flow_data_ptr->input_tables_in_process); 2792 3239 2793 - /* free all the current tables output tables in SEP (if needed) */ 2794 - if (flow_data_ptr->output_tables_in_process.physical_address != 0xffffffff) 2795 - sep_deallocated_flow_tables(&flow_data_ptr->output_tables_in_process); 3240 + /* free all the current tables output tables in SEP (if needed) */ 3241 + if (flow_data_ptr->output_tables_in_process.physical_address != 0xffffffff) 3242 + sep_deallocated_flow_tables(&flow_data_ptr->output_tables_in_process); 2796 3243 2797 - /* check if we have additional tables to be sent to SEP only input 2798 - flag may be checked */ 2799 - if (flow_data_ptr->input_tables_flag) { 2800 - /* copy the message to the shared RAM and signal SEP */ 2801 - memcpy((void *)flow_data_ptr->message, 2802 - (void *)sep_dev->shared_area_addr, 2803 - flow_data_ptr->message_size_in_bytes); 3244 + /* check if we have additional tables to be sent to SEP only input 3245 + flag may be checked */ 3246 + if (flow_data_ptr->input_tables_flag) { 3247 + /* copy the message to the shared RAM and signal SEP */ 3248 + memcpy((void *) flow_data_ptr->message, (void *) sep_dev->shared_area_addr, flow_data_ptr->message_size_in_bytes); 2804 3249 2805 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 0x2); 2806 - } 2807 - mutex_unlock(&sep_mutex); 3250 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR2_REG_ADDR, 0x2); 3251 + } 3252 + mutex_unlock(&sep_mutex); 2808 3253 } 2809 3254 2810 3255 ··· 2811 3260 the first and last tables of the list 2812 3261 */ 2813 3262 static int sep_prepare_flow_dma_tables(unsigned long num_virtual_buffers, 2814 - unsigned long first_buff_addr, 2815 - struct sep_flow_context_t *flow_data_ptr, 2816 - struct sep_lli_entry_t *first_table_data_ptr, 2817 - struct sep_lli_entry_t *last_table_data_ptr, 2818 - bool isKernelVirtualAddress) 3263 + unsigned long first_buff_addr, struct sep_flow_context_t *flow_data_ptr, struct sep_lli_entry_t *first_table_data_ptr, struct sep_lli_entry_t *last_table_data_ptr, bool isKernelVirtualAddress) 2819 3264 { 2820 - /* error */ 2821 - int error; 3265 + /* error */ 3266 + int error; 2822 3267 2823 - /* virtaul address of one buffer */ 2824 - unsigned long virt_buff_addr; 3268 + /* virtaul address of one buffer */ 3269 + unsigned long virt_buff_addr; 2825 3270 2826 - /* virtual size of one buffer */ 2827 - unsigned long virt_buff_size; 3271 + /* virtual size of one buffer */ 3272 + unsigned long virt_buff_size; 2828 3273 2829 - /* table data for each created table */ 2830 - struct sep_lli_entry_t table_data; 3274 + /* table data for each created table */ 3275 + struct sep_lli_entry_t table_data; 2831 3276 2832 - /* info entry */ 2833 - struct sep_lli_entry_t *info_entry_ptr; 3277 + /* info entry */ 3278 + struct sep_lli_entry_t *info_entry_ptr; 2834 3279 2835 - /* prevouis info entry */ 2836 - struct sep_lli_entry_t *prev_info_entry_ptr; 3280 + /* prevouis info entry */ 3281 + struct sep_lli_entry_t *prev_info_entry_ptr; 2837 3282 2838 - /* counter */ 2839 - unsigned long i; 3283 + /* counter */ 3284 + unsigned long i; 2840 3285 2841 3286 /*------------------------------- 2842 3287 CODE 2843 3288 ----------------------------------*/ 2844 3289 2845 - /* init vars */ 2846 - error = 0; 2847 - prev_info_entry_ptr = 0; 3290 + /* init vars */ 3291 + error = 0; 3292 + prev_info_entry_ptr = 0; 2848 3293 2849 - /* init the first table to default */ 2850 - table_data.physical_address = 0xffffffff; 2851 - first_table_data_ptr->physical_address = 0xffffffff; 2852 - table_data.block_size = 0; 3294 + /* init the first table to default */ 3295 + table_data.physical_address = 0xffffffff; 3296 + first_table_data_ptr->physical_address = 0xffffffff; 3297 + table_data.block_size = 0; 2853 3298 2854 - for (i = 0; i < num_virtual_buffers; i++) { 2855 - /* get the virtual buffer address */ 2856 - error = get_user(virt_buff_addr, &first_buff_addr); 2857 - if (error) 2858 - goto end_function; 3299 + for (i = 0; i < num_virtual_buffers; i++) { 3300 + /* get the virtual buffer address */ 3301 + error = get_user(virt_buff_addr, &first_buff_addr); 3302 + if (error) 3303 + goto end_function; 2859 3304 2860 - /* get the virtual buffer size */ 2861 - first_buff_addr++; 2862 - error = get_user(virt_buff_size, &first_buff_addr); 2863 - if (error) 2864 - goto end_function; 3305 + /* get the virtual buffer size */ 3306 + first_buff_addr++; 3307 + error = get_user(virt_buff_size, &first_buff_addr); 3308 + if (error) 3309 + goto end_function; 2865 3310 2866 - /* advance the address to point to the next pair of address|size */ 2867 - first_buff_addr++; 3311 + /* advance the address to point to the next pair of address|size */ 3312 + first_buff_addr++; 2868 3313 2869 - /* now prepare the one flow LLI table from the data */ 2870 - error = sep_prepare_one_flow_dma_table(virt_buff_addr, 2871 - virt_buff_size, 2872 - &table_data, 2873 - &info_entry_ptr, 2874 - flow_data_ptr, 2875 - isKernelVirtualAddress); 2876 - if (error) 2877 - goto end_function; 3314 + /* now prepare the one flow LLI table from the data */ 3315 + error = sep_prepare_one_flow_dma_table(virt_buff_addr, virt_buff_size, &table_data, &info_entry_ptr, flow_data_ptr, isKernelVirtualAddress); 3316 + if (error) 3317 + goto end_function; 2878 3318 2879 - if (i == 0) { 2880 - /* if this is the first table - save it to return to the user 2881 - application */ 2882 - *first_table_data_ptr = table_data; 3319 + if (i == 0) { 3320 + /* if this is the first table - save it to return to the user 3321 + application */ 3322 + *first_table_data_ptr = table_data; 2883 3323 2884 - /* set the pointer to info entry */ 2885 - prev_info_entry_ptr = info_entry_ptr; 2886 - } else { 2887 - /* not first table - the previous table info entry should 2888 - be updated */ 2889 - prev_info_entry_ptr->block_size = 2890 - (0x1 << SEP_INT_FLAG_OFFSET_IN_BITS) | 2891 - (table_data.block_size); 3324 + /* set the pointer to info entry */ 3325 + prev_info_entry_ptr = info_entry_ptr; 3326 + } else { 3327 + /* not first table - the previous table info entry should 3328 + be updated */ 3329 + prev_info_entry_ptr->block_size = (0x1 << SEP_INT_FLAG_OFFSET_IN_BITS) | (table_data.block_size); 2892 3330 2893 - /* set the pointer to info entry */ 2894 - prev_info_entry_ptr = info_entry_ptr; 3331 + /* set the pointer to info entry */ 3332 + prev_info_entry_ptr = info_entry_ptr; 3333 + } 2895 3334 } 2896 - } 2897 3335 2898 - /* set the last table data */ 2899 - *last_table_data_ptr = table_data; 3336 + /* set the last table data */ 3337 + *last_table_data_ptr = table_data; 2900 3338 2901 - end_function: 3339 + end_function: 2902 3340 2903 - return error; 3341 + return error; 2904 3342 } 2905 3343 2906 3344 ··· 2897 3357 This function creates one DMA table for flow and returns its data, 2898 3358 and pointer to its info entry 2899 3359 */ 2900 - static int sep_prepare_one_flow_dma_table( 2901 - unsigned long virt_buff_addr, 2902 - unsigned long virt_buff_size, 2903 - struct sep_lli_entry_t *table_data, 2904 - struct sep_lli_entry_t **info_entry_ptr, 2905 - struct sep_flow_context_t *flow_data_ptr, 2906 - bool isKernelVirtualAddress) 3360 + static int sep_prepare_one_flow_dma_table(unsigned long virt_buff_addr, unsigned long virt_buff_size, struct sep_lli_entry_t *table_data, struct sep_lli_entry_t **info_entry_ptr, struct sep_flow_context_t *flow_data_ptr, bool isKernelVirtualAddress) 2907 3361 { 2908 - /* error */ 2909 - int error; 3362 + /* error */ 3363 + int error; 2910 3364 2911 - /* the range in pages */ 2912 - unsigned long lli_array_size; 3365 + /* the range in pages */ 3366 + unsigned long lli_array_size; 2913 3367 2914 - /* array of pointers ot page */ 2915 - struct sep_lli_entry_t *lli_array; 3368 + /* array of pointers ot page */ 3369 + struct sep_lli_entry_t *lli_array; 2916 3370 2917 - /* pointer to the entry in the dma table */ 2918 - struct sep_lli_entry_t *flow_dma_table_entry_ptr; 3371 + /* pointer to the entry in the dma table */ 3372 + struct sep_lli_entry_t *flow_dma_table_entry_ptr; 2919 3373 2920 - /* address of the dma table */ 2921 - unsigned long *start_dma_table_ptr; 3374 + /* address of the dma table */ 3375 + unsigned long *start_dma_table_ptr; 2922 3376 2923 - /* total table data counter */ 2924 - unsigned long dma_table_data_count; 3377 + /* total table data counter */ 3378 + unsigned long dma_table_data_count; 2925 3379 2926 - /* pointer that will keep the pointer t the pages of the virtual buffer */ 2927 - struct page **page_array_ptr; 3380 + /* pointer that will keep the pointer t the pages of the virtual buffer */ 3381 + struct page **page_array_ptr; 2928 3382 2929 - /* counter */ 2930 - unsigned long entry_count; 3383 + /* counter */ 3384 + unsigned long entry_count; 2931 3385 2932 3386 /*------------------------------- 2933 3387 CODE 2934 3388 ----------------------------------*/ 2935 3389 2936 - /* find the space for the new table */ 2937 - error = sep_find_free_flow_dma_table_space(&start_dma_table_ptr); 2938 - if (error) 2939 - goto end_function; 3390 + /* find the space for the new table */ 3391 + error = sep_find_free_flow_dma_table_space(&start_dma_table_ptr); 3392 + if (error) 3393 + goto end_function; 2940 3394 2941 - /* check if the pages are in Kernel Virtual Address layout */ 2942 - if (isKernelVirtualAddress == true) 2943 - /* lock kernel buffer in the memory */ 2944 - error = sep_lock_kernel_pages(virt_buff_addr, 2945 - virt_buff_size, 2946 - &lli_array_size, 2947 - &lli_array, 2948 - &page_array_ptr); 2949 - else 2950 - /* lock user buffer in the memory */ 2951 - error = sep_lock_user_pages(virt_buff_addr, 2952 - virt_buff_size, 2953 - &lli_array_size, 2954 - &lli_array, 2955 - &page_array_ptr); 3395 + /* check if the pages are in Kernel Virtual Address layout */ 3396 + if (isKernelVirtualAddress == true) 3397 + /* lock kernel buffer in the memory */ 3398 + error = sep_lock_kernel_pages(virt_buff_addr, virt_buff_size, &lli_array_size, &lli_array, &page_array_ptr); 3399 + else 3400 + /* lock user buffer in the memory */ 3401 + error = sep_lock_user_pages(virt_buff_addr, virt_buff_size, &lli_array_size, &lli_array, &page_array_ptr); 2956 3402 2957 - if (error) 2958 - goto end_function; 3403 + if (error) 3404 + goto end_function; 2959 3405 2960 - /* set the pointer to page array at the beginning of table - this table is 2961 - now considered taken */ 2962 - *start_dma_table_ptr = lli_array_size; 3406 + /* set the pointer to page array at the beginning of table - this table is 3407 + now considered taken */ 3408 + *start_dma_table_ptr = lli_array_size; 2963 3409 2964 - /* point to the place of the pages pointers of the table */ 2965 - start_dma_table_ptr++; 3410 + /* point to the place of the pages pointers of the table */ 3411 + start_dma_table_ptr++; 2966 3412 2967 - /* set the pages pointer */ 2968 - *start_dma_table_ptr = (unsigned long)page_array_ptr; 3413 + /* set the pages pointer */ 3414 + *start_dma_table_ptr = (unsigned long) page_array_ptr; 2969 3415 2970 - /* set the pointer to the first entry */ 2971 - flow_dma_table_entry_ptr = (struct sep_lli_entry_t *)(++start_dma_table_ptr); 3416 + /* set the pointer to the first entry */ 3417 + flow_dma_table_entry_ptr = (struct sep_lli_entry_t *) (++start_dma_table_ptr); 2972 3418 2973 - /* now create the entries for table */ 2974 - for (dma_table_data_count = entry_count = 0; 2975 - entry_count < lli_array_size; 2976 - entry_count++) { 2977 - flow_dma_table_entry_ptr->physical_address = 2978 - lli_array[entry_count].physical_address; 3419 + /* now create the entries for table */ 3420 + for (dma_table_data_count = entry_count = 0; entry_count < lli_array_size; entry_count++) { 3421 + flow_dma_table_entry_ptr->physical_address = lli_array[entry_count].physical_address; 2979 3422 2980 - flow_dma_table_entry_ptr->block_size = 2981 - lli_array[entry_count].block_size; 3423 + flow_dma_table_entry_ptr->block_size = lli_array[entry_count].block_size; 2982 3424 2983 - /* set the total data of a table */ 2984 - dma_table_data_count += lli_array[entry_count].block_size; 3425 + /* set the total data of a table */ 3426 + dma_table_data_count += lli_array[entry_count].block_size; 2985 3427 2986 - flow_dma_table_entry_ptr++; 2987 - } 3428 + flow_dma_table_entry_ptr++; 3429 + } 2988 3430 2989 - /* set the physical address */ 2990 - table_data->physical_address = virt_to_phys(start_dma_table_ptr); 3431 + /* set the physical address */ 3432 + table_data->physical_address = virt_to_phys(start_dma_table_ptr); 2991 3433 2992 - /* set the num_entries and total data size */ 2993 - table_data->block_size = ((lli_array_size + 1) << 2994 - SEP_NUM_ENTRIES_OFFSET_IN_BITS) | 2995 - (dma_table_data_count); 3434 + /* set the num_entries and total data size */ 3435 + table_data->block_size = ((lli_array_size + 1) << SEP_NUM_ENTRIES_OFFSET_IN_BITS) | (dma_table_data_count); 2996 3436 2997 - /* set the info entry */ 2998 - flow_dma_table_entry_ptr->physical_address = 0xffffffff; 2999 - flow_dma_table_entry_ptr->block_size = 0; 3437 + /* set the info entry */ 3438 + flow_dma_table_entry_ptr->physical_address = 0xffffffff; 3439 + flow_dma_table_entry_ptr->block_size = 0; 3000 3440 3001 - /* set the pointer to info entry */ 3002 - *info_entry_ptr = flow_dma_table_entry_ptr; 3441 + /* set the pointer to info entry */ 3442 + *info_entry_ptr = flow_dma_table_entry_ptr; 3003 3443 3004 - /* the array of the lli entries */ 3005 - kfree(lli_array); 3444 + /* the array of the lli entries */ 3445 + kfree(lli_array); 3006 3446 3007 - end_function: 3447 + end_function: 3008 3448 3009 - return error; 3449 + return error; 3010 3450 } 3011 3451 3012 3452 ··· 2994 3474 This function returns pointer to the flow data structure 2995 3475 that conatins the given id 2996 3476 */ 2997 - static int sep_find_flow_context( 2998 - unsigned long flow_id, 2999 - struct sep_flow_context_t **flow_data_ptr) 3477 + static int sep_find_flow_context(unsigned long flow_id, struct sep_flow_context_t **flow_data_ptr) 3000 3478 { 3001 - /* count */ 3002 - unsigned long count; 3479 + /* count */ 3480 + unsigned long count; 3003 3481 3004 - /* error */ 3005 - int error; 3482 + /* error */ 3483 + int error; 3006 3484 3007 3485 /*----------------------- 3008 3486 CODE 3009 3487 ---------------------------*/ 3010 3488 3011 - error = 0; 3489 + error = 0; 3012 3490 3013 - /* 3014 - always search for flow with id default first - in case we 3015 - already started working on the flow there can be no situation 3016 - when 2 flows are with default flag 3017 - */ 3018 - for (count = 0; count < SEP_DRIVER_NUM_FLOWS; count++) { 3019 - if (sep_dev->flows_data_array[count].flow_id == flow_id) { 3020 - *flow_data_ptr = &sep_dev->flows_data_array[count]; 3021 - break; 3491 + /* 3492 + always search for flow with id default first - in case we 3493 + already started working on the flow there can be no situation 3494 + when 2 flows are with default flag 3495 + */ 3496 + for (count = 0; count < SEP_DRIVER_NUM_FLOWS; count++) { 3497 + if (sep_dev->flows_data_array[count].flow_id == flow_id) { 3498 + *flow_data_ptr = &sep_dev->flows_data_array[count]; 3499 + break; 3500 + } 3022 3501 } 3023 - } 3024 3502 3025 - if (count == SEP_DRIVER_NUM_FLOWS) 3026 - /* no flow found */ 3027 - error = -ENOMEM; 3503 + if (count == SEP_DRIVER_NUM_FLOWS) 3504 + /* no flow found */ 3505 + error = -ENOMEM; 3028 3506 3029 - return error; 3507 + return error; 3030 3508 } 3031 3509 3032 3510 /* 3033 3511 this function find a space for the new flow dma table 3034 3512 */ 3035 - static int sep_find_free_flow_dma_table_space( 3036 - unsigned long **table_address_ptr) 3513 + static int sep_find_free_flow_dma_table_space(unsigned long **table_address_ptr) 3037 3514 { 3038 - /* error */ 3039 - int error; 3515 + /* error */ 3516 + int error; 3040 3517 3041 - /* pointer to the id field of the flow dma table */ 3042 - unsigned long *start_table_ptr; 3518 + /* pointer to the id field of the flow dma table */ 3519 + unsigned long *start_table_ptr; 3043 3520 3044 - /* start address of the flow dma area */ 3045 - unsigned long flow_dma_area_start_addr; 3521 + /* start address of the flow dma area */ 3522 + unsigned long flow_dma_area_start_addr; 3046 3523 3047 - /* end address of the flow dma area */ 3048 - unsigned long flow_dma_area_end_addr; 3524 + /* end address of the flow dma area */ 3525 + unsigned long flow_dma_area_end_addr; 3049 3526 3050 - /* maximum table size in words */ 3051 - unsigned long table_size_in_words; 3527 + /* maximum table size in words */ 3528 + unsigned long table_size_in_words; 3052 3529 3053 3530 /*--------------------- 3054 3531 CODE 3055 3532 -----------------------*/ 3056 3533 3057 - error = 0; 3534 + error = 0; 3058 3535 3059 - /* find the start address of the flow DMA table area */ 3060 - flow_dma_area_start_addr = sep_dev->shared_area_addr + 3061 - SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES; 3536 + /* find the start address of the flow DMA table area */ 3537 + flow_dma_area_start_addr = sep_dev->shared_area_addr + SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES; 3062 3538 3063 - /* set end address of the flow table area */ 3064 - flow_dma_area_end_addr = flow_dma_area_start_addr + 3065 - SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES; 3539 + /* set end address of the flow table area */ 3540 + flow_dma_area_end_addr = flow_dma_area_start_addr + SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES; 3066 3541 3067 - /* set table size in words */ 3068 - table_size_in_words = SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE * 3069 - (sizeof(struct sep_lli_entry_t) / sizeof(long)) + 2; 3542 + /* set table size in words */ 3543 + table_size_in_words = SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE * (sizeof(struct sep_lli_entry_t) / sizeof(long)) + 2; 3070 3544 3071 - /* set the pointer to the start address of DMA area */ 3072 - start_table_ptr = (unsigned long *)flow_dma_area_start_addr; 3545 + /* set the pointer to the start address of DMA area */ 3546 + start_table_ptr = (unsigned long *) flow_dma_area_start_addr; 3073 3547 3074 - /* find the space for the next table */ 3075 - while (((*start_table_ptr & 0x7FFFFFFF) != 0) && 3076 - ((unsigned long)start_table_ptr < 3077 - flow_dma_area_end_addr)) 3078 - start_table_ptr += table_size_in_words; 3548 + /* find the space for the next table */ 3549 + while (((*start_table_ptr & 0x7FFFFFFF) != 0) && ((unsigned long) start_table_ptr < flow_dma_area_end_addr)) 3550 + start_table_ptr += table_size_in_words; 3079 3551 3080 - /* check if we reached the end of floa tables area */ 3081 - if ((unsigned long)start_table_ptr >= flow_dma_area_end_addr) 3082 - error = -1; 3083 - else 3084 - *table_address_ptr = start_table_ptr; 3552 + /* check if we reached the end of floa tables area */ 3553 + if ((unsigned long) start_table_ptr >= flow_dma_area_end_addr) 3554 + error = -1; 3555 + else 3556 + *table_address_ptr = start_table_ptr; 3085 3557 3086 - return error; 3558 + return error; 3087 3559 } 3088 3560 3089 3561 /* ··· 3084 3572 */ 3085 3573 static void sep_deallocated_flow_tables(struct sep_lli_entry_t *first_table_ptr) 3086 3574 { 3087 - /* id poiner */ 3088 - unsigned long *table_ptr; 3575 + /* id poiner */ 3576 + unsigned long *table_ptr; 3089 3577 3090 - /* end address of the flow dma area */ 3091 - unsigned long num_entries; 3578 + /* end address of the flow dma area */ 3579 + unsigned long num_entries; 3092 3580 3093 - unsigned long num_pages; 3581 + unsigned long num_pages; 3094 3582 3095 - /* pages ptr */ 3096 - struct page **pages_ptr; 3583 + /* pages ptr */ 3584 + struct page **pages_ptr; 3097 3585 3098 - /* maximum table size in words */ 3099 - struct sep_lli_entry_t *info_entry_ptr; 3586 + /* maximum table size in words */ 3587 + struct sep_lli_entry_t *info_entry_ptr; 3100 3588 3101 3589 /*------------------------------- 3102 3590 CODE 3103 3591 ---------------------------------*/ 3104 3592 3105 - /* set the pointer to the first table */ 3106 - table_ptr = (unsigned long *)first_table_ptr->physical_address; 3593 + /* set the pointer to the first table */ 3594 + table_ptr = (unsigned long *) first_table_ptr->physical_address; 3107 3595 3108 - /* set the num of entries */ 3109 - num_entries = (first_table_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) 3110 - & SEP_NUM_ENTRIES_MASK; 3596 + /* set the num of entries */ 3597 + num_entries = (first_table_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) 3598 + & SEP_NUM_ENTRIES_MASK; 3111 3599 3112 - /* go over all the connected tables */ 3113 - while (*table_ptr != 0xffffffff) { 3114 - /* get number of pages */ 3115 - num_pages = *(table_ptr - 2); 3600 + /* go over all the connected tables */ 3601 + while (*table_ptr != 0xffffffff) { 3602 + /* get number of pages */ 3603 + num_pages = *(table_ptr - 2); 3116 3604 3117 - /* get the pointer to the pages */ 3118 - pages_ptr = (struct page **)(*(table_ptr - 1)); 3605 + /* get the pointer to the pages */ 3606 + pages_ptr = (struct page **) (*(table_ptr - 1)); 3119 3607 3120 - /* free the pages */ 3121 - sep_free_dma_pages(pages_ptr, num_pages, 1); 3608 + /* free the pages */ 3609 + sep_free_dma_pages(pages_ptr, num_pages, 1); 3122 3610 3123 - /* goto to the info entry */ 3124 - info_entry_ptr = ((struct sep_lli_entry_t *)table_ptr) + 3125 - (num_entries - 1); 3611 + /* goto to the info entry */ 3612 + info_entry_ptr = ((struct sep_lli_entry_t *) table_ptr) + (num_entries - 1); 3126 3613 3127 - table_ptr = (unsigned long *)info_entry_ptr->physical_address; 3128 - num_entries = (info_entry_ptr->block_size >> 3129 - SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK; 3130 - } 3614 + table_ptr = (unsigned long *) info_entry_ptr->physical_address; 3615 + num_entries = (info_entry_ptr->block_size >> SEP_NUM_ENTRIES_OFFSET_IN_BITS) & SEP_NUM_ENTRIES_MASK; 3616 + } 3131 3617 3132 - return; 3618 + return; 3133 3619 } 3134 3620 3135 3621 /* ··· 3135 3625 */ 3136 3626 static int sep_set_flow_id_handler(unsigned long arg) 3137 3627 { 3138 - /* error */ 3139 - int error; 3628 + /* error */ 3629 + int error; 3140 3630 3141 - /* flow _id */ 3142 - unsigned long flow_id; 3631 + /* flow _id */ 3632 + unsigned long flow_id; 3143 3633 3144 - /* pointer to flow data structre */ 3145 - struct sep_flow_context_t *flow_data_ptr; 3634 + /* pointer to flow data structre */ 3635 + struct sep_flow_context_t *flow_data_ptr; 3146 3636 3147 3637 /*---------------------- 3148 3638 CODE 3149 3639 -----------------------*/ 3150 3640 3151 - dbg("------------>SEP Driver: sep_set_flow_id_handler start\n"); 3641 + dbg("------------>SEP Driver: sep_set_flow_id_handler start\n"); 3152 3642 3153 - error = get_user(flow_id, 3154 - &(((struct sep_driver_set_flow_id_t *)arg)->flow_id)); 3155 - if (error) 3156 - goto end_function; 3643 + error = get_user(flow_id, &(((struct sep_driver_set_flow_id_t *) arg)->flow_id)); 3644 + if (error) 3645 + goto end_function; 3157 3646 3158 - /* find the flow data structure that was just used for creating new flow 3159 - - its id should be default */ 3160 - error = sep_find_flow_context(SEP_TEMP_FLOW_ID, &flow_data_ptr); 3161 - if (error) 3162 - goto end_function; 3647 + /* find the flow data structure that was just used for creating new flow 3648 + - its id should be default */ 3649 + error = sep_find_flow_context(SEP_TEMP_FLOW_ID, &flow_data_ptr); 3650 + if (error) 3651 + goto end_function; 3163 3652 3164 - /* set flow id */ 3165 - flow_data_ptr->flow_id = flow_id; 3653 + /* set flow id */ 3654 + flow_data_ptr->flow_id = flow_id; 3166 3655 3167 - end_function: 3656 + end_function: 3168 3657 3169 - dbg("SEP Driver:<-------- sep_set_flow_id_handler end\n"); 3658 + dbg("SEP Driver:<-------- sep_set_flow_id_handler end\n"); 3170 3659 3171 3660 3172 - return error; 3661 + return error; 3173 3662 } 3174 3663 3175 3664 3176 3665 /* 3177 3666 calculates time and sets it at the predefined address 3178 3667 */ 3179 - static int sep_set_time(unsigned long *address_ptr, 3180 - unsigned long *time_in_sec_ptr) 3668 + static int sep_set_time(unsigned long *address_ptr, unsigned long *time_in_sec_ptr) 3181 3669 { 3182 - /* time struct */ 3183 - struct timeval time; 3670 + /* time struct */ 3671 + struct timeval time; 3184 3672 3185 - /* address of time in the kernel */ 3186 - unsigned long time_addr; 3673 + /* address of time in the kernel */ 3674 + unsigned long time_addr; 3187 3675 3188 3676 3189 3677 /*------------------------ 3190 3678 CODE 3191 3679 --------------------------*/ 3192 3680 3193 - dbg("SEP Driver:--------> sep_set_time start\n"); 3681 + dbg("SEP Driver:--------> sep_set_time start\n"); 3194 3682 3195 3683 3196 - do_gettimeofday(&time); 3684 + do_gettimeofday(&time); 3197 3685 3198 - /* set value in the SYSTEM MEMORY offset */ 3199 - time_addr = sep_dev->message_shared_area_addr + 3200 - SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES; 3686 + /* set value in the SYSTEM MEMORY offset */ 3687 + time_addr = sep_dev->message_shared_area_addr + SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES; 3201 3688 3202 - *(unsigned long *)time_addr = SEP_TIME_VAL_TOKEN; 3203 - *(unsigned long *)(time_addr + 4) = time.tv_sec; 3689 + *(unsigned long *) time_addr = SEP_TIME_VAL_TOKEN; 3690 + *(unsigned long *) (time_addr + 4) = time.tv_sec; 3204 3691 3205 - edbg( 3206 - "SEP Driver:time.tv_sec is %lu\n", 3207 - time.tv_sec); 3208 - edbg( 3209 - "SEP Driver:time_addr is %lu\n", 3210 - time_addr); 3211 - edbg( 3212 - "SEP Driver:g_message_shared_area_addr is %lu\n", 3213 - sep_dev->message_shared_area_addr); 3692 + edbg("SEP Driver:time.tv_sec is %lu\n", time.tv_sec); 3693 + edbg("SEP Driver:time_addr is %lu\n", time_addr); 3694 + edbg("SEP Driver:g_message_shared_area_addr is %lu\n", sep_dev->message_shared_area_addr); 3214 3695 3215 - /* set the output parameters if needed */ 3216 - if (address_ptr) 3217 - *address_ptr = sep_shared_area_virt_to_phys(time_addr); 3696 + /* set the output parameters if needed */ 3697 + if (address_ptr) 3698 + *address_ptr = sep_shared_area_virt_to_phys(time_addr); 3218 3699 3219 - if (time_in_sec_ptr) 3220 - *time_in_sec_ptr = time.tv_sec; 3700 + if (time_in_sec_ptr) 3701 + *time_in_sec_ptr = time.tv_sec; 3221 3702 3222 - dbg("SEP Driver:<-------- sep_set_time end\n"); 3703 + dbg("SEP Driver:<-------- sep_set_time end\n"); 3223 3704 3224 - return 0; 3705 + return 0; 3225 3706 } 3226 3707 3227 3708 static void sep_wait_busy(struct sep_device *dev) ··· 3232 3731 3233 3732 #define HW_AHB_RD_WR_BURSTS_REG_ADDR 0x0E10UL 3234 3733 3235 - dbg("SEP Driver:<-------- sep_configure_dma_burst start \n"); 3734 + dbg("SEP Driver:<-------- sep_configure_dma_burst start \n"); 3236 3735 3237 - /* request access to registers from SEP */ 3238 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2); 3736 + /* request access to registers from SEP */ 3737 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2); 3239 3738 3240 - dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (write reg) \n"); 3739 + dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (write reg) \n"); 3241 3740 3242 - sep_wait_busy(sep_dev); 3741 + sep_wait_busy(sep_dev); 3243 3742 3244 - dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (while(revVal) wait loop) \n"); 3743 + dbg("SEP Driver:<-------- sep_configure_dma_burst finished request access to registers from SEP (while(revVal) wait loop) \n"); 3245 3744 3246 - /* set the DMA burst register to single burst*/ 3247 - sep_write_reg(sep_dev, HW_AHB_RD_WR_BURSTS_REG_ADDR, 0x0UL); 3745 + /* set the DMA burst register to single burst */ 3746 + sep_write_reg(sep_dev, HW_AHB_RD_WR_BURSTS_REG_ADDR, 0x0UL); 3248 3747 3249 - /* release the sep busy */ 3250 - sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x0UL); 3251 - sep_wait_busy(sep_dev); 3748 + /* release the sep busy */ 3749 + sep_write_reg(sep_dev, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x0UL); 3750 + sep_wait_busy(sep_dev); 3252 3751 3253 - dbg("SEP Driver:<-------- sep_configure_dma_burst done \n"); 3752 + dbg("SEP Driver:<-------- sep_configure_dma_burst done \n"); 3254 3753 3255 3754 } 3256 3755