Defines | Functions | Variables

llcontrol-core.c File Reference

module implements the core of llcontrol loop. More...

#include "local.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <popt.h>
#include "acq32ioctl.h"
#include "acq32busprot.h"
#include "llif.h"
#include "llprotocol.h"
#include "llcontrol.h"
#include "x86timer.h"
#include "llcontrol-core.h"
#include <signal.h>

Go to the source code of this file.

Defines

#define FLAVOR   "ACQ32"
#define EACHMFA   (dac_buf[icard].mfa)
#define EACHBBB   (dac_buf[icard].bbb)
#define EACHDAC_BASE   (EACHBBB + EACHMFA)
#define EACHDAC_BASE16   ((u16*)EACHDAC_BASE)
#define NMEASURE   20

Functions

static void mbox_updateTstats (u32 cmd, struct Card *card, struct TimingStats *tstats)
 update timing stats from card mailbox.
void v2_updateTstats (u32 cmd, struct Card *card, struct TimingStats *tstats)
 updates timing stats from embedded host buffer data
void doApplicationWork (struct TestDescription *td, u32 offset)
static u32 card_v1_WaitDmaDone (struct Card *card)
u32 card_v2_WaitDmaDone (struct Card *card)
 updates timing stats from embedded host buffer data
static int do_run (struct TestDescription *td, int soft_clock)
 runs the test.
static int runSCM (struct TestDescription *td)
 Run a Test - Soft Clock Master.
static int runECM (struct TestDescription *td)
 Run a Test - External Clock Master.
u32 commandModifiers (struct TestDescription *td)
static int measureBridge (struct MU *mu)
 Run a test - measureBridge performance.
static int measureBridgeStats (struct TestDescription *td, struct MU *mu)
int runTest (struct TestDescription *td)
 generic top level text exec.
static void quit_handler (int signum)
void setupAbortHandler (struct TestDescription *td)
static void monitor_handler (int signum)
void setupMonitor (int millisec)
void initCardResource (struct Card *card)
static void debug_prompt (int icard, int ibuf, u32 addr)
 promnpt user to ensure pram set (temporary pre-update measure).
void initV2Stats (struct TestDescription *td)

Variables

const char * core_ident = "$Revision: 1.1.4.33 $ B1102\n"
void(* updateTstats )(u32 cmd, struct Card *card, struct TimingStats *tstats)
 virtual function to retrieve timing stats.
u32(* waitDmaDone )(struct Card *c) = card_v1_WaitDmaDone
 virtual function to block until DMA done.
int user_abort = 0
static struct TestDescriptionS_td

Detailed Description

module implements the core of llcontrol loop.

Linux 2.4 Host Only:

2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4

Note on HOST MEMORY MAP: assumes bootcommand configured as follows, to allow a 16MB host area per card in at the top of memory. This host area will be slaved off the pci backplane

eg

[dt100 dt100]$ cat /proc/cmdline mem=320M acq32.load_order=slotbased

acq32_big_buf_base=0x18000000 acq32_big_buf_len=0x08000000

For the purpose of LLCONTROL, each 16MB card are is used as follows:

2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4 2.4

This means that if the llcontrol app is using an incrementing memory strategy in host buffer for AI, this is subject to max 15MB (80K samples at 96 channels).

The message buffers are used for DAC output. The application reserves a Mesage Frame Address (MFA) from the target before copying data to slave memory. The MFA is an index into the message buffer memory.

Linux 2.6 Host:

the host buffer is setup dynamically, but is LIMITED to 4MB, of which the top 1M is used for messaging.

Definition in file llcontrol-core.c.


Define Documentation

#define EACHBBB   (dac_buf[icard].bbb)
#define EACHDAC_BASE   (EACHBBB + EACHMFA)
#define EACHDAC_BASE16   ((u16*)EACHDAC_BASE)
#define EACHMFA   (dac_buf[icard].mfa)

Referenced by do_run().

#define FLAVOR   "ACQ32"

