Javier A.
09/10/2012 1:27 PM
post95486
|
Hi guys,
Thank you for the update.
Here is what I am doing right now.
volatile qtime_entry* qtime_ptr_;
//-Map the qtime kernel struct to local memory
void init_memory(){
struct qtime_entry* kernel_qtime = SYSPAGE_ENTRY ( qtime );
off64_t offset = 0;
if( -1 == mem_offset64(kernel_qtime, NOFD, sizeof(qtime_entry), &offset, 0)){
fprintf(stderr, "Failed to get phyaddr %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
printf("Qtime physical addr 0x%x\n", offset);
qtime_ptr_ = (struct qtime_entry*) mmap_device_memory(0, sizeof(qtime_entry), PROT_READ | PROT_WRITE | PROT_NOCACHE,
0, offset);
if (qtime_ptr_ == MAP_FAILED){
fprintf(stderr, "Failed to map qtime %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
}
//-ISR
const struct sigevent * isr(void* p, int id) {
//If not interrupt pending on my HW return NULL
.....
//-Disable timing interrupt
InterruptMask(qtime_ptr_->intr, -1);
//-Read until there is no change (this will ensure the clock is not in the middle of an update)
uint64_t current_nsec;
do{
current_nsec = qtime_ptr_->nsec;
} while (qtime_ptr_->nsec != current_nsec);
//-Adjust clock (set it to next_time_sec & next_time_nsec)
qtime_ptr_->nsec_tod_adjust = (next_time_sec * 1000000000) + next_time_nsec -
current_nsec;
InterruptUnmask(qtime_ptr_->intr, -1);
//-Fire event
return (&intr_event_);
}
If the 2 ISRs can run concurrently the only way to do a proper synchronization would be to share a spinlock (which I do
believe QNX has it but is only internal to the Kernel). So far this is the best I ca do. If you have any ideas or
critics go ahead…
Javier
|
|
|