### Start NFS server Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Start the NFS server using either /etc/init.d/nfs start or service nfs start, regardless of how the server was built. ```bash $ /etc/init.d/nfs start or $ service nfs start ``` -------------------------------- ### modprobe command with same options as boot setup Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/sym53c8xx_2.txt Installs the sym53c8xx driver module with the same options as the boot setup example: cmd_per_lun=4, sync=10, debug=0x200. ```bash modprobe sym53c8xx cmd_per_lun=4 sync=10 debug=0x200 ``` -------------------------------- ### Boot setup command example for sym53c8xx driver Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/sym53c8xx_2.txt Example of passing driver options at the lilo prompt. Enables tagged commands (up to 4), sets synchronous negotiation speed to 10 Mega-transfers/second, and sets the DEBUG_NEGO flag. ```bash lilo: linux root=/dev/sda2 sym53c8xx.cmd_per_lun=4 sym53c8xx.sync=10 sym53c8xx.debug=0x200 ``` -------------------------------- ### Create root disk image with dd and qemu Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/tools/lguest/lguest.txt Create a 2GB root file and install a distribution ISO under qemu. Ensure a getty is installed on /dev/hvc0 for console login. ```bash dd if=/dev/zero of=rootfile bs=1M count=2048 ``` ```bash qemu -cdrom image.iso -hda rootfile -net user -net nic -boot d ``` -------------------------------- ### Start pcmcia-cs (BSD style) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/NinjaSCSI.txt Starts or restarts pcmcia-cs using the BSD-style init script. ```bash # /etc/rc.d/rc.pcmcia start (BSD style) ``` -------------------------------- ### Start espeakup via init script Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt If espeakup was installed as a package, use the distribution-specific init script. Replace init.d with rc.d if needed. ```bash /etc/init.d/espeakup start ``` -------------------------------- ### Start espeakup manually Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt If espeakup was built manually, run the binary directly as root. ```bash /usr/bin/espeakup ``` -------------------------------- ### Manual installation: insmod dl2k.o media examples Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/networking/dl2k.txt Examples of loading the driver with the media parameter. The parameter can be a named speed or a numeric value; multiple values are for multiple cards. ```bash example: insmod dl2k.o media=100mbps_hd or insmod dl2k.o media=3 or insmod dl2k.o media=3,2 ; for 2 cards ``` -------------------------------- ### Start pcmcia-cs (SYSV style) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/NinjaSCSI.txt Starts or restarts pcmcia-cs using the SYSV-style init script. ```bash # /etc/init.d/pcmcia start (SYSV style) ``` -------------------------------- ### Safe boot setup commands Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/ncr53c8xx.txt Safe boot setups for installation diskettes or safe but not fast systems. Four alternative commands are shown. ```text ncr53c8xx=safe:y,mpar:y,disc:y ``` ```text ncr53c8xx=safe:y,disc:y ``` ```text ncr53c8xx=safe:y,mpar:y ``` ```text ncr53c8xx=safe:y ``` -------------------------------- ### VFIO container, group, and device setup in C Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/vfio.txt C code demonstrating how to set up a VFIO container, open a group, enable the IOMMU, map DMA, and access a device. It includes error checks for API version, IOMMU extension, group viability, and device setup. The example uses device 0000:06:0d.0 and group /dev/vfio/26. ```c int container, group, device, i; struct vfio_group_status group_status = { .argsz = sizeof(group_status) }; struct vfio_iommu_type1_info iommu_info = { .argsz = sizeof(iommu_info) }; struct vfio_iommu_type1_dma_map dma_map = { .argsz = sizeof(dma_map) }; struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; /* Create a new container */ container = open("/dev/vfio/vfio", O_RDWR); if (ioctl(container, VFIO_GET_API_VERSION) != VFIO_API_VERSION) /* Unknown API version */ if (!ioctl(container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) /* Doesn't support the IOMMU driver we want. */ /* Open the group */ group = open("/dev/vfio/26", O_RDWR); /* Test the group is viable and available */ ioctl(group, VFIO_GROUP_GET_STATUS, &group_status); if (!(group_status.flags & VFIO_GROUP_FLAGS_VIABLE)) /* Group is not viable (ie, not all devices bound for vfio) */ /* Add the group to the container */ ioctl(group, VFIO_GROUP_SET_CONTAINER, &container); /* Enable the IOMMU model we want */ ioctl(container, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU); /* Get addition IOMMU info */ ioctl(container, VFIO_IOMMU_GET_INFO, &iommu_info); /* Allocate some space and setup a DMA mapping */ dma_map.vaddr = mmap(0, 1024 * 1024, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); dma_map.size = 1024 * 1024; dma_map.iova = 0; /* 1MB starting at 0x0 from device view */ dma_map.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE; ioctl(container, VFIO_IOMMU_MAP_DMA, &dma_map); /* Get a file descriptor for the device */ device = ioctl(group, VFIO_GROUP_GET_DEVICE_FD, "0000:06:0d.0"); /* Test and setup the device */ ioctl(device, VFIO_DEVICE_GET_INFO, &device_info); for (i = 0; i < device_info.num_regions; i++) { struct vfio_region_info reg = { .argsz = sizeof(reg) }; reg.index = i; ioctl(device, VFIO_DEVICE_GET_REGION_INFO, ®); /* Setup mappings... read/write offsets, mmaps * For PCI devices, config space is a region */ } for (i = 0; i < device_info.num_irqs; i++) { struct vfio_irq_info irq = { .argsz = sizeof(irq) }; irq.index = i; ioctl(device, VFIO_DEVICE_GET_IRQ_INFO, &irq); /* Setup IRQs... eventfds, VFIO_DEVICE_SET_IRQS */ } /* Gratuitous device reset and go... */ ioctl(device, VFIO_DEVICE_RESET); ``` -------------------------------- ### Platform callback: setup function Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/fb/ep93xx-fb.txt Example setup callback for the EP93xx framebuffer driver. Obtains mach_info from pdev->dev.platform_data and fb_info via platform_get_drvdata(pdev). Called when the driver is installed. ```c static int some_board_fb_setup(struct platform_device *pdev) { struct ep93xxfb_mach_info *mach_info = pdev->dev.platform_data; struct fb_info *fb_info = platform_get_drvdata(pdev); /* Board specific framebuffer setup */ } ``` -------------------------------- ### Test InfiniBand with IPoIB between two hosts Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Bring up IPoIB interfaces and assign IP addresses on two hosts, then ping each other to verify the InfiniBand stack. Replace a.b.c.x and a.b.c.y with actual addresses. ```bash host1$ ip link set dev ib0 up host1$ ip address add dev ib0 a.b.c.x host2$ ip link set dev ib0 up host2$ ip address add dev ib0 a.b.c.y host1$ ping a.b.c.y host2$ ping a.b.c.x ``` -------------------------------- ### HelloWorld.java example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/java.txt Simple Java application to test the binfmt_misc setup. Compile with javac, set executable permissions, then run directly. ```java class HelloWorld { public static void main(String args[]) { System.out.println("Hello World!"); } } ``` -------------------------------- ### Oprofile: one-time setup Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/basic_profiling.txt Set up Oprofile with the vmlinux file. Requires CONFIG_PROFILING=y and CONFIG_OPROFILE=y, and 'idle=poll' on the kernel command line. Run after installing Oprofile. ```bash opcontrol --setup --vmlinux=/boot/vmlinux ``` -------------------------------- ### Typical .gdbinit file Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/s390/Debugging390.txt Example .gdbinit file with breakpoints and run. ```gdb break main run break runtime_exception cont ``` -------------------------------- ### Configure /etc/exports for NFS/RDMA Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Example exports entries for NFS/RDMA. The IP address is the client's IPoIB address for InfiniBand or iWARP address for RNIC. The 'insecure' option is required because the NFS/RDMA client does not use a reserved port. ```text /vol0 192.168.0.47(fsid=0,rw,async,insecure,no_root_squash) /vol0 192.168.0.0/255.255.255.0(fsid=0,rw,async,insecure,no_root_squash) ``` -------------------------------- ### LOADLIN initrd boot example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/initrd.txt Example of using LOADLIN to boot with an initrd image, including the required command line parameters. ```bash LOADLIN initrd= ``` ```bash LOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 rw ``` -------------------------------- ### Default boot setup command Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/ncr53c8xx.txt Equivalent boot setup when the driver is configured with default options. Includes a line continuation backslash. ```text ncr53c8xx=mpar:y,spar:y,disc:y,specf:3,fsn:n,ultra:2,fsn:n,revprob:n,verb:1\ tags:0,sync:50,debug:0,burst:7,led:0,wide:1,settle:2,diff:0,irqm:0 ``` -------------------------------- ### Check mount.nfs version Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Run this command to verify the installed version of mount.nfs. If the version is less than 1.1.2 or the command does not exist, install the latest nfs-utils package. ```bash $ /sbin/mount.nfs -V ``` -------------------------------- ### Example: mounting guest filesystems and running perf kvm top Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/tools/perf/Documentation/perf-kvm.txt Shows how to mount guest OS root directories using sshfs and then run perf kvm with --host, --guest, and --guestmount to collect a top profile. The example assumes two guest OSes with PIDs 8888 and 9999. ```shell #mkdir ~/guestmount; cd ~/guestmount #sshfs -o allow_other,direct_io -p 5551 localhost:/ 8888/ #sshfs -o allow_other,direct_io -p 5552 localhost:/ 9999/ #perf kvm --host --guest --guestmount=~/guestmount top ``` -------------------------------- ### Install mount.nfs binary Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Copy the built mount.nfs binary to /sbin/mount.nfs so it is invoked automatically for NFS mounts by the system mount command. This is only required on the NFS client machine. ```bash $ sudo cp utils/mount/mount.nfs /sbin/mount.nfs ``` -------------------------------- ### Setup SDRAM (part 3) with dummy read Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/arch/sh/include/mach-ecovec24/mach/partner-jet-setup.txt Final SDRAM initialization including a dummy read. Includes a WAIT 1 after the writes. ```text ED 0xfd000010, 0x00000001 ED 0xfd000044, 0x00000613 ED 0xfd000048, 0x238C003A ED 0xfd000014, 0x00000002 LIST "Dummy read" DD 0x0c400000, 0x0c400000 ED 0xfd000014, 0x00000002 ED 0xfd000014, 0x00000004 ED 0xfd000108, 0x00000080 ED 0xfd000040, 0x00010000 WAIT 1 ``` -------------------------------- ### Configure nfs-utils without GSS and NFSv4 Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Use this configure command to simplify the nfs-utils installation by disabling the idmapper and gssd executables, which are not needed for creating an NFS/RDMA enabled mount command. ```bash $ ./configure --disable-gss --disable-nfsv4 ``` -------------------------------- ### Verbosity level 2 boot option Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/ncr53c8xx.txt Use 'ncr53c8xx=verb:2' to print the driver's actual setup. The driver prints its setup when verbosity level is 2. ```text ncr53c8xx=verb:2 ``` -------------------------------- ### Load xprtrdma module for NFS/RDMA client Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Load the RDMA client module if the NFS/RDMA client was built as a module (CONFIG_SUNRPC_XPRT_RDMA=m). ```bash $ modprobe xprtrdma.ko ``` -------------------------------- ### Load svcrdma module for NFS/RDMA server Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Load the RDMA transport module if the NFS/RDMA server was built as a module (CONFIG_SUNRPC_XPRT_RDMA=m). ```bash $ modprobe svcrdma ``` -------------------------------- ### Setup cpuset mount and create new cpuset Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/cgroup-legacy/cpusets.txt Steps to mount the cpuset cgroup filesystem and create a new cpuset. The commands include mounting, creating directories, writing CPU and memory node settings, and attaching a task. ```shell mkdir /sys/fs/cgroup/cpuset ``` ```shell mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset ``` ```shell cd /sys/fs/cgroup/cpuset mkdir Charlie cd Charlie /bin/echo 2-3 > cpuset.cpus /bin/echo 1 > cpuset.mems /bin/echo $$ > tasks sh ``` -------------------------------- ### Example Build file for ex Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/tools/build/Documentation/Build.txt Build file listing objects for 'ex' and 'libex' targets. Duplicates are allowed. Includes nested directory 'arch/'. ```makefile ex/Build: ex-y += a.o ex-y += b.o ex-y += b.o # duplicates in the lists are allowed libex-y += c.o libex-y += d.o libex-y += arch/ ``` -------------------------------- ### LILO initrd configuration example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/initrd.txt Example of configuring LILO to use an initrd image, including the initrd option and append parameters. ```bash image = /bzImage initrd = /boot/initrd.gz append = "root=/dev/ram0 rw" ``` -------------------------------- ### Instruct NFS server to listen on RDMA transport Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Write 'rdma 20049' to /proc/fs/nfsd/portlist to make the server listen on the RDMA transport. ```bash $ echo rdma 20049 > /proc/fs/nfsd/portlist ``` -------------------------------- ### Getting first item from list with mutex Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/kref.txt Example of rule 3: use a mutex to safely get a reference to the first item in a list without already holding a valid pointer. Includes release function. ```c static DEFINE_MUTEX(mutex); static LIST_HEAD(q); struct my_data { struct kref refcount; struct list_head link; }; static struct my_data *get_entry() { struct my_data *entry = NULL; mutex_lock(&mutex); if (!list_empty(&q)) { entry = container_of(q.next, struct my_data, link); kref_get(&entry->refcount); } mutex_unlock(&mutex); return entry; } static void release_entry(struct kref *ref) { struct my_data *entry = container_of(ref, struct my_data, refcount); list_del(&entry->link); kfree(entry); } ``` -------------------------------- ### Copy dec_pc directory to /usr/local/lib Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt As root, copy the entire dec_pc directory into /usr/local/lib to install the DecTalk PC software. ```bash cp dec_pc /usr/local/lib ``` -------------------------------- ### Personal system boot setup command Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/ncr53c8xx.txt A boot setup that works flawlessly on the author's personal system. Includes a line continuation backslash. ```text ncr53c8xx=mpar:y,spar:y,disc:y,specf:1,fsn:n,ultra:2,fsn:n,revprob:n,verb:1\ tags:32,sync:12,debug:0,burst:7,led:1,wide:1,settle:2,diff:0,irqm:0 ``` -------------------------------- ### Check InfiniBand port state Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Verify the InfiniBand port is active by reading the state file. Expect '4: ACTIVE' when a Subnet Manager is running. ```bash $ cat /sys/class/infiniband/driverX/ports/1/state 4: ACTIVE ``` -------------------------------- ### Create and test a static hello world initramfs Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/ramfs-rootfs-initramfs.txt Commands to create a minimal initramfs with a statically linked 'hello world' program as init. The example writes a C source file, compiles it with gcc -static, and packages it with cpio and gzip. The resulting test.cpio.gz can be tested under an emulator like qemu or User Mode Linux. ```shell cat > hello.c << EOF #include #include int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } EOF gcc -static hello.c -o init echo init | cpio -o -H newc | gzip > test.cpio.gz ``` -------------------------------- ### Example output of ls -1 /speakup/* Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt Shows the expected output of the ls command, listing parameter files and the i18n and soft subdirectories. ```plaintext /speakup/attrib_bleep /speakup/bell_pos /speakup/bleep_time /speakup/bleeps /speakup/cursor_time /speakup/delimiters /speakup/ex_num /speakup/key_echo /speakup/keymap /speakup/no_interrupt /speakup/punc_all /speakup/punc_level /speakup/punc_most /speakup/punc_some /speakup/reading_punc /speakup/repeats /speakup/say_control /speakup/say_word_ctl /speakup/silent /speakup/spell_delay /speakup/synth /speakup/synth_direct /speakup/version /speakup/i18n: announcements characters chartab colors ctl_keys formatted function_names key_names states /speakup/soft: caps_start caps_stop delay_time direct freq full_time jiffy_delta pitch punct rate tone trigger_time voice vol ``` -------------------------------- ### Load RDMA modules for Mellanox Tavor/Sinai/Arbel Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Load the ib_mthca and ib_ipoib modules to enable RDMA on Mellanox adapters. Use when the RDMA components are built as modules. ```bash $ modprobe ib_mthca $ modprobe ib_ipoib ``` -------------------------------- ### VM Debugger: Profile.exec PF Key Shortcuts Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/s390/Debugging390.txt Example profile.exec file entries to set PF keys for command history, continue, and switching trace sets. ```text /* this gives me command history on issuing f12 */ set pf12 retrieve /* this continues */ set pf8 imm b /* goes to trace set a */ set pf1 imm tr goto a /* goes to trace set b */ set pf2 imm tr goto b /* goes to trace set c */ set pf3 imm tr goto c ``` -------------------------------- ### Mount NFS/RDMA server Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Mount the NFS/RDMA server using the rdma option and port 20049. Verify the mount uses RDMA by checking the 'proto' field in /proc/mounts. ```bash $ mount -o rdma,port=20049 :/ /mnt ``` -------------------------------- ### Load and configure RDMA drivers for InfiniBand Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/nfs/nfs-rdma.txt Load the ib_mthca and ib_ipoib modules and bring up the ib0 interface with an IP address. Use unique addresses for client and server. ```bash $ modprobe ib_mthca $ modprobe ib_ipoib $ ip li set dev ib0 up $ ip addr add dev ib0 a.b.c.d ``` -------------------------------- ### Setup SDRAM (part 1) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/arch/sh/include/mach-ecovec24/mach/partner-jet-setup.txt First part of SDRAM initialization. Includes a WAIT 1 after the writes. ```text ED 0xfd000108, 0x00000181 ED 0xfd000020, 0x015B0002 ED 0xfd000030, 0x03061502 ED 0xfd000034, 0x02020102 ED 0xfd000038, 0x01090305 ED 0xfd00003c, 0x00000002 ED 0xfd000008, 0x00000005 ED 0xfd000018, 0x00000001 WAIT 1 ``` -------------------------------- ### Load real-mode kernel and set up command line (boot.txt) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/x86/boot.txt Sets up the heap end, command line magic and offset, relocates the real-mode kernel to 0x90000 if needed, copies the command line, and clears memory up to the 32K mark. Used when loading a very old kernel protocol. ```c heap_end = 0x9800; cmd_line_magic = 0xA33F; cmd_line_offset = heap_end; /* A very old kernel MUST have its real-mode code loaded at 0x90000 */ if ( base_ptr != 0x90000 ) { /* Copy the real-mode kernel */ memcpy(0x90000, base_ptr, (setup_sects+1)*512); base_ptr = 0x90000; /* Relocated */ } strcpy(0x90000+cmd_line_offset, cmdline); /* It is recommended to clear memory up to the 32K mark */ memset(0x90000 + (setup_sects+1)*512, 0, (64-(setup_sects+1))*512); } ``` -------------------------------- ### dev_hint examples Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/media/usb/pwc/philips.txt Examples of the dev_hint parameter showing how to assign video device nodes to cameras. The first example assigns the first detected camera to /dev/video3 and the second to /dev/video5. The second example assigns a PCA645 camera to /dev/video1 and a PCVC680 to /dev/video2. The third example assigns two PCA645 cameras with specific serial numbers to /dev/video3 and /dev/video0. The fourth example assigns a PCVC750 camera to /dev/video1 and the next three Philips cams to /dev/video4 through /dev/video6. ```text dev_hint=3,5 ``` ```text dev_hint=645:1,680:2 ``` ```text dev_hint=645.0123:3,645.4567:0 ``` ```text dev_hint=750:1,4,5,6 ``` -------------------------------- ### Example: Input control transfer to get port status Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/usb/usbmon.txt Shows a submission (S) and completion (C) event for an input control transfer to get a port status. The 's' tag indicates a setup packet, '=' indicates data present, and the data words follow in hexadecimal. ```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 ``` -------------------------------- ### insmod: Override default number of tty devices Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/powerpc/hvcs.txt Use the hvcs_parm_num_devs parameter to request a specific number of tty devices (example: 4). The maximum is 1024, changeable in source. ```shell insmod hvcs.ko hvcs_parm_num_devs=4 ``` -------------------------------- ### Pass arguments to daemon with talkwith Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt Any arguments following the daemon name are passed to the daemon when invoked. Example: 'talkwith espeakup --default-voice=fr' causes espeakup to use the French voice. Requires root privileges. ```bash talkwith espeakup --default-voice=fr ``` -------------------------------- ### Create a core dump with ulimit and kill -SIGSEGV Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/s390/Debugging390.txt Set the core file size to unlimited, launch gdb as the victim, then send SIGSEGV from another session to generate a core dump. Use killall -SIGSEGV gdb if killall is available. ```bash ulimit -c unlimited ``` ```bash gdb ``` ```bash ps -aux | grep gdb ``` ```bash kill -SIGSEGV ``` ```bash killall -SIGSEGV gdb ``` -------------------------------- ### Jump to kernel entry point (boot.txt) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/x86/boot.txt Sets up segment registers and stack, then jumps to the kernel entry point at segment offset 0x20. Requires interrupts disabled and base_ptr == 0x90000 for the old protocol. It is recommended to set fs = gs = ds = es = ss. ```c /* Note: in the case of the "old" kernel protocol, base_ptr must be == 0x90000 at this point; see the previous sample code */ seg = base_ptr >> 4; cli(); /* Enter with interrupts disabled! */ /* Set up the real-mode kernel stack */ _SS = seg; _SP = heap_end; _DS = _ES = _FS = _GS = seg; jmp_far(seg+0x20, 0); /* Run the kernel */ ``` -------------------------------- ### Run speechd_up daemon Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt Start speechd_up in the background after enabling the soft driver. ```bash speechd_up & ``` -------------------------------- ### Run lguest guest with tunnet and block Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/tools/lguest/lguest.txt Launch an lguest guest as root with 64MB memory, a kernel image, a tap network device, and a block device. The command line after the kernel image is passed as boot parameters. ```bash tools/lguest/lguest 64 vmlinux --tunnet=192.168.19.1 \ --block=rootfile root=/dev/vda ``` -------------------------------- ### Start network stack with /etc/rc.d/init.d/network Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/s390/Debugging390.txt Starts the network stack and hopefully brings up the network device (e.g., tr0) if it is not already up. ```bash /etc/rc.d/init.d/network start ``` -------------------------------- ### Setup SDRAM (part 2) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/arch/sh/include/mach-ecovec24/mach/partner-jet-setup.txt Second part of SDRAM initialization. Includes a WAIT 1 after the writes. ```text ED 0xfd000014, 0x00000002 ED 0xfd000060, 0x00020000 ED 0xfd000060, 0x00030000 ED 0xfd000060, 0x00010040 ED 0xfd000060, 0x00000532 ED 0xfd000014, 0x00000002 ED 0xfd000014, 0x00000004 ED 0xfd000014, 0x00000004 ED 0xfd000060, 0x00000432 ED 0xfd000060, 0x000103C0 ED 0xfd000060, 0x00010040 WAIT 1 ``` -------------------------------- ### Example io.weight output Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/cgroup.txt Read-write flat-keyed file on non-root cgroups. Default is "default 100". First line is default weight, rest are overrides keyed by $MAJ:$MIN device numbers. Weights range [1, 10000]. ```text default 100 8:16 200 8:0 50 ``` -------------------------------- ### Line number matching examples for dynamic debug Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/dynamic-debug-howto.txt Shows how to specify a single line, a range, an open-ended start, or an open-ended end for matching pr_debug() callsites. An empty first number means the first line in the file; an empty second number means the last line in the file. ```text line 1603 // exactly line 1603 line 1600-1605 // the six lines from line 1600 to line 1605 line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file ``` -------------------------------- ### modprobe pwc example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/media/usb/pwc/philips.txt Example of loading the pwc module with the size, fps, and power_save parameters. The fbufs, mbufs, and trace parameters are global and apply to all connected cameras. size and fps only specify defaults when opening the device; the default is QCIF size at 10 fps. The compression parameter is semiglobal and can be set per camera with the VIDIOCPWCSCQUAL ioctl() call. ```bash # modprobe pwc size=cif fps=15 power_save=1 ``` -------------------------------- ### Enable soft driver for Espeakup Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt Tell Speakup to use the soft driver before starting espeakup. ```bash echo soft > /speakup/synth ``` -------------------------------- ### modprobe: Install hvcs with parameter Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/powerpc/hvcs.txt Recommended method to install hvcs as a module. Uses depmod to build modules.dep, then modprobe inserts hvcserver.ko before hvcs.ko automatically. ```shell modprobe hvcs hvcs_parm_num_devs=4 ``` -------------------------------- ### Start xend and create domU Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/ia64/xen.txt Commands to start xend and then create the domU. For debugging, use XEND_DEBUG=1 xend trace_start instead of the normal start command. After xend is running, create the domain with xm create -c rhel5. ```bash # /etc/init.d/xend start ( In the debugging case, # XEND_DEBUG=1 xend trace_start ) ``` ```bash # xm create -c rhel5 ``` -------------------------------- ### Start ddd for UML debugging Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/virtual/uml/UserModeLinux-HOWTO.txt Launch ddd to debug a UML kernel. After starting, get the gdb pid with ps and pass it to UML via debug=parent gdb-pid=. ```shell host% ddd linux ``` -------------------------------- ### AF_PACKET fanout minimal example (incomplete) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/networking/packet_mmap.txt Starts a minimal example for AF_PACKET fanout mode by David S. Miller. The snippet is incomplete in the source, showing only the initial includes. ```c #include #include #include #include ``` -------------------------------- ### Example output of /proc/asound/seq/oss for AWE64 Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/sound/alsa/seq_oss.html Example output from an AWE64 card showing the OSS sequencer emulation version, ALSA client/receiver port, and lists of synth and MIDI devices with their capabilities and ALSA ports. ```text OSS sequencer emulation version 0.1.8 ALSA client number 63 ALSA receiver port 0 Number of applications: 0 Number of synth devices: 1 synth 0: [EMU8000] type 0x1 : subtype 0x20 : voices 32 capabilties : ioctl enabled / load_patch enabled Number of MIDI devices: 3 midi 0: [Emu8000 Port-0] ALSA port 65:0 capability write / opened none midi 1: [Emu8000 Port-1] ALSA port 65:1 capability write / opened none midi 2: [0: MPU-401 (UART)] ALSA port 64:0 capability read/write / opened none ``` -------------------------------- ### Setup BSC (Bus State Controller) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/arch/sh/include/mach-ecovec24/mach/partner-jet-setup.txt Configures BSC registers. Includes a WAIT 1 after the writes. ```text ED 0xff800020, 0xa5a50000 ED 0xfec10000, 0x00001013 ED 0xfec10004, 0x11110400 ED 0xfec10024, 0x00000440 WAIT 1 ``` -------------------------------- ### Boot-args example for dynamic debug Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/dynamic-debug-howto.txt Shows boot-args configuration for dynamic debug, including verbose logging, enabling pr_debugs in builtins, and enabling functions in a module loaded later. ```bash // boot-args example, with newlines and comments for readability Kernel command line: ... // see whats going on in dyndbg=value processing dynamic_debug.verbose=1 // enable pr_debugs in 2 builtins, #cmt is stripped dyndbg="module params +p #cmt ; module sys +p" // enable pr_debugs in 2 functions in a module loaded later pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p" ``` -------------------------------- ### Reclaim 2M from 0x100000 via /proc/PID/reclaim Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/proc.txt Example that reclaims 2 megabytes starting at address 0x100000. ```shell > echo 0x100000 2M > /proc/PID/reclaim ``` -------------------------------- ### Hexdump active_mm+pgd offset Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/s390/Debugging390.txt Hexdump /dev/mem at active_mm+pgd offset to get the pgd value. Example offset 0x0feecc6c. ```text hexdump -s 0x0feecc6c /dev/mem | more ``` -------------------------------- ### Setup cpuset cgroup hierarchy Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/cgroup-legacy/cgroups.txt Commands to mount the cgroup filesystem and create a cpuset subsystem. Steps 1-3 from the 'How do I use cgroups?' section. ```shell mount -t tmpfs cgroup_root /sys/fs/cgroup mkdir /sys/fs/cgroup/cpuset mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset ``` -------------------------------- ### Load cs89x0 module with io, irq, and media parameters Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/networking/cs89x0.txt Loads the cs89x0 driver module with command-line arguments to override EEPROM settings or configure the adapter when no EEPROM is used. The example sets IO port base address to 200h, interrupt 10, and AUI media connection. The io parameter must be specified; adding one to the io value (e.g., 0x301 for 0x300) forces partial hardware initialization before probing. ```bash insmod cs89x0.o io=0x200 irq=0xA media=aui ``` -------------------------------- ### Example: IPv4 route lookup for vrf-red Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/networking/vrf.txt Example output of `ip route get 10.2.1.40 oif vrf-red` showing the route lookup result for an IPv4 address in the VRF. ```bash $ ip route get 10.2.1.40 oif vrf-red 10.2.1.40 dev eth1 table vrf-red src 10.2.1.2 cache ``` -------------------------------- ### Boot setup command for ncr53c8xx driver under lilo Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/ncr53c8xx.txt Boot setup command for the ncr53c8xx (sym53c8xx) driver under the lilo prompt. The kernel syntax parser expects an optional list of integers separated with comma followed by an optional list of comma-separated strings. This example enables tagged commands (up to 4 queued), sets synchronous negotiation speed to 10 Mega-transfers/second, and sets the DEBUG_NEGO flag. ```text lilo: linux root=/dev/hda2 ncr53c8xx=tags:4,sync:10,debug:0x200 ``` -------------------------------- ### Original keymap lines for say_first_char and say_last_char Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt These lines from speakupmap.map show the default key assignments for say_first_char and say_last_char. They are used as a starting point for swapping the command names. ```text spk key_pageup = say_first_char spk key_pagedown = say_last_char ``` -------------------------------- ### dmsetup status output example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/device-mapper/dm-raid.txt Example output from 'dmsetup status' for a RAID4 array with 5 devices, all alive, and 2/490221568 complete with initial recovery. ```plaintext 0 1960893648 raid raid4 5 AAAAA 2/490221568 init 0 ``` -------------------------------- ### tag_info option example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/scsi/aic7xxx.txt Sets tag depth per controller and target. In the example, Controller 1 targets 0 and 2 get a depth of 32; all other targets retain the default depth. Valid values are 1-253, default is 32. ```plaintext tag_info:{{},{32,,32}} ``` -------------------------------- ### Example /proc/key-users output Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/security/keys.txt Sample output of the /proc/key-users file, showing per-user key tracking data including quota and statistics. The line format is documented in the surrounding text: UID, usage, instantiated/total keys, key count quota, and key size quota. ```text [root@andromeda root]# cat /proc/key-users 0: 46 45/45 1/100 13/10000 29: 2 2/2 2/100 40/10000 32: 2 2/2 2/100 40/10000 38: 2 2/2 2/100 40/10000 ``` -------------------------------- ### Example: IPv6 route lookup for vrf-red Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/networking/vrf.txt Example output of `ip -6 route get 2002:1::32 oif vrf-red` showing the route lookup result for an IPv6 address in the VRF. ```bash $ ip -6 route get 2002:1::32 oif vrf-red 2002:1::32 from :: dev eth1 table vrf-red proto kernel src 2002:1::2 metric 256 pref medium ``` -------------------------------- ### dmsetup Create Cache Device Example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/device-mapper/cache-policies.txt Creates a 128GB mapped device named 'blah' with sequential threshold 1024 and random threshold 8 using the mq policy. ```text dmsetup create blah --table "0 268435456 cache /dev/sdb /dev/sdc \ /dev/sdd 512 0 mq 4 sequential_threshold 1024 random_threshold 8" ``` -------------------------------- ### Get watchdog timeout with WDIOC_GETTIMEOUT Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/watchdog/watchdog-api.txt Queries the current timeout; available starting with Linux 2.4.18. ```c ioctl(fd, WDIOC_GETTIMEOUT, &timeout); printf("The timeout was is %d seconds\n", timeout); ``` -------------------------------- ### rmmod: Remove hvcs module Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/powerpc/hvcs.txt Remove the hvcs kernel module. ```shell rmmod hvcs.ko ``` -------------------------------- ### FAQ Q3: Replicating mount tree with shared mounts - step 3 Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/filesystems/sharedsubtree.txt Step 3 of the example: creating /tmp/m2 and rbind mounting /root to it. ```shell mkdir -p /tmp/m2 mount --rbind /root /tmp/m2 ``` -------------------------------- ### GDB startup banner Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/frv/gdbstub.txt Example output shown when GDB starts, indicating the version and configuration. ```text GNU gdb frv-031024 Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=frv-uclinux"... (gdb) ``` -------------------------------- ### cat /speakup/KWD/vol Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt Command to display the current volume level from the Speakup sys system. ```bash cat /speakup/KWD/vol ``` -------------------------------- ### Example /proc/keys output Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/security/keys.txt Sample output of the /proc/keys file, listing keys viewable by the reading task. Shows serial, flags, usage, expiry, permissions, UID/GID, type, and description. The flags legend (I, R, D, Q, U, N) is provided in the surrounding text. ```text SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY 00000001 I----- 39 perm 1f3f0000 0 0 keyring _uid_ses.0: 1/4 00000002 I----- 2 perm 1f3f0000 0 0 keyring _uid.0: empty 00000007 I----- 1 perm 1f3f0000 0 0 keyring _pid.1: empty 0000018d I----- 1 perm 1f3f0000 0 0 keyring _pid.412: empty 000004d2 I--Q-- 1 perm 1f3f0000 32 -1 keyring _uid.32: 1/4 000004d3 I--Q-- 3 perm 1f3f0000 32 -1 keyring _uid_ses.32: empty 00000892 I--QU- 1 perm 1f000000 0 0 user metal:copper: 0 00000893 I--Q-N 1 35s 1f3f0000 0 0 user metal:silver: 0 00000894 I--Q-- 1 10h 003f0000 0 0 user metal:gold: 0 ``` -------------------------------- ### dma_buf_fd Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/dma-buf-sharing.txt Installs a file descriptor for the anonymous file associated with the buffer. Returns the fd or an error. ```APIDOC ## dma_buf_fd ### Description Installs a file descriptor for the anonymous file associated with the buffer. Returns the fd or an error. ### Syntax `int dma_buf_fd(struct dma_buf *dmabuf, int flags)` ### Parameters - **dmabuf** (struct dma_buf *) - Required - Pointer to the dma_buf structure. - **flags** (int) - Required - Flags for the file descriptor. ### Return Value - **int** - The file descriptor on success, or an error code. ``` -------------------------------- ### GDB directory command example Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/s390/Debugging390.txt Add directories to search for source files. Use 'directory //' to add root. ```gdb directory // ``` -------------------------------- ### String field glob filter examples Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/trace/events.txt Examples of valid glob patterns for string fields using the '~' operator. The wildcard (*) is only allowed at the start or end of the string; a wildcard in the middle (e.g., "ba*sh") is invalid. ```text prev_comm ~ "*sh" ``` ```text prev_comm ~ "sh*" ``` ```text prev_comm ~ "*sh*" ``` -------------------------------- ### CAN_BCM socket creation and connect (example without error checking) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/networking/can.txt Shows how to create and connect a CAN_BCM socket instead of binding it. The example uses socket(PF_CAN, SOCK_DGRAM, CAN_BCM), retrieves the interface index for 'can0' via ioctl, and connects to the address. Error checking is omitted for brevity. ```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)); (..) ``` -------------------------------- ### Get current printer status (prn_example -get_status) Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/usb/gadget_printer.txt Runs the example program to get the current printer status from the gadget driver. The output shows the printer status: 'Printer is NOT Selected', 'Paper is Out', and 'Printer OK'. ```bash # prn_example -get_status Printer status is: Printer is NOT Selected Paper is Out Printer OK ``` -------------------------------- ### Silly extra get and put Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/kref.txt Unnecessary kref_get and kref_put when passing an object to a queue. Just enqueue and pass the refcount. ```c /* Silly extra get and put */ kref_get(&obj->ref); enqueue(obj); kref_put(&obj->ref, obj_cleanup); ``` -------------------------------- ### Enter the new cpuset directory Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/Documentation/cgroup-legacy/cpusets.txt Changes into the newly created cpuset directory. ```shell # cd my_cpuset ``` -------------------------------- ### Enable decpc synthesizer Source: https://github.com/riarumoda/kernel_samsung_a9y18qlte/blob/master/drivers/staging/speakup/spkguide.txt After loading the DecTalk PC software with dtload, echo the decpc keyword to the synth entry. ```bash echo decpc >/speakup/synth ```