require '_h2ph_pre.ph';

unless(defined(&_MC146818RTC_H)) {
    eval 'sub _MC146818RTC_H () {1;}' unless defined(&_MC146818RTC_H);
    require 'asm/io.ph';
    require 'linux/rtc.ph';
    require 'linux/spinlock.ph';
    require 'asm/mc146818rtc.ph';
    eval 'sub RTC_SECONDS () {0;}' unless defined(&RTC_SECONDS);
    eval 'sub RTC_SECONDS_ALARM () {1;}' unless defined(&RTC_SECONDS_ALARM);
    eval 'sub RTC_MINUTES () {2;}' unless defined(&RTC_MINUTES);
    eval 'sub RTC_MINUTES_ALARM () {3;}' unless defined(&RTC_MINUTES_ALARM);
    eval 'sub RTC_HOURS () {4;}' unless defined(&RTC_HOURS);
    eval 'sub RTC_HOURS_ALARM () {5;}' unless defined(&RTC_HOURS_ALARM);
    eval 'sub RTC_ALARM_DONT_CARE () {0xc0;}' unless defined(&RTC_ALARM_DONT_CARE);
    eval 'sub RTC_DAY_OF_WEEK () {6;}' unless defined(&RTC_DAY_OF_WEEK);
    eval 'sub RTC_DAY_OF_MONTH () {7;}' unless defined(&RTC_DAY_OF_MONTH);
    eval 'sub RTC_MONTH () {8;}' unless defined(&RTC_MONTH);
    eval 'sub RTC_YEAR () {9;}' unless defined(&RTC_YEAR);
    eval 'sub RTC_REG_A () {10;}' unless defined(&RTC_REG_A);
    eval 'sub RTC_REG_B () {11;}' unless defined(&RTC_REG_B);
    eval 'sub RTC_REG_C () {12;}' unless defined(&RTC_REG_C);
    eval 'sub RTC_REG_D () {13;}' unless defined(&RTC_REG_D);
    eval 'sub RTC_FREQ_SELECT () { &RTC_REG_A;}' unless defined(&RTC_FREQ_SELECT);
    eval 'sub RTC_UIP () {0x80;}' unless defined(&RTC_UIP);
    eval 'sub RTC_DIV_CTL () {0x70;}' unless defined(&RTC_DIV_CTL);
    eval 'sub RTC_REF_CLCK_4MHZ () {0x;}' unless defined(&RTC_REF_CLCK_4MHZ);
    eval 'sub RTC_REF_CLCK_1MHZ () {0x10;}' unless defined(&RTC_REF_CLCK_1MHZ);
    eval 'sub RTC_REF_CLCK_32KHZ () {0x20;}' unless defined(&RTC_REF_CLCK_32KHZ);
    eval 'sub RTC_DIV_RESET1 () {0x60;}' unless defined(&RTC_DIV_RESET1);
    eval 'sub RTC_DIV_RESET2 () {0x70;}' unless defined(&RTC_DIV_RESET2);
    eval 'sub RTC_RATE_SELECT () {0xf;}' unless defined(&RTC_RATE_SELECT);
    eval 'sub RTC_CONTROL () { &RTC_REG_B;}' unless defined(&RTC_CONTROL);
    eval 'sub RTC_SET () {0x80;}' unless defined(&RTC_SET);
    eval 'sub RTC_PIE () {0x40;}' unless defined(&RTC_PIE);
    eval 'sub RTC_AIE () {0x20;}' unless defined(&RTC_AIE);
    eval 'sub RTC_UIE () {0x10;}' unless defined(&RTC_UIE);
    eval 'sub RTC_SQWE () {0x8;}' unless defined(&RTC_SQWE);
    eval 'sub RTC_DM_BINARY () {0x4;}' unless defined(&RTC_DM_BINARY);
    eval 'sub RTC_24H () {0x2;}' unless defined(&RTC_24H);
    eval 'sub RTC_DST_EN () {0x1;}' unless defined(&RTC_DST_EN);
    eval 'sub RTC_INTR_FLAGS () { &RTC_REG_C;}' unless defined(&RTC_INTR_FLAGS);
    eval 'sub RTC_IRQF () {0x80;}' unless defined(&RTC_IRQF);
    eval 'sub RTC_PF () {0x40;}' unless defined(&RTC_PF);
    eval 'sub RTC_AF () {0x20;}' unless defined(&RTC_AF);
    eval 'sub RTC_UF () {0x10;}' unless defined(&RTC_UF);
    eval 'sub RTC_VALID () { &RTC_REG_D;}' unless defined(&RTC_VALID);
    eval 'sub RTC_VRT () {0x80;}' unless defined(&RTC_VRT);
    unless(defined(&BCD_TO_BIN)) {
	eval 'sub BCD_TO_BIN {
	    local($val) = @_;
    	    eval q((($val)=(($val)&15) + (($val)>>4)*10));
	}' unless defined(&BCD_TO_BIN);
    }
    unless(defined(&BIN_TO_BCD)) {
	eval 'sub BIN_TO_BCD {
	    local($val) = @_;
    	    eval q((($val)=((($val)/10)<<4) + ($val)%10));
	}' unless defined(&BIN_TO_BCD);
    }
}
1;
