添加硬盘驱动 - 写磁盘

来源:互联网 发布:手机屏幕条纹修复软件 编辑:程序博客网 时间:2024/04/30 19:16

hd.c中


#define WIN_WRITE0x30char testbuf[256]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};static void write_intr(void){printk("write_intr\n");}void write_hd(void){#ifdef LBA//LBA模式//写硬盘0的0扇区(第一个扇区),读一个扇区,回调函数为read_intrhd_out(0,1,0,WIN_WRITE,&write_intr);#else//CHS模式//写硬盘0的0磁头0柱面1扇区(第一个扇区),写一个扇区,回调函数为write_intrhd_out(0,1,1,0,0,WIN_WRITE,&write_intr);#endifdelay(20);port_write(HD_DATA,testbuf,256);}

read函数改名为:read_hd,read_intr我们打印前30个字节

在main.c中我们先写数据,然后读出来看是不是我们写进去的数据。

write_hd();
read_hd();

0 0
原创粉丝点击