### SMP2P Device Tree Setup Example Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/soc/qcom/qcom,smp2p.txt This example demonstrates the SMP2P setup from the perspective of the 8974 apps processor, including one inbound and one outbound entry for communication with the wireless processor. ```dts wcnss-smp2p { compatible = "qcom,smp2p"; qcom,smem = <431>, <451>; interrupts = <0 143 1>; qcom,ipc = <&apcs 8 18>; qcom,local-pid = <0>; qcom,remote-pid = <4>; wcnss_smp2p_out: master-kernel { qcom,entry-name = "master-kernel"; #qcom,smem-state-cells = <1>; }; wcnss_smp2p_in: slave-kernel { qcom,entry-name = "slave-kernel"; interrupt-controller; #interrupt-cells = <2>; }; }; ``` -------------------------------- ### Run an Example QUIC Server with OpenSSL Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/README-QUIC.md This command starts a basic QUIC server example provided by OpenSSL. You need to specify the port number, certificate file, and key file. This is a dedicated example and not part of the standard 'openssl s_server'. ```shell $ ./demos/quic/server/server ``` ```shell $ ./demos/quic/server/server 4433 server.pem server.key ``` -------------------------------- ### Basic wpa_supplicant Command Line Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/wpa/wpa_supplicant/README-Windows.txt Example of how to start wpa_supplicant from the command line with a configuration file and debug output enabled. ```bash wpa_supplicant.exe -iAtheros -c wpa_supplicant.conf -d ``` -------------------------------- ### Minimal Unbound Configuration Example Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/unbound/doc/unbound.conf.rst A basic unbound.conf file example. Most settings will use their default values. This can be copied to @ub_conf_file@ to start the server. ```text # unbound.conf(5) config file for unbound(8). server: directory: "@UNBOUND_RUN_DIR@" username: unbound # make sure unbound can access entropy from inside the chroot. # e.g. on linux the use these commands (on BSD, devfs(8) is used): # mount --bind -n /dev/urandom @UNBOUND_RUN_DIR@/dev/urandom # and mount --bind -n /dev/log @UNBOUND_RUN_DIR@/dev/log chroot: "@UNBOUND_CHROOT_DIR@" # logfile: "@UNBOUND_RUN_DIR@/unbound.log" #uncomment to use logfile. pidfile: "@UNBOUND_PIDFILE@" # verbosity: 1 # uncomment and increase to get more logging. # listen on all interfaces, answer queries from the local subnet. interface: 0.0.0.0 interface: ::0 access-control: 10.0.0.0/8 allow access-control: 2001:db8::/64 allow ``` -------------------------------- ### Setup Functions Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/bc/manuals/bcl.3.md Functions to initialize, start, and clean up the bcl library, as well as configure global settings like error handling and leading zero display. ```APIDOC ## Setup These items allow clients to set up bcl(3). **BclError bcl_start(void);** **void bcl_end(void);** **BclError bcl_init(void);** **void bcl_free(void);** **bool bcl_abortOnFatalError(void);** **void bcl_setAbortOnFatalError(bool abrt);** **bool bcl_leadingZeroes(void);** **void bcl_setLeadingZeroes(bool leadingZeroes);** **void bcl_gc(void);** **bool bcl_digitClamp(void);** **void bcl_setDigitClamp(bool digitClamp);** ``` -------------------------------- ### Makefile for Standard Expat Installation Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/expat/doc/reference.html This Makefile example demonstrates how to link against the Expat library when it's installed in a standard system location. It specifies the C compiler, linker flags, and the Expat library. ```makefile CC=cc LDFLAGS= LIBS= -lexpat xmlapp: xmlapp.o $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS) ``` -------------------------------- ### Compile pkgconf and libpkgconf with Meson on Windows Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/pkgconf/README.md Compile pkgconf and libpkgconf using Meson, typically for Windows. This example disables tests during setup. ```bash $ meson setup build -Dtests=disabled $ meson compile -C build $ meson install -C build ``` -------------------------------- ### Standard Build and Install Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/bc/manuals/build.md After configuring the build with desired options, use 'make' to build the project and 'make install' to install it. ```shell make make install ``` -------------------------------- ### Remote Filesystem Memory Setup Example Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/reserved-memory/qcom,rmtfs-mem.txt This example demonstrates the device tree setup for a remote filesystem memory region on APQ8016, specifying the Hexagon DSP as client ID 1 and its memory location. ```dts reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; rmtfs@86700000 { compatible = "qcom,rmtfs-mem"; reg = <0x0 0x86700000 0x0 0xe0000>; no-map; qcom,client-id = <1>; }; }; ``` -------------------------------- ### Setup libxo Build Environment Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/libxo/doc/getting.md Run the setup script to generate necessary build files like the configure script. This step can be skipped if using a downloaded distfile. ```bash sh bin/setup.sh ``` -------------------------------- ### Run QUIC Server Demo Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/demos/guide/README.md Start a QUIC server. Ensure libcrypto and libssl are on the library path. Provide the port, certificate chain, and private key. ```bash LD_LIBRARY_PATH=../.. ./quic-server-block 4443 ./chain.pem ./pkey.pem ``` -------------------------------- ### Install GPE Handler and Enable GPE Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/dev/acpica/changes.txt Example of installing a GPE handler and then explicitly enabling the GPE. The GPE type must be set before enabling. ```c AcpiInstallGpeHandler (NULL, GpeNum, ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); AcpiSetGpeType (NULL, GpeNum, ACPI_GPE_TYPE_RUNTIME); AcpiEnableGpe (NULL, GpeNum, ACPI_NOT_ISR); ``` -------------------------------- ### Get Autosetup Reference Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/sqlite3/autosetup/README.md View the comprehensive Autosetup API reference by running this command in the project root. Pipe the output to 'less' for easier navigation. ```bash $ ./configure --reference | less ``` -------------------------------- ### Makefile for Custom Expat Installation Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/expat/doc/reference.html This Makefile example shows how to link against Expat when it's installed in a custom directory (e.g., /home/me/mystuff). It includes flags to specify the custom include and library paths. ```makefile CC=cc CFLAGS= -I/home/me/mystuff/include LDFLAGS= LIBS= -L/home/me/mystuff/lib -lexpat xmlapp: xmlapp.o $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS) ``` -------------------------------- ### Example Assembly Function Generation Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/crypto/perlasm/README.md A comprehensive example demonstrating how to generate assembly code for a C function using perlasm functions. It includes setup, variable assignments, loops, function calls, and finalization. ```perl push(@INC,"perlasm","../../perlasm"); require "x86asm.pl"; &asm_init($ARGV[0]); &external_label("other"); $tmp1= "eax"; $j= "edi"; $data= "esi"; $i= "ebp"; &comment("a simple function"); &function_begin("calc"); &mov( $data, &wparam(1)); # data &xor( $j, $j); &xor( $i, $i); &set_label("loop"); &cmp( $i, &wparam(0)); &jge( &label("end")); &mov( $tmp1, &DWP(0,$data,$i,4)); &push( $tmp1); &call( "other"); &add( $j, "eax"); &pop( $tmp1); &inc( $i); &jmp( &label("loop")); &set_label("end"); &mov( "eax", $j); &function_end("calc"); &asm_finish(); ``` -------------------------------- ### Library build.info Example with Generation Rule Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/Configurations/README-design.md Specifies source files for a library and demonstrates how to generate a header file using a script, including its dependencies. ```makefile # crypto/build.info LIBS=../libcrypto SOURCE[../libcrypto]=aes.c evp.c cversion.c DEPEND[cversion.o]=buildinf.h GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)" DEPEND[buildinf.h]=../Makefile DEPEND[../util/mkbuildinf.pl]=../util/Foo.pm ``` -------------------------------- ### Build and Run QUIC Server Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/demos/quic/server/README.md Build the server using `make` and run it with `make run`. The server requires port, certificate, and key file arguments. ```bash make make run ``` -------------------------------- ### SMSM Device Tree Configuration Example Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/soc/qcom/qcom,smsm.txt This example demonstrates the device tree setup for the SMSM, including compatible string, address/size cells, IPC configuration, and definitions for local and remote processor state bits. ```dts smsm { compatible = "qcom,smsm"; #address-cells = <1>; #size-cells = <0>; qcom,ipc-3 = <&apcs 8 19>; apps_smsm: apps@0 { reg = <0>; #qcom,smem-state-cells = <1>; }; wcnss_smsm: wcnss@7 { reg = <7>; interrupts = <0 144 1>; interrupt-controller; #interrupt-cells = <2>; }; }; ``` -------------------------------- ### Ingenic JZ4740 Pin Controller Example Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/pinctrl/ingenic,pinctrl.txt This example demonstrates the device tree configuration for the Ingenic JZ4740 pin controller and its associated GPIO chip. It includes register definitions, GPIO ranges, and interrupt controller setup. ```dts pinctrl: pin-controller@10010000 { compatible = "ingenic,jz4740-pinctrl"; reg = <0x10010000 0x400>; #address-cells = <1>; #size-cells = <0>; gpa: gpio@0 { compatible = "ingenic,jz4740-gpio"; reg = <0>; gpio-controller; gpio-ranges = <&pinctrl 0 0 32>; #gpio-cells = <2>; interrupt-controller; #interrupt-cells = <2>; interrupt-parent = <&intc>; interrupts = <28>; }; }; ``` -------------------------------- ### Basic GMock Test Setup Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/googletest/docs/gmock_for_dummies.md Demonstrates the basic setup for a GMock test, including including necessary headers, importing GMock namespaces, creating a mock object, setting an expectation on a mock method, and exercising code that uses the mock. ```cpp #include "path/to/mock-turtle.h" #include #include using ::testing::AtLeast; TEST(PainterTest, CanDrawSomething) { MockTurtle turtle; EXPECT_CALL(turtle, PenDown()) .Times(AtLeast(1)); Painter painter(&turtle); EXPECT_TRUE(painter.DrawCircle(0, 0, 10)); } ``` -------------------------------- ### Install Library and Header Files Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/libdivsufsort/README.md Optionally install the compiled library and header files using 'sudo make install'. ```shell sudo make install ``` -------------------------------- ### Build and Run HTTP/3 Demo Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/demos/http3/README.md Build the demo application using make and then execute it with a hostname and port. Ensure the LD_LIBRARY_PATH is set if necessary. ```shell $ make $ LD_LIBRARY_PATH=../.. ./ossl-nghttp3-demo www.google.com:443 ``` -------------------------------- ### XML_GetCurrentColumnNumber Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/expat/doc/reference.html Gets the column offset from the beginning of the current line for the current parse position. Column numbering starts at 0. ```APIDOC ## XML_GetCurrentColumnNumber ### Description Return the _offset_, from the beginning of the current line, of the position. The first column is reported as `0`. ### Signature XML_Size XMLCALL XML_GetCurrentColumnNumber(XML_Parser p); ### Parameters * **p** (XML_Parser) - The XML parser instance. ``` -------------------------------- ### Configure, Build, and Install bc Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/bc/manuals/build.md General steps for configuring, building, and installing bc on POSIX-compliant systems. Environment variables can be set to customize the build. ```shell [ENVIRONMENT_VARIABLE=...] ./configure.sh [build_options...] make make install ``` -------------------------------- ### Expat Start Element Handler Example Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/expat/doc/reference.html This C code defines a start element handler for Expat. It prints the element name and its attributes, indented based on the current depth in the XML structure. The Depth variable is incremented after processing the element. ```c int Depth; void XMLCALL start(void *data, const char *el, const char **attr) { int i; for (i = 0; i < Depth; i++) printf(" "); printf("%s", el); for (i = 0; attr[i]; i += 2) { printf(" %s='%s'", attr[i], attr[i + 1]); } printf("\n"); Depth++; } /* End of start handler */ ``` -------------------------------- ### Build and Install Expat Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/expat/README.md After running the configure script, use `make` to build the library and `make install` to install it. Ensure you have write permissions to the target installation directories. ```bash make make install ``` -------------------------------- ### Example SPI MCP23S17 Device Tree Configuration Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/pinctrl/pinctrl-mcp23s08.txt This example demonstrates the DeviceTree configuration for an MCP23S17 SPI device. It includes the SPI compatible string, GPIO controller setup, SPI present mask, chipselect, and maximum SPI frequency. ```dts gpiom1: gpio@0 { compatible = "microchip,mcp23s17"; gpio-controller; #gpio-cells = <2>; microchip,spi-present-mask = <0x01>; reg = <0>; spi-max-frequency = <1000000>; }; ``` -------------------------------- ### Get Specified Attribute Count in Expat Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/expat/doc/reference.html Returns twice the number of attributes explicitly set in an element's start tag. This indicates the offset in the 'atts' array to the first attribute set by default. Information is for the last start handler call. ```c int XMLCALL XML_GetSpecifiedAttributeCount(XML_Parser p); ``` -------------------------------- ### Complete libxo Build Process Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/libxo/doc/getting.md Execute the sequence of commands to set up, configure, build, test, and install libxo. This is a summary of the entire build process. ```bash sh bin/setup.sh cd build ../configure make make test sudo make install ``` -------------------------------- ### SMEM Device Tree Setup Example Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/soc/qcom/qcom,smem.txt This example demonstrates the device tree configuration for the Qualcomm Shared Memory Manager (SMEM) on an MSM8974 platform. It includes the definition of the main SMEM region, the SMEM device itself, and the associated RPM message RAM. ```dts reserved-memory { #address-cells = <1>; #size-cells = <1>; ranges; smem_region: smem@fa00000 { reg = <0xfa00000 0x200000>; no-map; }; }; smem@fa00000 { compatible = "qcom,smem"; memory-region = <&smem_region>; qcom,rpm-msg-ram = <&rpm_msg_ram>; hwlocks = <&tcsr_mutex 3>; }; soc { rp_msg_ram: memory@fc428000 { compatible = "qcom,rpm-msg-ram"; reg = <0xfc428000 0x4000>; }; }; ``` -------------------------------- ### Compile libecc Examples Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/libecc/README.md Navigate to the examples directory and run 'make' to compile the provided user examples. ```bash $ cd src/examples $ make ``` -------------------------------- ### Application build.info Example Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/Configurations/README-design.md Defines a program to be built, its source file, include paths, and dependencies. Paths are relative to the current directory. ```makefile # apps/build.info PROGRAMS=openssl SOURCE[openssl]=openssl.c INCLUDE[openssl]=.. ../include DEPEND[openssl]=../libssl ``` -------------------------------- ### Indefinite Map Encoding Example Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/libcbor/doc/source/api/type_5_maps.rst This example shows the byte representation of an indefinite map containing a single key-value pair (1: 2). It starts with the indefinite map header (0xbf), followed by the key (0x01) and value (0x02), and ends with the break token (0xff). ```cbor 0xbf 0x01 0x02 0xff ``` -------------------------------- ### Top-level build.info Example Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/Configurations/README-design.md Declares libraries to be built and specifies include directories for them. This is a foundational configuration for the build. ```makefile # build.info LIBS=libcrypto libssl INCLUDE[libcrypto]=include INCLUDE[libssl]=include DEPEND[libssl]=libcrypto ``` -------------------------------- ### Include Path for Headers Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/libcbor/doc/source/getting_started.rst When 'cbor.h not found' errors occur, explicitly add the include path during compilation. This example assumes headers are installed in /usr/local/include. ```bash cc -I/usr/local/include hello_cbor.c -lcbor -o hello_cbor ``` -------------------------------- ### Create Project Directory Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/googletest/docs/quickstart-cmake.md Initializes a new project directory. This is the first step in setting up your project. ```bash $ mkdir my_project && cd my_project ``` -------------------------------- ### TPS61052 GPIO Operation Only Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/mfd/tps6105x.txt Example of a device tree configuration for the TPS61052 in GPIO operation mode only. This snippet shows the basic setup with compatible and reg properties. ```dts i2c0 { tps61052@33 { compatible = "ti,tps61052"; reg = <0x33>; }; }; ``` -------------------------------- ### Load and Use a Dynamic Engine via Command Line Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/README-ENGINES.md Shows how to achieve the same result as the programmatic example using the 'openssl engine' utility. This is useful for testing and direct interaction. ```bash openssl engine dynamic \ -pre SO_PATH:/lib/libfoo.so \ ``` -------------------------------- ### IIO Example: hwmon Consumer Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/iio/iio-bindings.txt Demonstrates an 'iio-hwmon' consumer node connected to multiple channels of an 'adc' provider. This setup is typical for hardware monitoring applications. ```dts adc: max1139@35 { compatible = "maxim,max1139"; reg = <0x35>; #io-channel-cells = <1>; }; ... iio-hwmon { compatible = "iio-hwmon"; io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>, <&adc 4>, <&adc 5>, <&adc 6>, <&adc 7>, <&adc 8>, <&adc 9>; }; ``` -------------------------------- ### Example Client Connection Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/demos/quic/server/README.md Connect to the running QUIC server using `openssl s_client` with the `-quic` and `-alpn` options. ```bash openssl s_client -quic -alpn ossltest -connect 127.0.0.1: ``` -------------------------------- ### Build and Install Flex Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/flex/README.md Follow the standard routine to configure, build, and install flex after preparing the source tree. This process uses the configure script generated by autogen.sh. ```bash configure && make && make install ``` -------------------------------- ### IOMMU Map for PCI Domain Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/virtio/iommu.txt Configures the IOMMU mapping for a PCI domain. This example shows mapping all functions except the IOMMU itself, using endpoint IDs starting from 0x0. ```dts iommu-map = <0x0 &iommu0 0x0 0x8> <0x9 &iommu0 0x9 0xfff7>; ``` -------------------------------- ### LAN9303 I2C Managed Mode Configuration Source: https://github.com/freebsd/freebsd-src/blob/main/sys/contrib/device-tree/Bindings/net/dsa/lan9303.txt Example Device Tree configuration for the LAN9303 switch in I2C managed mode. It includes fixed link setup and port definitions. ```dts master: masterdevice@X { fixed-link { /* RMII fixed link to LAN9303 */ speed = <100>; full-duplex; }; }; switch: switch@a { compatible = "smsc,lan9303-i2c"; reg = <0xa>; reset-gpios = <&gpio7 6 GPIO_ACTIVE_LOW>; reset-duration = <200>; ports { #address-cells = <1>; #size-cells = <0>; port@0 { /* RMII fixed link to master */ reg = <0>; ethernet = <&master>; }; port@1 { /* external port 1 */ reg = <1>; label = "lan1"; }; port@2 { /* external port 2 */ reg = <2>; label = "lan2"; }; }; }; ``` -------------------------------- ### Configure Installation Path Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/bc/manuals/build.md Use the --prefix option to specify the installation directory. Ensure to run make and make install after configuration. ```shell ./configure.sh --prefix=/usr make make install ``` -------------------------------- ### Live Preview Documentation Build Source: https://github.com/freebsd/freebsd-src/blob/main/contrib/libcbor/doc/source/development.rst Builds and serves the documentation locally for live preview. Navigate to the 'doc' directory before running this command. ```bash cd doc make livehtml ``` -------------------------------- ### Configure OpenSSL with RPATH using LIBRPATH Source: https://github.com/freebsd/freebsd-src/blob/main/crypto/openssl/NOTES-UNIX.md Example of configuring OpenSSL to use the LIBRPATH variable for setting the runtime shared library search path. This helps manage multilib installations. ```shell $ ./Configure --prefix=/usr/local/ssl --openssldir=/usr/local/ssl \ '-Wl,-rpath,$(LIBRPATH)' ```