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

📄 romdisk.c

📁 ertfs文件系统里面既有完整ucos程序
💻 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.
*/
/* romdisk.c - Rom disk device driver.

Summary

 Description
    Provides a rom drive capability.

    This utility requires romdisk.h which is generated by the mkrom utility

*/
#include <pcdisk.h>


/* Include the rom disk data */
#include "romdisk.h"
/* extern byte KS_FAR romdisk_data[];
*/

byte KS_FAR *romdisk_block(int driveno, word block)                                       /*__fn__*/
{
word byte_number;

    /* Get the page number */
    byte_number = (word) (block * 512);
    return((byte KS_FAR *)&romdisk_data[byte_number]);
}


/* BOOLEAN romdisk_io(BLOCKT block, void *buffer, word count, BOOLEAN reading)
*
*   Perform io from the romdisk. 
*
*   If the reading flag is true copy data from the romdisk (read).
*   
*
*/

BOOLEAN romdisk_io(int driveno, dword block, void KS_FAR *buffer, word count, BOOLEAN reading) /*__fn__*/
{
    byte KS_FAR *p;
    int i;
    byte KS_FAR *pbuffer;

    pbuffer = (byte KS_FAR *)buffer;

    while (count)
    {
        if (!reading)
            return(FALSE);
        p = romdisk_block(driveno, (word) block);
        if (!p)
            return(FALSE);
        for (i = 0; i < 512; i++)
            *pbuffer++ = *p++;
        count--;
        block++;   
    }
    return(TRUE);
}





int romdisk_perform_device_ioctl(int driveno, int opcode, PFVOID pargs)
{
DDRIVE *pdr;

    pdr = pc_drno_to_drive_struct(driveno);
    if (!pdr)
        return (-1);

    switch (opcode)
    {
        /* Getgeometry and format share common code */
        case DEVCTL_GET_GEOMETRY:
        case DEVCTL_FORMAT:
            return(-1);
        case DEVCTL_CHECKSTATUS:
            return(DEVTEST_NOCHANGE);
        case DEVCTL_WARMSTART:
            pdr->drive_flags |= DRIVE_FLAGS_VALID;
            return(0);
            /* Fall through */
        case DEVCTL_POWER_RESTORE:
            /* Fall through */
        case DEVCTL_POWER_LOSS:
            /* Fall through */
        default:
            break;
    }
    return(0);

}





⌨️ 快捷键说明

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