コード例 #1
0
ファイル: interrupt.c プロジェクト: champo/ArqvengerOS
/**
 * Remaps the PIC.
 *
 * Initially, in real mode, the first 32 positions of the IDT are occupied by the exceptions
 * and the PIC's interrupts, IRQs. This function moves the IRQs in the IDT, so they
 *  don't overlap with the exceptions.
 *
 * @param offset1 The offset of the position where the IRQ0 was.
 * @param offset2 The offset of the position where the IRQ0 will be moved.
 */
void reMapPIC(int offset1,int offset2){
    unsigned char mask1,mask2;

    // Saving masks
    mask1 = inB(PIC1_DATA);
    mask2 = inB(PIC2_DATA);

    // Starting initialization
    outB(PIC1_COMMAND,0x11);
    outB(PIC2_COMMAND,0x11);

    // Setting PIC offset
    outB(PIC1_DATA,offset1);
    outB(PIC2_DATA,offset2);

    // Continuing initialization
    outB(PIC1_DATA,4);
    outB(PIC2_DATA,2);

    outB(PIC1_DATA,ICW4_8086);
    outB(PIC2_DATA,ICW4_8086);

    // Restore masks
    outB(PIC1_DATA,mask1);
    outB(PIC2_DATA,mask2);
}
コード例 #2
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the registers from the Real Time Clock.
 *
 * It reads the registers from the RTC and stores the data in the struct which
 * pointer it receives. It handles the different types of format in which the data
 * is stored in the RTC registers.
 *
 * @param regs Pointer to struct where the data from RTC registers will be stored.
 *
 */
void readRTCRegisters(RTCRegisters *regs){
    int format;

    // Getting format register
    outB(RTCADDRESS, 11);
    format = inB(RTCDATA);

    // Getting seconds
    regs->seconds = readSeconds();

    // Getting minutes
    regs->minutes = readMinutes();

    // Getting hours (value may be 12hs o 24hs format)
    regs->hours = readHours();

    // Getting day of the month
    regs->day = readDay();

    // Getting month
    regs->month = readMonth();

    // Getting year
    regs->year = readYear();

    // Getting century
    regs->century = readCentury();

    // If in BCD mode, convert to binary
    if ((format & 0x02) ==  0x02 ) {
       regs->seconds = BCDTOBINARY(regs->seconds);
       regs->minutes = BCDTOBINARY( regs->minutes);
       regs->hours = BCDTOBINARY(regs->hours);
       regs->day = BCDTOBINARY(regs->day );
       regs->month = BCDTOBINARY(regs->month);
       regs->year = BCDTOBINARY(regs->year);
       regs->century = BCDTOBINARY(regs->century);
    }

    // If in 12 hs mode, convert to 24 hs mode
    if ((format & 0x04) == 0x04) {
      // Masking off the pm/am bit
        if ( (regs->hours & 0x80) == 0x80 ) {
            regs->hours &= 0x7F;
            // Setting 12 pm as 0 regs->hours and adjusting the rest
            regs->hours = (regs->hours == 12)? 0 : regs->hours + 12;
        }
    }
}
コード例 #3
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC century register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readCentury(void) {
    outB(RTCADDRESS, CENTURYREGISTER);
    return inB(RTCDATA);
}
コード例 #4
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC year register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readYear(void) {
    outB(RTCADDRESS, YEARREGISTER);
    return inB(RTCDATA);
}
コード例 #5
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC month register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readMonth(void) {
    outB(RTCADDRESS, MONTHREGISTER);
    return  inB(RTCDATA);
}
コード例 #6
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC day of the month register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readDay(void) {
    outB(RTCADDRESS, DAYREGISTER);
    return  inB(RTCDATA);
}
コード例 #7
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC hours register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readHours(void) {
    outB(RTCADDRESS, HOURSREGISTER);
    return inB(RTCDATA);
}
コード例 #8
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC minutes register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readMinutes(void) {
    outB(RTCADDRESS, MINUTESREGISTER);
    return  inB(RTCDATA);
}
コード例 #9
0
ファイル: rtc.c プロジェクト: dariosus/ArqvengerOS
/**
 * Read the RTC seconds register.
 *
 * @return An integer representing the data stored in the register (different formats).
 */
int readSeconds(void) {
    outB(RTCADDRESS, SECONDSREGISTER);
    return  inB(RTCDATA);
}