### Start Espeakup (Manual Installation) Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/drivers/staging/speakup/spkguide.txt Starts the Espeakup speech synthesizer if it was installed manually from source. The binary is typically located in /usr/bin. Requires root privileges. ```bash /usr/bin/espeakup ``` -------------------------------- ### GDB Configuration: .gdbinit Example Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/s390/Debugging390.txt Provides an example of a typical .gdbinit file. This file can be placed in the current working directory or home directory to automate GDB setup and commands upon launch. ```gdb break main run break runtime_exception cont ``` -------------------------------- ### Start Espeakup (Package Installation) Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/drivers/staging/speakup/spkguide.txt Starts the Espeakup speech synthesizer daemon if it was installed as a system package. The command path may vary depending on the Linux distribution (/etc/init.d or /etc/rc.d). Requires root privileges. ```bash /etc/init.d/espeakup start ``` -------------------------------- ### LILO Bootloader Configuration Example Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/power/swsusp-dmcrypt.txt An example configuration for the LILO bootloader, specifying the kernel image, initrd path, and boot parameters. This setup is crucial for booting the system with the custom initrd that handles dm-crypt and swsusp. ```lilo image=/boot/vmlinuz initrd=/boot/initrd.gz label=linux append="root=/dev/ram0 init=/linuxrc rw" ``` -------------------------------- ### Intel PT with AutoFDO Example Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/tools/perf/Documentation/intel-pt.txt An example demonstrating the integration of Intel PT with AutoFDO for profile-guided optimization. This involves compiling code, recording performance data with Intel PT, injecting trace data, creating gcov profiles, and recompiling with AutoFDO. ```shell $ gcc-5 -O3 sort.c -o sort_optimized $ ./sort_optimized 30000 $ cat ~/.perfconfig [intel-pt] mispred-all = on $ perf record -e intel_pt//u ./sort 3000 $ perf inject -i perf.data -o inj --itrace=i100usle --strip $ ./create_gcov --binary=./sort --profile=inj --gcov=sort.gcov -gcov_version=1 $ gcc-5 -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo $ ./sort_autofdo 30000 ``` -------------------------------- ### 32-bit Linux Kernel Boot Protocol Setup Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/x86/boot.txt This section describes the setup required for the 32-bit boot protocol. The CPU must be in 32-bit protected mode with paging disabled, a GDT loaded with specific descriptors, interrupts disabled, and certain registers set to specific values before jumping to the kernel entry point. ```assembly At entry, the CPU must be in 32-bit protected mode with paging disabled; a GDT must be loaded with the descriptors for selectors __BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat segment; __BOOT_CS must have execute/read permission, and __BOOT_DS must have read/write permission; CS must be __BOOT_CS and DS, ES, SS must be __BOOT_DS; interrupt must be disabled; %esi must hold the base address of the struct boot_params. %ebp, %edi and %ebx must be zero. ``` -------------------------------- ### Flat Function Graph Trace Output Example Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/trace/ftrace.txt This example demonstrates the flat output format for the function graph tracer. It lists function entry ('graph_ent') and return ('graph_ret') events sequentially, along with task, CPU, and timestamp information. ```text # tracer: function_graph # # entries-in-buffer/entries-written: 68355/68355 #P:2 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | sh-1806 [001] d... 198.843443: graph_ent: func=_raw_spin_lock sh-1806 [001] d... 198.843445: graph_ent: func=__raw_spin_lock sh-1806 [001] d..1 198.843447: graph_ret: func=__raw_spin_lock sh-1806 [001] d..1 198.843449: graph_ret: func=_raw_spin_lock sh-1806 [001] d..1 198.843451: graph_ent: func=_raw_spin_unlock_irqrestore sh-1806 [001] d... 198.843453: graph_ret: func=_raw_spin_unlock_irqrestore ``` -------------------------------- ### Build and Install Driver Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/scsi/NinjaSCSI.txt Standard shell commands for extracting kernel sources, compiling the driver, and starting the PCMCIA service. ```bash cd /usr/src tar -zxvf linux-x.x.x.tar.gz cd linux make config tar -zxvf nsp_cs-x.x.tar.gz cd nsp_cs-x.x make /etc/init.d/pcmcia start ``` -------------------------------- ### Create and Test Minimal Initramfs Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/filesystems/ramfs-rootfs-initramfs.txt Demonstrates how to write a simple C program to act as the init process, compile it statically, package it into a cpio archive, and test it using QEMU. ```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 Git bisect session Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/driver-api/80211/bug-bisect.md A practical example of starting a bisect session where the current HEAD is broken and version 4.8 is confirmed as a working state. ```shell git bisect start git bisect bad git bisect good v4.8 ``` -------------------------------- ### Example Module Options for Output Type Configuration Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/doc-guide/v4l-drivers/vivid.md This example demonstrates configuring a video output device with a specific number of outputs and defining their types using a hexadecimal bitmask. It shows how to set outputs as S-Video and HDMI. ```none num_outputs=8 output_types=0xf0 ``` -------------------------------- ### Get Callback with Private Value Parsing Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/media/kernel-api/writing-an-alsa-driver.md An example 'get' callback demonstrating how to parse `private_value` which is often used to store register, shift, and mask information. This allows the callback to dynamically determine how to read the control's value from hardware registers. ```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; .... } ``` -------------------------------- ### Mount and Prepare Initrd Filesystem Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/driver-api/pm/initrd.md These commands show how to mount the created initrd filesystem using a loopback device, create necessary directories and device nodes, and copy essential files like '/sbin/init'. The execute permission for '/sbin/init' is crucial. ```shell # mount -t ext2 -o loop initrd /mnt # mkdir /mnt/dev # mknod /mnt/dev/console c 5 1 # cp -a /path/to/your/init/files/* /mnt/ ``` -------------------------------- ### DMA Mapping and Preparation Example using C Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/dmaengine/client.txt Demonstrates the typical setup for a slave DMA operation, including mapping scatterlists using dma_map_sg and then preparing the transaction with dmaengine_prep_slave_sg. Error handling for mapping failures is included. ```c nr_sg = dma_map_sg(chan->device->dev, sgl, sg_len); if (nr_sg == 0) /* error */ desc = dmaengine_prep_slave_sg(chan, sgl, nr_sg, direction, flags); ``` -------------------------------- ### Example Module Options for Input Type Configuration Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/doc-guide/v4l-drivers/vivid.md This example illustrates configuring a video capture device with a specific number of inputs and defining their types using a hexadecimal bitmask. It shows how to set inputs as TV tuner, S-Video, and HDMI. ```none num_inputs=8 input_types=0xffa9 ``` -------------------------------- ### Kernel Execution Entry Point Setup Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/x86/boot.txt C-style pseudo-code for configuring segment registers and the stack before jumping to the kernel entry point, ensuring the environment meets the required boot state. ```C seg = base_ptr >> 4; cli(); _SS = seg; _SP = heap_end; _DS = _ES = _FS = _GS = seg; jmp_far(seg+0x20, 0); ``` -------------------------------- ### Install VMA Policy via mbind Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/vm/numa_memory_policy.txt Installs a memory policy for a specific range of the calling task's address space. It defines the policy mode and node mask for the memory range starting at 'start' with length 'len'. ```c long mbind(void *start, unsigned long len, int mode, const unsigned long *nmask, unsigned long maxnode, unsigned flags); ``` -------------------------------- ### CAN BCM Socket Setup Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/networking/can.txt Example of how to create and connect a CAN_BCM socket. ```APIDOC ## CAN BCM Socket Setup ### Description This section demonstrates the basic steps to create a CAN_BCM socket and connect it to a specified CAN interface. ### Method `socket()`, `ioctl()`, `connect()` ### Endpoint N/A (System calls) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c int s; struct sockaddr_can addr; struct ifreq ifr; s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM); strcpy(ifr.ifr_name, "can0"); ioctl(s, SIOCGIFINDEX, &ifr); addr.can_family = AF_CAN; addr.can_ifindex = ifr.ifr_ifindex; connect(s, (struct sockaddr *)&addr, sizeof(addr)); ``` ### Response #### Success Response (0) Socket successfully created and connected. #### Response Example N/A (System calls do not return JSON examples for success) ``` -------------------------------- ### Initiate Streaming I/O with DMABUF File Descriptors (C Example) Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/gpu/uapi/v4l/v4l2.md An example demonstrating how to initiate streaming I/O using DMABUF file descriptors in V4L2. This is useful for zero-copy data transfers between different hardware components. ```c // Example: Initiating streaming I/O with DMABUF file descriptors // ... implementation details ... // int dmabuf_fd = ...; // struct v4l2_buffer buf; // buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; // buf.memory = V4L2_MEMORY_DMABUF; // buf.m.fd = dmabuf_fd; // ... ioctl(fd, VIDIOC_QBUF, &buf); ``` -------------------------------- ### Install Dummy SELinux Policy Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/admin-guide/LSM/SELinux.md Executes the dummy policy installation script located in the scripts/selinux directory. This script compiles the policy, updates the SELinux configuration, and relabels the filesystem. ```shell cd scripts/selinux sh install_policy.sh ``` -------------------------------- ### Creating and Configuring Task Groups with cgroups Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/scheduler/sched-design-CFS.txt This example demonstrates how to set up and manage task groups for CPU resource allocation using the 'cgroup' pseudo-filesystem in Linux. It covers mounting the cgroup filesystem, creating directories for task groups, setting CPU share weights for these groups, and assigning tasks (identified by their PIDs) to specific groups. ```bash # Mount tmpfs for cgroup root mount -t tmpfs cgroup_root /sys/fs/cgroup # Create and mount cpu controller mkdir /sys/fs/cgroup/cpu mount -t cgroup -ocpu none /sys/fs/cgroup/cpu cd /sys/fs/cgroup/cpu # Create task groups mkdir multimedia mkdir browser # Configure CPU shares (multimedia gets twice the shares of browser) echo 2048 > multimedia/cpu.shares echo 1024 > browser/cpu.shares # Example: Launching applications and assigning them to groups # firefox & # echo > browser/tasks # # # Launch movie player # echo > multimedia/tasks ``` -------------------------------- ### Create Encrypted Device with dmsetup Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/device-mapper/dm-crypt.txt Demonstrates how to initialize an encrypted block device using the dmsetup utility. The scripts show both standard key usage and integration with the kernel keyring service. ```shell #!/bin/sh # Create a crypt device using dmsetup dmsetup create crypt1 --table "0 `blockdev --getsz $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0" ``` ```shell #!/bin/sh # Create a crypt device using dmsetup when encryption key is stored in keyring service dmsetup create crypt2 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 :32:logon:my_prefix:my_key 0 $1 0" ``` -------------------------------- ### Example: Input Control Transfer (Hex Log) Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/usb/usbmon.txt Example log entry showing an input control transfer to get a port status. It includes timestamps and data related to the transfer. ```text d5ea89a0 3575914555 S Ci:1:001:0 s a3 00 0000 0003 0004 4 < d5ea89a0 3575914560 C Ci:1:001:0 0 4 = 01050000 ``` -------------------------------- ### Create Guest OS Disk Image Source: https://github.com/david7xwshenanigans/kernel_samsung_a22/blob/lineage-20/Documentation/ia64/xen.txt Commands to create a sparse file, format it as ext3, and populate it with a base file system for a guest virtual machine. ```bash # dd if=/dev/zero of=/root/rhel5.img bs=1M seek=4096 count=0 # mke2fs -F -j /root/rhel5.img # mount -o loop /root/rhel5.img /mnt # cp -ax /{dev,var,etc,usr,bin,sbin,lib} /mnt # mkdir /mnt/{root,proc,sys,home,tmp} ```