⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flsocket.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
{
  if (!vol.cardDetected(&vol)) {
    vol.cardChanged = TRUE;
    return flDriveNotReady;
  }

  if (vol.getAndClearCardChangeIndicator &&
      vol.getAndClearCardChangeIndicator(&vol))
    vol.cardChanged = TRUE;

  return vol.cardChanged ? flDiskChange : flOK;
}

#endif

/*----------------------------------------------------------------------*/
/*                   f l G e t M a p p i n g C o n t e x t              */
/*                                                                      */
/* Returns the currently mapped window page (in 4KB units)              */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*                                                                      */
/* Returns:                                                             */
/*        unsigned int        : Current mapped page no.                 */
/*----------------------------------------------------------------------*/

unsigned flGetMappingContext(FLSocket vol)
{
  return vol.window.currentPage;
}


/*----------------------------------------------------------------------*/
/*                              f l M a p                               */
/*                                                                      */
/* Maps the window to a specified card address and returns a pointer to */
/* that location (some offset within the window).                       */
/*                                                                      */
/* NOTE: Addresses over 128M are attribute memory. On PCMCIA adapters,  */
/* subtract 128M from the address and map to attribute memory.          */
/*                                                                      */
/* Parameters:                                                          */
/*      vol         : Pointer identifying drive                         */
/*      address     : Byte-address on card. NOT necessarily on a        */
/*                    full-window boundary.                             */
/*                    If above 128MB, address is in attribute space.    */
/*                                                                      */
/* Returns:                                                             */
/*        Pointer to a location within the window mapping the address.  */
/*----------------------------------------------------------------------*/

void FAR0 *flMap(FLSocket vol, CardAddress address)
{
  unsigned pageToMap;

  if (vol.window.currentPage == UNDEFINED_MAPPING)
    vol.setWindow(&vol);
  pageToMap = (unsigned) ((address & -vol.window.size) >> 12);

  if (vol.window.currentPage != pageToMap) {
    vol.setMappingContext(&vol, pageToMap);
    vol.window.currentPage = pageToMap;
    vol.remapped = TRUE;        /* indicate remapping done */
  }

  return addToFarPointer(vol.window.base,address & (vol.window.size - 1));
}


/*----------------------------------------------------------------------*/
/*                    f l S e t W i n d o w B u s W i d t h             */
/*                                                                      */
/* Requests to set the window bus width to 8 or 16 bits.                */
/* Whether the request is filled depends on hardware capabilities.      */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*      width                : Requested bus width                      */
/*                                                                      */
/*----------------------------------------------------------------------*/

void flSetWindowBusWidth(FLSocket vol, unsigned width)
{
  vol.window.busWidth = width;
  vol.window.currentPage = UNDEFINED_MAPPING;        /* force remapping */
}


/*----------------------------------------------------------------------*/
/*                   f l S e t W i n d o w S p e e d                    */
/*                                                                      */
/* Requests to set the window speed to a specified value.               */
/* The window speed is set to a speed equal or slower than requested,   */
/* if possible in hardware.                                             */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*      nsec                : Requested window speed in nanosec.        */
/*                                                                      */
/*----------------------------------------------------------------------*/

void flSetWindowSpeed(FLSocket vol, unsigned nsec)
{
  vol.window.speed = nsec;
  vol.window.currentPage = UNDEFINED_MAPPING;        /* force remapping */
}


/*----------------------------------------------------------------------*/
/*                    f l S e t W i n d o w S i z e                     */
/*                                                                      */
/* Requests to set the window size to a specified value (power of 2).   */
/* The window size is set to a size equal or greater than requested,    */
/* if possible in hardware.                                             */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*      sizeIn4KBUnits : Requested window size in 4 KByte units.        */
/*                         MUST be a power of 2.                        */
/*                                                                      */
/*----------------------------------------------------------------------*/

void flSetWindowSize(FLSocket vol, unsigned sizeIn4KBunits)
{
  vol.window.size = (long) (sizeIn4KBunits) * 0x1000L;
        /* Size may not be possible. Actual size will be set by 'setWindow' */
  vol.window.base = physicalToPointer((long) vol.window.baseAddress << 12,
                                      vol.window.size,vol.volNo);
  vol.window.currentPage = UNDEFINED_MAPPING;        /* force remapping */
}


/*----------------------------------------------------------------------*/
/*                   f l S o c k e t S e t B u s y                      */
/*                                                                      */
/* Notifies the start and end of a file-system operation.               */
/*                                                                      */
/* Parameters:                                                          */
/*        vol      : Pointer identifying drive                          */
/*      state      : FL_ON (1) = operation entry                        */
/*                   FL_OFF(0) = operation exit                         */
/*                                                                      */
/*----------------------------------------------------------------------*/

void flSocketSetBusy(FLSocket vol, FLBoolean state)
{
  if (state == FL_OFF) 
  {
#if POLLING_INTERVAL == 0
    /* If we are not polling, activate the interval routine before exit */
    flIntervalRoutine(&vol);
#endif
  }
  else 
  {
    /* Set verify write operation to this socket */
#if (defined(VERIFY_WRITE) || defined(VERIFY_ERASED_SECTOR))
    if(flVerifyWrite[vol.volNo][vol.curPartition] == FL_ON)
    {
       vol.verifyWrite = FL_ON;
    }
    else
    {
       vol.verifyWrite = FL_OFF;
    }
#endif /* VERIFY_WRITE || VERIFY_ERASED_SECTOR */
    vol.window.currentPage = UNDEFINED_MAPPING;        /* don't assume mapping still valid */
#ifdef FIXED_MEDIA
    vol.remapped = TRUE;
#endif /* FIXED_MEDIA */
  }
}


/*----------------------------------------------------------------------*/
/*                          f l N e e d V c c                           */
/*                                                                      */
/* Turns on Vcc, if not on already                                      */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*                                                                      */
/* Returns:                                                             */
/*        FLStatus        : 0 on success, failed otherwise              */
/*----------------------------------------------------------------------*/

void flNeedVcc(FLSocket vol)
{
  vol.VccUsers++;
  if (vol.VccState == PowerOff) {
    vol.VccOn(&vol);
    if (vol.powerOnCallback)
      vol.powerOnCallback(vol.flash);
  }
  vol.VccState = PowerOn;
}


/*----------------------------------------------------------------------*/
/*                       f l D o n t N e e d V c c                      */
/*                                                                      */
/* Notifies that Vcc is no longer needed, allowing it to be turned off. */
/*                                                                      */
/* Parameters:                                                          */
/*        vol                : Pointer identifying drive                */
/*                                                                      */
/*----------------------------------------------------------------------*/

void flDontNeedVcc(FLSocket vol)
{
  if (vol.VccUsers > 0)
    vol.VccUsers--;
}

#ifdef SOCKET_12_VOLTS

/*----------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -