### Board-Specific Setup Code Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/arch/sh/new-machine.rst Provides definitions for get_system_type() and platform_setup(), which are required for board setup. This example demonstrates minimal setup for an imaginary board, including placeholder comments for hardware initialization. ```c /* * arch/sh/boards/vapor/setup.c - Setup code for imaginary board */ #include const char *get_system_type(void) { return "FooTech Vaporboard"; } int __init platform_setup(void) { /* * If our hardware actually existed, we would do real * setup here. Though it's also sane to leave this empty * if there's no real init work that has to be done for * this board. */ /* Start-up imaginary PCI ... */ /* And whatever else ... */ return 0; } ``` -------------------------------- ### Start Espeakup (Manual Install) Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/spkguide.txt Executes the Espeakup binary after manual installation. Requires root privileges. ```bash /usr/bin/espeakup ``` -------------------------------- ### HW Consumer Setup Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/driver-api/iio/hw-consumer.rst A typical setup demonstrating how to use the IIO hardware consumer functions within an IIO device probe function and read callback. ```APIDOC ## HW Consumer Setup Example This example illustrates a common setup for an IIO hardware consumer. ```c static struct iio_hw_consumer *hwc; static const struct iio_info adc_info = { .read_raw = adc_read_raw, }; static int adc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { int ret; ret = iio_hw_consumer_enable(hwc); if (ret < 0) { /* Handle error */ return ret; } /* Acquire data */ ret = iio_hw_consumer_disable(hwc); if (ret < 0) { /* Handle error */ return ret; } return 0; } static int adc_probe(struct platform_device *pdev) { struct iio_dev *iio; /* Assume iio is allocated and initialized */ hwc = devm_iio_hw_consumer_alloc(&iio->dev); if (IS_ERR(hwc)) { return PTR_ERR(hwc); } /* ... rest of the probe function ... */ return 0; } ``` ``` -------------------------------- ### Finalize disk image setup inside VM Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/bpf/s390.rst After starting the QEMU VM for the first time, run debootstrap's second stage to finalize the installation within the guest. Mount necessary host directories. ```bash /debootstrap/debootstrap --second-stage mkdir -p /linux mount -t 9p linux /linux mount -t proc proc /proc mount -t sysfs sys /sys ``` -------------------------------- ### NCR53c8xx Boot Setup Command Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/scsi/ncr53c8xx.rst Example of passing boot setup commands to the ncr53c8xx driver via the lilo bootloader. This enables tagged commands, sets synchronous negotiation speed, and enables the DEBUG_NEGO flag. ```bash lilo: linux root=/dev/hda2 ncr53c8xx=tags:4,sync:10,debug:0x200 ``` -------------------------------- ### IIO HW Consumer Setup Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/driver-api/iio/hw-consumer.rst Demonstrates the typical setup for an IIO HW consumer within a device probe and read function. It shows allocation, enabling, and disabling the consumer. ```c static struct iio_hw_consumer *hwc; static const struct iio_info adc_info = { .read_raw = adc_read_raw, }; static int adc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { ret = iio_hw_consumer_enable(hwc); /* Acquire data */ ret = iio_hw_consumer_disable(hwc); } static int adc_probe(struct platform_device *pdev) { hwc = devm_iio_hw_consumer_alloc(&iio->dev); } ``` -------------------------------- ### Example udev install rules script Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/aoe/examples.rst This shell script provides an example for installing udev rules. It is intended to be executed with root privileges. ```shell #!/bin/sh # Example script to install udev rules # Copy the udev rule file to the system's rules directory cp udev.rules /etc/udev/rules.d/ # Reload udev rules udevadm control --reload-rules && udevadm trigger echo "Udev rules installed successfully." ``` -------------------------------- ### Start a Virtual Machine Source: https://github.com/koverstreet/bcachefs/blob/master/tools/perf/Documentation/perf-intel-pt.txt Example command to start a virtual machine using virsh. ```bash sudo virsh start kubuntu20.04 ``` -------------------------------- ### Example Setup Command with Multiple Exit Codes Source: https://github.com/koverstreet/bcachefs/blob/master/tools/testing/selftests/tc-testing/creating-testcases/AddingTestCases.txt Demonstrates how to specify multiple acceptable exit codes for a setup or teardown command. This prevents test execution from halting due to non-critical errors. ```json "setup": [ [ "$TC actions flush action gact", 0, 1, 255 ], ``` -------------------------------- ### Start 9pfs Server (diod) Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/filesystems/9p.rst Example command to start the 'diod' 9pfs server on a host. It listens on all interfaces on port 9999 and exports the current directory. ```bash $ diod -f -n -d 0 -S -l 0.0.0.0:9999 -e $PWD ``` -------------------------------- ### Example Bond Configuration in boot.local Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/networking/bonding.rst Example configuration for creating a simple bond with two e100 devices (eth0, eth1) in balance-alb mode, including module loading and interface setup, intended for persistence across reboots. ```bash modprobe bonding modprobe e100 echo balance-alb > /sys/class/net/bond0/bonding/mode ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up echo 100 > /sys/class/net/bond0/bonding/miimon echo +eth0 > /sys/class/net/bond0/bonding/slaves echo +eth1 > /sys/class/net/bond0/bonding/slaves ``` -------------------------------- ### Pktgen Sample Script Usage Example Source: https://github.com/koverstreet/bcachefs/blob/master/samples/pktgen/README.rst This example demonstrates how to use the -a parameter to append configuration for creating different flows simultaneously. It shows adding two devices sequentially and then starting joint traffic. ```shell source ./samples/pktgen/functions.sh pg_ctrl reset # add first device ./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f0 -m 34:80:0d:a3:fc:c9 -t 8 # add second device ./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f1 -m 34:80:0d:a3:fc:c9 -t 8 # run joint traffic on two devs pg_ctrl start ``` -------------------------------- ### Unbindable Mount Example: Setup with Unbindable Property Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/filesystems/sharedsubtree.rst Demonstrates setting up a replicated tree using unbindable mounts to prevent exponential growth. ```bash mount --bind /root/tmp /root/tmp mount --make-rshared /root mount --make-unbindable /root/tmp mkdir -p /tmp/m1 mount --rbind /root /tmp/m1 ``` -------------------------------- ### Create and Test a Simple Initramfs Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/filesystems/ramfs-rootfs-initramfs.rst This example demonstrates how to create a minimal 'hello world' C program, compile it statically, package it into a cpio.gz archive, and test it using QEMU with the initrd loading mechanism. This is a good first step for understanding initramfs. ```c #include #include int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } ``` ```bash gcc -static hello.c -o init echo init | cpio -o -H newc | gzip > test.cpio.gz qemu -kernel /boot/vmlinuz -initrd test.cpio.gz /dev/zero ``` -------------------------------- ### Example: Pointing to SETUP_E820_EXT Data using setup_indirect Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/arch/x86/boot.rst Illustrates how to use the setup_indirect structure to point to SETUP_E820_EXT data. This involves setting the 'type' to SETUP_INDIRECT, specifying the size of setup_indirect, and providing the address and length of the actual data. ```c struct setup_data { .next = 0, /* or */ .type = SETUP_INDIRECT, .len = sizeof(setup_indirect), .data[sizeof(setup_indirect)] = (struct setup_indirect) { .type = SETUP_INDIRECT | SETUP_E820_EXT, .reserved = 0, .len = , .addr = , }, } ``` -------------------------------- ### Boot Config File Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/bootconfig.rst Example of a boot configuration file defining parameters for the kernel and init process. ```json kernel { root = 01234567-89ab-cdef-0123-456789abcd } init { splash } ``` -------------------------------- ### V4L2 Video Capture Example Setup Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/userspace-api/media/v4l/capture.c.rst Includes necessary headers and defines for V4L2 video capture. It sets up constants and enumerations for I/O methods and buffer structures. ```c #include #include #include #include #include /* getopt_long() */ #include /* low-level i/o */ #include #include #include #include #include #include #include #include #define CLEAR(x) memset(&(x), 0, sizeof(x)) enum io_method { IO_METHOD_READ, IO_METHOD_MMAP, IO_METHOD_USERPTR, }; struct buffer { void *start; size_t length; }; static char *dev_name; static enum io_method io = IO_METHOD_MMAP; static int fd = -1; struct buffer *buffers; static unsigned int n_buffers; static int out_buf; static int force_format; static int frame_count = 70; ``` -------------------------------- ### Example: Sending Start Event to WIP Monitor Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/trace/rv/monitor_synthesis.rst Demonstrates sending the 'preempt_enabled' start event to the WIP monitor. ```c da_handle_start_event_wip(preempt_enable_wip); ``` -------------------------------- ### ALSA Get Callback Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/sound/kernel-api/writing-an-alsa-driver.rst Implement a get callback to read the current value of a control and return it to user-space. ```c static int snd_myctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct mychip *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = get_some_value(chip); return 0; } ``` -------------------------------- ### NCR53c8xx Driver Exclusion Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/scsi/ncr53c8xx.rst Example demonstrating how to exclude a specific 53C8xx adapter using the 'excl' keyword with insmod. This installs the driver on all adapters except the one at the specified IO port address, and then installs the sym53c8xx driver to that specific adapter. ```bash insmod sym53c8xx sym53c8xx=excl:0x1400 insmod ncr53c8xx ``` -------------------------------- ### w1-gpio Master Setup Example (mach-at91) Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/w1/masters/w1-gpio.rst This example shows how to configure a w1-gpio master using machine descriptor tables and platform data. It includes necessary headers, defines a GPIO lookup table, platform data, and a platform device, followed by device registration and GPIO configuration. ```c #include #include static struct gpiod_lookup_table foo_w1_gpiod_table = { .dev_id = "w1-gpio", .table = { GPIO_LOOKUP_IDX("at91-gpio", AT91_PIN_PB20, NULL, 0, GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN), }, }; static struct w1_gpio_platform_data foo_w1_gpio_pdata = { .ext_pullup_enable_pin = -EINVAL, }; static struct platform_device foo_w1_device = { .name = "w1-gpio", .id = -1, .dev.platform_data = &foo_w1_gpio_pdata, }; ... at91_set_GPIO_periph(foo_w1_gpio_pdata.pin, 1); at91_set_multi_drive(foo_w1_gpio_pdata.pin, 1); gpiod_add_lookup_table(&foo_w1_gpiod_table); platform_device_register(&foo_w1_device); ``` -------------------------------- ### CXL fwctl RPC Get Feature Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/userspace-api/fwctl/fwctl-cxl.rst Example of how to send a 'Get Feature' command to a CXL device using fwctl. This involves preparing input and output structures and using the send_command function. Ensure proper memory allocation and error handling. ```c static int cxl_fwctl_rpc_get_test_feature(int fd, struct test_feature *feat_ctx, const uint32_t expected_data) { struct cxl_mbox_get_feat_in *feat_in; struct fwctl_rpc_cxl_out *out; struct fwctl_rpc rpc = {0}; struct fwctl_rpc_cxl *in; size_t out_size, in_size; uint32_t val; void *data; int rc; in_size = sizeof(*in) + sizeof(*feat_in); rc = posix_memalign((void **)&in, 16, in_size); if (rc) return -ENOMEM; memset(in, 0, in_size); feat_in = &in->get_feat_in; uuid_copy(feat_in->uuid, feat_ctx->uuid); feat_in->count = feat_ctx->get_size; out_size = sizeof(*out) + feat_ctx->get_size; rc = posix_memalign((void **)&out, 16, out_size); if (rc) goto free_in; memset(out, 0, out_size); in->opcode = CXL_MBOX_OPCODE_GET_FEATURE; in->op_size = sizeof(*feat_in); rpc.size = sizeof(rpc); rpc.scope = FWCTL_RPC_CONFIGURATION; rpc.in_len = in_size; rpc.out_len = out_size; rpc.in = (uint64_t)(uint64_t *)in; rpc.out = (uint64_t)(uint64_t *)out; rc = send_command(fd, &rpc, out); if (rc) goto free_all; ``` -------------------------------- ### Format and open LUKS device with cryptsetup Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/device-mapper/dm-crypt.rst This example shows the standard procedure for setting up disk encryption using LUKS with the cryptsetup utility. It first formats the device and then opens it for use. ```sh #!/bin/sh # Create a crypt device using cryptsetup and LUKS header with default cipher cryptsetup luksFormat $1 cryptsetup luksOpen $1 crypt1 ``` -------------------------------- ### Mount and Setup Cpuset Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/cgroup-v1/cpusets.rst Demonstrates the steps to mount the cpuset filesystem and create a new cpuset named 'Charlie' with specific CPU and memory node assignments. It then starts a subshell within this cpuset and verifies the current cpuset configuration. ```bash mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset cd /sys/fs/cgroup/cpuset mkdir Charlie cd Charlie /bin/echo 2-3 > cpuset.cpus /bin/echo 1 > cpuset.mems /bin/echo $$ > tasks sh # The subshell 'sh' is now running in cpuset Charlie # The next line should display '/Charlie' cat /proc/self/cpuset ``` -------------------------------- ### Boot Config File Syntax Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/bootconfig.rst Illustrates the basic syntax for boot configuration files, including key-value pairs, array values, and the use of semicolons or newlines as delimiters. ```plaintext KEY[.WORD[...]] = VALUE[, VALUE2[...]][;] ``` -------------------------------- ### Example: Latency Debugging Interface Setup Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/filesystems/resctrl.rst This example demonstrates setting up the tracing infrastructure to measure and visualize cache access latency using a histogram trigger. ```bash # :> /sys/kernel/tracing/trace # echo 'hist:keys=latency' > /sys/kernel/tracing/events/resctrl/pseudo_lock_mem_latency/trigger ``` -------------------------------- ### ALSA Mixer Get Single Callback Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/sound/kernel-api/writing-an-alsa-driver.rst Example of a get callback for a single-element mixer control, demonstrating how to retrieve register, shift, and mask values from private_value. ```c static int snd_sbmixer_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0xff; int mask = (kcontrol->private_value >> 24) & 0xff; .... } ``` -------------------------------- ### IIO Triggered Buffer Setup Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/driver-api/iio/triggered-buffers.rst Demonstrates the typical setup for a triggered buffer, including defining buffer setup operations, poll functions, and the trigger handler. This is usually called within a device's probe function. ```c const struct iio_buffer_setup_ops sensor_buffer_setup_ops = { .preenable = sensor_buffer_preenable, .postenable = sensor_buffer_postenable, .postdisable = sensor_buffer_postdisable, .predisable = sensor_buffer_predisable, }; irqreturn_t sensor_iio_pollfunc(int irq, void *p) { pf->timestamp = iio_get_time_ns((struct indio_dev *)p); return IRQ_WAKE_THREAD; } irqreturn_t sensor_trigger_handler(int irq, void *p) { u16 buf[8]; int i = 0; /* read data for each active channel */ for_each_set_bit(bit, active_scan_mask, masklength) buf[i++] = sensor_get_data(bit) iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp); iio_trigger_notify_done(trigger); return IRQ_HANDLED; } /* setup triggered buffer, usually in probe function */ iio_triggered_buffer_setup(indio_dev, sensor_iio_polfunc, sensor_trigger_handler, sensor_buffer_setup_ops); ``` -------------------------------- ### Start Guest3 with VFIO AP Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/arch/s390/vfio-ap.rst Launch Guest3 using QEMU, enabling AP features and specifying the VFIO AP device with its sysfs path. ```bash /usr/bin/qemu-system-s390x ... -cpu host,ap=on,apqci=on,apft=on,apqi=on \ -device vfio-ap,sysfsdev=/sys/devices/vfio_ap/matrix/$uuid3 ... ``` -------------------------------- ### Get Printer Status Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/usb/gadget_printer.rst Run the example program to retrieve the current status of the printer gadget. This includes selected status, paper status, and error status. ```bash # prn_example -get_status ``` -------------------------------- ### Reading and Writing Schemata File Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/filesystems/resctrl.rst Demonstrates how to read the current state of resources from the 'schemata' file and how to update specific values by echoing new configurations. ```shell # cat schemata L3DATA:0=fffff;1=fffff;2=fffff;3=fffff L3CODE:0=fffff;1=fffff;2=fffff;3=fffff # echo "L3DATA:2=3c0;" > schemata # cat schemata L3DATA:0=fffff;1=fffff;2=3c0;3=fffff L3CODE:0=fffff;1=fffff;2=fffff;3=fffff ``` -------------------------------- ### NCR53c8xx insmod Command Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/scsi/ncr53c8xx.rst Example of installing the ncr53c8xx driver module with options using insmod. This command achieves the same configuration as the lilo example, using spaces as separators since commas may not be allowed in insmod string variables. ```bash insmod ncr53c8xx.o ncr53c8xx="tags:4 sync:10 debug:0x200" ``` -------------------------------- ### IO QoS Configuration Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/cgroup-v2.rst Configure Quality of Service parameters for the IO cost model by writing to the io.cost.qos file. This example enables controller, sets latency thresholds, and defines min/max scaling percentages for a specific device. ```shell 8:16 enable=1 ctrl=auto rpct=95.00 rlat=75000 wpct=95.00 wlat=150000 min=50.00 max=150.0 ``` -------------------------------- ### Preemptirqsoff Tracer Output Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/trace/ftrace.rst This is an example output from the preemptirqsoff tracer, showing a latency event for the 'ls' command. It details the start and end points of the event and the call stack. ```text # tracer: preemptirqsoff # # preemptirqsoff latency trace v1.1.5 on 3.8.0-test+ # -------------------------------------------------------------------- # latency: 100 us, #4/4, CPU#3 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4) # ----------------- # | task: ls-2230 (uid:0 nice:0 policy:0 rt_prio:0) # ----------------- # => started at: ata_scsi_queuecmd # => ended at: ata_scsi_queuecmd # # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # \ / ||||| \ | / ls-2230 3d... 0us+: _raw_spin_lock_irqsave <-ata_scsi_queuecmd ls-2230 3...1 100us : _raw_spin_unlock_irqrestore <-ata_scsi_queuecmd ls-2230 3...1 101us+: trace_preempt_on <-ata_scsi_queuecmd ls-2230 3...1 111us : => sub_preempt_count => _raw_spin_unlock_irqrestore => ata_scsi_queuecmd => scsi_dispatch_cmd => scsi_request_fn => __blk_run_queue_uncond => __blk_run_queue => blk_queue_bio => submit_bio_noacct => submit_bio => submit_bh => ext3_bread => ext3_dir_bread => htree_dirblock_to_tree => ext3_htree_fill_tree => ext3_readdir => vfs_readdir => sys_getdents => system_call_fastpath ``` -------------------------------- ### Example Control Initialization and Addition Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/driver-api/media/v4l2-controls.rst Demonstrates initializing a control handler and adding standard and menu controls. ```c static const s64 exp_bias_qmenu[] = { -2, -1, 0, 1, 2 }; static const char * const test_pattern[] = { "Disabled", "Vertical Bars", "Solid Black", "Solid White", }; v4l2_ctrl_handler_init(&foo->ctrl_handler, nr_of_controls); v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops, V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); v4l2_ctrl_new_std(&foo->ctrl_handler, &foo_ctrl_ops, V4L2_CID_CONTRAST, 0, 255, 1, 128); v4l2_ctrl_new_std_menu(&foo->ctrl_handler, &foo_ctrl_ops, V4L2_CID_POWER_LINE_FREQUENCY, V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0, V4L2_CID_POWER_LINE_FREQUENCY_DISABLED); ``` -------------------------------- ### CPU Mask Example 2 Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/cputopology.rst This example shows CPU mask values when NR_CPUS is 128, but the kernel was started with possible_cpus=144. CPU 2 is offline and is the only CPU that can be brought online. ```text kernel_max: 127 offline: 2,4-127,128-143 online: 0-1,3 possible: 0-127 present: 0-3 ``` -------------------------------- ### LOADLIN Boot Command Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/initrd.rst Example of how to boot a kernel with an initrd using the LOADLIN boot loader. ```bash LOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 rw ``` -------------------------------- ### Install xed Tool Source: https://github.com/koverstreet/bcachefs/blob/master/tools/perf/Documentation/build-xed.txt Clone the mbuild and xed repositories, build xed with examples, install it, and update the dynamic linker cache. Finally, copy the xed executable to the bin directory. ```bash git clone https://github.com/intelxed/mbuild.git mbuild git clone https://github.com/intelxed/xed cd xed ./mfile.py --share ./mfile.py examples sudo ./mfile.py --prefix=/usr/local install sudo ldconfig sudo cp obj/examples/xed /usr/local/bin ``` -------------------------------- ### Starting a UML Instance Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/virt/uml/user_mode_linux_howto_v2.rst Run a UML instance with specified memory, root filesystem image, network configuration (tap0), and console settings. Console 1 is set to use standard input/output. ```bash # linux mem=2048M umid=TEST \ ubd0=Filesystem.img \ vec0:transport=tap,ifname=tap0,depth=128,gro=1 \ root=/dev/ubda con=null con0=null,fd:2 con1=fd:0,fd:1 ``` -------------------------------- ### Start Guest1 with VFIO AP Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/arch/s390/vfio-ap.rst Launch Guest1 using QEMU, enabling AP features and specifying the VFIO AP device with its sysfs path. ```bash /usr/bin/qemu-system-s390x ... -cpu host,ap=on,apqci=on,apft=on,apqi=on \ -device vfio-ap,sysfsdev=/sys/devices/vfio_ap/matrix/$uuid1 ... ``` -------------------------------- ### Start Espeakup (init.d) Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/spkguide.txt Starts the Espeakup daemon using a distribution-specific init script. Requires root privileges. ```bash /etc/init.d/espeakup start ``` -------------------------------- ### Example ftrace 'irqsoff' latency trace output Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/trace/ftrace.rst This is an example of the output format for the 'irqsoff' latency tracer. It provides details on latency, task information, and the start and end points of the traced event. ```text # tracer: irqsoff # # irqsoff latency trace v1.1.5 on 3.8.0-test+ # -------------------------------------------------------------------- # latency: 259 us, #4/4, CPU#2 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:4) # ----------------- # | task: ps-6143 (uid:0 nice:0 policy:0 rt_prio:0) # ----------------- # => started at: __lock_task_sighand # => ended at: _raw_spin_unlock_irqrestore # # # _------=> CPU# # / _-----=> irqs-off # | / _----=> need-resched # || / _---=> hardirq/softirq # ||| / _--=> preempt-depth # |||| / delay # cmd pid ||||| time | caller # \ / ||||| \ | / ps-6143 2d... 0us!: trace_hardirqs_off <-__lock_task_sighand ps-6143 2d..1 259us+: trace_hardirqs_on <-_raw_spin_unlock_irqrestore ``` -------------------------------- ### IIO Trigger Setup Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/driver-api/iio/triggers.rst Demonstrates the basic steps to set up an IIO trigger. This involves allocating memory for the trigger, defining its operations, and registering it with the IIO core. Ensure the trigger operations structure is properly initialized. ```c struct iio_trigger_ops trigger_ops = { .set_trigger_state = sample_trigger_state, .validate_device = sample_validate_device, } struct iio_trigger *trig; /* first, allocate memory for our trigger */ trig = iio_trigger_alloc(dev, "trig-%s-%d", name, idx); /* setup trigger operations field */ trig->ops = &trigger_ops; /* now register the trigger with the IIO core */ iio_trigger_register(trig); ``` -------------------------------- ### Start DAMON and Monitor a Program Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/admin-guide/mm/damon/start.rst This command starts DAMON to monitor a specified program. Ensure 'damo' is in your PATH and the kernel is configured with DAMON support. The program 'masim' is used here as an example workload. ```bash $ git clone https://github.com/sjp38/masim; cd masim; make $ sudo damo start "./masim ./configs/stairs.cfg --quiet" ``` -------------------------------- ### RCU Memory Barrier Requirement Example 2 Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/RCU/Design/Requirements/Requirements.rst Illustrates the necessity of a memory barrier between the start of the grace period and the start of an RCU read-side critical section to prevent dereferencing freed memory. ```c CPU 0: list_del_rcu(p); CPU 0: synchronize_rcu() starts. CPU 1: rcu_read_lock() CPU 1: q = rcu_dereference(gp); /* Might return p if no memory barrier. */ CPU 0: synchronize_rcu() returns. CPU 0: kfree(p); CPU 1: do_something_with(q->a); /* Boom!!! */ CPU 1: rcu_read_unlock() ``` -------------------------------- ### V4L2 Read/Write Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/userspace-api/media/v4l/rw.rst Demonstrates using vidctrl to set up a video device and dd to capture image data using the read/write method. ```none $ vidctrl /dev/video --input=0 --format=YUYV --size=352x288 $ dd if=/dev/video of=myimage.422 bs=202752 count=1 ``` -------------------------------- ### CAIF Channel Setup Message Structure Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/networking/caif/caif.rst Example structure of the CAIF channel setup message, detailing STX, length, control channel, command, channel type, priority/link-ID, endpoint, and checksum. ```text 0000000 02 07 00 00 00 21 a1 00 48 df | | | | | | | | STX(1) | | | | | | Length(2)| | | | | Control Channel(1) Command:Channel Setup(1) Channel Type(1) Priority and Link-ID(1) Endpoint(1) Checksum(2) ``` -------------------------------- ### Unbindable Mount Example: Step 2 Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/filesystems/sharedsubtree.rst Initial setup for demonstrating unbindable mounts, involving making a directory shared and performing a recursive bind mount. ```bash mount --make-shared / mkdir -p /tmp/m1 mount --rbind /root /tmp/m1 ``` -------------------------------- ### Start Guest2 with VFIO AP Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/arch/s390/vfio-ap.rst Launch Guest2 using QEMU, enabling AP features and specifying the VFIO AP device with its sysfs path. ```bash /usr/bin/qemu-system-s390x ... -cpu host,ap=on,apqci=on,apft=on,apqi=on \ -device vfio-ap,sysfsdev=/sys/devices/vfio_ap/matrix/$uuid2 ... ``` -------------------------------- ### MAX77620 Device Tree Configuration Example Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/devicetree/bindings/mfd/max77620.txt This example shows a typical Device Tree configuration for the MAX77620, including interrupt controller setup and configuration for its FPS (Fast Power Sequencing) sub-module. ```dts #include max77620@3c { compatible = "maxim,max77620"; reg = <0x3c>; interrupt-parent = <&intc>; interrupts = <0 86 IRQ_TYPE_NONE>; interrupt-controller; #interrupt-cells = <2>; fps { fps0 { maxim,shutdown-fps-time-period-us = <1280>; maxim,fps-event-source = ; }; fps1 { maxim,shutdown-fps-time-period-us = <1280>; maxim,fps-event-source = ; }; fps2 { maxim,shutdown-fps-time-period-us = <1280>; maxim,fps-event-source = ; }; }; }; ``` -------------------------------- ### KVM_SEV_LAUNCH_START Source: https://github.com/koverstreet/bcachefs/blob/master/Documentation/virt/kvm/x86/amd-memory-encryption.rst Initiates the SEV guest launch process by setting up the initial guest state and obtaining a guest handle. Requires a valid sev_fd. ```APIDOC ## KVM_SEV_LAUNCH_START ### Description Initiates the SEV guest launch process. It sets up the initial guest state, including the owner's public Diffie-Hellman (PDH) key and session information, and obtains a guest handle. ### Parameters #### In/Out - **struct kvm_sev_launch_start** - Structure containing launch parameters and returning the guest handle. - **handle** (unsigned int) - If zero, firmware creates a new handle. On success, this field contains the new handle. - **policy** (unsigned int) - Guest's security policy. - **dh_uaddr** (unsigned long long) - Userspace address pointing to the guest owner's PDH key. - **dh_len** (unsigned int) - Length of the PDH key data. - **session_addr** (unsigned long long) - Userspace address pointing to the guest session information. - **session_len** (unsigned int) - Length of the session information. ### Returns - 0 on success. - -negative on error. ### Notes - Requires the ``sev_fd`` field to be valid. - For more details, see SEV spec Section 6.2. ```