Definition at line 226 of file llcontrol-core.c.

#define NMEASURE   20

Referenced by measureBridge().


Function Documentation

static u32 card_v1_WaitDmaDone ( struct Card card  )  [static]

Definition at line 292 of file llcontrol-core.c.

References llWaitDmaDone(), and Card::mbx.

u32 card_v2_WaitDmaDone ( struct Card card  ) 

updates timing stats from embedded host buffer data

Definition at line 297 of file llcontrol-core.c.

References Card::buf, getVaddr(), LLCV2_OFFSET_STATUS_HSBT, llv2WaitDmaDone(), and Card::mbx.

u32 commandModifiers ( struct TestDescription td  ) 
static void debug_prompt ( int  icard,
int  ibuf,
u32  addr 
) [static]

promnpt user to ensure pram set (temporary pre-update measure).

Definition at line 862 of file llcontrol-core.c.

Referenced by initV2Stats().

static int do_run ( struct TestDescription td,
int  soft_clock 
) [static]

runs the test.

Todo:
could be set by a signal

PSEUDO-CODE:

  • (1) Clear the latch timer
  • (2) Set a local memory target address and arm the capture
  • (3) Poll for counter running (hardware counter starts on external gate)
  • (4) Iterate for required number of samples:
  • (5) [optionally send a soft clock command] trigger an acquisition
  • (6) Wait for DMA Done - at this point data is available in target mem. A "real" control application is probably getting most of its calcs done here rather than simply polling
  • (7) [Get the latch (sample) and current uSec counters from the boards - only if interested]
  • (8) Check the process has not stopped (external gate high)
  • (9) [optionally update the target address - else it gets overwritten]
  • (a) using DACS - preallocate a MFA for dac data.
  • (b) write data to host side buffer(f(MFA)) and post MFA
  • (b.1) take the incoming value on feedback_channel and propagate to all DACS. default is to assume HAWG on DAC0 (so feedback_channel better be 0 !), but td->update_dacs makes a better test.
  • (b.15) special case where we are DRIVING the initial DAC signal from host side.
  • (b.2) simple feedforward case - just drive all DACS from AWG pattern.
  • (c) later, pick up another MFA
  • (d) finally, return final set of MFA's. might be a good idea to ensure data is zero at this point

(b.2)

Definition at line 313 of file llcontrol-core.c.

References TestDescription::arg, TestDescription::channels, DAC_COUNT, DAC_SAMPLE_SIZE, TestDescription::decimation, TestDescription::do_work, doApplicationWork(), EACHBBB, EACHBUF, EACHCARD, EACHDAC_BASE, EACHDAC_BASE16, EACHMBX, EACHMFA, TestDescription::feedback, TestDescription::feedback_channel, FIRSTBUF, FIRSTMBX, FOREACHCARD, FOREACHCARD_MARK_TIME, G_quit, getMboxPollcount(), getVaddr(), TestDescription::hardware_gate_off, TimingStats::hb_poll, TestDescription::hb_polling, hbPoll(), hbPrimePoll(), icard, TestDescription::ARG::interval, TestDescription::iter, TestDescription::iterations, LLC_CSR_M_ARM, LLC_CSR_M_READCTR, LLC_CSR_M_SOFTCLOCK, LLC_MAKE_DECIM, llCounterRunning(), llGetTinst(), llSetCmd(), llSetDacs(), llSetTlatch(), MARK_TIME, memset32(), TestDescription::min_latency_test, mu_putOutbound(), mu_reserveOutbound(), TestDescription::overwrite, POLLALERT, PRINTF, TestDescription::sample_offset, TestDescription::stats_buf, TimingStats::target_poll, td_get_next_dac_data(), td_sample_size(), TimingStats::tlatch, TestDescription::tlog, TestDescription::update_dacs, updateTargetAddr(), updateTimingStats(), updateTstats, user_abort, and waitDmaDone.

Referenced by runECM(), and runSCM().

void doApplicationWork ( struct TestDescription td,
u32  offset 
)
void initCardResource ( struct Card card  ) 
void initV2Stats ( struct TestDescription td  ) 
static void mbox_updateTstats ( u32  cmd,
struct Card card,
struct TimingStats tstats 
) [static]

update timing stats from card mailbox.

Todo:
  • with hbpoll ON, WaitDmaDone should be a formality - single poll to confirm done - we should CHECK THIS IS TRUE

Definition at line 238 of file llcontrol-core.c.

References LLC_CSR_M_READCTR, llGetTinst(), llGetTprocess(), llSetCmd(), Card::mbx, PRINTF, Card::slot, TimingStats::tinst, TimingStats::tlatch, and TimingStats::tprocess.

static int measureBridge ( struct MU mu  )  [static]

Run a test - measureBridge performance.

Definition at line 565 of file llcontrol-core.c.

References get_elapsed_microseconds(), getMbox(), and NMEASURE.

Referenced by runTest().

static int measureBridgeStats ( struct TestDescription td,
struct MU mu 
) [static]
static void monitor_handler ( int  signum  )  [static]
static void quit_handler ( int  signum  )  [static]

Definition at line 771 of file llcontrol-core.c.

References EACHMBX, FOREACHCARD, getMbox(), leaveLLC(), and showLastWrites().

Referenced by setupAbortHandler().

static int runECM ( struct TestDescription td  )  [static]

Run a Test - External Clock Master.

Definition at line 547 of file llcontrol-core.c.

References do_run().

Referenced by runTest().

static int runSCM ( struct TestDescription td  )  [static]

Run a Test - Soft Clock Master.

Definition at line 537 of file llcontrol-core.c.

References do_run().

Referenced by runTest().

int runTest ( struct TestDescription td  ) 
void setupAbortHandler ( struct TestDescription td  ) 

Definition at line 796 of file llcontrol-core.c.

References quit_handler().

Referenced by main().

void setupMonitor ( int  millisec  ) 

Definition at line 839 of file llcontrol-core.c.

References monitor_handler().

Referenced by main(), and monitor_handler().

void v2_updateTstats ( u32  cmd,
struct Card card,
struct TimingStats tstats 
)

updates timing stats from embedded host buffer data

Definition at line 257 of file llcontrol-core.c.

References BP_MB_LLC_CSR, BP_MB_LLC_TINST, Card::buf, getVaddr(), LLC_GET_TCYCLE, LLCV2_OFFSET_STATUS_HSBT, LLCV2_STATUS_TINST, llv2_extend32(), TimingStats::tinst, and TimingStats::tprocess.


Variable Documentation

const char* core_ident = "$Revision: 1.1.4.33 $ B1102\n"

Definition at line 232 of file llcontrol-core.c.

Referenced by main().

struct TestDescription* S_td [static]

Definition at line 769 of file llcontrol-core.c.

Initial value:

virtual function to retrieve timing stats.

defaults to V1 mbox.

defaults to V1 mode mbox_updateTstats().

Definition at line 268 of file llcontrol-core.c.

Referenced by appEnterLLC_SYNC_2V(), appEnterLLC_SYNC_2VAO32(), appEnterLLC_SYNC_ECM(), do_run(), initV2Stats(), runSCM216(), runSYNC_2V(), runSYNC_2VAO32(), runSYNC_2VRFM(), and runSYNC_ECM().

int user_abort = 0

Definition at line 311 of file llcontrol-core.c.

Referenced by do_run(), and runSCM216().

waitDmaDone = card_v1_WaitDmaDone

virtual function to block until DMA done.

defaults to V1 mbox

Definition at line 305 of file llcontrol-core.c.

Referenced by appEnterLLC_SYNC_2V(), appEnterLLC_SYNC_2VAO32(), appEnterLLC_SYNC_ECM(), do_run(), initV2Stats(), runSCM216(), runSYNC_2V(), runSYNC_2VAO32(), runSYNC_2VRFM(), and runSYNC_ECM().