student-distrib/rtc.c
int32_t rtc_write(int32_t* fd, uint32_t* i, char* buf, uint32_t nbytes) {
	// Check if nbytes = 4, if not, invalid
	if(nbytes != 4) {
		return -1;
	}
	
	//return rtc_set_frequency(*(uint32_t*)buf);
	// Check if input is a valid power of 2, otherwise return failure
	if((*(uint32_t*)buf <= 1024) && (*(uint32_t*)buf >= 2) && !(*(uint32_t*)buf & (*(uint32_t*)buf - 1))) {
		// Valid power of 2, reset interrupt count and set frequency
		rtc_inter_count = 0;
		virt_freq = *(uint32_t*)buf;
		return 0;
	}
	// Invald input, so return failure
	return -1;
}
/* rtc_write() (heffley)
 * Inputs: fd unused, buf ptr containing new frequency, nbytes to check if 4 bytes
 * Returns: 0 on success, -1 on failure
 * Effects: Changes the frequency at which the real time clock generates interrupts
 */
rtc_write() (heffley)
Inputs: fd unused, buf ptr containing new frequency, nbytes to check if 4 bytes
Returns: 0 on success, -1 on failure
Effects: Changes the frequency at which the real time clock generates interrupts
rtc_write () ( heffley ) Inputs : fd unused buf ptr containing new frequency nbytes to check if 4 bytes Returns : 0 on success - 1 on failure Effects : Changes the frequency at which the real time clock generates interrupts
int32_t rtc_write(int32_t* fd, uint32_t* i, char* buf, uint32_t nbytes) {
	if(nbytes != 4) {
		return -1;
	}
	if((*(uint32_t*)buf <= 1024) && (*(uint32_t*)buf >= 2) && !(*(uint32_t*)buf & (*(uint32_t*)buf - 1))) {
		rtc_inter_count = 0;
		virt_freq = *(uint32_t*)buf;
		return 0;
	}
	return -1;
}
int32_t rtc_write ( int32_t * fd , uint32_t * i , char * buf , uint32_t nbytes ) { if ( nbytes != 4 ) { return -1 ; } if ( ( * ( uint32_t * ) buf <= 1024 ) && ( * ( uint32_t * ) buf >= 2 ) && ! ( * ( uint32_t * ) buf & ( * ( uint32_t * ) buf - 1 ) ) ) { rtc_inter_count = 0 ; virt_freq = * ( uint32_t * ) buf ; return 0 ; } return -1 ; }
rtc_write() (heffley)
 Inputs: fd unused, buf ptr containing new frequency, nbytes to check if 4 bytes
 Returns: 0 on success, -1 on failure
 Effects: Changes the frequency at which the real time clock generates interrupts
rtc_write () ( heffley ) Inputs : fd unused buf ptr containing new frequency nbytes to check if 4 bytes Returns : 0 on success - 1 on failure Effects : Changes the frequency at which the real time clock generates interrupts
// Check if nbytes = 4, if not, invalid //return rtc_set_frequency(*(uint32_t*)buf); // Check if input is a valid power of 2, otherwise return failure // Valid power of 2, reset interrupt count and set frequency // Invald input, so return failure