📄 hba_exp.c
字号:
#include "hba_header.h"#include "linux_main.h"#include "hba_exp.h"/* * * Other exposed functions * */int __mv_is_mod_all_started(struct mv_adp_desc *adp_desc);/* * The extension is the calling module extension. * It can be any module extension. */void HBA_ModuleStarted(struct mv_mod_desc *mod_desc){ /* FIXME : this whole thing is a hack, fix it A.S.A.P. */ struct hba_extension *hba; struct mv_mod_desc *desc; desc = mod_desc; while (desc->parent) desc = desc->parent; /* hba to be the uppermost */ hba = (struct hba_extension *) desc->extension; if (__mv_is_mod_all_started(desc->hba_desc)) { MV_DBG(DMSG_HBA, "all modules have been started.\n"); complete(&hba->cmpl); /* We are totally ready for requests handling. */ hba->State = DRIVER_STATUS_STARTED; /* Module 0 is the last module */ hba->desc->ops->module_notification(hba, EVENT_MODULE_ALL_STARTED, NULL); } else { /* * TBD: hba's start has already been called, so we should not * call it here. (hba is the highest module, it has no parent.) */ if (mod_desc->parent && mod_desc->parent->parent) mod_desc->parent->ops->module_start(mod_desc->parent->extension); }}#ifdef __BIG_ENDIANvoid hba_swap_buf_le16(u16 *buf, unsigned int words){ unsigned int i; for (i=0; i < words; i++) buf[i] = le16_to_cpu(buf[i]);}#elseinline void hba_swap_buf_le16(u16 *buf, unsigned int words) {}#endif /* __BIG_ENDIAN */void hba_map_sg_to_buffer(void *preq){ struct scsi_cmnd *scmd =NULL; struct scatterlist *sg =NULL; PMV_Request req =NULL; req = (PMV_Request) preq; if (REQ_TYPE_OS != req->Req_Type) return; scmd = (struct scsi_cmnd *) req->Org_Req; sg = (struct scatterlist *) scmd->request_buffer; if (scmd->use_sg) { if (scmd->use_sg > 1) MV_DBG(DMSG_SCSI, "_MV_ more than 1 sg entry in an inst cmd.\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14) req->Data_Buffer = kmalloc(sg->length, GFP_ATOMIC); if (req->Data_Buffer) { memset(req->Data_Buffer, 0, sg->length); }#else req->Data_Buffer = kzalloc(sg->length, GFP_ATOMIC);#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14) */ req->Data_Transfer_Length = sg->length; } else { req->Data_Buffer = scmd->request_buffer; }}void hba_unmap_sg_to_buffer(void *preq){ void *buf; struct scsi_cmnd *scmd = NULL; struct scatterlist *sg = NULL; PMV_Request req = NULL; req = (PMV_Request) preq; if (REQ_TYPE_OS != req->Req_Type) return; scmd = (struct scsi_cmnd *) req->Org_Req; sg = (struct scatterlist *) scmd->request_buffer; if (scmd->use_sg) { WARN_ON(!irqs_disabled()); buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; memcpy(buf, req->Data_Buffer, sg->length); kunmap_atomic(buf, KM_IRQ0); kfree(req->Data_Buffer); }}#define LO_ADDR(x) ((MV_U32) ((MV_PTR_INTEGER) (x)))#define HI_ADDR(x) ((MV_U32) (sizeof(void *)>4?((MV_PTR_INTEGER) (x))>>32:0))#ifdef __AC_LOG__/* log messages viewed thru /proc ( or /sys in the future ) */#define HBA_LOG_BUF_SIZE 2048static unsigned char hba_log_buf[HBA_LOG_BUF_SIZE+1];static unsigned long hba_log_pos;int __hba_dump_log(unsigned char *buf){ memcpy(buf, hba_log_buf, HBA_LOG_BUF_SIZE); return HBA_LOG_BUF_SIZE;}void hba_log_msg(unsigned char *buf, unsigned int len){ /* used as a ring buffer */ while ( (hba_log_pos + len) > HBA_LOG_BUF_SIZE ) { memcpy(hba_log_buf+hba_log_pos, buf, HBA_LOG_BUF_SIZE - hba_log_pos); len -= HBA_LOG_BUF_SIZE - hba_log_pos; buf += HBA_LOG_BUF_SIZE - hba_log_pos; hba_log_pos = 0; } memcpy(hba_log_buf+hba_log_pos, buf, len); hba_log_pos = (hba_log_pos + len) % HBA_LOG_BUF_SIZE; hba_log_buf[hba_log_pos++] = '\n';}#endif /* __AC_LOG__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -