📄 pcmsram.c
字号:
/*
* EBS - RTFS (Real Time File Manager)
*
* Copyright Peter Van Oudenaren , 1993
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*/
/* pcmsram.c - PCMCIA SRam disk device driver.
Summary
Description
Provides a configurable pcmcia SRAM drive capability.
Change the constant SRAM_CARD_SIZE in this file to use a different
size ram card.
Note: Currently limitted to 1024 bocks maximum do to the
statement
gc.dev_geometry_cylinders = SRAM_CARD_SIZE;
Note: Does not autosize ram cards.
*/
#include "pcdisk.h"
#if (INCLUDE_PCMCIA)
#include "pcmcia.h"
/* Set up for a 256K ram disk pcmcia card */
#define SRAM_CARD_SIZE 512
byte KS_FAR *pcmsram_block(int socket_no, word block) /*__fn__*/
{
byte KS_FAR *p;
dword offset;
offset = block;
offset <<= 8; /* Map cis multiplies the address by 2 so here we
multiply # blocks by 256 intead of 512 to get the
byte offset */
offset += 256; /* The SRAM starts at 512 */
p = pd67xx_map_sram(socket_no , offset);
return(p);
}
/* BOOLEAN sram_io(BLOCKT block, void *buffer, word count, BOOLEAN reading)
*
* Perform io to and from the ramdisk.
*
* If the reading flag is true copy data from the ramdisk (read).
* else copy to the ramdisk. (write). called by pc_gblock and pc_pblock
*
* This routine is called by pc_rdblock.
*
*/
BOOLEAN pcmsram_io(word driveno, dword block, void KS_FAR *buffer, word count, BOOLEAN reading) /*__fn__*/
{
byte KS_FAR *p;
int i;
byte KS_FAR *pbuffer;
DDRIVE *pdr;
pdr = pc_drno_to_drive_struct(driveno);
if (!pdr)
return (FALSE);
pbuffer = (byte KS_FAR *)buffer;
while (count)
{
p = pcmsram_block(pdr->pcmcia_slot_number, (word) block);
if (!p)
return(FALSE);
if (reading)
{
for (i = 0; i < 512; i++)
*pbuffer++ = *p++;
}
else
{
for (i = 0; i < 512; i++)
{
*p++ = *pbuffer++;
}
}
count--;
block++;
}
return(TRUE);
}
int pcmsram_perform_device_ioctl(int driveno, int opcode, PFVOID pargs)
{
DDRIVE *pdr;
DEV_GEOMETRY gc; // used by DEVCTL_GET_GEOMETRY
pdr = pc_drno_to_drive_struct(driveno);
if (!pdr)
return (-1);
switch (opcode)
{
case DEVCTL_GET_GEOMETRY:
pc_memfill(&gc, sizeof(gc), '\0');
/* Now set the geometry section */
gc.dev_geometry_heads = 1;
gc.dev_geometry_cylinders = SRAM_CARD_SIZE;
gc.dev_geometry_secptrack = 1;
copybuff(pargs, &gc, sizeof(gc));
return (0);
case DEVCTL_FORMAT:
{
byte KS_FAR *p;
dword block;
int i;
for (block = 0; block < SRAM_CARD_SIZE; block++)
{
p = pcmsram_block(pdr->pcmcia_slot_number, (word)block);
if (!p)
return(-1);
for (i = 0 ; i < 512; i++)
*p++ = 0;
}
}
return(0);
case DEVCTL_REPORT_REMOVE:
pdr->drive_flags &= ~DRIVE_FLAGS_INSERTED;
return(0);
case DEVCTL_CHECKSTATUS:
if (pdr->drive_flags & DRIVE_FLAGS_INSERTED)
return(DEVTEST_NOCHANGE);
else
{
if (pcmctrl_card_installed(pdr->pcmcia_slot_number))
{
pdr->drive_flags |= DRIVE_FLAGS_INSERTED;
return(DEVTEST_CHANGED);
}
else
return(DEVTEST_NOMEDIA);
}
// never get's here
case DEVCTL_WARMSTART:
// BUGBUG - Use pcmcia controller status
pcmctrl_init();
pdr->drive_flags |= (DRIVE_FLAGS_VALID|DRIVE_FLAGS_REMOVABLE);
return(0);
case DEVCTL_POWER_RESTORE:
/* Fall through */
case DEVCTL_POWER_LOSS:
/* Fall through */
default:
break;
}
return(0);
}
#endif // (INCLUDE_PCMCIA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -