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

📄 zlg_fs_sd.c

📁 三星2410在linux下的SD卡驱动
💻 C
字号:
/****************************************Copyright (c)****************************************************                               Guangzou ZLG-MCU Development Co.,LTD.**                                     graduate school**                                 http://www.zlgmcu.com****--------------File Info-------------------------------------------------------------------------------** File name:			zlg_fs_driver.c** Last modified Date:  2005-05-27** Last Version:		1.0** Descriptions:		This is a Kernel module for uClinux 2.4.x .**                      This module let uClinux 2.4.x can use ZLG/DRIVER . **------------------------------------------------------------------------------------------------------** Created by:			Chenmingji** Created date:		2005-05-27** Version:				1.0** Descriptions:		The original version****------------------------------------------------------------------------------------------------------** Modified by:** Modified date:** Version:** Descriptions:**********************************************************************************************************/#define IN_ZLG_FS_DRIVER#include "config.h"/********************************************************************************************************              function announce********************************************************************************************************/int  zlg_fs_driver_init(void);void zlg_fs_driver_cleanup(void);/********************************************************************************************************              define announce********************************************************************************************************/module_init(zlg_fs_driver_init);module_exit(zlg_fs_driver_cleanup);MODULE_LICENSE("Proprietary");MODULE_DESCRIPTION("Guangzou ZLG-MCU Development Co.,LTD.\ngraduate school\nhttp://www.zlgmcu.com");MODULE_SUPPORTED_DEVICE("uClinux2.4.x LPC2200 " DEVICE_NAME);MODULE_AUTHOR("chenmingji");/***********************************************************************************************************                  "全局和静态变量在这里定义"         **        global variables and static variables define here********************************************************************************************************/static fs_drivers zlg_driver_driver[MAX_DISK_DRIVES];/*********************************************************************************************************** Function name: zlg_fs_driver_open** Descriptions: open device** Input:inode:  information of device**       filp:   pointer of file** Output 0:     OK**        other: not OK** Created by:   Chenmingji** Created Date: 2005-05-27**-------------------------------------------------------------------------------------------------------** Modified by:** Modified Date: **------------------------------------------------------------------------------------------------------********************************************************************************************************/        static int  zlg_fs_driver_get_info(struct _zlg_driver_Info *Disk){    Disk_RW_Parameter dp;        dp.RsvdForLow = Disk->RsvdForLow;    dp.SectorIndex = DISK_GET_BYTES_PER_SECTOR;    if (Disk->DiakCommand(DISK_CHECK_CMD, &dp) == DISK_TRUE)    {        Disk->DiakCommand(DISK_GET_BYTES_PER_SECTOR, &dp);        Disk->BytesPerSec = dp.SectorIndex;    }    else    {        Disk->BytesPerSec = DEVICE_BYTES_PER_SEC;    }        dp.SectorIndex = DISK_GET_SECTOR_NUMBER;    if (Disk->DiakCommand(DISK_CHECK_CMD, &dp) == DISK_TRUE)    {        Disk->DiakCommand(DISK_GET_SECTOR_NUMBER, &dp);        Disk->SecPerDisk = dp.SectorIndex;    }    else    {        Disk->SecPerDisk = DEVICE_SEC_PER_DISK;    }    return 0;          /* success */} /*********************************************************************************************************** Function name: zlg_fs_driver_open** Descriptions: open device** Input:inode:  information of device**       filp:   pointer of file** Output 0:     OK**        other: not OK** Created by:   Chenmingji** Created Date: 2005-05-27**-------------------------------------------------------------------------------------------------------** Modified by:** Modified Date: **------------------------------------------------------------------------------------------------------********************************************************************************************************/        static int  zlg_fs_driver_open(struct inode *inode, struct file *filp){    MOD_INC_USE_COUNT;    return 0;          /* success */} /*********************************************************************************************************** Function name: zlg_fs_driver_release** Descriptions: release device** Input:inode:  information of device**       filp:   pointer of file** Output 0:     OK**        other: not OK** Created by:   Chenmingji** Created Date: 2005-05-27**-------------------------------------------------------------------------------------------------------** Modified by:** Modified Date: **------------------------------------------------------------------------------------------------------********************************************************************************************************/        static int  zlg_fs_driver_release(struct inode *inode, struct file *filp) {    MOD_DEC_USE_COUNT;    return 0; } /*********************************************************************************************************** Function name: zlg_fs_driver_init** Descriptions: init driver** Input:none** Output 0:     OK**        other: not OK** Created by:   Chenmingji** Created Date: 2005-05-27**-------------------------------------------------------------------------------------------------------** Modified by:** Modified Date: **------------------------------------------------------------------------------------------------------********************************************************************************************************/        int  zlg_fs_driver_init(void){    int i;        drive_init();    for (i = 0; i < MAX_DISK_DRIVES; i++)    {#ifdef DISK_INFO        zlg_driver_driver[i].RsvdForLow = &(DISK_INFO[i]);#else        zlg_driver_driver[i].RsvdForLow = NULL;#endif        zlg_driver_driver[i].DiakCommand = COMMAND_FUNCTION;        zlg_driver_driver[i].open = zlg_fs_driver_open;        zlg_driver_driver[i].release = zlg_fs_driver_release;        zlg_driver_driver[i].get_info = zlg_fs_driver_get_info;        zlg_fs_add_driver(&(zlg_driver_driver[i]));    }    printk(KERN_INFO DEVICE_NAME ": init OK\n");    return(0); }/*********************************************************************************************************** Function name: zlg_fs_driver_cleanup** Descriptions: exit driver** Input:none** Output none** Created by:   Chenmingji** Created Date: 2005-05-27**-------------------------------------------------------------------------------------------------------** Modified by:** Modified Date: **------------------------------------------------------------------------------------------------------********************************************************************************************************/        void zlg_fs_driver_cleanup(void){    int i;    for (i = 0; i < MAX_DISK_DRIVES; i++)    {        zlg_fs_remove_driver(&(zlg_driver_driver[i]));    }        drive_clean();}/***********************************************************************************************************                            End Of File********************************************************************************************************/

⌨️ 快捷键说明

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