Files
Jungfraujoch/acquisition_device/PCIExpressDevice.h
T
leonarski_f 040cdeacf1 acquisition_device: give each device sole ownership of its buffers
The base AcquisitionDevice no longer allocates or frees frame buffers;
buffer_device is now just a non-owning view of addresses. Each subclass
owns its backing memory and the matching lifecycle:

- PCIExpressDevice mmap's the kernel DMA buffers and munmap's them in its
  own destructor (and on ctor failure), symmetric with MapKernelBuffer.
- HLSSimulatedDevice owns plain zeroed heap buffers it points
  buffer_device into, declared before the HLSDevice so they outlive the
  action thread that writes them. The buffers are page-aligned to match
  the real device's kernel DMA buffers - the modelled AXI datamover and
  FPGAIntegrationTest require aligned output buffers.

This drops the NUMA/mmap dance from the simulated path (not
performance-critical) - removing libnuma from acquisition_device - and
replaces the base-class cleanup that had to guess the allocation
strategy with a single clear owner per device.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 19:18:32 +02:00

40 lines
1.6 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "FPGAAcquisitionDevice.h"
#include "../fpga/host_library/JungfraujochDevice.h"
class PCIExpressDevice : public FPGAAcquisitionDevice {
JungfraujochDevice dev;
void HW_LoadCalibration(const LoadCalibrationConfig &config) override;
bool HW_ReadMailbox(uint32_t *values) override;
bool HW_SendWorkRequest(uint32_t handle) override;
void FPGA_StartAction(const DiffractionExperiment &experiment) override;
bool HW_IsIdle() const final;
void HW_WriteActionRegister(const DataCollectionConfig *job) override;
void HW_ReadActionRegister(DataCollectionConfig *job) override;
void HW_SetSpotFinderParameters(const SpotFinderParameters &params) override;
void FPGA_EndAction() override;
uint32_t GetNumKernelBuffers() const;
void HW_RunInternalGenerator(const FrameGeneratorConfig &config) override;
void UnmapBuffers();
public:
explicit PCIExpressDevice(uint16_t data_stream);
PCIExpressDevice(uint16_t data_stream, uint16_t pci_slot);
PCIExpressDevice(uint16_t data_stream, const std::string &device_name);
~PCIExpressDevice() override;
void Cancel() override;
int32_t GetNUMANode() const override;
void SetIPv4Address(uint32_t ipv4_addr_network_order) override;
std::string GetMACAddress() const override;
std::string GetIPv4Address() const override;
DeviceStatus GetDeviceStatus() const override;
DataCollectionStatus GetDataCollectionStatus() const override;
};