The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/aacraid/aacraid_endian.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2019 Leandro Lupori
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   25  * SUCH DAMAGE.
   26  */
   27 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD$");
   30 
   31 #include <sys/param.h>
   32 #include <sys/types.h>
   33 
   34 #include <dev/aacraid/aacraid_reg.h>
   35 #include <dev/aacraid/aacraid_endian.h>
   36 
   37 #if _BYTE_ORDER != _LITTLE_ENDIAN
   38 
   39 #define TOH2(field, bits)       field = le##bits##toh(field)
   40 #define TOH(field, bits)        TOH2(field, bits)
   41 
   42 #define TOLE2(field, bits)      field = htole##bits(field)
   43 #define TOLE(field, bits)       TOLE2(field, bits)
   44 
   45 /* Convert from Little-Endian to host order (TOH) */
   46 
   47 void
   48 aac_fib_header_toh(struct aac_fib_header *ptr)
   49 {
   50         TOH(ptr->XferState, 32);
   51         TOH(ptr->Command, 16);
   52         TOH(ptr->Size, 16);
   53         TOH(ptr->SenderSize, 16);
   54         TOH(ptr->SenderFibAddress, 32);
   55         TOH(ptr->u.ReceiverFibAddress, 32);
   56         TOH(ptr->Handle, 32);
   57         TOH(ptr->Previous, 32);
   58         TOH(ptr->Next, 32);
   59 }
   60 
   61 void
   62 aac_adapter_info_toh(struct aac_adapter_info *ptr)
   63 {
   64         TOH(ptr->PlatformBase, 32);
   65         TOH(ptr->CpuArchitecture, 32);
   66         TOH(ptr->CpuVariant, 32);
   67         TOH(ptr->ClockSpeed, 32);
   68         TOH(ptr->ExecutionMem, 32);
   69         TOH(ptr->BufferMem, 32);
   70         TOH(ptr->TotalMem, 32);
   71 
   72         TOH(ptr->KernelRevision.buildNumber, 32);
   73         TOH(ptr->MonitorRevision.buildNumber, 32);
   74         TOH(ptr->HardwareRevision.buildNumber, 32);
   75         TOH(ptr->BIOSRevision.buildNumber, 32);
   76 
   77         TOH(ptr->ClusteringEnabled, 32);
   78         TOH(ptr->ClusterChannelMask, 32);
   79         TOH(ptr->SerialNumber, 64);
   80         TOH(ptr->batteryPlatform, 32);
   81         TOH(ptr->SupportedOptions, 32);
   82         TOH(ptr->OemVariant, 32);
   83 }
   84 
   85 void
   86 aac_container_creation_toh(struct aac_container_creation *ptr)
   87 {
   88         u_int32_t *date = (u_int32_t *)ptr + 1;
   89 
   90         *date = le32toh(*date);
   91         TOH(ptr->ViaAdapterSerialNumber, 64);
   92 }
   93 
   94 void
   95 aac_mntobj_toh(struct aac_mntobj *ptr)
   96 {
   97         TOH(ptr->ObjectId, 32);
   98         aac_container_creation_toh(&ptr->CreateInfo);
   99         TOH(ptr->Capacity, 32);
  100         TOH(ptr->VolType, 32);
  101         TOH(ptr->ObjType, 32);
  102         TOH(ptr->ContentState, 32);
  103         TOH(ptr->ObjExtension.BlockDevice.BlockSize, 32);
  104         TOH(ptr->ObjExtension.BlockDevice.bdLgclPhysMap, 32);
  105         TOH(ptr->AlterEgoId, 32);
  106         TOH(ptr->CapacityHigh, 32);
  107 }
  108 
  109 void
  110 aac_mntinforesp_toh(struct aac_mntinforesp *ptr)
  111 {
  112         TOH(ptr->Status, 32);
  113         TOH(ptr->MntType, 32);
  114         TOH(ptr->MntRespCount, 32);
  115         aac_mntobj_toh(&ptr->MntTable[0]);
  116 }
  117 
  118 void
  119 aac_fsa_ctm_toh(struct aac_fsa_ctm *ptr)
  120 {
  121         int i;
  122 
  123         TOH(ptr->command, 32);
  124         for (i = 0; i < CT_FIB_PARAMS; i++)
  125                 TOH(ptr->param[i], 32);
  126 }
  127 
  128 void
  129 aac_cnt_config_toh(struct aac_cnt_config *ptr)
  130 {
  131         TOH(ptr->Command, 32);
  132         aac_fsa_ctm_toh(&ptr->CTCommand);
  133 }
  134 
  135 void
  136 aac_ctcfg_resp_toh(struct aac_ctcfg_resp *ptr)
  137 {
  138         TOH(ptr->Status, 32);
  139         TOH(ptr->resp, 32);
  140         TOH(ptr->param, 32);
  141 }
  142 
  143 void
  144 aac_getbusinf_toh(struct aac_getbusinf *ptr)
  145 {
  146         TOH(ptr->ProbeComplete, 32);
  147         TOH(ptr->BusCount, 32);
  148         TOH(ptr->TargetsPerBus, 32);
  149 }
  150 
  151 void
  152 aac_vmi_businf_resp_toh(struct aac_vmi_businf_resp *ptr)
  153 {
  154         TOH(ptr->Status, 32);
  155         TOH(ptr->ObjType, 32);
  156         TOH(ptr->MethId, 32);
  157         TOH(ptr->ObjId, 32);
  158         TOH(ptr->IoctlCmd, 32);
  159         aac_getbusinf_toh(&ptr->BusInf);
  160 }
  161 
  162 void
  163 aac_srb_response_toh(struct aac_srb_response *ptr)
  164 {
  165         TOH(ptr->fib_status, 32);
  166         TOH(ptr->srb_status, 32);
  167         TOH(ptr->scsi_status, 32);
  168         TOH(ptr->data_len, 32);
  169         TOH(ptr->sense_len, 32);
  170 }
  171 
  172 /* Convert from host order to Little-Endian (TOLE) */
  173 
  174 void
  175 aac_adapter_init_tole(struct aac_adapter_init *ptr)
  176 {
  177         TOLE(ptr->InitStructRevision, 32);
  178         TOLE(ptr->NoOfMSIXVectors, 32);
  179         TOLE(ptr->FilesystemRevision, 32);
  180         TOLE(ptr->CommHeaderAddress, 32);
  181         TOLE(ptr->FastIoCommAreaAddress, 32);
  182         TOLE(ptr->AdapterFibsPhysicalAddress, 32);
  183         TOLE(ptr->AdapterFibsVirtualAddress, 32);
  184         TOLE(ptr->AdapterFibsSize, 32);
  185         TOLE(ptr->AdapterFibAlign, 32);
  186         TOLE(ptr->PrintfBufferAddress, 32);
  187         TOLE(ptr->PrintfBufferSize, 32);
  188         TOLE(ptr->HostPhysMemPages, 32);
  189         TOLE(ptr->HostElapsedSeconds, 32);
  190         TOLE(ptr->InitFlags, 32);
  191         TOLE(ptr->MaxIoCommands, 32);
  192         TOLE(ptr->MaxIoSize, 32);
  193         TOLE(ptr->MaxFibSize, 32);
  194         TOLE(ptr->MaxNumAif, 32);
  195         TOLE(ptr->HostRRQ_AddrLow, 32);
  196         TOLE(ptr->HostRRQ_AddrHigh, 32);
  197 }
  198 
  199 void
  200 aac_fib_header_tole(struct aac_fib_header *ptr)
  201 {
  202         TOLE(ptr->XferState, 32);
  203         TOLE(ptr->Command, 16);
  204         TOLE(ptr->Size, 16);
  205         TOLE(ptr->SenderSize, 16);
  206         TOLE(ptr->SenderFibAddress, 32);
  207         TOLE(ptr->u.ReceiverFibAddress, 32);
  208         TOLE(ptr->Handle, 32);
  209         TOLE(ptr->Previous, 32);
  210         TOLE(ptr->Next, 32);
  211 }
  212 
  213 void
  214 aac_mntinfo_tole(struct aac_mntinfo *ptr)
  215 {
  216         TOLE(ptr->Command, 32);
  217         TOLE(ptr->MntType, 32);
  218         TOLE(ptr->MntCount, 32);
  219 }
  220 
  221 void
  222 aac_fsa_ctm_tole(struct aac_fsa_ctm *ptr)
  223 {
  224         int i;
  225 
  226         TOLE(ptr->command, 32);
  227         for (i = 0; i < CT_FIB_PARAMS; i++)
  228                 TOLE(ptr->param[i], 32);
  229 }
  230 
  231 void
  232 aac_cnt_config_tole(struct aac_cnt_config *ptr)
  233 {
  234         TOLE(ptr->Command, 32);
  235         aac_fsa_ctm_tole(&ptr->CTCommand);
  236 }
  237 
  238 void
  239 aac_raw_io_tole(struct aac_raw_io *ptr)
  240 {
  241         TOLE(ptr->BlockNumber, 64);
  242         TOLE(ptr->ByteCount, 32);
  243         TOLE(ptr->ContainerId, 16);
  244         TOLE(ptr->Flags, 16);
  245         TOLE(ptr->BpTotal, 16);
  246         TOLE(ptr->BpComplete, 16);
  247 }
  248 
  249 void
  250 aac_raw_io2_tole(struct aac_raw_io2 *ptr)
  251 {
  252         TOLE(ptr->strtBlkLow, 32);
  253         TOLE(ptr->strtBlkHigh, 32);
  254         TOLE(ptr->byteCnt, 32);
  255         TOLE(ptr->ldNum, 16);
  256         TOLE(ptr->flags, 16);
  257         TOLE(ptr->sgeFirstSize, 32);
  258         TOLE(ptr->sgeNominalSize, 32);
  259 }
  260 
  261 void
  262 aac_fib_xporthdr_tole(struct aac_fib_xporthdr *ptr)
  263 {
  264         TOLE(ptr->HostAddress, 64);
  265         TOLE(ptr->Size, 32);
  266         TOLE(ptr->Handle, 32);
  267 }
  268 
  269 void
  270 aac_ctcfg_tole(struct aac_ctcfg *ptr)
  271 {
  272         TOLE(ptr->Command, 32);
  273         TOLE(ptr->cmd, 32);
  274         TOLE(ptr->param, 32);
  275 }
  276 
  277 void
  278 aac_vmioctl_tole(struct aac_vmioctl *ptr)
  279 {
  280         TOLE(ptr->Command, 32);
  281         TOLE(ptr->ObjType, 32);
  282         TOLE(ptr->MethId, 32);
  283         TOLE(ptr->ObjId, 32);
  284         TOLE(ptr->IoctlCmd, 32);
  285         TOLE(ptr->IoctlBuf[0], 32);
  286 }
  287 
  288 void
  289 aac_pause_command_tole(struct aac_pause_command *ptr)
  290 {
  291         TOLE(ptr->Command, 32);
  292         TOLE(ptr->Type, 32);
  293         TOLE(ptr->Timeout, 32);
  294         TOLE(ptr->Min, 32);
  295         TOLE(ptr->NoRescan, 32);
  296         TOLE(ptr->Parm3, 32);
  297         TOLE(ptr->Parm4, 32);
  298         TOLE(ptr->Count, 32);
  299 }
  300 
  301 void
  302 aac_srb_tole(struct aac_srb *ptr)
  303 {
  304         TOLE(ptr->function, 32);
  305         TOLE(ptr->bus, 32);
  306         TOLE(ptr->target, 32);
  307         TOLE(ptr->lun, 32);
  308         TOLE(ptr->timeout, 32);
  309         TOLE(ptr->flags, 32);
  310         TOLE(ptr->data_len, 32);
  311         TOLE(ptr->retry_limit, 32);
  312         TOLE(ptr->cdb_len, 32);
  313 }
  314 
  315 void
  316 aac_sge_ieee1212_tole(struct aac_sge_ieee1212 *ptr)
  317 {
  318         TOLE(ptr->addrLow, 32);
  319         TOLE(ptr->addrHigh, 32);
  320         TOLE(ptr->length, 32);
  321         TOLE(ptr->flags, 32);
  322 }
  323 
  324 void
  325 aac_sg_entryraw_tole(struct aac_sg_entryraw *ptr)
  326 {
  327         TOLE(ptr->Next, 32);
  328         TOLE(ptr->Prev, 32);
  329         TOLE(ptr->SgAddress, 64);
  330         TOLE(ptr->SgByteCount, 32);
  331         TOLE(ptr->Flags, 32);
  332 }
  333 
  334 void
  335 aac_sg_entry_tole(struct aac_sg_entry *ptr)
  336 {
  337         TOLE(ptr->SgAddress, 32);
  338         TOLE(ptr->SgByteCount, 32);
  339 }
  340 
  341 void
  342 aac_sg_entry64_tole(struct aac_sg_entry64 *ptr)
  343 {
  344         TOLE(ptr->SgAddress, 64);
  345         TOLE(ptr->SgByteCount, 32);
  346 }
  347 
  348 void
  349 aac_blockread_tole(struct aac_blockread *ptr)
  350 {
  351         TOLE(ptr->Command, 32);
  352         TOLE(ptr->ContainerId, 32);
  353         TOLE(ptr->BlockNumber, 32);
  354         TOLE(ptr->ByteCount, 32);
  355 }
  356 
  357 void
  358 aac_blockwrite_tole(struct aac_blockwrite *ptr)
  359 {
  360         TOLE(ptr->Command, 32);
  361         TOLE(ptr->ContainerId, 32);
  362         TOLE(ptr->BlockNumber, 32);
  363         TOLE(ptr->ByteCount, 32);
  364         TOLE(ptr->Stable, 32);
  365 }
  366 
  367 void
  368 aac_blockread64_tole(struct aac_blockread64 *ptr)
  369 {
  370         TOLE(ptr->Command, 32);
  371         TOLE(ptr->ContainerId, 16);
  372         TOLE(ptr->SectorCount, 16);
  373         TOLE(ptr->BlockNumber, 32);
  374         TOLE(ptr->Pad, 16);
  375         TOLE(ptr->Flags, 16);
  376 }
  377 
  378 void
  379 aac_blockwrite64_tole(struct aac_blockwrite64 *ptr)
  380 {
  381         TOLE(ptr->Command, 32);
  382         TOLE(ptr->ContainerId, 16);
  383         TOLE(ptr->SectorCount, 16);
  384         TOLE(ptr->BlockNumber, 32);
  385         TOLE(ptr->Pad, 16);
  386         TOLE(ptr->Flags, 16);
  387 }
  388 
  389 #endif

Cache object: 5a1bdde5a01b1d5c30dab9d152f1f140


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.