/* It is worth noting that these functions all access bytes of general *purposememoryintheNVRAM-thatistosay,theyalladdthe *NVRAM_FIRST_BYTEoffset.PassthemoffsetsintoNVRAMasifyoudidnot *knowabouttheRTCcruft.
*/
/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with *rtc_lockheld.Duetotheindex-port/data-portdesignoftheRTC,we *don'twanttwodifferentthingstryingtogettoitatonce.(e.g.the *periodic11minsyncfromkernel/time/ntp.cvs.thisdriver.)
*/
/* This races nicely with trying to read with checksum checking */ staticvoid __nvram_write_byte(unsignedchar c, int i)
{
CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
}
/* On Ataris, the checksum is over all bytes except the checksum bytes *themselves;theseareattheveryend.
*/ #define ATARI_CKS_RANGE_START 0 #define ATARI_CKS_RANGE_END 47 #define ATARI_CKS_LOC 48
staticint __nvram_check_checksum(void)
{ int i; unsignedchar sum = 0;
for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
sum += __nvram_read_byte(i); return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) &&
(__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
}
staticvoid __nvram_set_checksum(void)
{ int i; unsignedchar sum = 0;
for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i)
sum += __nvram_read_byte(i);
__nvram_write_byte(~sum, ATARI_CKS_LOC);
__nvram_write_byte(sum, ATARI_CKS_LOC + 1);
}
long atari_nvram_set_checksum(void)
{
spin_lock_irq(&rtc_lock);
__nvram_set_checksum();
spin_unlock_irq(&rtc_lock); return0;
}
long atari_nvram_initialize(void)
{
loff_t i;
spin_lock_irq(&rtc_lock); for (i = 0; i < NVRAM_BYTES; ++i)
__nvram_write_byte(0, i);
__nvram_set_checksum();
spin_unlock_irq(&rtc_lock); return0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.