Beispiel #1
0
static void
initiator_reset(void)
{
   // Perform a reset of the Initiator device by setting the low bit of the Device
   // Control Register (DCR) high.
   write_ctrl(DCR_OFFSET, 0x1);
   
   // Clears a reset of the Initiator device by setting the low bit of the Device
   // Control Register (DCR) low, then setting it low again.
   write_ctrl(DCR_OFFSET, 0x0);
   
}
Beispiel #2
0
/*
 * Transition the current processor to the requested state.
 */
static void
pwrnow_pstate_transition(uint32_t req_state)
{
	cpupm_mach_state_t *mach_state =
	    (cpupm_mach_state_t *)CPU->cpu_m.mcpu_pm_mach_state;
	cpu_acpi_handle_t handle = mach_state->ms_acpi_handle;
	cpu_acpi_pstate_t *req_pstate;
	uint32_t ctrl;

	req_pstate = (cpu_acpi_pstate_t *)CPU_ACPI_PSTATES(handle);
	req_pstate += req_state;

	DTRACE_PROBE1(pwrnow_transition_freq, uint32_t,
	    CPU_ACPI_FREQ(req_pstate));

	/*
	 * Initiate the processor p-state change.
	 */
	ctrl = CPU_ACPI_PSTATE_CTRL(req_pstate);
	write_ctrl(handle, ctrl);

	if (mach_state->ms_turbo != NULL)
		cpupm_record_turbo_info(mach_state->ms_turbo,
		    mach_state->ms_pstate.cma_state.pstate, req_state);

	mach_state->ms_pstate.cma_state.pstate = req_state;
	cpu_set_curr_clock((uint64_t)CPU_ACPI_FREQ(req_pstate) * 1000000);
}
Beispiel #3
0
static void
write_dma_start(void)
{
   unsigned int regValue;
   initiator_reset(); // always must happen first before starting a DMA transfer
   
   // Initiate any DMA transfers that have been set up in the Read/Write registers.
   regValue = read_ctrl(DCSR_OFFSET); // Read the entire register to preserve bits
   regValue |= 0x1;
   write_ctrl(DCSR_OFFSET, regValue);
   
}
Beispiel #4
0
static void
read_dma_count(unsigned int count)
{
   unsigned int regvalue;
   if(count > MAX_TLP_COUNT) {
      printk("ERROR, cannot have TLP larger than %u\n", MAX_TLP_COUNT);
      return ;
   }
   
   // Sets the number of TLPs to transfer by writing the value to the Write DMA TLP Count Register.
   regvalue = read_ctrl(READ_COUNT_OFFSET);// read the entire register to preserve the upper bits
   regvalue &= 0xffff0000;// clear the lower 16 bits for the new count value
   regvalue |= (count & 0xffff);// set the new count
   write_ctrl(READ_COUNT_OFFSET, regvalue);
}
Beispiel #5
0
static void
read_dma_size(unsigned int size)
{
   // Sets the size in bytes of each TLP by writing the value to the Write DMA TLP Size Register.
   unsigned int regValue;
   
   if(size > MAX_TLP_SIZE) {
      printk("ERROR, cannot have TLP larger than %u\n", MAX_TLP_SIZE);
      return ;
   }
   // Set the new Write TLP size.
   regValue = read_ctrl(READ_SIZE_OFFSET); // Read the entire register to preserve the upper bits
   regValue &= 0xFFFFF000; // Clear the lower 12 bits for the new size value
   regValue |= (size & 0xFFF); // Set the new size
   write_ctrl(READ_SIZE_OFFSET, regValue);
}
Beispiel #6
0
/** *******************************************************************************************************************
  @brief send everything in the ringbuffer to the controller.
 ******************************************************************************************************************** */
static void
buddy_flush_ringbuffer(void)
{
    static sigset_t         sigset, oldset;
    static buddy_cmnd_t     ack, curcmnd;
    static buddy_info_t volatile *volatile thisp;

    ack = curcmnd = this_command;
    sigfillset(&sigset);

    upk_debug1("flushing ringbuffer; which currently has %d pending msg's \n", ringbuffer_pending);
    phone_home_if_appropriate();

    if(buddy_ctrlfd >= 0) {
        sigprocmask(SIG_BLOCK, &sigset, &oldset);

        thisp = info_ringbuffer;
        do {
            if(info_ringbuffer->populated) {
                info_ringbuffer->remaining = ringbuffer_pending - 1;
                if(write_ctrl(info_ringbuffer) > 0) {
                    if((read_ctrl(&ack)) > 0 && ack == UPK_CTRL_ACK) {
                        buddy_zero_info();
                        info_ringbuffer = info_ringbuffer->next;
                        continue;
                    }
                }
                info_ringbuffer = thisp;
                break;
            }
            info_ringbuffer = info_ringbuffer->next;
        } while(info_ringbuffer != thisp);
        errno = 0;
        buddy_disconnect(0);

        this_command = curcmnd;
        sigprocmask(SIG_SETMASK, &oldset, NULL);
    }
    return;
}
Beispiel #7
0
 static void
 atomic_dma_read(unsigned int tlp_size, unsigned int tlp_count)
 {
    write_ctrl(ATOMIC_READ_OFFSET, (tlp_size & 0xffff) | ((tlp_size << 16)&0xffff0000));
 }
Beispiel #8
0
static void
write_dma_addr(unsigned int addr)
{
   // Writes the target address on the host for a DMA transfer to the Write DMA TLP Address Register.
   write_ctrl(WRITE_ADDR_OFFSET, addr & 0xFFFFFFFC);
}