Import backup from 2004-07-09
This commit is contained in:
1 parent
f3fe4ef3b8
commit
0729754659
76 files changed
+470
-7676
No files matched your search
@@ -1,42 +0,0 @@
|
||||
// cmos.c
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements various CMOS function calls
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "cmos.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
//Returns the cmos type of floppy disk drive 0 (0 = not present)
|
||||
unsigned char cmos_getfd0()
|
||||
{
|
||||
outportb(0x70, 0x10);
|
||||
return (inportb(0x71) >> 4);
|
||||
}
|
||||
|
||||
|
||||
//Returns the cmos type of floppy disk drive 1 (0 = not present)
|
||||
unsigned char cmos_getfd1()
|
||||
{
|
||||
outportb(0x70, 0x10);
|
||||
return (inportb(0x71) & 0x0F);
|
||||
}
|
||||
|
||||
|
||||
//Returns the cmos type of hard disk drive 0 (0 = not present)
|
||||
unsigned char cmos_gethd0()
|
||||
{
|
||||
outportb(0x70, 0x12);
|
||||
return (inportb(0x71) >> 4);
|
||||
}
|
||||
|
||||
|
||||
//Returns the cmos type of hard disk drive 1 (0 = not present)
|
||||
unsigned char cmos_gethd1()
|
||||
{
|
||||
outportb(0x70, 0x12);
|
||||
return (inportb(0x71) & 0x0F);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// cmos.h
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements various CMOS function calls
|
||||
|
||||
#include "hos_defines.h"
|
||||
|
||||
#ifndef __HOS_CMOS__
|
||||
#define __HOS_CMOS__ __HOS_CMOS__
|
||||
|
||||
unsigned char cmos_getfd0();
|
||||
unsigned char cmos_getfd1();
|
||||
unsigned char cmos_gethd0();
|
||||
unsigned char cmos_gethd1();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// io.c
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements basic port input/output functions
|
||||
|
||||
#include "io.h"
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// io.h
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements basic port input/output functions
|
||||
|
||||
#ifndef __HOS_IO__
|
||||
#define __HOS_IO__ __HOS_IO__
|
||||
|
||||
#include "hos_defines.h"
|
||||
|
||||
//void outportb(unsigned int port, unsigned char value);
|
||||
//inline void outportw(unsigned int port, unsigned int value);
|
||||
//inline unsigned char inportb(unsigned short port);
|
||||
|
||||
//Writes a byte out to a port
|
||||
static inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
||||
{
|
||||
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
||||
}
|
||||
|
||||
//Writes a word out to a port
|
||||
static inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
||||
{
|
||||
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
||||
}
|
||||
|
||||
//Reads a byte from a port
|
||||
static inline unsigned char inportb(unsigned short port)
|
||||
{
|
||||
unsigned char ret_val;
|
||||
|
||||
asm volatile("inb %w1,%b0"
|
||||
: "=a"(ret_val)
|
||||
: "d"(port));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// pic.c
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "pic.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
//Re-maps the Programmable Interrupr Controllers so IRQ0->pic1 base address, IRG8->pic2 base address
|
||||
void pic_remap(int pic1, int pic2)
|
||||
{
|
||||
byte a1, a2;
|
||||
|
||||
a1 = inportb(PIC1_DATA); //0x21
|
||||
a2 = inportb(PIC2_DATA); //0xA1
|
||||
|
||||
outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4); //0x20, 0x10+0x01 00010001b
|
||||
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4); //0xA0, 0x10+0x01 00010001b
|
||||
outportb(PIC1_DATA, pic1); //0x21, pic1
|
||||
outportb(PIC2_DATA, pic2); //0xA1, pic2
|
||||
outportb(PIC1_DATA, 4); //0x21, 0x04 00000100b
|
||||
outportb(PIC2_DATA, 2); //0xA1, 0x02 00000010b
|
||||
outportb(PIC1_DATA, ICW4_8086); //0x21, 0x01 00000001b
|
||||
outportb(PIC2_DATA, ICW4_8086); //0xA1, 0x01 00000001b
|
||||
|
||||
outportb(PIC1_DATA, a1); //0x21
|
||||
outportb(PIC2_DATA, a2); //0xA1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
// pic.h
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
|
||||
#ifndef __HOS_PIC__
|
||||
#define __HOS_PIC__ __HOS_PIC__
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
#define PIC1 0x20
|
||||
#define PIC2 0xA0
|
||||
#define PIC1_COMMAND PIC1
|
||||
#define PIC1_DATA (PIC1+1)
|
||||
#define PIC2_COMMAND PIC2
|
||||
#define PIC2_DATA (PIC2+1)
|
||||
#define PIC_EOI 0x20
|
||||
|
||||
#define ICW1_ICW4 0x01 /* ICW4 (not) needed */
|
||||
#define ICW1_SINGLE 0x02 /* Single (cascade) mode */
|
||||
#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */
|
||||
#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */
|
||||
#define ICW1_INIT 0x10 /* Initialization - required! */
|
||||
|
||||
#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
|
||||
#define ICW4_AUTO 0x02 /* Auto (normal) EOI */
|
||||
#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */
|
||||
#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
|
||||
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
|
||||
|
||||
void pic_remap(int pic1, int pic2);
|
||||
//inline void pic_mask1(byte mask);
|
||||
//inline void pic_mask2(byte mask);
|
||||
//inline void pic_eoi();
|
||||
//inline void pic_eoi2();
|
||||
|
||||
//Masks interrupts on first Programmable Interrupt Controller
|
||||
static inline void pic_mask1(byte mask)
|
||||
{
|
||||
outportb(PIC1_DATA, mask); //0x21, maskfield *OCW1*
|
||||
}
|
||||
|
||||
//Masks interrupts on second Programmable Interrupt Controller
|
||||
static inline void pic_mask2(byte mask)
|
||||
{
|
||||
outportb(PIC2_DATA, mask); //0xA1, maskfield *OCW1*
|
||||
}
|
||||
|
||||
|
||||
//Signals an End Of Interrupt signal to the first PIC
|
||||
static inline void pic_eoi()
|
||||
{
|
||||
outportb(0x20, 0x20);
|
||||
}
|
||||
|
||||
//Signals an End Of Interrupt signal to both the second and first PIC unit
|
||||
static inline void pic_eoi2()
|
||||
{
|
||||
outportb(0xA0, 0x20);
|
||||
outportb(0x20, 0x20);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
// rtc.c
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements Real-Time Clock function calls
|
||||
// These functions are for reading and writing various values stored on the CMOS Real Time Clock
|
||||
// Parameters / return values are in BCD format
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "rtc.h"
|
||||
#include "sys/io.h"
|
||||
|
||||
unsigned char rtc_readDay()
|
||||
{
|
||||
outportb(0x70, 7);
|
||||
return inportb(0x71);
|
||||
}
|
||||
|
||||
unsigned char rtc_readMonth()
|
||||
{
|
||||
outportb(0x70, 8);
|
||||
return inportb(0x71);
|
||||
}
|
||||
|
||||
unsigned char rtc_readYear()
|
||||
{
|
||||
outportb(0x70, 9);
|
||||
return inportb(0x71);
|
||||
}
|
||||
|
||||
unsigned char rtc_readSecond()
|
||||
{
|
||||
outportb(0x70, 0);
|
||||
return inportb(0x71);
|
||||
}
|
||||
|
||||
unsigned char rtc_readMinute()
|
||||
{
|
||||
outportb(0x70, 2);
|
||||
return inportb(0x71);
|
||||
}
|
||||
|
||||
unsigned char rtc_readHour()
|
||||
{
|
||||
outportb(0x70, 4);
|
||||
return inportb(0x71);
|
||||
}
|
||||
|
||||
void rtc_setDay(unsigned char day)
|
||||
{
|
||||
outportb(0x70, 7);
|
||||
outportb(0x71, day);
|
||||
}
|
||||
|
||||
void rtc_setMonth(unsigned char month)
|
||||
{
|
||||
outportb(0x70, 8);
|
||||
outportb(0x71, month);
|
||||
}
|
||||
|
||||
void rtc_setYear(unsigned char year)
|
||||
{
|
||||
outportb(0x70, 9);
|
||||
outportb(0x71, year);
|
||||
}
|
||||
|
||||
void rtc_setSecond(unsigned char second)
|
||||
{
|
||||
outportb(0x70, 0);
|
||||
outportb(0x71, second);
|
||||
}
|
||||
|
||||
void rtc_setMinute(unsigned char minute)
|
||||
{
|
||||
outportb(0x70, 2);
|
||||
outportb(0x71, minute);
|
||||
}
|
||||
|
||||
void rtc_setHour(unsigned char hour)
|
||||
{
|
||||
outportb(0x70, 4);
|
||||
outportb(0x71, hour);
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// rtc.h
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements Real-Time Clock function calls
|
||||
// These functions are for reading and writing various values stored on the CMOS Real Time Clock
|
||||
// Parameters / return values are in BCD format
|
||||
|
||||
#ifndef __HOS_RTC__
|
||||
#define __HOS_RTC__ __HOS_RTC__
|
||||
|
||||
#include "hos_defines.h"
|
||||
|
||||
unsigned char rtc_readDay();
|
||||
unsigned char rtc_readMonth();
|
||||
unsigned char rtc_readYear();
|
||||
unsigned char rtc_readSecond();
|
||||
unsigned char rtc_readMinute();
|
||||
unsigned char rtc_readHour();
|
||||
void rtc_setDay(unsigned char dat);
|
||||
void rtc_setMonth(unsigned char month);
|
||||
void rtc_setYear(unsigned char year);
|
||||
void rtc_setSecond(unsigned char second);
|
||||
void rtc_setMinute(unsigned char minute);
|
||||
void rtc_setHour(unsigned char hour);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user