📄 ide_lib.h
字号:
/*
Copyright (C) 2003 Bart Bilos <boombox666@yahoo.com>.
Adapted from original work by Paul Stoffregen.
http://www.pjrc.com/tech/8051/ide/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// 8255 control register settings for IDE
#define rd_ide_8255 0x92
#define wr_ide_8255 0x80
// IDE variables where each bit is located in the control port (port C)
#define ide_a0_line 0x01 //direct from 8255 to ide interface
#define ide_a1_line 0x02 //direct from 8255 to ide interface
#define ide_a2_line 0x04 //direct from 8255 to ide interface
#define ide_cs0_line 0x08 //inverter between 8255 and ide interface
#define ide_cs1_line 0x10 //inverter between 8255 and ide interface
#define ide_wr_line 0x20 //inverter between 8255 and ide interface
#define ide_rd_line 0x40 //inverter between 8255 and ide interface
#define ide_rst_line 0x80 //inverter between 8255 and ide interface
// IDE control line constants
#define ide_data ide_cs0_line
#define ide_err ide_cs0_line + ide_a0_line
#define ide_sec_cnt ide_cs0_line + ide_a1_line
#define ide_sector ide_cs0_line + ide_a1_line + ide_a0_line
#define ide_cyl_lsb ide_cs0_line + ide_a2_line
#define ide_cyl_msb ide_cs0_line + ide_a2_line + ide_a0_line
#define ide_head ide_cs0_line + ide_a2_line + ide_a1_line
#define ide_command ide_cs0_line + ide_a2_line + ide_a1_line + ide_a0_line
#define ide_status ide_cs0_line + ide_a2_line + ide_a1_line + ide_a0_line
#define ide_control ide_cs1_line + ide_a2_line + ide_a1_line
#define ide_astatus ide_cs1_line + ide_a2_line + ide_a1_line + ide_a0_line
// IDE commands
#define ide_cmd_recal 0x10
#define ide_cmd_read 0x20
#define ide_cmd_write 0x30
#define ide_cmd_init 0x91
#define ide_cmd_id 0xEC
#define ide_cmd_spindown 0xE0
#define ide_cmd_spinup 0xE1
void spinup(void);
void spindown(void);
char ide_busy(unsigned int a_timeout);
int ide_drq(unsigned int a_timeout);
void ide_init (void);
char get_err(void);
char read_sector(unsigned long int a_lba,char * a_buffer);
char write_sector(unsigned long int a_lba,char * a_buffer);
void wr_lba(unsigned long int a_lba);
void drive_id(char * a_buffer);
void read_data(char * a_buffer);
void write_data(char * a_buffer);
int ide_rd(char a_reg);
void ide_wr(char a_reg, int a_input);
void ide_hard_reset (void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -