me.bechberger.ebpf.bpf.raw.ifmap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rawbpf Show documentation
Show all versions of rawbpf Show documentation
Raw Panama bindings for libbpf generated for jextract on 64-bit Linux
The newest version!
// Generated by jextract
package me.bechberger.ebpf.bpf.raw;
import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;
/**
* {@snippet lang=c :
* struct ifmap {
* unsigned long mem_start;
* unsigned long mem_end;
* unsigned short base_addr;
* unsigned char irq;
* unsigned char dma;
* unsigned char port;
* }
* }
*/
public class ifmap {
ifmap() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
Lib.C_LONG.withName("mem_start"),
Lib.C_LONG.withName("mem_end"),
Lib.C_SHORT.withName("base_addr"),
Lib.C_CHAR.withName("irq"),
Lib.C_CHAR.withName("dma"),
Lib.C_CHAR.withName("port"),
MemoryLayout.paddingLayout(3)
).withName("ifmap");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final OfLong mem_start$LAYOUT = (OfLong)$LAYOUT.select(groupElement("mem_start"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned long mem_start
* }
*/
public static final OfLong mem_start$layout() {
return mem_start$LAYOUT;
}
private static final long mem_start$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned long mem_start
* }
*/
public static final long mem_start$offset() {
return mem_start$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned long mem_start
* }
*/
public static long mem_start(MemorySegment struct) {
return struct.get(mem_start$LAYOUT, mem_start$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned long mem_start
* }
*/
public static void mem_start(MemorySegment struct, long fieldValue) {
struct.set(mem_start$LAYOUT, mem_start$OFFSET, fieldValue);
}
private static final OfLong mem_end$LAYOUT = (OfLong)$LAYOUT.select(groupElement("mem_end"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned long mem_end
* }
*/
public static final OfLong mem_end$layout() {
return mem_end$LAYOUT;
}
private static final long mem_end$OFFSET = 8;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned long mem_end
* }
*/
public static final long mem_end$offset() {
return mem_end$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned long mem_end
* }
*/
public static long mem_end(MemorySegment struct) {
return struct.get(mem_end$LAYOUT, mem_end$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned long mem_end
* }
*/
public static void mem_end(MemorySegment struct, long fieldValue) {
struct.set(mem_end$LAYOUT, mem_end$OFFSET, fieldValue);
}
private static final OfShort base_addr$LAYOUT = (OfShort)$LAYOUT.select(groupElement("base_addr"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned short base_addr
* }
*/
public static final OfShort base_addr$layout() {
return base_addr$LAYOUT;
}
private static final long base_addr$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned short base_addr
* }
*/
public static final long base_addr$offset() {
return base_addr$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned short base_addr
* }
*/
public static short base_addr(MemorySegment struct) {
return struct.get(base_addr$LAYOUT, base_addr$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned short base_addr
* }
*/
public static void base_addr(MemorySegment struct, short fieldValue) {
struct.set(base_addr$LAYOUT, base_addr$OFFSET, fieldValue);
}
private static final OfByte irq$LAYOUT = (OfByte)$LAYOUT.select(groupElement("irq"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned char irq
* }
*/
public static final OfByte irq$layout() {
return irq$LAYOUT;
}
private static final long irq$OFFSET = 18;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned char irq
* }
*/
public static final long irq$offset() {
return irq$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned char irq
* }
*/
public static byte irq(MemorySegment struct) {
return struct.get(irq$LAYOUT, irq$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned char irq
* }
*/
public static void irq(MemorySegment struct, byte fieldValue) {
struct.set(irq$LAYOUT, irq$OFFSET, fieldValue);
}
private static final OfByte dma$LAYOUT = (OfByte)$LAYOUT.select(groupElement("dma"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned char dma
* }
*/
public static final OfByte dma$layout() {
return dma$LAYOUT;
}
private static final long dma$OFFSET = 19;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned char dma
* }
*/
public static final long dma$offset() {
return dma$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned char dma
* }
*/
public static byte dma(MemorySegment struct) {
return struct.get(dma$LAYOUT, dma$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned char dma
* }
*/
public static void dma(MemorySegment struct, byte fieldValue) {
struct.set(dma$LAYOUT, dma$OFFSET, fieldValue);
}
private static final OfByte port$LAYOUT = (OfByte)$LAYOUT.select(groupElement("port"));
/**
* Layout for field:
* {@snippet lang=c :
* unsigned char port
* }
*/
public static final OfByte port$layout() {
return port$LAYOUT;
}
private static final long port$OFFSET = 20;
/**
* Offset for field:
* {@snippet lang=c :
* unsigned char port
* }
*/
public static final long port$offset() {
return port$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* unsigned char port
* }
*/
public static byte port(MemorySegment struct) {
return struct.get(port$LAYOUT, port$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* unsigned char port
* }
*/
public static void port(MemorySegment struct, byte fieldValue) {
struct.set(port$LAYOUT, port$OFFSET, fieldValue);
}
/**
* Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
* The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
*/
public static MemorySegment asSlice(MemorySegment array, long index) {
return array.asSlice(layout().byteSize() * index);
}
/**
* The size (in bytes) of this struct
*/
public static long sizeof() { return layout().byteSize(); }
/**
* Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
*/
public static MemorySegment allocate(SegmentAllocator allocator) {
return allocator.allocate(layout());
}
/**
* Allocate an array of size {@code elementCount} using {@code allocator}.
* The returned segment has size {@code elementCount * layout().byteSize()}.
*/
public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
}
/**
* Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
* The returned segment has size {@code layout().byteSize()}
*/
public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) {
return reinterpret(addr, 1, arena, cleanup);
}
/**
* Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
* The returned segment has size {@code elementCount * layout().byteSize()}
*/
public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) {
return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
}
}