├── .clang-format ├── .github └── workflows │ ├── examples.yaml │ ├── pr.yaml │ ├── push.yaml │ └── setup_ssh_key.sh ├── .gitignore ├── .reuse └── dep5 ├── CHANGES.md ├── LICENSE.md ├── LICENSES ├── BSD-2-Clause.txt ├── BSD-3-Clause.txt ├── CC-BY-SA-4.0.txt ├── GPL-2.0-only.txt ├── ISC.txt ├── LicenseRef-APACHE-2-LLVM-EXCEPTION.txt ├── LicenseRef-BSD-LWIP.txt └── MIT.txt ├── README.md ├── benchmark ├── benchmark.c ├── benchmark.mk └── idle.c ├── blk └── components │ ├── blk_components.mk │ ├── gpt.h │ ├── msdos_mbr.h │ ├── partitioning.c │ ├── virt.c │ └── virt.h ├── build.zig ├── build.zig.zon ├── ci ├── README.md ├── build.py ├── common.py ├── examples │ ├── blk.py │ ├── echo_server.py │ ├── i2c.py │ ├── serial.py │ └── timer.py ├── lib │ ├── backends │ │ ├── __init__.py │ │ ├── base.py │ │ ├── common.py │ │ ├── machine_queue.py │ │ ├── polyfills.py │ │ ├── qemu.py │ │ ├── streams.py │ │ └── tty.py │ ├── log.py │ └── runner.py ├── matrix.py └── run.py ├── docs ├── developing.md └── drivers.md ├── drivers ├── blk │ ├── mmc │ │ └── imx │ │ │ ├── README.md │ │ │ ├── blk_driver.mk │ │ │ ├── config.json │ │ │ ├── usdhc.c │ │ │ └── usdhc.h │ └── virtio │ │ ├── blk_driver.mk │ │ ├── block.c │ │ ├── block.h │ │ └── config.json ├── gpu │ └── virtio │ │ ├── gpu.c │ │ ├── gpu.h │ │ └── gpu_driver.mk ├── i2c │ └── meson │ │ ├── clk.h │ │ ├── config.json │ │ ├── driver.h │ │ ├── gpio.h │ │ ├── i2c.c │ │ └── i2c_driver.mk ├── network │ ├── dwmac-5.10a │ │ ├── config.json │ │ ├── eth_driver.mk │ │ ├── ethernet.c │ │ └── ethernet.h │ ├── imx │ │ ├── config.json │ │ ├── eth_driver.mk │ │ ├── ethernet.c │ │ └── ethernet.h │ ├── meson │ │ ├── config.json │ │ ├── eth_driver.mk │ │ ├── ethernet.c │ │ └── ethernet.h │ └── virtio │ │ ├── Makefile │ │ ├── config.json │ │ ├── eth_driver.mk │ │ ├── ethernet.c │ │ └── ethernet.h ├── serial │ ├── arm │ │ ├── config.json │ │ ├── include │ │ │ └── uart.h │ │ ├── serial_driver.mk │ │ └── uart.c │ ├── imx │ │ ├── config.json │ │ ├── include │ │ │ └── uart.h │ │ ├── serial_driver.mk │ │ └── uart.c │ ├── meson │ │ ├── config.json │ │ ├── include │ │ │ └── uart.h │ │ ├── serial_driver.mk │ │ └── uart.c │ ├── ns16550a │ │ ├── config.json │ │ ├── include │ │ │ └── uart.h │ │ ├── serial_driver.mk │ │ └── uart.c │ └── virtio │ │ ├── config.json │ │ ├── console.c │ │ ├── include │ │ └── console.h │ │ └── serial_driver.mk └── timer │ ├── arm │ ├── config.json │ ├── timer.c │ └── timer_driver.mk │ ├── goldfish │ ├── config.json │ ├── timer.c │ └── timer_driver.mk │ ├── imx │ ├── config.json │ ├── timer.c │ └── timer_driver.mk │ ├── jh7110 │ ├── config.json │ ├── timer.c │ └── timer_driver.mk │ └── meson │ ├── config.json │ ├── timer.c │ └── timer_driver.mk ├── dts ├── imx8mm_evk.dts ├── imx8mp_evk.dts ├── imx8mq_evk.dts ├── maaxboard.dts ├── odroidc2.dts ├── odroidc4.dts ├── qemu_virt_aarch64.dts ├── qemu_virt_riscv64.dts └── star64.dts ├── examples ├── blk │ ├── Makefile │ ├── README.md │ ├── basic_data.h │ ├── basic_data.txt │ ├── blk.mk │ ├── build.zig │ ├── build.zig.zon │ ├── client.c │ └── meta.py ├── echo_server │ ├── Makefile │ ├── README.md │ ├── echo.c │ ├── echo.h │ ├── echo.mk │ ├── include │ │ └── lwip │ │ │ ├── arch │ │ │ └── cc.h │ │ │ └── lwipopts.h │ ├── meta.py │ ├── tcp_echo_socket.c │ ├── udp_echo_socket.c │ └── utilization_socket.c ├── gpu │ ├── Makefile │ ├── README.md │ ├── board │ │ └── qemu_virt_aarch64 │ │ │ └── gpu.system │ ├── build.zig │ ├── build.zig.zon │ ├── client.c │ ├── fb_img.S │ ├── fb_img.jpeg │ ├── gpu.mk │ └── include │ │ └── gpu_config.h ├── i2c │ ├── Makefile │ ├── README.md │ ├── build.zig │ ├── build.zig.zon │ ├── client_ds3231.c │ ├── client_pn532.c │ ├── i2c.mk │ └── meta.py ├── serial │ ├── Makefile │ ├── README.md │ ├── build.zig │ ├── build.zig.zon │ ├── client.c │ ├── meta.py │ └── serial.mk └── timer │ ├── Makefile │ ├── README.md │ ├── build.zig │ ├── build.zig.zon │ ├── client.c │ ├── meta.py │ └── timer.mk ├── flake.lock ├── flake.nix ├── gpu └── components │ ├── gpu_components.mk │ └── virt.c ├── i2c ├── components │ ├── i2c_virt.mk │ └── virt.c └── devices │ ├── ds3231 │ ├── README.md │ ├── ds3231.c │ └── ds3231.mk │ └── pn532 │ ├── README.md │ ├── pn532.c │ └── pn532.mk ├── include ├── extern │ └── os │ │ └── sddf.h ├── microkit │ └── os │ │ └── sddf.h └── sddf │ ├── benchmark │ ├── bench.h │ ├── config.h │ └── sel4bench.h │ ├── blk │ ├── config.h │ ├── queue.h │ └── storage_info.h │ ├── gpu │ ├── events.h │ ├── gpu.h │ └── queue.h │ ├── i2c │ ├── client.h │ ├── config.h │ ├── devices │ │ ├── ds3231 │ │ │ └── ds3231.h │ │ └── pn532 │ │ │ └── pn532.h │ └── queue.h │ ├── network │ ├── arp.h │ ├── config.h │ ├── constants.h │ ├── lib_sddf_lwip.h │ ├── queue.h │ └── util.h │ ├── resources │ ├── common.h │ └── device.h │ ├── serial │ ├── config.h │ └── queue.h │ ├── sound │ ├── queue.h │ └── sound.h │ ├── timer │ ├── client.h │ ├── config.h │ └── protocol.h │ ├── util │ ├── bitarray.h │ ├── cache.h │ ├── fence.h │ ├── fsmalloc.h │ ├── ialloc.h │ ├── printf.h │ ├── string.h │ ├── udivmodti4.h │ └── util.h │ └── virtio │ ├── virtio.h │ └── virtio_queue.h ├── libco ├── LICENSE.txt ├── aarch64.c ├── amd64.c ├── arm.c ├── libco.c ├── libco.h ├── libco.mk └── settings.h ├── network ├── README.md ├── components │ ├── arp.c │ ├── copy.c │ ├── network_components.mk │ ├── virt_rx.c │ └── virt_tx.c ├── ipstacks │ └── lwip │ │ ├── CHANGELOG │ │ ├── CMakeLists.txt │ │ ├── COPYING │ │ ├── FEATURES │ │ ├── FILES │ │ ├── README │ │ ├── UPGRADING │ │ ├── doc │ │ ├── FILES │ │ ├── NO_SYS_SampleCode.c │ │ ├── ZeroCopyRx.c │ │ ├── contrib.txt │ │ ├── doxygen │ │ │ ├── generate.bat │ │ │ ├── generate.sh │ │ │ ├── lwip.Doxyfile │ │ │ ├── lwip.Doxyfile.cmake.in │ │ │ ├── main_page.h │ │ │ └── output │ │ │ │ └── index.html │ │ ├── mdns.txt │ │ ├── mqtt_client.txt │ │ ├── ppp.txt │ │ └── savannah.txt │ │ ├── src │ │ ├── FILES │ │ ├── Filelists.cmake │ │ ├── Filelists.mk │ │ ├── api │ │ │ ├── api_lib.c │ │ │ ├── api_msg.c │ │ │ ├── err.c │ │ │ ├── if_api.c │ │ │ ├── netbuf.c │ │ │ ├── netdb.c │ │ │ ├── netifapi.c │ │ │ ├── sockets.c │ │ │ └── tcpip.c │ │ ├── apps │ │ │ ├── altcp_tls │ │ │ │ ├── altcp_tls_mbedtls.c │ │ │ │ ├── altcp_tls_mbedtls_mem.c │ │ │ │ ├── altcp_tls_mbedtls_mem.h │ │ │ │ └── altcp_tls_mbedtls_structs.h │ │ │ ├── http │ │ │ │ ├── altcp_proxyconnect.c │ │ │ │ ├── fs.c │ │ │ │ ├── fs │ │ │ │ │ ├── 404.html │ │ │ │ │ ├── img │ │ │ │ │ │ └── sics.gif │ │ │ │ │ └── index.html │ │ │ │ ├── fsdata.c │ │ │ │ ├── fsdata.h │ │ │ │ ├── http_client.c │ │ │ │ ├── httpd.c │ │ │ │ ├── httpd_structs.h │ │ │ │ └── makefsdata │ │ │ │ │ ├── makefsdata │ │ │ │ │ ├── makefsdata.c │ │ │ │ │ ├── readme.txt │ │ │ │ │ └── tinydir.h │ │ │ ├── lwiperf │ │ │ │ └── lwiperf.c │ │ │ ├── mdns │ │ │ │ └── mdns.c │ │ │ ├── mqtt │ │ │ │ └── mqtt.c │ │ │ ├── netbiosns │ │ │ │ └── netbiosns.c │ │ │ ├── smtp │ │ │ │ └── smtp.c │ │ │ ├── snmp │ │ │ │ ├── snmp_asn1.c │ │ │ │ ├── snmp_asn1.h │ │ │ │ ├── snmp_core.c │ │ │ │ ├── snmp_core_priv.h │ │ │ │ ├── snmp_mib2.c │ │ │ │ ├── snmp_mib2_icmp.c │ │ │ │ ├── snmp_mib2_interfaces.c │ │ │ │ ├── snmp_mib2_ip.c │ │ │ │ ├── snmp_mib2_snmp.c │ │ │ │ ├── snmp_mib2_system.c │ │ │ │ ├── snmp_mib2_tcp.c │ │ │ │ ├── snmp_mib2_udp.c │ │ │ │ ├── snmp_msg.c │ │ │ │ ├── snmp_msg.h │ │ │ │ ├── snmp_netconn.c │ │ │ │ ├── snmp_pbuf_stream.c │ │ │ │ ├── snmp_pbuf_stream.h │ │ │ │ ├── snmp_raw.c │ │ │ │ ├── snmp_scalar.c │ │ │ │ ├── snmp_snmpv2_framework.c │ │ │ │ ├── snmp_snmpv2_usm.c │ │ │ │ ├── snmp_table.c │ │ │ │ ├── snmp_threadsync.c │ │ │ │ ├── snmp_traps.c │ │ │ │ ├── snmpv3.c │ │ │ │ ├── snmpv3_mbedtls.c │ │ │ │ └── snmpv3_priv.h │ │ │ ├── sntp │ │ │ │ └── sntp.c │ │ │ └── tftp │ │ │ │ └── tftp_server.c │ │ ├── core │ │ │ ├── altcp.c │ │ │ ├── altcp_alloc.c │ │ │ ├── altcp_tcp.c │ │ │ ├── def.c │ │ │ ├── dns.c │ │ │ ├── inet_chksum.c │ │ │ ├── init.c │ │ │ ├── ip.c │ │ │ ├── ipv4 │ │ │ │ ├── autoip.c │ │ │ │ ├── dhcp.c │ │ │ │ ├── etharp.c │ │ │ │ ├── icmp.c │ │ │ │ ├── igmp.c │ │ │ │ ├── ip4.c │ │ │ │ ├── ip4_addr.c │ │ │ │ └── ip4_frag.c │ │ │ ├── ipv6 │ │ │ │ ├── dhcp6.c │ │ │ │ ├── ethip6.c │ │ │ │ ├── icmp6.c │ │ │ │ ├── inet6.c │ │ │ │ ├── ip6.c │ │ │ │ ├── ip6_addr.c │ │ │ │ ├── ip6_frag.c │ │ │ │ ├── mld6.c │ │ │ │ └── nd6.c │ │ │ ├── mem.c │ │ │ ├── memp.c │ │ │ ├── netif.c │ │ │ ├── pbuf.c │ │ │ ├── raw.c │ │ │ ├── stats.c │ │ │ ├── sys.c │ │ │ ├── tcp.c │ │ │ ├── tcp_in.c │ │ │ ├── tcp_out.c │ │ │ ├── timeouts.c │ │ │ └── udp.c │ │ ├── include │ │ │ ├── compat │ │ │ │ ├── posix │ │ │ │ │ ├── arpa │ │ │ │ │ │ └── inet.h │ │ │ │ │ ├── net │ │ │ │ │ │ └── if.h │ │ │ │ │ ├── netdb.h │ │ │ │ │ └── sys │ │ │ │ │ │ └── socket.h │ │ │ │ └── stdc │ │ │ │ │ └── errno.h │ │ │ ├── lwip │ │ │ │ ├── altcp.h │ │ │ │ ├── altcp_tcp.h │ │ │ │ ├── altcp_tls.h │ │ │ │ ├── api.h │ │ │ │ ├── apps │ │ │ │ │ ├── FILES │ │ │ │ │ ├── altcp_proxyconnect.h │ │ │ │ │ ├── altcp_tls_mbedtls_opts.h │ │ │ │ │ ├── fs.h │ │ │ │ │ ├── http_client.h │ │ │ │ │ ├── httpd.h │ │ │ │ │ ├── httpd_opts.h │ │ │ │ │ ├── lwiperf.h │ │ │ │ │ ├── mdns.h │ │ │ │ │ ├── mdns_opts.h │ │ │ │ │ ├── mdns_priv.h │ │ │ │ │ ├── mqtt.h │ │ │ │ │ ├── mqtt_opts.h │ │ │ │ │ ├── mqtt_priv.h │ │ │ │ │ ├── netbiosns.h │ │ │ │ │ ├── netbiosns_opts.h │ │ │ │ │ ├── smtp.h │ │ │ │ │ ├── smtp_opts.h │ │ │ │ │ ├── snmp.h │ │ │ │ │ ├── snmp_core.h │ │ │ │ │ ├── snmp_mib2.h │ │ │ │ │ ├── snmp_opts.h │ │ │ │ │ ├── snmp_scalar.h │ │ │ │ │ ├── snmp_snmpv2_framework.h │ │ │ │ │ ├── snmp_snmpv2_usm.h │ │ │ │ │ ├── snmp_table.h │ │ │ │ │ ├── snmp_threadsync.h │ │ │ │ │ ├── snmpv3.h │ │ │ │ │ ├── sntp.h │ │ │ │ │ ├── sntp_opts.h │ │ │ │ │ ├── tftp_opts.h │ │ │ │ │ └── tftp_server.h │ │ │ │ ├── arch.h │ │ │ │ ├── autoip.h │ │ │ │ ├── debug.h │ │ │ │ ├── def.h │ │ │ │ ├── dhcp.h │ │ │ │ ├── dhcp6.h │ │ │ │ ├── dns.h │ │ │ │ ├── err.h │ │ │ │ ├── errno.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethip6.h │ │ │ │ ├── icmp.h │ │ │ │ ├── icmp6.h │ │ │ │ ├── if_api.h │ │ │ │ ├── igmp.h │ │ │ │ ├── inet.h │ │ │ │ ├── inet_chksum.h │ │ │ │ ├── init.h │ │ │ │ ├── init.h.cmake.in │ │ │ │ ├── ip.h │ │ │ │ ├── ip4.h │ │ │ │ ├── ip4_addr.h │ │ │ │ ├── ip4_frag.h │ │ │ │ ├── ip6.h │ │ │ │ ├── ip6_addr.h │ │ │ │ ├── ip6_frag.h │ │ │ │ ├── ip6_zone.h │ │ │ │ ├── ip_addr.h │ │ │ │ ├── mem.h │ │ │ │ ├── memp.h │ │ │ │ ├── mld6.h │ │ │ │ ├── nd6.h │ │ │ │ ├── netbuf.h │ │ │ │ ├── netdb.h │ │ │ │ ├── netif.h │ │ │ │ ├── netifapi.h │ │ │ │ ├── opt.h │ │ │ │ ├── pbuf.h │ │ │ │ ├── priv │ │ │ │ │ ├── altcp_priv.h │ │ │ │ │ ├── api_msg.h │ │ │ │ │ ├── mem_priv.h │ │ │ │ │ ├── memp_priv.h │ │ │ │ │ ├── memp_std.h │ │ │ │ │ ├── nd6_priv.h │ │ │ │ │ ├── raw_priv.h │ │ │ │ │ ├── sockets_priv.h │ │ │ │ │ ├── tcp_priv.h │ │ │ │ │ └── tcpip_priv.h │ │ │ │ ├── prot │ │ │ │ │ ├── autoip.h │ │ │ │ │ ├── dhcp.h │ │ │ │ │ ├── dhcp6.h │ │ │ │ │ ├── dns.h │ │ │ │ │ ├── etharp.h │ │ │ │ │ ├── ethernet.h │ │ │ │ │ ├── iana.h │ │ │ │ │ ├── icmp.h │ │ │ │ │ ├── icmp6.h │ │ │ │ │ ├── ieee.h │ │ │ │ │ ├── igmp.h │ │ │ │ │ ├── ip.h │ │ │ │ │ ├── ip4.h │ │ │ │ │ ├── ip6.h │ │ │ │ │ ├── mld6.h │ │ │ │ │ ├── nd6.h │ │ │ │ │ ├── tcp.h │ │ │ │ │ └── udp.h │ │ │ │ ├── raw.h │ │ │ │ ├── sio.h │ │ │ │ ├── snmp.h │ │ │ │ ├── sockets.h │ │ │ │ ├── stats.h │ │ │ │ ├── sys.h │ │ │ │ ├── tcp.h │ │ │ │ ├── tcpbase.h │ │ │ │ ├── tcpip.h │ │ │ │ ├── timeouts.h │ │ │ │ └── udp.h │ │ │ └── netif │ │ │ │ ├── bridgeif.h │ │ │ │ ├── bridgeif_opts.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethernet.h │ │ │ │ ├── ieee802154.h │ │ │ │ ├── lowpan6.h │ │ │ │ ├── lowpan6_ble.h │ │ │ │ ├── lowpan6_common.h │ │ │ │ ├── lowpan6_opts.h │ │ │ │ ├── ppp │ │ │ │ ├── ccp.h │ │ │ │ ├── chap-md5.h │ │ │ │ ├── chap-new.h │ │ │ │ ├── chap_ms.h │ │ │ │ ├── eap.h │ │ │ │ ├── ecp.h │ │ │ │ ├── eui64.h │ │ │ │ ├── fsm.h │ │ │ │ ├── ipcp.h │ │ │ │ ├── ipv6cp.h │ │ │ │ ├── lcp.h │ │ │ │ ├── magic.h │ │ │ │ ├── mppe.h │ │ │ │ ├── polarssl │ │ │ │ │ ├── arc4.h │ │ │ │ │ ├── des.h │ │ │ │ │ ├── md4.h │ │ │ │ │ ├── md5.h │ │ │ │ │ └── sha1.h │ │ │ │ ├── ppp.h │ │ │ │ ├── ppp_impl.h │ │ │ │ ├── ppp_opts.h │ │ │ │ ├── pppapi.h │ │ │ │ ├── pppcrypt.h │ │ │ │ ├── pppdebug.h │ │ │ │ ├── pppoe.h │ │ │ │ ├── pppol2tp.h │ │ │ │ ├── pppos.h │ │ │ │ ├── upap.h │ │ │ │ └── vj.h │ │ │ │ ├── slipif.h │ │ │ │ └── zepif.h │ │ └── netif │ │ │ ├── FILES │ │ │ ├── bridgeif.c │ │ │ ├── bridgeif_fdb.c │ │ │ ├── ethernet.c │ │ │ ├── lowpan6.c │ │ │ ├── lowpan6_ble.c │ │ │ ├── lowpan6_common.c │ │ │ ├── ppp │ │ │ ├── PPPD_FOLLOWUP │ │ │ ├── auth.c │ │ │ ├── ccp.c │ │ │ ├── chap-md5.c │ │ │ ├── chap-new.c │ │ │ ├── chap_ms.c │ │ │ ├── demand.c │ │ │ ├── eap.c │ │ │ ├── ecp.c │ │ │ ├── eui64.c │ │ │ ├── fsm.c │ │ │ ├── ipcp.c │ │ │ ├── ipv6cp.c │ │ │ ├── lcp.c │ │ │ ├── magic.c │ │ │ ├── mppe.c │ │ │ ├── multilink.c │ │ │ ├── polarssl │ │ │ │ ├── README │ │ │ │ ├── arc4.c │ │ │ │ ├── des.c │ │ │ │ ├── md4.c │ │ │ │ ├── md5.c │ │ │ │ └── sha1.c │ │ │ ├── ppp.c │ │ │ ├── pppapi.c │ │ │ ├── pppcrypt.c │ │ │ ├── pppoe.c │ │ │ ├── pppol2tp.c │ │ │ ├── pppos.c │ │ │ ├── upap.c │ │ │ ├── utils.c │ │ │ └── vj.c │ │ │ ├── slipif.c │ │ │ └── zepif.c │ │ └── test │ │ ├── fuzz │ │ ├── Makefile │ │ ├── README │ │ ├── config.h │ │ ├── fuzz.c │ │ ├── inputs │ │ │ ├── arp │ │ │ │ └── arp_req.bin │ │ │ ├── icmp │ │ │ │ └── icmp_ping.bin │ │ │ ├── ipv6 │ │ │ │ ├── neighbor_solicitation.bin │ │ │ │ └── router_adv.bin │ │ │ ├── tcp │ │ │ │ └── tcp_syn.bin │ │ │ └── udp │ │ │ │ └── udp_port_5000.bin │ │ ├── lwipopts.h │ │ └── output_to_pcap.sh │ │ ├── sockets │ │ ├── sockets_stresstest.c │ │ └── sockets_stresstest.h │ │ └── unit │ │ ├── Filelists.cmake │ │ ├── Filelists.mk │ │ ├── api │ │ ├── test_sockets.c │ │ └── test_sockets.h │ │ ├── arch │ │ ├── sys_arch.c │ │ └── sys_arch.h │ │ ├── core │ │ ├── test_def.c │ │ ├── test_def.h │ │ ├── test_mem.c │ │ ├── test_mem.h │ │ ├── test_netif.c │ │ ├── test_netif.h │ │ ├── test_pbuf.c │ │ ├── test_pbuf.h │ │ ├── test_timers.c │ │ └── test_timers.h │ │ ├── dhcp │ │ ├── test_dhcp.c │ │ └── test_dhcp.h │ │ ├── etharp │ │ ├── test_etharp.c │ │ └── test_etharp.h │ │ ├── ip4 │ │ ├── test_ip4.c │ │ └── test_ip4.h │ │ ├── ip6 │ │ ├── test_ip6.c │ │ └── test_ip6.h │ │ ├── lwip_check.h │ │ ├── lwip_unittests.c │ │ ├── lwipopts.h │ │ ├── mdns │ │ ├── test_mdns.c │ │ └── test_mdns.h │ │ ├── mqtt │ │ ├── test_mqtt.c │ │ └── test_mqtt.h │ │ ├── tcp │ │ ├── tcp_helper.c │ │ ├── tcp_helper.h │ │ ├── test_tcp.c │ │ ├── test_tcp.h │ │ ├── test_tcp_oos.c │ │ └── test_tcp_oos.h │ │ └── udp │ │ ├── test_udp.c │ │ └── test_udp.h └── lib_sddf_lwip │ ├── lib_sddf_lwip.c │ └── lib_sddf_lwip.mk ├── serial └── components │ ├── serial_components.mk │ ├── virt_rx.c │ └── virt_tx.c ├── sound └── components │ ├── sound_components.mk │ └── virt.c ├── tools └── mkvirtdisk └── util ├── assert.c ├── bitarray.c ├── cache.c ├── fsmalloc.c ├── newlibc.c ├── printf.c ├── putchar_debug.c ├── putchar_serial.c └── util.mk /.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright 2024, UNSW 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | Language: Cpp 6 | ColumnLimit: 120 7 | IndentWidth: 4 8 | UseTab: Never 9 | 10 | ReflowComments: false 11 | SortIncludes: Never 12 | PointerAlignment: Right 13 | AlignTrailingComments: 14 | Kind: Leave 15 | # function() \n{} vs function() {} 16 | BreakBeforeBraces: Linux 17 | # we prefer expanded 18 | AllowShortFunctionsOnASingleLine: None 19 | # while(true); vs while(true)\n; 20 | AllowShortLoopsOnASingleLine: true 21 | AllowShortBlocksOnASingleLine: Empty 22 | # (struct xxx) {} vs (struct xxx){} 23 | SpaceBeforeCpp11BracedList: true 24 | # { 1, 2, 3 } (false) vs {1, 2, 3} (true). 25 | Cpp11BracedListStyle: false 26 | # don't do anything to macros 27 | SkipMacroDefinitionBody: true 28 | # break before + etc 29 | BreakBeforeBinaryOperators: NonAssignment 30 | # align operands with the = sign. 31 | AlignOperands: AlignAfterOperator 32 | # try not to break around = 33 | PenaltyBreakAssignment: 50 34 | 35 | --- 36 | Language: Json 37 | IndentWidth: 4 38 | -------------------------------------------------------------------------------- /.github/workflows/pr.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024, UNSW 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # Actions to *only* run on GitHub pull requests 6 | 7 | name: PR 8 | 9 | on: [pull_request] 10 | 11 | jobs: 12 | whitespace: 13 | name: 'Trailing Whitespace' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: seL4/ci-actions/git-diff-check@master 17 | 18 | style: 19 | name: Style 20 | runs-on: ubuntu-24.04 21 | steps: 22 | - name: Checkout repository 23 | run: | 24 | curl https://raw.githubusercontent.com/seL4/ci-actions/master/scripts/checkout.sh | bash 25 | curl https://raw.githubusercontent.com/seL4/ci-actions/master/scripts/fetch-base.sh | bash 26 | # This creates a "test-revision" rev in the git repo. 27 | # Print this out for visibility. 28 | git rev-parse test-revision 29 | 30 | - name: Ensure clang-format-18 31 | run: | 32 | clang-format-18 --version 33 | 34 | - name: Check formatting 35 | run: | 36 | git clang-format-18 --diff ${GITHUB_BASE_REF} test-revision --verbose 37 | -------------------------------------------------------------------------------- /.github/workflows/push.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024, UNSW 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # Actions to run on Push and Pull Request 6 | name: CI 7 | 8 | on: 9 | push: 10 | branches: 11 | - main 12 | pull_request: 13 | 14 | jobs: 15 | check: 16 | name: License Check 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: seL4/ci-actions/license-check@master 20 | 21 | -------------------------------------------------------------------------------- /.github/workflows/setup_ssh_key.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | set -e 6 | 7 | mkdir -p ~/.ssh 8 | 9 | cat >> ~/.ssh/known_hosts <<\EOF 10 | login.trustworthy.systems ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBD111xPT6mKt1s+wJvXIGwUXaebbM/B1GE7ztMUgKBqySbO/5AXXFUr/xflvSluH3lYG5tTpGwPYbJyHOmnJGLY= 11 | login.trustworthy.systems ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCYZpsSbQVXO1FUK/OLYsHZm8nceROnrb/pOPoZOJjeOesE5JtL0g2c8AXWp8mEJ/8eWCUXD/iVDQs2FN9MGanh1ZgzmU6OyyE050W31owcMEX8pK8PVsHKZCal2YFKBzh5gbTKmFw7cNweXRdu49V9M8K8rc5We3TGU8NVx6c6UTOtZ/jg47t0GNukt7EKeMKlJKjxnaE32ECYhSYAmJ0u1tZQFIYP4Cz8vXcBdujdo2+7OMs5tBDhGFufITg6OQDgBFLEgRmKZCLV+17Qxop/Cp4S/BmGPpid4PfRDpTW9ccYdiuymjmoJpXY6QB+bH++gnQhxOpdfM8vKjJDxsOyUNqh0H20uIn/er6gGIdbLqS1nI/DtmGmbSfRVXBuNKxQMxcBh45MEYxrQp51p9kW/eN5/2YdFYDNSw7/fagfiwmjcKUvsiySeRXZzGu5fRHqZktKXGCFeuA6O4uXx/kqshLdGJ6X0d1Kl4v02S7Jh0pcA8i146/1he1+D4FLpb8= 12 | login.trustworthy.systems ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINn1vg1dwyMuDFVWdUqoIRmOHv9FdbCZ4q+0zDY/xTJN 13 | login.trustworthy.systems ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDSzWm9H9EKxcinJs8qwBP3U89DBAB+aO+0zb30gynjdnTKpoCMh58LFxzWWs3bM6liNQKj2FJ7Bpog1N7qExxB3dwo34xQ1Nt4YYSE8TIgfjHGmcvo81F8mElNJYH8d7r1iFsVQcjrnhUzapMyeSIL5UtAVHcJmxKNLjgUOeP6YrAE8q6e0Ods1dLS0p3K4IA1LMz57gTdeZfld3GJ/LPg/6D7LEcxkPX+KG15Y7J/zc1uE0GuPFfLYY16rCcbY0ezhqqqgCig/PIQPqc12g6m+n2WkSjMDv6XycyedoCORKySfOCCBkmI8BkTmoO7Nlm/tQ8UbGDH+6o5CiP5WjEDvbf6Gm9gBANemfxP6Nkyhf+0HrBTXSKjSYVXe99q6YZOG2TvUiDsR8Y7cdWDukbge2AdSy7aRRGPnKPWk2HkFBXahpHQm/wFft/1DZaurX/Vee2GlsFXCGkog0vWi2COvWcGFTIMPwcSyuoLTc5exoy5zF3tcDsPWagkLSxBxbU= 14 | login.trustworthy.systems ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCRA/W8LVxLFjzPvijygdSw+rPW/EQEG8WoUVcTm5dYXDIhCc0Zxibd19zPb1LQpE2/Ohe+I16iC5glpmFyDfrs= 15 | login.trustworthy.systems ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPYp/3vDMDnHnjtqt5Oqievgz04g/LJ4yEKOlXCu9Yux 16 | tftp.keg.cse.unsw.edu.au ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEj7X6doSoop91gTvBD7L4O7VGwCO5pLNsu5YAGS1L64MJqo+3wTYgFRdMWTM0hL3YN+1sSabJPICJzKk0EJxkg= 17 | EOF 18 | 19 | cat >> ~/.ssh/config < ~/.ssh/id_ed25519 37 | chmod 600 ~/.ssh/id_ed25519 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2024, UNSW 2 | # SPDX-License-Identifier: BSD-2-Clause 3 | 4 | build/ 5 | *.o 6 | *.elf 7 | *.depend 8 | .DS_Store 9 | .vscode 10 | *.P 11 | *.d 12 | ci_build/ 13 | ci_logs/ 14 | *.orig 15 | *~ 16 | .#* 17 | zig-out/ 18 | .zig-cache/ 19 | venv/ 20 | __pycache__ 21 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: seL4 Device Driver Framework 3 | Source: https://github.com/au-ts/sddf 4 | 5 | Files: 6 | flake.lock 7 | CHANGES.md 8 | build.zig.zon 9 | examples/i2c/build.zig.zon 10 | examples/serial/build.zig.zon 11 | examples/timer/build.zig.zon 12 | examples/blk/build.zig.zon 13 | examples/blk/basic_data.txt 14 | examples/blk/basic_data.h 15 | examples/gpu/build.zig.zon 16 | drivers/blk/mmc/imx/config.json 17 | drivers/blk/virtio/config.json 18 | drivers/i2c/meson/config.json 19 | drivers/network/imx/config.json 20 | drivers/network/meson/config.json 21 | drivers/network/virtio/config.json 22 | drivers/network/dwmac-5.10a/config.json 23 | drivers/serial/arm/config.json 24 | drivers/serial/imx/config.json 25 | drivers/serial/meson/config.json 26 | drivers/serial/ns16550a/config.json 27 | drivers/serial/virtio/config.json 28 | drivers/timer/arm/config.json 29 | drivers/timer/imx/config.json 30 | drivers/timer/jh7110/config.json 31 | drivers/timer/meson/config.json 32 | drivers/timer/goldfish/config.json 33 | Copyright: UNSW 34 | License: BSD-2-Clause 35 | 36 | Files: 37 | examples/gpu/fb_img.jpeg 38 | Copyright: UNSW 39 | License: CC-BY-SA-4.0 40 | 41 | Files: libco/* 42 | Copyright: byuu and the higan team 43 | License: ISC 44 | 45 | Files: network/ipstacks/lwip/* 46 | Copyright: Copyright (c) 2001-2004 Swedish Institute of Computer Science 47 | License: LicenseRef-BSD-LWIP 48 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # License 7 | 8 | The files in the seL4 Device Driver Framework project are released under standard 9 | open source licenses, identified by [SPDX license tags][1]. See the individual file 10 | headers for details, or use one of the publicly available SPDX tools to generate a bill 11 | of materials. The directory [`LICENSES`][2] contains the text for all licenses 12 | that are mentioned by files in this project. 13 | 14 | Code contributions to this project should be licensed under the [BSD-2-Clause] 15 | license, and documentation under the [CC-BY-SA-4.0] license. 16 | 17 | [1]: https://spdx.org 18 | [2]: LICENSES/ 19 | [BSD-2-CLAUSE]: LICENSES/BSD-2-Clause.txt 20 | [CC-BY-SA-4.0]: LICENSES/CC-BY-SA-4.0.txt 21 | -------------------------------------------------------------------------------- /LICENSES/BSD-2-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /LICENSES/BSD-3-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /LICENSES/ISC.txt: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /LICENSES/LicenseRef-BSD-LWIP.txt: -------------------------------------------------------------------------------- 1 | lwIP is licenced under the BSD license: 2 | 3 | Copyright (c) 2001-2004 Swedish Institute of Computer Science. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 3. The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 22 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 26 | OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | Copyright 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /benchmark/benchmark.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the benchmark.elf and idle.elf programs. 8 | # 9 | BENCH_OBJS := benchmark/benchmark.o 10 | IDLE_OBJS := benchmark/idle.o 11 | LIBUTIL_DBG := libsddf_util_debug.a 12 | LIBUTIL := libsddf_util.a 13 | 14 | ${BENCH_OBJS} ${IDLE_OBJS}: ${CHECK_FLAGS_BOARD_MD5} |benchmark 15 | benchmark: 16 | mkdir -p benchmark 17 | 18 | benchmark.elf: $(BENCH_OBJS) ${LIBUTIL} 19 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 20 | 21 | idle.elf: $(IDLE_OBJS) ${LIBUTIL_DBG} 22 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 23 | -------------------------------------------------------------------------------- /benchmark/idle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define MAGIC_CYCLES 150 16 | 17 | __attribute__((__section__(".benchmark_config"))) benchmark_idle_config_t config; 18 | 19 | struct bench *b; 20 | 21 | void count_idle(void) 22 | { 23 | #if defined(MICROKIT_CONFIG_benchmark) && defined(CONFIG_ARCH_ARM) 24 | uint64_t val; 25 | SEL4BENCH_READ_CCNT(val); 26 | b->prev = val; 27 | b->ccount = 0; 28 | 29 | while (1) { 30 | SEL4BENCH_READ_CCNT(val); 31 | __atomic_store_n(&b->ts, val, __ATOMIC_RELAXED); 32 | uint64_t diff = b->ts - b->prev; 33 | 34 | if (diff < MAGIC_CYCLES) { 35 | __atomic_store_n(&b->ccount, __atomic_load_n(&b->ccount, __ATOMIC_RELAXED) + diff, __ATOMIC_RELAXED); 36 | } 37 | 38 | b->prev = b->ts; 39 | } 40 | #endif 41 | } 42 | 43 | void notified(microkit_channel ch) 44 | { 45 | if (ch == config.init_channel) { 46 | count_idle(); 47 | } else { 48 | sddf_dprintf("Idle thread notified on unexpected channel: %u\n", ch); 49 | } 50 | } 51 | 52 | void init(void) 53 | { 54 | b = (void *)config.cycle_counters; 55 | return; 56 | } 57 | -------------------------------------------------------------------------------- /blk/components/blk_components.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # This Makefile snippet builds the blk virtualiser 7 | # it should be included into your project Makefile 8 | # 9 | # NOTES: 10 | # Generates blk_virt.elf 11 | # 12 | 13 | 14 | BLK_IMAGES := blk_virt.elf 15 | 16 | CFLAGS_blk ?= 17 | 18 | CHECK_BLK_FLAGS_MD5:=.blk_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_blk} | shasum | sed 's/ *-//') 19 | 20 | ${CHECK_BLK_FLAGS_MD5}: 21 | -rm -f .blk_cflags-* 22 | touch $@ 23 | 24 | 25 | blk_virt.elf: blk_virt.o blk_partitioning.o 26 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 27 | 28 | blk_virt.o: ${CHECK_BLK_FLAGS_MD5} 29 | blk_virt.o: ${SDDF}/blk/components/virt.c 30 | ${CC} ${CFLAGS} -I${SDDF}/blk/components ${CFLAGS_blk} -o $@ -c $< 31 | 32 | blk_partitioning.o: ${CHECK_BLK_FLAGS_MD5} 33 | blk_partitioning.o: ${SDDF}/blk/components/partitioning.c 34 | ${CC} ${CFLAGS} ${CFLAGS_blk} -o $@ -c $< 35 | 36 | clean:: 37 | rm -f blk_virt.[od] blk_partitioning.[od] .blk_cflags-* 38 | 39 | clobber:: 40 | rm -f ${BLK_IMAGES} 41 | 42 | 43 | -include blk_virt.d 44 | -include blk_partitioning.d 45 | -------------------------------------------------------------------------------- /blk/components/gpt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | /** 11 | * GUID Partition Table 12 | * 13 | * https://en.wikipedia.org/wiki/GUID_Partition_Table 14 | * */ 15 | 16 | #define GPT_MAX_PARTITIONS 128 17 | #define GPT_SECTOR_SIZE 512 18 | #define GPT_PARTITION_INFO_CODE 0x1 19 | #define GPT_PARTITION_INFO_MIRROR_CODE 0x2 20 | #define GPT_HEADER_SIGNATURE "EFI PART" 21 | 22 | struct gpt_partition_header { 23 | char signature[8]; 24 | uint32_t revision; 25 | uint32_t header_size; 26 | uint32_t crc32_header; 27 | uint32_t reserved; 28 | uint64_t lba_header; 29 | uint64_t lba_alt_header; 30 | uint64_t block_first; 31 | uint64_t block_last; 32 | uint8_t guid[16]; 33 | uint64_t lba_start; 34 | uint32_t num_entries; 35 | uint32_t entry_size; 36 | uint32_t crc32_entry_array; 37 | } __attribute__((packed)); 38 | 39 | struct gpt_partition_entry { 40 | uint8_t guid_type[16]; 41 | uint8_t guid_unique[16]; 42 | uint64_t lba_start; 43 | uint64_t lba_end; 44 | uint64_t attributes; 45 | char name[72]; 46 | } __attribute__((packed)); 47 | -------------------------------------------------------------------------------- /blk/components/msdos_mbr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | /** 11 | * Master Boot Record with MSDOS partition table. 12 | * 13 | * https://en.wikipedia.org/wiki/Master_boot_record 14 | */ 15 | 16 | #define MSDOS_MBR_SIGNATURE 0xAA55 17 | #define MSDOS_MBR_MAX_PRIMARY_PARTITIONS 4 18 | #define MSDOS_MBR_SECTOR_SIZE 512 19 | 20 | struct msdos_mbr_partition { 21 | uint8_t status; 22 | uint8_t chs_start[3]; 23 | uint8_t type; 24 | uint8_t chs_end[3]; 25 | uint32_t lba_start; 26 | uint32_t sectors; 27 | } __attribute__((packed)); 28 | 29 | struct msdos_mbr { 30 | uint8_t bootstrap[446]; 31 | struct msdos_mbr_partition partitions[MSDOS_MBR_MAX_PRIMARY_PARTITIONS]; 32 | uint16_t signature; 33 | } __attribute__((packed)); 34 | 35 | #define MSDOS_MBR_PARTITION_TYPE_EMPTY 0x00 36 | #define MSDOS_MBR_PARTITION_TYPE_GPT 0xEE 37 | -------------------------------------------------------------------------------- /blk/components/virt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define DRIVER_MAX_NUM_BUFFERS 1024 17 | 18 | extern blk_virt_config_t config; 19 | 20 | /* Uncomment this to enable debug logging */ 21 | // #define DEBUG_BLK_VIRT 22 | 23 | #if defined(DEBUG_BLK_VIRT) 24 | #define LOG_BLK_VIRT(...) do{ sddf_dprintf("BLK_VIRT|INFO: "); sddf_dprintf(__VA_ARGS__); }while(0) 25 | #else 26 | #define LOG_BLK_VIRT(...) do{}while(0) 27 | #endif 28 | #define LOG_BLK_VIRT_ERR(...) do{ sddf_dprintf("BLK_VIRT|ERROR: "); sddf_dprintf(__VA_ARGS__); }while(0) 29 | 30 | extern blk_queue_handle_t drv_h; 31 | extern ialloc_t ialloc; 32 | 33 | /** 34 | * Get the block number for the driver from the client's request information. 35 | * 36 | * @param cli_block_number the block number the client requested 37 | * @param cli_count the number of blocks the client requested 38 | * @param cli_id the client ID number 39 | * @param drv_block_number the address of variable to store the block number in 40 | */ 41 | blk_resp_status_t get_drv_block_number(uint64_t cli_block_number, uint16_t cli_count, int cli_id, 42 | uint64_t *drv_block_number); 43 | 44 | /** 45 | * Initialise the block device partition metadata, either MBR or GPT 46 | * 47 | * This function is intended to be called multiple times until it returns true when 48 | * it has finished all the request/response handling to get the partition metadata. 49 | * The process is as follows: 50 | * 1. Request MBR partition metadata. 51 | * 2. Read MBR partition metadata, see if we are dealing with just MBR or GPT. 52 | * 3. If MBR then we fill client storage info based on partitions, and then we are done. 53 | * 4. If GPT, then we have more requests to send, then validate the partitions, then 54 | * fill the client storage info based on that. 55 | */ 56 | bool virt_partition_init(void); 57 | -------------------------------------------------------------------------------- /build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .sddf, 3 | .version = "0.0.0", 4 | 5 | .paths = .{ 6 | "dts", 7 | "drivers", 8 | "benchmark", 9 | "blk", 10 | "gpu", 11 | "i2c", 12 | "include", 13 | "libco", 14 | "network", 15 | "serial", 16 | "sound", 17 | "util", 18 | "build.zig", 19 | "build.zig.zon", 20 | "LICENSE", 21 | "README.md" 22 | }, 23 | .fingerprint = 0xb250d95cee7aa2e9, 24 | } 25 | -------------------------------------------------------------------------------- /ci/common.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | from pathlib import Path 6 | import sys 7 | 8 | sys.path.insert(1, Path(__file__).parents[1].as_posix()) 9 | 10 | from ci.lib.backends import HardwareBackend, QemuBackend, MachineQueueBackend 11 | from ci.lib.runner import TestConfig 12 | from ci.matrix import MACHINE_QUEUE_BOARDS 13 | 14 | 15 | CI_BUILD_DIR = Path(__file__).parents[1] / "ci_build" 16 | 17 | 18 | def example_build_path(example_name: str, test_config: TestConfig): 19 | return ( 20 | CI_BUILD_DIR 21 | / "examples" 22 | / example_name 23 | / test_config.build_system 24 | / test_config.board 25 | / test_config.config 26 | ) 27 | 28 | 29 | def loader_img_path( 30 | example_name: str, 31 | test_config: TestConfig, 32 | ): 33 | return ( 34 | example_build_path(example_name, test_config) 35 | / ("bin" if test_config.build_system == "zig" else "") 36 | / "loader.img" 37 | ) 38 | 39 | 40 | def backend_fn( 41 | test_config: TestConfig, 42 | loader_img: Path, 43 | ) -> HardwareBackend: 44 | 45 | if test_config.is_qemu(): 46 | QEMU_COMMON_FLAGS = ( 47 | # fmt: off 48 | "-m", "size=2G", 49 | "-serial", "mon:stdio", 50 | "-nographic", 51 | "-d", "guest_errors", 52 | # fmt: on 53 | ) 54 | 55 | if test_config.board == "qemu_virt_riscv64": 56 | return QemuBackend( 57 | "qemu-system-riscv64", 58 | # fmt: off 59 | "-machine", "virt", 60 | "-kernel", str(loader_img.resolve()), 61 | # fmt: on 62 | *QEMU_COMMON_FLAGS, 63 | ) 64 | elif test_config.board == "qemu_virt_aarch64": 65 | return QemuBackend( 66 | "qemu-system-aarch64", 67 | # fmt: off 68 | "-machine", "virt,virtualization=on", 69 | "-cpu", "cortex-a53", 70 | "-device", f"loader,file={loader_img.resolve()},addr=0x70000000,cpu-num=0", 71 | # fmt: on 72 | *QEMU_COMMON_FLAGS, 73 | ) 74 | else: 75 | raise NotImplementedError(f"unknown qemu board {test_config.board}") 76 | 77 | else: 78 | mq_boards: list[str] = MACHINE_QUEUE_BOARDS[test_config.board] 79 | return MachineQueueBackend(loader_img.resolve(), mq_boards) 80 | -------------------------------------------------------------------------------- /ci/examples/blk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | import asyncio 6 | import functools 7 | import subprocess 8 | from pathlib import Path 9 | import sys 10 | import tempfile 11 | 12 | sys.path.insert(1, Path(__file__).parents[2].as_posix()) 13 | 14 | from ci.lib.backends import * 15 | from ci.lib.runner import TestConfig, cli, matrix_product 16 | from ci import common, matrix 17 | 18 | TEST_MATRIX = matrix_product( 19 | board=matrix.EXAMPLES["blk"]["boards_test"], 20 | config=matrix.EXAMPLES["blk"]["configs"], 21 | build_system=matrix.EXAMPLES["blk"]["build_systems"], 22 | ) 23 | 24 | SDDF = Path(__file__).parents[2] 25 | mkvirtdisk = (SDDF / "tools" / "mkvirtdisk").resolve() 26 | 27 | 28 | def backend_fn( 29 | disks_dir: str, test_config: TestConfig, loader_img: Path 30 | ) -> HardwareBackend: 31 | backend = common.backend_fn(test_config, loader_img) 32 | 33 | if isinstance(backend, QemuBackend): 34 | (_, disk_path) = tempfile.mkstemp(dir=disks_dir) 35 | 36 | subprocess.run( 37 | [mkvirtdisk, disk_path, "1", "512", "16777216", "GPT"], 38 | check=True, 39 | capture_output=True, 40 | ) 41 | 42 | # fmt: off 43 | backend.invocation_args.extend([ 44 | "-global", "virtio-mmio.force-legacy=false", 45 | "-drive", "file={},if=none,format=raw,id=hd".format(disk_path), 46 | "-device", "virtio-blk-device,drive=hd", 47 | ]) 48 | # fmt: on 49 | 50 | return backend 51 | 52 | 53 | async def test(backend: HardwareBackend, test_config: TestConfig): 54 | async with asyncio.timeout(10): 55 | await wait_for_output(backend, b"CLIENT|INFO: starting\r\n") 56 | async with asyncio.timeout(10): 57 | await wait_for_output(backend, b"device config ready\r\n") 58 | await wait_for_output(backend, b"basic: STATE_CHECK_READ state\r\n") 59 | await wait_for_output( 60 | backend, b"CLIENT|INFO: basic: successfully finished!\r\n" 61 | ) 62 | 63 | 64 | if __name__ == "__main__": 65 | with tempfile.TemporaryDirectory(suffix="sddf_blk_disks") as qemu_disks_dir: 66 | cli( 67 | "blk", 68 | test, 69 | TEST_MATRIX, 70 | functools.partial(backend_fn, qemu_disks_dir), 71 | common.loader_img_path, 72 | ) 73 | -------------------------------------------------------------------------------- /ci/examples/echo_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | import asyncio 6 | import re 7 | from pathlib import Path 8 | import sys 9 | 10 | sys.path.insert(1, Path(__file__).parents[2].as_posix()) 11 | 12 | from ci.lib.backends import * 13 | from ci.lib.runner import TestConfig, cli, matrix_product 14 | from ci.lib import log 15 | from ci import common, matrix 16 | 17 | TEST_MATRIX = matrix_product( 18 | board=matrix.EXAMPLES["echo_server"]["boards_test"], 19 | config=matrix.EXAMPLES["echo_server"]["configs"], 20 | build_system=matrix.EXAMPLES["echo_server"]["build_systems"], 21 | ) 22 | 23 | 24 | def backend_fn(test_config: TestConfig, loader_img: Path) -> HardwareBackend: 25 | backend = common.backend_fn(test_config, loader_img) 26 | 27 | if isinstance(backend, QemuBackend): 28 | # fmt: off 29 | backend.invocation_args.extend([ 30 | "-global", "virtio-mmio.force-legacy=false", 31 | "-device", "virtio-net-device,netdev=netdev0", 32 | "-netdev", "user,id=netdev0,hostfwd=tcp::1236-:1236,hostfwd=tcp::1237-:1237,hostfwd=udp::1235-:1235", 33 | ]) 34 | # fmt: on 35 | 36 | return backend 37 | 38 | 39 | async def test(backend: HardwareBackend, test_config: TestConfig): 40 | async with asyncio.timeout(20): 41 | await wait_for_output(backend, b"DHCP request finished") 42 | dhcp_client1 = await wait_for_output(backend, b"\r\n") 43 | await wait_for_output(backend, b"DHCP request finished") 44 | dhcp_client0 = await wait_for_output(backend, b"\r\n") 45 | 46 | dhcp_client1, dhcp_client0 = ( 47 | (dhcp_client1, dhcp_client0) 48 | if b"client1" in dhcp_client1 49 | else (dhcp_client0, dhcp_client1) 50 | ) 51 | 52 | try: 53 | # fmt: off 54 | ip1 = re.search(rb"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", dhcp_client1).group(0).decode() # type: ignore 55 | ip0 = re.search(rb"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", dhcp_client0).group(0).decode() # type: ignore 56 | # fmt: on 57 | except (IndexError, AttributeError): 58 | raise TestFailureException( 59 | "could not find IP address in DHCP request result" 60 | ) 61 | 62 | reset_terminal() 63 | log.info(f"client IPs: client1={ip1}, client0={ip0}") 64 | 65 | 66 | if __name__ == "__main__": 67 | cli("echo_server", test, TEST_MATRIX, backend_fn, common.loader_img_path) 68 | -------------------------------------------------------------------------------- /ci/examples/i2c.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | import asyncio 6 | from pathlib import Path 7 | import sys 8 | 9 | sys.path.insert(1, Path(__file__).parents[2].as_posix()) 10 | 11 | from ci.lib.backends import * 12 | from ci.lib.runner import TestConfig, cli, matrix_product 13 | from ci import common, matrix 14 | 15 | TEST_MATRIX = matrix_product( 16 | board=matrix.EXAMPLES["i2c"]["boards_test"], 17 | config=matrix.EXAMPLES["i2c"]["configs"], 18 | build_system=matrix.EXAMPLES["i2c"]["build_systems"], 19 | ) 20 | 21 | 22 | def backend_fn(test_config: TestConfig, loader_img: Path) -> HardwareBackend: 23 | backend = common.backend_fn(test_config, loader_img) 24 | 25 | if isinstance(backend, MachineQueueBackend) and test_config.board == "odroidc4": 26 | # Only odroidc4_2 is connected to the I²C tests 27 | backend.boards = ["odroidc4_2"] 28 | 29 | return backend 30 | 31 | 32 | async def test(backend: HardwareBackend, test_config: TestConfig): 33 | async with asyncio.timeout(30): 34 | await wait_for_output( 35 | backend, b"Set Date and Time on DS3231 to: 31-12-23 23:59:42 (Sunday)\r\n" 36 | ) 37 | 38 | # It should take us less than 20 sec before it becomes Monday. 39 | await wait_for_output(backend, b"Date and Time: 01-01-24 00:00:00 (Monday)\r\n") 40 | 41 | 42 | if __name__ == "__main__": 43 | cli("i2c", test, TEST_MATRIX, backend_fn, common.loader_img_path) 44 | -------------------------------------------------------------------------------- /ci/examples/serial.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | import asyncio 6 | from pathlib import Path 7 | import sys 8 | 9 | sys.path.insert(1, Path(__file__).parents[2].as_posix()) 10 | 11 | from ci.lib.backends import * 12 | from ci.lib.runner import TestConfig, cli, matrix_product 13 | from ci import common, matrix 14 | 15 | TEST_MATRIX = matrix_product( 16 | board=matrix.EXAMPLES["serial"]["boards_test"], 17 | config=matrix.EXAMPLES["serial"]["configs"], 18 | build_system=matrix.EXAMPLES["serial"]["build_systems"], 19 | ) 20 | 21 | ANSI_RED = b"\x1b[31m" 22 | ANSI_GREEN = b"\x1b[32m" 23 | ANSI_RESET = b"\x1b[0m" 24 | 25 | def colour_number(num: bytes, colour: bytes) -> bytes: 26 | out = b"" 27 | for c in num: 28 | out += (colour + bytes([c]) + ANSI_RESET) 29 | return out 30 | 31 | 32 | async def test(backend: HardwareBackend, test_config: TestConfig): 33 | # TODO: We really need some kind of colour (de)multiplexer.... 34 | 35 | async with asyncio.timeout(10): 36 | await wait_for_output(backend, b"Begin input\r\n") 37 | await wait_for_output(backend, b"Please give me character!\r\n") 38 | await wait_for_output(backend, b"Please give me character!\r\n") 39 | await wait_for_output(backend, ANSI_RESET) 40 | 41 | await send_input(backend, b"1234567890") 42 | await expect_output(backend, colour_number(b"1234567890", ANSI_RED)) 43 | await wait_for_output(backend, b"client0 has received 10 characters so far!\r\n") 44 | await wait_for_output(backend, ANSI_RESET) 45 | 46 | # Switch to client 1. 47 | await send_input(backend, b"\x1c1\r") 48 | # TODO: ??? 49 | if test_config.config == "debug": 50 | await expect_output(backend, b"VIRT_RX|LOG: switching to client 1\r\n") 51 | 52 | await send_input(backend, b"1234567890") 53 | await expect_output(backend, colour_number(b"1234567890", ANSI_GREEN)) 54 | await wait_for_output(backend, b"client1 has received 10 characters so far!\r\n") 55 | 56 | 57 | if __name__ == "__main__": 58 | cli("serial", test, TEST_MATRIX, common.backend_fn, common.loader_img_path) 59 | -------------------------------------------------------------------------------- /ci/examples/timer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | import asyncio 6 | from pathlib import Path 7 | import sys 8 | 9 | sys.path.insert(1, Path(__file__).parents[2].as_posix()) 10 | 11 | from ci.lib.backends import * 12 | from ci.lib.runner import TestConfig, cli, matrix_product 13 | from ci.lib import log 14 | from ci import common, matrix 15 | 16 | TEST_MATRIX = matrix_product( 17 | board=matrix.EXAMPLES["timer"]["boards_test"], 18 | config=matrix.EXAMPLES["timer"]["configs"], 19 | build_system=matrix.EXAMPLES["timer"]["build_systems"], 20 | ) 21 | 22 | DRIFT_THRESHOLD = 0.05 # 5 percent. 23 | TIME_MEASURE_COUNT = 5 24 | TIME_LENGTH = 1000**3 # 1 second in nanoseconds 25 | 26 | 27 | async def test(backend: HardwareBackend, test_config: TestConfig): 28 | await wait_for_output(backend, b"CLIENT|INFO: starting\r\n") 29 | 30 | async with asyncio.timeout(5 + TIME_MEASURE_COUNT): 31 | await wait_for_output(backend, b"The time now is: ") 32 | await wait_for_output(backend, b"Setting a time out for 1 second\r\n") 33 | 34 | times: list[int] = [] 35 | for _ in range(TIME_MEASURE_COUNT): 36 | await wait_for_output(backend, b"Got a timeout!\r\n") 37 | # "CLIENT|INFO: Now the time (in nanoseconds) is: 1015768000" 38 | line = await wait_for_output(backend, b"\r\n") 39 | assert line.startswith(b"CLIENT|INFO: Now the time (in nanoseconds) is: ") 40 | time = int( 41 | line.replace(b"CLIENT|INFO: Now the time (in nanoseconds) is: ", b"") 42 | ) 43 | times.append(time) 44 | 45 | log.info(f"Times: {times}") 46 | 47 | for i in range(1, len(times)): 48 | delta_ns = times[i] - times[i - 1] 49 | if abs(delta_ns - TIME_LENGTH) > (DRIFT_THRESHOLD * TIME_LENGTH): 50 | raise TestFailureException( 51 | f"time delta between t{i} and t{i-1} of {delta_ns}ns exceeds {DRIFT_THRESHOLD:.0%} threshold" 52 | ) 53 | 54 | log.info(f"Deltas within {DRIFT_THRESHOLD:.0%} threshold") 55 | 56 | 57 | if __name__ == "__main__": 58 | cli("timer", test, TEST_MATRIX, common.backend_fn, common.loader_img_path) 59 | -------------------------------------------------------------------------------- /ci/lib/backends/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | """ 6 | Set of "classes" (in the duck-typing way) that describe how we interact with the 7 | actual system that is running the test. 8 | 9 | In broad strokes, requirements of these backends are: 10 | 11 | - Can collect log outputs (at a line granularity, i.e. streaming) 12 | - Can enter test inputs 13 | - Can kill tests. 14 | """ 15 | 16 | # Setup asyncio.timeout, contextlib.chdir 17 | from . import polyfills 18 | 19 | # Re-Exports 20 | from .base import HardwareBackend 21 | from .common import ( 22 | LockedBoardException, 23 | TestFailureException, 24 | TestRetryException, 25 | reset_terminal, 26 | log_output_to_file, 27 | OUTPUT, 28 | ) 29 | from .streams import send_input, wait_for_output, expect_output 30 | from .machine_queue import MachineQueueBackend 31 | from .qemu import QemuBackend 32 | from .tty import TtyBackend 33 | 34 | __all__ = ( 35 | # .base 36 | "HardwareBackend", 37 | # .common 38 | "LockedBoardException", 39 | "TestFailureException", 40 | "TestRetryException", 41 | "reset_terminal", 42 | "log_output_to_file", 43 | "OUTPUT", 44 | # .streams 45 | "send_input", 46 | "wait_for_output", 47 | "expect_output", 48 | # backends 49 | "MachineQueueBackend", 50 | "QemuBackend", 51 | "TtyBackend", 52 | ) 53 | -------------------------------------------------------------------------------- /ci/lib/backends/base.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | from abc import ABC, abstractmethod 6 | from asyncio import StreamReader, StreamWriter 7 | 8 | 9 | class HardwareBackend(ABC): 10 | @abstractmethod 11 | async def start(self): 12 | """Start the hardware and wait for it to have booted""" 13 | 14 | @abstractmethod 15 | async def stop(self): 16 | """Stop the hardware""" 17 | 18 | @property 19 | @abstractmethod 20 | def output_stream(self) -> StreamReader: ... 21 | 22 | @property 23 | @abstractmethod 24 | def input_stream(self) -> StreamWriter: ... 25 | -------------------------------------------------------------------------------- /ci/lib/backends/common.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | 6 | from contextlib import contextmanager 7 | from dataclasses import dataclass 8 | import io 9 | from pathlib import Path 10 | import sys 11 | from typing import BinaryIO, Union 12 | 13 | 14 | def reset_terminal(): 15 | OUTPUT.write(b"\n\x1b[0m") 16 | 17 | 18 | class TestRetryException(Exception): 19 | """Test needs to be retried""" 20 | 21 | 22 | @dataclass 23 | class LockedBoardException(TestRetryException): 24 | """Board is locked or otherwise unavailable""" 25 | 26 | lock_failures: list[str] 27 | 28 | def __str__(self) -> str: 29 | out = self.__class__.__name__ 30 | for failure in self.lock_failures: 31 | out += f"\n - {failure}" 32 | return out 33 | 34 | 35 | class TestFailureException(Exception): 36 | """Test failed""" 37 | 38 | 39 | class _TeeOut: 40 | def __init__(self, stdout: BinaryIO): 41 | self.stdout = stdout 42 | self.fileio: BinaryIO | None = None 43 | 44 | def write(self, s: Union[bytes, bytearray]): 45 | self.stdout.write(s) 46 | self.stdout.flush() 47 | 48 | if self.fileio: 49 | self.fileio.write(s) 50 | 51 | # fmt: off 52 | def close(self): return self.stdout.close() 53 | def flush(self): ... 54 | def readable(self): return False 55 | def writable(self): return True 56 | def seekable(self): return False 57 | @property 58 | def closed(self): return self.stdout.closed 59 | # fmt: on 60 | 61 | 62 | OUTPUT = _TeeOut(sys.stdout.buffer) 63 | sys.stdout = io.TextIOWrapper(OUTPUT, write_through=True) # type: ignore 64 | 65 | 66 | @contextmanager 67 | def log_output_to_file(log_file: Path): 68 | assert OUTPUT.fileio is None 69 | 70 | with open(log_file, mode="wb", buffering=0) as log: 71 | OUTPUT.fileio = log 72 | 73 | try: 74 | yield 75 | finally: 76 | OUTPUT.fileio = None 77 | -------------------------------------------------------------------------------- /ci/lib/backends/qemu.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | import asyncio 6 | from asyncio.subprocess import STDOUT, PIPE 7 | 8 | from .base import HardwareBackend 9 | 10 | 11 | class QemuBackend(HardwareBackend): 12 | def __init__(self, invocation_exe: str, *invocation_args: str): 13 | self.process = None 14 | self.invocation_exe = invocation_exe 15 | self.invocation_args = list(invocation_args) 16 | 17 | async def start(self): 18 | assert self.process is None, "start() not previously called" 19 | self.process = await asyncio.create_subprocess_exec( 20 | self.invocation_exe, 21 | *self.invocation_args, 22 | stdin=PIPE, 23 | stdout=PIPE, 24 | stderr=STDOUT, 25 | ) 26 | 27 | async def stop(self): 28 | assert self.process is not None, "process not running" 29 | try: 30 | self.process.terminate() 31 | await self.process.wait() 32 | except ProcessLookupError: 33 | pass 34 | 35 | @property 36 | def input_stream(self): 37 | assert self.process is not None, "process not running" 38 | return self.process.stdin 39 | 40 | @property 41 | def output_stream(self): 42 | assert self.process is not None, "process not running" 43 | return self.process.stdout 44 | -------------------------------------------------------------------------------- /ci/lib/backends/tty.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | from .base import HardwareBackend 6 | 7 | 8 | class TtyBackend(HardwareBackend): 9 | def __init__(self, path: str, baudrate=115200): 10 | self.path = path 11 | self.baudrate = baudrate 12 | 13 | self.reader = None 14 | self.writer = None 15 | 16 | try: 17 | import serial_asyncio_fast 18 | except ImportError: 19 | raise ModuleNotFoundError( 20 | "no module 'serial_asyncio_fast; install 'pyserial-asyncio-fast'" 21 | ) 22 | 23 | async def start(self): 24 | assert self.reader is None, "start() not previously called" 25 | 26 | self.reader, self.writer = await serial_asyncio_fast.open_serial_connection( 27 | url=self.path, 28 | baudrate=self.baudrate, 29 | ) 30 | 31 | async def stop(self): 32 | assert self.reader is not None, "tty not connected" 33 | self.writer.close() 34 | 35 | @property 36 | def input_stream(self): 37 | assert self.writer is not None, "tty not connected" 38 | return self.writer 39 | 40 | @property 41 | def output_stream(self): 42 | assert self.reader is not None, "tty not connect" 43 | return self.reader 44 | -------------------------------------------------------------------------------- /ci/lib/log.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2025, UNSW 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | import os 5 | 6 | from .backends import OUTPUT 7 | 8 | # For Github Actions etc. 9 | IS_CI = bool(os.environ.get("CI")) 10 | 11 | 12 | def info(s): 13 | print("CI|INFO: " + s) 14 | 15 | 16 | def error(s): 17 | print("CI|ERROR: " + s) 18 | 19 | 20 | def group_start(s): 21 | if IS_CI: 22 | print(f"::group::{s}") 23 | else: 24 | info(s) 25 | 26 | 27 | def group_end(s): 28 | info(s) 29 | if IS_CI: 30 | print("::endgroup::") 31 | -------------------------------------------------------------------------------- /docs/drivers.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Available drivers 8 | 9 | Below is a list of all the avaiable drivers in sDDF, grouped by 10 | their device class. 11 | 12 | Each driver is listed by the device family it is written for 13 | and a list of Device Tree compatible strings it is known to work with. 14 | 15 | ## Block 16 | 17 | * i.MX8 uSDHC 18 | * `fsl,imx8mq-usdhc` 19 | * virtIO block 20 | * `virtio,mmio` 21 | 22 | ## I2C 23 | 24 | * Meson 25 | * `amlogic,meson-axg-i2c` 26 | 27 | ## Network 28 | 29 | * DWMAC 30 | * `nxp,imx8mp-dwmac-eqos` 31 | * `snps,dwmac-5.10a` 32 | * `snps,dwmac-5.20` 33 | * i.MX8 34 | * `fsl,imx8mq-fec` 35 | * Meson 36 | * `amlogic,meson-gxbb-dwmac` 37 | * `amlogic,meson-g12a-dwmac` 38 | * virtIO network 39 | * `virtio,mmio` 40 | 41 | ## GPU 42 | 43 | * virtIO GPU (2D only) 44 | * `virtio,mmio` 45 | 46 | ## Serial 47 | 48 | * ARM UART 49 | * `arm,pl011` 50 | * i.MX8 UART 51 | * `fsl,imx8mq-uart` 52 | * `fsl,imx8mm-uart` 53 | * `fsl,imx8mp-uart` 54 | * NS16550A 55 | * `starfive,jh7110-uart` 56 | * `ns16550a` 57 | * virtIO console 58 | * `virtio,mmio` 59 | 60 | ## Timer 61 | 62 | * ARM architectural timer 63 | * `arm,armv8-timer` 64 | * Google Goldfish RTC 65 | * `google,goldfish-rtc` 66 | * i.MX8 General Purpose Timer 67 | * `fsl,imx8mm-gpt` 68 | * `fsl,imx8mq-gpt` 69 | * `fsl,imx8mp-gpt` 70 | * Meson 71 | * `amlogic,meson-gxbb-wdt` 72 | * StarFive JH7110 73 | * `starfive,jh7110-timer` 74 | -------------------------------------------------------------------------------- /drivers/blk/mmc/imx/README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # uSDHC iMX8 Driver 7 | 8 | This is a driver for the MaaXBoard SD host controller, based on the following documents: 9 | 10 | - i.MX 8M Dual/8M QuadLite/8M Quad Applications Processors Reference Manual 11 | Document Number: IMX8MDQLQRM, Rev 3.1, 06/2021. 12 | https://www.nxp.com/webapp/Download?colCode=IMX8MDQLQRM 13 | - SD Specifications Part 1 Physical Layer Simplified Specification. 14 | Version 9.10, Dec. 2023. 15 | https://www.sdcard.org/downloads/pls/ 16 | - SD Specifications Part A2 SD Host Controller Simplified Specification. 17 | Version 4.20, July 2018. 18 | https://www.sdcard.org/downloads/pls/ 19 | 20 | ## Implemented 21 | - IRQ & DMA based driver 22 | - Supports Version 2 SD Cards (SDSC, SDHC, SDXC, SDUC) operating at 3.3V 23 | - $f_{OD}$ (400kHz) initialisation, then data transfer at $f_{PP}$ Default Speed (25 MHz) 24 | 25 | ## Not Implemented 26 | - Voltage Negotiation (anything but 3.3V) 27 | - Version 1 SD cards (the initialisation flow) 28 | - Higher speed operations and DDR and more data lanes 29 | - Setting as RO when write protect is set on the SD card 30 | - Clock setup (currently inherits 150MHz clock from U-Boot) 31 | - Pinmux setup (again, inherits from U-Boot) 32 | - Timeouts as required by some SD commands 33 | - Card detection 34 | -------------------------------------------------------------------------------- /drivers/blk/mmc/imx/blk_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build the IMX8 uSDHC driver. 7 | # Assumes libsddf_util_debug.a is in ${LIBS}. 8 | 9 | USDHC_DRIVER_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) 10 | 11 | blk_driver.elf: blk/mmc/imx/blk_driver.o 12 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 13 | 14 | blk/mmc/imx/blk_driver.o: ${USDHC_DRIVER_DIR}/usdhc.c |blk/mmc/imx 15 | $(CC) -c $(CFLAGS) -o $@ $< 16 | 17 | -include blk/mmc/imx/mmc_driver.d 18 | 19 | blk/mmc/imx: 20 | mkdir -p $@ 21 | 22 | clean:: 23 | rm -f blk/mmc/imx/blk_driver.[do] 24 | 25 | clobber:: 26 | rm -rf blk/mmc 27 | -------------------------------------------------------------------------------- /drivers/blk/mmc/imx/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "fsl,imx8mq-usdhc" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 65536, 11 | "dt_index": 0 12 | } 13 | ], 14 | "irqs": [ 15 | { 16 | "dt_index": 0 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /drivers/blk/virtio/blk_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build the virtIO block driver. 7 | # Assumes libsddf_util_debug.a is in ${LIBS}. 8 | 9 | VIRTIO_BLK_DRIVER_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) 10 | 11 | blk_driver.elf: blk/virtio/blk_driver.o 12 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 13 | 14 | blk/virtio/blk_driver.o: ${VIRTIO_BLK_DRIVER_DIR}/block.c |blk/virtio 15 | $(CC) -c $(CFLAGS) -I${VIRTIO_BLK_DRIVER_DIR}/include -o $@ $< 16 | 17 | -include blk_driver.d 18 | 19 | blk/virtio: 20 | mkdir -p $@ 21 | 22 | clean:: 23 | rm -f blk/virtio/blk_driver.[do] 24 | 25 | clobber:: 26 | rm -rf blk 27 | -------------------------------------------------------------------------------- /drivers/blk/virtio/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "virtio,mmio" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | }, 13 | { 14 | "name": "virtio_headers", 15 | "size": 65536 16 | }, 17 | { 18 | "name": "virtio_metadata", 19 | "size": 2097152 20 | } 21 | ], 22 | "irqs": [ 23 | { 24 | "dt_index": 0 25 | } 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /drivers/gpu/virtio/gpu_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the VirtIO driver 8 | # 9 | # NOTES: 10 | # Generates gpu_driver.elf 11 | # Assumes libsddf_util_debug.a is in LIBS 12 | 13 | GPU_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | CFLAGS_gpu ?= -mstrict-align 16 | 17 | CHECK_GPU_DRV_FLAGS_MD5:=.gpu_drv_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_gpu} | shasum | sed 's/ *-//') 18 | 19 | ${CHECK_GPU_DRV_FLAGS_MD5}: 20 | -rm -f .gpu_drv_cflags-* 21 | touch $@ 22 | 23 | gpu_driver.elf: gpu/virtio/gpu_driver.o 24 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 25 | 26 | gpu/virtio/gpu_driver.o: ${GPU_DRIVER_DIR}gpu.c ${CHECK_GPU_DRV_FLAGS_MD5} 27 | mkdir -p gpu/virtio 28 | ${CC} -c ${CFLAGS} ${CFLAGS_gpu} -I ${GPU_DRIVER_DIR} -o $@ $< 29 | 30 | -include virtio/gpu.d 31 | 32 | clean:: 33 | rm -f gpu/virtio/gpu_driver.[do] 34 | clobber:: clean 35 | rm -rf gpu_driver.elf gpu 36 | -------------------------------------------------------------------------------- /drivers/i2c/meson/clk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #ifndef __I2C_CLK_H__ 8 | #define __I2C_CLK_H__ 9 | #define I2C_CLK_OFFSET 320 10 | #define I2C_CLK81_BIT (1 << 9) // bit 9 11 | 12 | #endif -------------------------------------------------------------------------------- /drivers/i2c/meson/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "amlogic,meson-axg-i2c" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | } 13 | ], 14 | "irqs": [ 15 | { 16 | "dt_index": 0 17 | }, 18 | { 19 | "dt_index": 1 20 | } 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /drivers/i2c/meson/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | // gpio.h 8 | // Header for the ODROID C4's GPIO system. This should be replaced by a full 9 | // generic GPIO driver in the sDDF in the future. 10 | // Matt Rossouw (matthew.rossouw@unsw.edu.au) 11 | // 08/2023 12 | #pragma once 13 | 14 | #include 15 | 16 | #define GPIO_OFFSET 1024 17 | 18 | // Pinmux 19 | #define GPIO_PINMUX_5 0xb5 20 | #define GPIO_PM5_X17 BIT(4) | BIT(5) | BIT(6) | BIT(7) 21 | #define GPIO_PM5_X18 BIT(8) | BIT(9) | BIT(10) | BIT(11) 22 | #define GPIO_PM5_X_I2C 1 23 | 24 | #define GPIO_PINMUX_E 0xbe 25 | #define GPIO_PE_A14 BIT(27) | BIT(26) | BIT(25) | BIT(24) 26 | #define GPIO_PE_A15 BIT(31) | BIT(30) | BIT(29) | BIT(28) 27 | #define GPIO_PE_A_I2C 3 28 | 29 | // Drive strengths 30 | #define GPIO_DS_2B 0xd3 // M2 31 | #define GPIO_DS_2B_X17 BIT(3) | BIT(2) 32 | #define GPIO_DS_2B_X18 BIT(1) | BIT(0) // Also used for X19, for some reason 33 | #define GPIO_DS_2B_X17_SHIFT 2 34 | #define GPIO_DS_2B_X18_SHIFT 4 35 | 36 | #define GPIO_DS_5A 0xd4 // M3 37 | #define GPIO_DS_5A_A14 BIT(28) | BIT(29) 38 | #define GPIO_DS_5A_A15 BIT(30) | BIT(31) 39 | #define GPIO_DS_5A_A14_SHIFT 28 40 | #define GPIO_DS_5A_A15_SHIFT 30 41 | 42 | #define DS_3MA 2 43 | 44 | // Bias (pull up/down) 45 | #define GPIO_BIAS_2 0x3c // GPIO bank X 46 | #define GPIO_BIAS_2_EN 0x4a 47 | #define GPIO_BIAS_5 0x3f // GPIO bank A 48 | #define GPIO_BIAS_5_EN 0x4d 49 | -------------------------------------------------------------------------------- /drivers/i2c/meson/i2c_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the Meson i2c driver 8 | # 9 | # NOTES 10 | # Generates i2c_driver.elf 11 | # Requires libsddf_util_debug.a in ${LIBS} 12 | # Has one parameter: I2C_BUS_NUM to select which bus is being driven 13 | 14 | I2C_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 15 | 16 | i2c_driver.elf: i2c/i2c_driver.o 17 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 18 | 19 | i2c/i2c_driver.o: CFLAGS+=-I${I2C_DRIVER_DIR} -DI2C_BUS_NUM=${I2C_BUS_NUM} 20 | i2c/i2c_driver.o: ${I2C_DRIVER_DIR}/i2c.c |i2c 21 | ${CC} ${CFLAGS} -c -o $@ $< 22 | 23 | i2c: 24 | mkdir -p $@ 25 | 26 | clean:: 27 | rm -rf i2c 28 | 29 | clobber:: 30 | rm -f i2c_driver.elf 31 | 32 | -include i2c_driver.d 33 | -------------------------------------------------------------------------------- /drivers/network/dwmac-5.10a/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "nxp,imx8mp-dwmac-eqos", 4 | "snps,dwmac-5.10a", 5 | "snps,dwmac-5.20" 6 | ], 7 | "resources": { 8 | "regions": [ 9 | { 10 | "name": "regs", 11 | "perms": "rw", 12 | "size": 65536, 13 | "dt_index": 0 14 | }, 15 | { 16 | "name": "device_rx_ring", 17 | "size": 32768 18 | }, 19 | { 20 | "name": "device_tx_ring", 21 | "size": 32768 22 | } 23 | ], 24 | "irqs": [ 25 | { 26 | "dt_index": 0 27 | } 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /drivers/network/dwmac-5.10a/eth_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the Synopsys dwmac 5.10a NIC driver 8 | # 9 | # NOTES: 10 | # Generates eth_driver.elf 11 | # Assumes libsddf_util_debug.a is in LIBS 12 | 13 | ETHERNET_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | CHECK_NETDRV_FLAGS_MD5:=.netdrv_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_network} | shasum | sed 's/ *-//') 16 | 17 | ${CHECK_NETDRV_FLAGS_MD5}: 18 | -rm -f .netdrv_cflags-* 19 | touch $@ 20 | 21 | eth_driver.elf: network/starfive/ethernet.o 22 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 23 | 24 | network/starfive/ethernet.o: ${ETHERNET_DRIVER_DIR}ethernet.c ${CHECK_NETDRV_FLAGS} 25 | mkdir -p network/starfive 26 | ${CC} -c ${CFLAGS} ${CFLAGS_network} -I ${ETHERNET_DRIVER_DIR} -o $@ $< 27 | 28 | -include starfive/ethernet.d 29 | -------------------------------------------------------------------------------- /drivers/network/imx/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "fsl,imx8mq-fec" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 65536, 11 | "dt_index": 0 12 | }, 13 | { 14 | "name": "device_rx_ring", 15 | "size": 32768 16 | }, 17 | { 18 | "name": "device_tx_ring", 19 | "size": 32768 20 | } 21 | ], 22 | "irqs": [ 23 | { 24 | "dt_index": 2 25 | } 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /drivers/network/imx/eth_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the IMX8 NIC driver 8 | # 9 | # NOTES 10 | # Generates eth_driver.elf 11 | # Expects libsddf_util_debug.a to be in LIBS 12 | 13 | ETHERNET_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | CHECK_NETDRV_FLAGS_MD5:=.netdrv_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_network} | shasum | sed 's/ *-//') 15 | 16 | ${CHECK_NETDRV_FLAGS_MD5}: 17 | -rm -f .netdrv_cflags-* 18 | touch $@ 19 | 20 | eth_driver.elf: network/imx/ethernet.o 21 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 22 | 23 | network/imx/ethernet.o: ${ETHERNET_DRIVER_DIR}/ethernet.c ${CHECK_NETDRV_FLAGS_MD5} 24 | mkdir -p network/imx 25 | ${CC} -c ${CFLAGS} ${CFLAGS_network} -I ${ETHERNET_DRIVER_DIR} -o $@ $< 26 | 27 | 28 | -include imx/ethernet.d 29 | -------------------------------------------------------------------------------- /drivers/network/meson/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "amlogic,meson-gxbb-dwmac", 4 | "amlogic,meson-g12a-dwmac" 5 | ], 6 | "resources": { 7 | "regions": [ 8 | { 9 | "name": "regs", 10 | "perms": "rw", 11 | "size": 65536, 12 | "dt_index": 0 13 | }, 14 | { 15 | "name": "device_rx_ring", 16 | "size": 32768 17 | }, 18 | { 19 | "name": "device_tx_ring", 20 | "size": 32768 21 | } 22 | ], 23 | "irqs": [ 24 | { 25 | "dt_index": 0 26 | } 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /drivers/network/meson/eth_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the Amlogic NIC driver 8 | # 9 | # NOTES: 10 | # Generates eth_driver.elf 11 | # Assumes libsddf_util_debug.a is in LIBS 12 | 13 | ETHERNET_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | CHECK_NETDRV_FLAGS_MD5:=.netdrv_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_network} | shasum | sed 's/ *-//') 16 | 17 | ${CHECK_NETDRV_FLAGS_MD5}: 18 | -rm -f .netdrv_cflags-* 19 | touch $@ 20 | 21 | eth_driver.elf: network/meson/ethernet.o 22 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 23 | 24 | network/meson/ethernet.o: ${ETHERNET_DRIVER_DIR}/ethernet.c ${CHECK_NETDRV_FLAGS_MD5} 25 | mkdir -p network/meson 26 | ${CC} -c ${CFLAGS} ${CFLAGS_network} -I ${ETHERNET_DRIVER_DIR} -o $@ $< 27 | 28 | -include meson/ethernet.d 29 | -------------------------------------------------------------------------------- /drivers/network/virtio/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip $(MICROKIT_INCLUDE)),) 8 | $(error MICROKIT_INCLUDE must be specified) 9 | endif 10 | 11 | BUILD_DIR ?= . 12 | 13 | TOOLCHAIN := clang 14 | CC := clang 15 | TARGET := aarch64-none-elf 16 | SDDF := ../../.. 17 | 18 | CFLAGS := \ 19 | -target $(TARGET) \ 20 | -mstrict-align \ 21 | -ffreestanding \ 22 | -Wno-unused-function \ 23 | -I$(MICROKIT_INCLUDE) \ 24 | -I$(SDDF)/include 25 | 26 | all: $(BUILD_DIR)/ethernet.o 27 | 28 | $(BUILD_DIR)/ethernet.o: ethernet.c ethernet.h 29 | $(CC) -c $(CFLAGS) ethernet.c -o $(BUILD_DIR)/ethernet.o 30 | 31 | .PHONY: clean 32 | clean: 33 | rm $(BUILD_DIR)/ethernet.o 34 | -------------------------------------------------------------------------------- /drivers/network/virtio/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "virtio,mmio" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | }, 13 | { 14 | "name": "hw_ring_buffer", 15 | "size": 65536 16 | } 17 | ], 18 | "irqs": [ 19 | { 20 | "dt_index": 0 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /drivers/network/virtio/eth_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the VirtIO driver 8 | # 9 | # NOTES: 10 | # Generates eth_driver.elf 11 | # Assumes libsddf_util_debug.a is in LIBS 12 | 13 | ETHERNET_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | CHECK_NETDRV_FLAGS_MD5:=.netdrv_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_network} | shasum | sed 's/ *-//') 16 | 17 | ${CHECK_NETDRV_FLAGS_MD5}: 18 | -rm -f .netdrv_cflags-* 19 | touch $@ 20 | 21 | eth_driver.elf: network/virtio/ethernet.o 22 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 23 | 24 | network/virtio/ethernet.o: ${ETHERNET_DRIVER_DIR}/ethernet.c ${CHECK_NETDRV_FLAGS} 25 | mkdir -p network/virtio 26 | ${CC} -c ${CFLAGS} ${CFLAGS_network} -I ${ETHERNET_DRIVER_DIR} -o $@ $< 27 | 28 | -include virtio/ethernet.d 29 | -------------------------------------------------------------------------------- /drivers/serial/arm/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "arm,pl011" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | } 13 | ], 14 | "irqs": [ 15 | { 16 | "dt_index": 0 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /drivers/serial/arm/serial_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the PL011 UART driver 8 | 9 | SERIAL_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 10 | 11 | serial_driver.elf: serial/arm/serial_driver.o 12 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 13 | 14 | serial/arm/serial_driver.o: ${SERIAL_DRIVER_DIR}/uart.c |serial/arm 15 | $(CC) -c $(CFLAGS) -I${SERIAL_DRIVER_DIR}/include -o $@ $< 16 | 17 | serial/arm: 18 | mkdir -p $@ 19 | 20 | -include serial/arm/serial_driver.d 21 | 22 | clean:: 23 | rm -f serial/arm/serial_driver.[do] 24 | clobber:: clean 25 | rm -rf serial_driver.elf serial 26 | -------------------------------------------------------------------------------- /drivers/serial/imx/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "fsl,imx8mq-uart", 4 | "fsl,imx8mm-uart", 5 | "fsl,imx8mp-uart" 6 | ], 7 | "resources": { 8 | "regions": [ 9 | { 10 | "name": "regs", 11 | "perms": "rw", 12 | "size": 4096, 13 | "dt_index": 0 14 | } 15 | ], 16 | "irqs": [ 17 | { 18 | "dt_index": 0 19 | } 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /drivers/serial/imx/serial_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the IMX8 UART driver. 8 | # Assumes libsddf_util_debug.a is in ${LIBS}. 9 | 10 | SERIAL_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 11 | 12 | serial_driver.elf: serial/imx/serial_driver.o 13 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 14 | 15 | serial/imx/serial_driver.o: ${SERIAL_DRIVER_DIR}/uart.c |serial/imx 16 | $(CC) -c $(CFLAGS) -I${SERIAL_DRIVER_DIR}/include -o $@ $< 17 | 18 | -include serial_driver.d 19 | 20 | serial/imx: 21 | mkdir -p $@ 22 | 23 | clean:: 24 | rm -f serial/imx/serial_driver.[do] 25 | 26 | clobber:: 27 | rm -rf serial 28 | -------------------------------------------------------------------------------- /drivers/serial/meson/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "amlogic,meson-gx-uart", 4 | "amlogic,meson-ao-uart" 5 | ], 6 | "resources": { 7 | "regions": [ 8 | { 9 | "name": "regs", 10 | "perms": "rw", 11 | "size": 4096, 12 | "dt_index": 0 13 | } 14 | ], 15 | "irqs": [ 16 | { 17 | "dt_index": 0 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /drivers/serial/meson/serial_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the Meson UART driver. 8 | # 9 | # NOTES: 10 | # Builds serial_driver.elf 11 | 12 | SERIAL_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 13 | 14 | serial_driver.elf: serial/meson/serial_driver.o libsddf_util_debug.a 15 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 16 | 17 | serial/meson/serial_driver.o: ${SERIAL_DRIVER_DIR}/uart.c |serial/meson 18 | $(CC) -c $(CFLAGS) -I${SERIAL_DRIVER_DIR}/include -o $@ $< 19 | 20 | serial/meson: 21 | mkdir -p $@ 22 | 23 | -include serial/meson/serial_driver.d 24 | 25 | clean:: 26 | rm -f serial/meson/serial_driver.[do] 27 | 28 | clobber:: 29 | rm -rf serial 30 | -------------------------------------------------------------------------------- /drivers/serial/ns16550a/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "starfive,jh7110-uart", 4 | "ns16550a" 5 | ], 6 | "resources": { 7 | "regions": [ 8 | { 9 | "name": "regs", 10 | "perms": "rw", 11 | "size": 4096, 12 | "dt_index": 0 13 | } 14 | ], 15 | "irqs": [ 16 | { 17 | "dt_index": 0 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /drivers/serial/ns16550a/serial_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the Synopsis DesignWare ABP UART driver 8 | 9 | SERIAL_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 10 | 11 | serial_driver.elf: serial/ns16550a/serial_driver.o 12 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 13 | 14 | serial/ns16550a/serial_driver.o: ${SERIAL_DRIVER_DIR}/uart.c |serial/ns16550a 15 | $(CC) -c $(CFLAGS) -I${SERIAL_DRIVER_DIR}/include -o $@ $< 16 | 17 | serial/ns16550a: 18 | mkdir -p $@ 19 | 20 | -include serial/ns16550a/serial_driver.d 21 | 22 | clean:: 23 | rm -f serial/ns16550a/serial_driver.[do] 24 | clobber:: clean 25 | rm -rf serial_driver.elf serial 26 | -------------------------------------------------------------------------------- /drivers/serial/virtio/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "virtio,mmio" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | }, 13 | { 14 | "name": "hw_ring_buffer", 15 | "size": 65536 16 | }, 17 | { 18 | "name": "virtio_rx_buf", 19 | "size": 4096 20 | }, 21 | { 22 | "name": "virtio_tx_buf", 23 | "size": 4096 24 | } 25 | ], 26 | "irqs": [ 27 | { 28 | "dt_index": 0 29 | } 30 | ] 31 | } 32 | } -------------------------------------------------------------------------------- /drivers/serial/virtio/include/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | // #define DEBUG_DRIVER 9 | 10 | #ifdef DEBUG_DRIVER 11 | #define LOG_DRIVER(...) do{ sddf_dprintf("CONSOLE DRIVER|INFO: "); sddf_dprintf(__VA_ARGS__); }while(0) 12 | #else 13 | #define LOG_DRIVER(...) do{}while(0) 14 | #endif 15 | 16 | #define LOG_DRIVER_ERR(...) do{ sddf_printf("CONSOLE DRIVER|ERROR: "); sddf_printf(__VA_ARGS__); }while(0) 17 | 18 | #define VIRTIO_CONSOLE_F_SIZE 0 19 | #define VIRTIO_CONSOLE_F_MULTIPORT 1 20 | #define VIRTIO_CONSOLE_F_EMERG_WRITE 2 21 | 22 | static void virtio_console_print_features(uint64_t features) 23 | { 24 | if (features & ((uint64_t)1 << VIRTIO_CONSOLE_F_SIZE)) { 25 | LOG_DRIVER(" VIRTIO_CONSOLE_F_SIZE\n"); 26 | } 27 | if (features & ((uint64_t)1 << VIRTIO_CONSOLE_F_MULTIPORT)) { 28 | LOG_DRIVER(" VIRTIO_CONSOLE_F_MULTIPORT\n"); 29 | } 30 | if (features & ((uint64_t)1 << VIRTIO_CONSOLE_F_EMERG_WRITE)) { 31 | LOG_DRIVER(" VIRTIO_CONSOLE_F_EMERG_WRITE\n"); 32 | } 33 | virtio_print_reserved_feature_bits(features); 34 | } 35 | -------------------------------------------------------------------------------- /drivers/serial/virtio/serial_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the virtio console driver. 8 | # 9 | # NOTES: 10 | # Builds serial_driver.elf 11 | 12 | SERIAL_DRIVER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 13 | 14 | serial_driver.elf: serial/virtio/serial_driver.o libsddf_util_debug.a 15 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 16 | 17 | serial/virtio/serial_driver.o: ${SERIAL_DRIVER_DIR}/console.c |serial/virtio 18 | $(CC) -c $(CFLAGS) -I${SERIAL_DRIVER_DIR}/include -o $@ $< 19 | 20 | serial/virtio: 21 | mkdir -p $@ 22 | 23 | -include serial/virtio/serial_driver.d 24 | 25 | clean:: 26 | rm -f serial/virtio/serial_driver.[do] 27 | 28 | clobber:: 29 | rm -rf serial 30 | -------------------------------------------------------------------------------- /drivers/timer/arm/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "arm,armv8-timer" 4 | ], 5 | "resources": { 6 | "regions": [], 7 | "irqs": [ 8 | { 9 | "dt_index": 1 10 | } 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /drivers/timer/arm/timer_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the ARM timer driver 8 | # 9 | # NOTES: 10 | # Generates timer_driver.elf 11 | # Expects libsddf_util_debug.a to be in ${LIBS} 12 | 13 | TIMER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | timer_driver.elf: timer/timer.o 16 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 17 | 18 | timer/timer.o: ${TIMER_DIR}/timer.c ${CHECK_FLAGS_BOARD_MD5} |timer 19 | ${CC} ${CFLAGS} -o $@ -c $< 20 | 21 | timer: 22 | mkdir -p timer 23 | 24 | clean:: 25 | rm -rf timer 26 | clobber:: 27 | rm -f timer_driver.elf 28 | -------------------------------------------------------------------------------- /drivers/timer/goldfish/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "google,goldfish-rtc" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "dt_index": 0 10 | } 11 | ], 12 | "irqs": [ 13 | { 14 | "dt_index": 0 15 | } 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /drivers/timer/goldfish/timer_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2025, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the goldfish-rtc timer driver 8 | # 9 | # NOTES: 10 | # Generates timer_driver.elf 11 | # Expects libsddf_util_debug.a to be in ${LIBS} 12 | 13 | TIMER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | timer_driver.elf: timer/timer.o 16 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 17 | 18 | timer/timer.o: ${TIMER_DIR}/timer.c ${CHECK_FLAGS_BOARD_MD5} |timer 19 | ${CC} ${CFLAGS} -o $@ -c $< 20 | 21 | timer: 22 | mkdir -p timer 23 | 24 | clean:: 25 | rm -rf timer 26 | clobber:: 27 | rm -f timer_driver.elf 28 | -------------------------------------------------------------------------------- /drivers/timer/imx/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "fsl,imx8mm-gpt", 4 | "fsl,imx8mq-gpt", 5 | "fsl,imx8mp-gpt" 6 | ], 7 | "resources": { 8 | "regions": [ 9 | { 10 | "name": "regs", 11 | "perms": "rw", 12 | "size": 65536, 13 | "dt_index": 0 14 | } 15 | ], 16 | "irqs": [ 17 | { 18 | "dt_index": 0 19 | } 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /drivers/timer/imx/timer_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the IMX8 timer driver 8 | # 9 | # NOTES: 10 | # Generates timer_driver.elf 11 | # Expects libsddf_util_debug.a to be in ${LIBS} 12 | 13 | TIMER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | timer_driver.elf: timer/timer.o 16 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 17 | 18 | timer/timer.o: ${TIMER_DIR}/timer.c ${CHECK_FLAGS_BOARD_MD5} |timer 19 | ${CC} ${CFLAGS} -o $@ -c $< 20 | 21 | timer: 22 | mkdir -p timer 23 | 24 | clean:: 25 | rm -rf timer 26 | clobber:: 27 | rm -f timer_driver.elf 28 | -------------------------------------------------------------------------------- /drivers/timer/jh7110/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "starfive,jh7110-timer" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | } 13 | ], 14 | "irqs": [ 15 | { 16 | "dt_index": 0 17 | }, 18 | { 19 | "dt_index": 1 20 | } 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /drivers/timer/jh7110/timer_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the JH7110 timer driver 8 | # 9 | # NOTES: 10 | # Generates timer_driver.elf 11 | # Expects libsddf_util_debug.a to be in ${LIBS} 12 | 13 | TIMER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | timer_driver.elf: timer/timer.o 16 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 17 | 18 | timer/timer.o: ${TIMER_DIR}/timer.c ${CHECK_FLAGS_BOARD_MD5} |timer 19 | ${CC} ${CFLAGS} -o $@ -c $< 20 | 21 | timer: 22 | mkdir -p timer 23 | 24 | clean:: 25 | rm -rf timer 26 | clobber:: 27 | rm -f timer_driver.elf 28 | -------------------------------------------------------------------------------- /drivers/timer/meson/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "compatible": [ 3 | "amlogic,meson-gxbb-wdt" 4 | ], 5 | "resources": { 6 | "regions": [ 7 | { 8 | "name": "regs", 9 | "perms": "rw", 10 | "size": 4096, 11 | "dt_index": 0 12 | } 13 | ], 14 | "irqs": [ 15 | { 16 | "dt_index": 0 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /drivers/timer/meson/timer_driver.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the Meson timer driver 8 | # 9 | # NOTES: 10 | # Generates timer_driver.elf 11 | # Expects libsddf_util_debug.a in ${LIBS} 12 | 13 | TIMER_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 14 | 15 | timer_driver.elf: timer/timer.o 16 | $(LD) $(LDFLAGS) $< $(LIBS) -o $@ 17 | 18 | timer/timer.o: ${TIMER_DIR}/timer.c ${CHECK_FLAGS_BOARD_MD5} |timer 19 | ${CC} ${CFLAGS} -o $@ -c $< 20 | 21 | timer: 22 | mkdir -p timer 23 | 24 | clean:: 25 | rm -rf timer 26 | clobber:: 27 | rm -f timer_driver.elf 28 | -------------------------------------------------------------------------------- /examples/blk/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip $(MICROKIT_SDK)),) 8 | $(error MICROKIT_SDK must be specified) 9 | endif 10 | 11 | ifeq ($(strip $(MICROKIT_BOARD)),) 12 | $(error MICROKIT_BOARD must be specified) 13 | endif 14 | export MICROKIT_BOARD 15 | BUILD_DIR ?= build 16 | export SDDF=$(abspath ../..) 17 | export BUILD_DIR:=$(abspath ${BUILD_DIR}) 18 | export override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) 19 | 20 | IMAGE_FILE:= ${BUILD_DIR}/loader.img 21 | REPORT_FILE:= ${BUILD_DIR}/report.txt 22 | 23 | all: ${IMAGE_FILE} 24 | 25 | qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE 26 | ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) 27 | 28 | ${BUILD_DIR}/Makefile: blk.mk 29 | mkdir -p ${BUILD_DIR} 30 | cp blk.mk $@ 31 | 32 | FORCE: 33 | -------------------------------------------------------------------------------- /examples/blk/build.zig.zon: -------------------------------------------------------------------------------- 1 | 2 | .{ 3 | .name = .sddf_block_example, 4 | .version = "0.0.0", 5 | 6 | .dependencies = .{ 7 | .sddf = .{ 8 | .path = "../../" 9 | }, 10 | }, 11 | .paths = .{ 12 | "build.zig", 13 | "build.zig.zon", 14 | }, 15 | .fingerprint = 0xa388f03f74406e1b, 16 | } -------------------------------------------------------------------------------- /examples/echo_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2022, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip $(MICROKIT_SDK)),) 8 | $(error MICROKIT_SDK must be specified) 9 | endif 10 | 11 | ifeq ($(strip $(MICROKIT_BOARD)),) 12 | $(error MICROKIT_BOARD must be specified) 13 | endif 14 | export MICROKIT_BOARD 15 | BUILD_DIR ?= build 16 | export SDDF=$(abspath ../..) 17 | export BUILD_DIR:=$(abspath ${BUILD_DIR}) 18 | export override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) 19 | 20 | IMAGE_FILE := $(BUILD_DIR)/loader.img 21 | REPORT_FILE := $(BUILD_DIR)/report.txt 22 | 23 | export ECHO_INCLUDE:=$(abspath .)/include 24 | 25 | all: ${IMAGE_FILE} 26 | 27 | qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE 28 | ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) 29 | 30 | ${BUILD_DIR}/Makefile: echo.mk 31 | mkdir -p ${BUILD_DIR} 32 | cp echo.mk $@ 33 | 34 | FORCE: 35 | -------------------------------------------------------------------------------- /examples/echo_server/echo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #define UDP_ECHO_PORT 1235 11 | #define UTILIZATION_PORT 1236 12 | #define TCP_ECHO_PORT 1237 13 | 14 | int setup_udp_socket(void); 15 | int setup_utilization_socket(void *cycle_counters, sddf_channel start_ch, sddf_channel stop_ch); 16 | int setup_tcp_socket(void); 17 | -------------------------------------------------------------------------------- /examples/echo_server/include/lwip/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: BSD-3-Clause 3 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 4 | */ 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | typedef uint8_t u8_t; 11 | typedef uint16_t u16_t; 12 | typedef uint32_t u32_t; 13 | typedef uint64_t u64_t; 14 | 15 | typedef int8_t s8_t; 16 | typedef int16_t s16_t; 17 | typedef int32_t s32_t; 18 | typedef int64_t s64_t; 19 | 20 | typedef uintptr_t mem_ptr_t; 21 | 22 | 23 | #define U16_F "hu" 24 | #define S16_F "d" 25 | #define X16_F "hx" 26 | #define U32_F "u" 27 | #define S32_F "d" 28 | #define X32_F "x" 29 | #define SZT_F "lu" 30 | 31 | 32 | // BYTE_ORDER might be defined by the architecture 33 | #ifndef BYTE_ORDER 34 | #if defined(__BYTE_ORDER__) 35 | # define BYTE_ORDER __BYTE_ORDER__ 36 | #elif defined(__BIG_ENDIAN) 37 | # define BYTE_ORDER BIG_ENDIAN 38 | #elif defined(__LITTLE_ENDIAN) 39 | # define BYTE_ORDER LITTLE_ENDIAN 40 | #else 41 | # error Unable to detemine system endianess 42 | #endif 43 | #endif 44 | 45 | 46 | #define LWIP_CHKSUM_ALGORITHM 3 47 | 48 | #define PACK_STRUCT_STRUCT __attribute__((packed)) 49 | #define PACK_STRUCT_BEGIN 50 | #define PACK_STRUCT_END 51 | 52 | 53 | #define LWIP_PLATFORM_BYTESWAP 1 54 | #define LWIP_PLATFORM_HTONS(x) ( (((u16_t)(x))>>8) | (((x)&0xFF)<<8) ) 55 | #define LWIP_PLATFORM_HTONL(x) ( (((u32_t)(x))>>24) | (((x)&0xFF0000)>>8) \ 56 | | (((x)&0xFF00)<<8) | (((x)&0xFF)<<24) ) 57 | 58 | typedef unsigned long long ssize_t; 59 | 60 | #define LWIP_RAND rand 61 | 62 | /* Plaform specific diagnostic output */ 63 | #define LWIP_PLATFORM_DIAG(x) \ 64 | do { \ 65 | sddf_printf x ;\ 66 | } while(0) 67 | 68 | #define LWIP_PLATFORM_ASSERT(x) \ 69 | do { \ 70 | sddf_printf("Assertion failed: %s\n", #x); \ 71 | while(1); \ 72 | } while(0) 73 | -------------------------------------------------------------------------------- /examples/echo_server/udp_echo_socket.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | 8 | #include "lwip/ip.h" 9 | #include "lwip/pbuf.h" 10 | #include "lwip/udp.h" 11 | #include "lwip/err.h" 12 | 13 | #include 14 | #include 15 | 16 | #include "echo.h" 17 | 18 | static struct udp_pcb *udp_socket; 19 | 20 | static void lwip_udp_recv_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) 21 | { 22 | err_t error = udp_sendto(pcb, p, addr, port); 23 | if (error) { 24 | sddf_dprintf("Failed to send UDP packet through socket: %s\n", lwip_strerr(error)); 25 | } 26 | pbuf_free(p); 27 | } 28 | 29 | int setup_udp_socket(void) 30 | { 31 | udp_socket = udp_new_ip_type(IPADDR_TYPE_V4); 32 | if (udp_socket == NULL) { 33 | sddf_dprintf("Failed to open a UDP socket\n"); 34 | return -1; 35 | } 36 | 37 | int error = udp_bind(udp_socket, IP_ANY_TYPE, UDP_ECHO_PORT); 38 | if (error == ERR_OK) { 39 | udp_recv(udp_socket, lwip_udp_recv_callback, udp_socket); 40 | } else { 41 | sddf_dprintf("Failed to bind the UDP socket\n"); 42 | return -1; 43 | } 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /examples/gpu/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip ${MICROKIT_SDK}),) 8 | $(error MICROKIT_SDK must be specified) 9 | endif 10 | 11 | export FB_IMG ?= fb_img.jpeg 12 | export BLOB ?= 0 13 | export BUILD_DIR ?= build 14 | export MICROKIT_SDK 15 | export MICROKIT_BOARD ?= qemu_virt_aarch64 16 | export MICROKIT_CONFIG ?= debug 17 | export SDDF := $(abspath ../..) 18 | 19 | override FB_IMG := $(abspath ${FB_IMG}) 20 | override BUILD_DIR := $(abspath ${BUILD_DIR}) 21 | override MICROKIT_SDK := $(abspath ${MICROKIT_SDK}) 22 | 23 | IMAGE_FILE:= ${BUILD_DIR}/loader.img 24 | REPORT_FILE:= ${BUILD_DIR}/report.txt 25 | 26 | all: ${IMAGE_FILE} 27 | 28 | qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE 29 | ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} BUILD_DIR=${BUILD_DIR} FB_IMG=${FB_IMG} $(notdir $@) 30 | 31 | ${BUILD_DIR}/Makefile: gpu.mk 32 | mkdir -p ${BUILD_DIR} 33 | cp gpu.mk $@ 34 | 35 | FORCE: 36 | -------------------------------------------------------------------------------- /examples/gpu/build.zig.zon: -------------------------------------------------------------------------------- 1 | 2 | .{ 3 | .name = .sddf_gpu_example, 4 | .version = "0.0.0", 5 | 6 | .dependencies = .{ 7 | .sddf = .{ 8 | .path = "../../" 9 | }, 10 | }, 11 | .paths = .{ 12 | "build.zig", 13 | "build.zig.zon", 14 | }, 15 | .fingerprint = 0xedcb89c072ad1870, 16 | } 17 | -------------------------------------------------------------------------------- /examples/gpu/fb_img.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | /* This file is used to put our client framebuffer image into program memory */ 7 | 8 | .section .fb_img, "aw", @progbits 9 | .global _fb_img, _fb_img_end 10 | _fb_img: 11 | .incbin FB_IMG_PATH 12 | _fb_img_end: 13 | -------------------------------------------------------------------------------- /examples/gpu/fb_img.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/examples/gpu/fb_img.jpeg -------------------------------------------------------------------------------- /examples/i2c/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip $(MICROKIT_SDK)),) 8 | $(error MICROKIT_SDK must be specified) 9 | endif 10 | override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) 11 | 12 | export BUILD_DIR ?= build 13 | export MICROKIT_CONFIG ?= debug 14 | export MICROKIT_BOARD ?= odroidc4 15 | 16 | export I2C_BUS_NUM:=2 17 | export SDDF := $(abspath ../../) 18 | 19 | IMAGE_FILE := $(BUILD_DIR)/loader.img 20 | REPORT_FILE := $(BUILD_DIR)/report.txt 21 | 22 | all: ${IMAGE_FILE} 23 | 24 | ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE 25 | ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) 26 | 27 | ${BUILD_DIR}/Makefile: i2c.mk 28 | mkdir -p ${BUILD_DIR} 29 | cp i2c.mk $@ 30 | FORCE: 31 | -------------------------------------------------------------------------------- /examples/i2c/build.zig.zon: -------------------------------------------------------------------------------- 1 | 2 | .{ 3 | .name = .sddf_i2c_example, 4 | .version = "0.0.0", 5 | 6 | .dependencies = .{ 7 | .sddf = .{ 8 | .path = "../../" 9 | }, 10 | }, 11 | .paths = .{ 12 | "build.zig", 13 | "build.zig.zon", 14 | }, 15 | .fingerprint = 0xfa284ea0a5eec458, 16 | } 17 | 18 | -------------------------------------------------------------------------------- /examples/serial/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2022, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip $(MICROKIT_SDK)),) 8 | $(error MICROKIT_SDK must be specified) 9 | endif 10 | 11 | ifeq ($(strip $(MICROKIT_BOARD)),) 12 | $(error MICROKIT_BOARD must be specified) 13 | endif 14 | export MICROKIT_BOARD 15 | BUILD_DIR ?= build 16 | export SDDF=$(abspath ../..) 17 | export BUILD_DIR:=$(abspath ${BUILD_DIR}) 18 | export override MICROKIT_SDK:=$(abspath ${MICROKIT_SDK}) 19 | 20 | IMAGE_FILE:= ${BUILD_DIR}/loader.img 21 | REPORT_FILE:= ${BUILD_DIR}/report.txt 22 | 23 | all: ${IMAGE_FILE} 24 | 25 | qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: ${BUILD_DIR}/Makefile FORCE 26 | ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) 27 | 28 | ${BUILD_DIR}/Makefile: serial.mk 29 | mkdir -p ${BUILD_DIR} 30 | cp serial.mk $@ 31 | 32 | FORCE: 33 | -------------------------------------------------------------------------------- /examples/serial/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .sddf_serial_example, 3 | .version = "0.0.0", 4 | 5 | .dependencies = .{ 6 | .sddf = .{ 7 | .path = "../../" 8 | }, 9 | }, 10 | .paths = .{ 11 | "build.zig", 12 | "build.zig.zon", 13 | }, 14 | .fingerprint = 0xc011b2db3c1521be, 15 | } 16 | -------------------------------------------------------------------------------- /examples/serial/client.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | __attribute__((__section__(".serial_client_config"))) serial_client_config_t config; 12 | 13 | serial_queue_handle_t rx_queue_handle; 14 | serial_queue_handle_t tx_queue_handle; 15 | 16 | void init(void) 17 | { 18 | assert(serial_config_check_magic(&config)); 19 | 20 | serial_queue_init(&rx_queue_handle, config.rx.queue.vaddr, config.rx.data.size, config.rx.data.vaddr); 21 | serial_queue_init(&tx_queue_handle, config.tx.queue.vaddr, config.tx.data.size, config.tx.data.vaddr); 22 | 23 | serial_putchar_init(config.tx.id, &tx_queue_handle); 24 | sddf_printf("Hello world! I am %s.\nPlease give me character!\n", microkit_name); 25 | } 26 | 27 | uint16_t char_count; 28 | void notified(microkit_channel ch) 29 | { 30 | char c; 31 | while (!serial_dequeue(&rx_queue_handle, &c)) { 32 | if (c == '\r') { 33 | sddf_putchar_unbuffered('\\'); 34 | sddf_putchar_unbuffered('r'); 35 | } else { 36 | sddf_putchar_unbuffered(c); 37 | } 38 | char_count++; 39 | if (char_count % 10 == 0) { 40 | sddf_printf("\n%s has received %u characters so far!\n", microkit_name, char_count); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/timer/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2025, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | ifeq ($(strip $(MICROKIT_SDK)),) 8 | $(error MICROKIT_SDK must be specified) 9 | endif 10 | 11 | ifeq ($(strip $(MICROKIT_BOARD)),) 12 | $(error MICROKIT_BOARD must be specified) 13 | endif 14 | export MICROKIT_BOARD 15 | BUILD_DIR ?= build 16 | export SDDF := $(abspath ../..) 17 | export BUILD_DIR := $(abspath ${BUILD_DIR}) 18 | override MICROKIT_SDK := $(abspath ${MICROKIT_SDK}) 19 | 20 | IMAGE_FILE := $(BUILD_DIR)/loader.img 21 | REPORT_FILE := $(BUILD_DIR)/report.txt 22 | 23 | all: ${IMAGE_FILE} 24 | 25 | qemu ${IMAGE_FILE} ${REPORT_FILE} clean clobber: $(IMAGE_FILE) ${BUILD_DIR}/Makefile FORCE 26 | ${MAKE} -C ${BUILD_DIR} MICROKIT_SDK=${MICROKIT_SDK} $(notdir $@) 27 | 28 | ${BUILD_DIR}/Makefile: timer.mk 29 | mkdir -p ${BUILD_DIR} 30 | cp timer.mk ${BUILD_DIR}/Makefile 31 | 32 | FORCE: 33 | -------------------------------------------------------------------------------- /examples/timer/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Timer example 8 | 9 | This is a very simple example where a single client program is setting 10 | timeouts and getting the current time from a timer driver. 11 | 12 | ## Building 13 | 14 | The following platforms are supported: 15 | * imx8mm_evk 16 | * imx8mp_evk 17 | * imx8mq_evk 18 | * maaxboard 19 | * odroidc2 20 | * odroidc4 21 | * qemu_virt_aarch64 22 | * qemu_virt_riscv64 23 | * star64 24 | 25 | ### Make 26 | 27 | ```sh 28 | make MICROKIT_SDK= MICROKIT_BOARD= 29 | ``` 30 | 31 | After building, the system image to load will be `build/loader.img`. 32 | 33 | If you wish to simulate on the QEMU virt AArch64 platform, you can append `qemu` to your make command 34 | after building for qemu_virt_aarch64. 35 | 36 | ### Zig 37 | 38 | You can also build this example with the Zig build system: 39 | ```sh 40 | zig build -Dsdk=/path/to/sdk -Dboard= 41 | ``` 42 | 43 | The options for `` are the same as the Makefile. 44 | 45 | You can simulate QEMU with: 46 | ```sh 47 | zig build -Dsdk=/path/to/sdk -Dboard=qemu_virt_aarch64 qemu 48 | ``` 49 | 50 | The final bootable image will be in `zig-out/bin/loader.img`. 51 | 52 | ## Running 53 | 54 | When running the example, you should see something similar to the following 55 | output: 56 | ``` 57 | CLIENT|INFO: The time now is: 29422640 58 | CLIENT|INFO: Setting a time out for 1 second 59 | CLIENT|INFO: Got a timeout! 60 | CLIENT|INFO: Now the time (in nanoseconds) is: 1031980992 61 | CLIENT|INFO: Got a timeout! 62 | CLIENT|INFO: Now the time (in nanoseconds) is: 2032392176 63 | CLIENT|INFO: Got a timeout! 64 | CLIENT|INFO: Now the time (in nanoseconds) is: 3032782448 65 | CLIENT|INFO: Got a timeout! 66 | CLIENT|INFO: Now the time (in nanoseconds) is: 4033253600 67 | CLIENT|INFO: Got a timeout! 68 | CLIENT|INFO: Now the time (in nanoseconds) is: 5033766064 69 | CLIENT|INFO: Got a timeout! 70 | CLIENT|INFO: Now the time (in nanoseconds) is: 6034408576 71 | ``` 72 | 73 | The client will continuously set timeouts and read the current time. 74 | -------------------------------------------------------------------------------- /examples/timer/build.zig.zon: -------------------------------------------------------------------------------- 1 | .{ 2 | .name = .sddf_timer_example, 3 | .version = "0.0.0", 4 | 5 | .dependencies = .{ 6 | .sddf = .{ 7 | .path = "../../" 8 | }, 9 | }, 10 | .paths = .{ 11 | "build.zig", 12 | "build.zig.zon", 13 | }, 14 | .fingerprint = 0x7ad8c3845bf479d0, 15 | } 16 | 17 | -------------------------------------------------------------------------------- /examples/timer/client.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | __attribute__((__section__(".timer_client_config"))) timer_client_config_t config; 13 | 14 | microkit_channel timer_channel; 15 | 16 | void notified(microkit_channel ch) 17 | { 18 | /* 19 | * In this example we only have a single possible channel, 20 | * so we know it's a notification from the driver telling 21 | * us that the timeout we set has gone off. 22 | */ 23 | sddf_printf("CLIENT|INFO: Got a timeout!\n"); 24 | /* Get the current time */ 25 | uint64_t time = sddf_timer_time_now(timer_channel); 26 | sddf_printf("CLIENT|INFO: Now the time (in nanoseconds) is: %lu\n", time); 27 | /* Set another timeout */ 28 | sddf_timer_set_timeout(timer_channel, NS_IN_S); 29 | } 30 | 31 | void init(void) 32 | { 33 | sddf_printf("CLIENT|INFO: starting\n"); 34 | 35 | assert(timer_config_check_magic(&config)); 36 | 37 | timer_channel = config.driver_id; 38 | 39 | // lets get the time! 40 | uint64_t time = sddf_timer_time_now(timer_channel); 41 | sddf_printf("CLIENT|INFO: The time now is: %lu\n", time); 42 | 43 | // lets set a timeout 44 | sddf_printf("CLIENT|INFO: Setting a time out for 1 second\n"); 45 | sddf_timer_set_timeout(timer_channel, NS_IN_S); 46 | } 47 | -------------------------------------------------------------------------------- /gpu/components/gpu_components.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # This Makefile snippet builds the gpu virtualiser 7 | # it should be included into your project Makefile 8 | # 9 | # NOTES: 10 | # Generates gpu_virt.elf 11 | # 12 | 13 | CFLAGS_gpu ?= 14 | 15 | CHECK_GPU_VIRT_FLAGS_MD5:=.gpu_virt_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_gpu} | shasum | sed 's/ *-//') 16 | 17 | ${CHECK_GPU_VIRT_FLAGS_MD5}: 18 | -rm -f .gpu_virt_cflags-* 19 | touch $@ 20 | 21 | gpu_virt.elf: gpu_virt.o 22 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 23 | 24 | gpu_virt.o: ${SDDF}/gpu/components/virt.c ${CHECK_GPU_VIRT_FLAGS_MD5} 25 | ${CC} ${CFLAGS} ${CFLAGS_gpu} -o $@ -c $< 26 | 27 | -include gpu_virt.d 28 | 29 | clean:: 30 | rm -f gpu_virt.[od] .gpu_virt_cflags-* 31 | clobber:: clean 32 | rm -f gpu_virt.elf 33 | -------------------------------------------------------------------------------- /i2c/components/i2c_virt.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this snippet in your project Makefile to build 7 | # the i2c virtualiser 8 | # 9 | # NOTES: 10 | # Builds i2c_virt.elf 11 | # Depends on ${SDDF}/util/util.mk also being included 12 | 13 | i2c_virt.o: ${SDDF}/i2c/components/virt.c 14 | ${CC} ${CFLAGS} -c -o $@ $< 15 | 16 | i2c_virt.elf: i2c_virt.o libsddf_util_debug.a 17 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 18 | -------------------------------------------------------------------------------- /i2c/devices/ds3231/README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # DS3231 7 | 8 | This example makes use of the Analog Devices DS3231 RTC. 9 | Documentaion can be found [here](https://www.analog.com/media/en/technical-documentation/data-sheets/ds3231.pdf). -------------------------------------------------------------------------------- /i2c/devices/ds3231/ds3231.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | DS3231_DRIVER := $(SDDF)/i2c/devices/ds3231 7 | 8 | ds3231.o: ${DS3231_DRIVER}/ds3231.c 9 | ${CC} ${CFLAGS} -c -o $@ $< 10 | -------------------------------------------------------------------------------- /i2c/devices/pn532/README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # PN532 7 | 8 | This example makes use of the NXP PN532 card-reader. This example was developed and tested using 9 | the PN532 NFC RFID Module V3. Documentation on the card-reader itself can be found 10 | on the [NXP website](https://www.nxp.com/docs/en/user-guide/141520.pdf). 11 | 12 | The client code for dealing with the card-reader is based on an Arduino PN532 library, it can 13 | be found [here](https://github.com/elechouse/PN532/). -------------------------------------------------------------------------------- /i2c/devices/pn532/pn532.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | PN532_DRIVER := $(SDDF)/i2c/devices/pn532 7 | 8 | pn532.o: ${PN532_DRIVER}/pn532.c 9 | ${CC} ${CFLAGS} -c -o $@ $< 10 | -------------------------------------------------------------------------------- /include/extern/os/sddf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | typedef unsigned int sddf_channel; 12 | 13 | #define SDDF_NAME_LENGTH 64 14 | 15 | extern char *sddf_get_pd_name(); 16 | extern void sddf_irq_ack(sddf_channel id); 17 | extern void sddf_notify(sddf_channel id); 18 | extern void sddf_deferred_notify(sddf_channel id); 19 | extern void sddf_deferred_irq_ack(sddf_channel id); 20 | extern seL4_MessageInfo_t sddf_ppcall(sddf_channel id, seL4_MessageInfo_t msginfo); 21 | extern uint64_t sddf_get_mr(sddf_channel n); 22 | extern void sddf_set_mr(sddf_channel n, uint64_t val); 23 | extern sddf_channel sddf_deferred_notify_curr(); 24 | -------------------------------------------------------------------------------- /include/microkit/os/sddf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | typedef microkit_channel sddf_channel; 13 | 14 | #define SDDF_NAME_LENGTH MICROKIT_PD_NAME_LENGTH 15 | 16 | static inline char *sddf_get_pd_name() 17 | { 18 | return microkit_name; 19 | } 20 | 21 | static inline void sddf_irq_ack(sddf_channel ch) 22 | { 23 | microkit_irq_ack(ch); 24 | } 25 | 26 | static inline void sddf_deferred_irq_ack(sddf_channel ch) 27 | { 28 | microkit_deferred_irq_ack(ch); 29 | } 30 | 31 | static inline void sddf_notify(sddf_channel ch) 32 | { 33 | microkit_notify(ch); 34 | } 35 | 36 | static inline void sddf_deferred_notify(sddf_channel ch) 37 | { 38 | microkit_deferred_notify(ch); 39 | } 40 | 41 | static inline unsigned int sddf_deferred_notify_curr() 42 | { 43 | if (!microkit_have_signal) { 44 | return -1; 45 | } 46 | 47 | return microkit_signal_cap - BASE_OUTPUT_NOTIFICATION_CAP; 48 | } 49 | 50 | static inline microkit_msginfo sddf_ppcall(sddf_channel ch, microkit_msginfo msginfo) 51 | { 52 | return microkit_ppcall(ch, msginfo); 53 | } 54 | 55 | static inline uint64_t sddf_get_mr(unsigned int n) 56 | { 57 | return seL4_GetMR(n); 58 | } 59 | 60 | static inline void sddf_set_mr(unsigned int n, uint64_t val) 61 | { 62 | seL4_SetMR(n, val); 63 | } -------------------------------------------------------------------------------- /include/sddf/benchmark/bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | struct bench { 11 | uint64_t ccount; 12 | uint64_t prev; 13 | uint64_t ts; 14 | }; 15 | -------------------------------------------------------------------------------- /include/sddf/benchmark/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #define BENCHMARK_MAX_CHILDREN 64 // TODO: Can we have a higher upper bound on this? 12 | 13 | typedef struct benchmark_child_config { 14 | char name[SDDF_NAME_LENGTH]; 15 | uint8_t child_id; 16 | } benchmark_child_config_t; 17 | 18 | typedef struct benchmark_config { 19 | uint8_t start_ch; 20 | uint8_t stop_ch; 21 | uint8_t init_ch; 22 | uint8_t num_children; 23 | benchmark_child_config_t children[BENCHMARK_MAX_CHILDREN]; 24 | } benchmark_config_t; 25 | 26 | typedef struct benchmark_idle_config { 27 | void *cycle_counters; 28 | uint8_t init_channel; 29 | } benchmark_idle_config_t; 30 | 31 | typedef struct benchmark_client_config { 32 | void *cycle_counters; 33 | uint8_t start_ch; 34 | uint8_t stop_ch; 35 | } benchmark_client_config_t; 36 | -------------------------------------------------------------------------------- /include/sddf/blk/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define SDDF_BLK_MAX_CLIENTS 64 17 | 18 | #define SDDF_BLK_MAGIC_LEN 5 19 | static char SDDF_BLK_MAGIC[SDDF_BLK_MAGIC_LEN] = { 's', 'D', 'D', 'F', 0x2 }; 20 | 21 | typedef struct blk_connection_resource { 22 | region_resource_t storage_info; 23 | region_resource_t req_queue; 24 | region_resource_t resp_queue; 25 | uint16_t num_buffers; 26 | uint8_t id; 27 | } blk_connection_resource_t; 28 | 29 | typedef struct blk_driver_config { 30 | char magic[SDDF_BLK_MAGIC_LEN]; 31 | blk_connection_resource_t virt; 32 | } blk_driver_config_t; 33 | 34 | typedef struct blk_virt_config_client { 35 | blk_connection_resource_t conn; 36 | device_region_resource_t data; 37 | uint32_t partition; 38 | } blk_virt_config_client_t; 39 | 40 | typedef struct blk_virt_config_driver { 41 | blk_connection_resource_t conn; 42 | device_region_resource_t data; 43 | } blk_virt_config_driver_t; 44 | 45 | typedef struct blk_virt_config { 46 | char magic[SDDF_BLK_MAGIC_LEN]; 47 | uint64_t num_clients; 48 | blk_virt_config_driver_t driver; 49 | blk_virt_config_client_t clients[SDDF_BLK_MAX_CLIENTS]; 50 | } blk_virt_config_t; 51 | 52 | typedef struct blk_client_config { 53 | char magic[SDDF_BLK_MAGIC_LEN]; 54 | blk_connection_resource_t virt; 55 | region_resource_t data; 56 | } blk_client_config_t; 57 | 58 | static bool blk_config_check_magic(void *config) 59 | { 60 | char *magic = (char *)config; 61 | for (int i = 0; i < SDDF_BLK_MAGIC_LEN; i++) { 62 | if (magic[i] != SDDF_BLK_MAGIC[i]) { 63 | return false; 64 | } 65 | } 66 | 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /include/sddf/blk/storage_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #define BLK_STORAGE_INFO_REGION_SIZE 0x1000 13 | 14 | /* Device serial number max string length */ 15 | #define BLK_MAX_SERIAL_NUMBER 63 16 | 17 | typedef struct blk_storage_info { 18 | char serial_number[BLK_MAX_SERIAL_NUMBER + 1]; 19 | /* device does not accept write requests */ 20 | bool read_only; 21 | /* whether this configuration is populated yet */ 22 | bool ready; 23 | /* size of a sector, in bytes */ 24 | uint16_t sector_size; 25 | /* optimal block size, specified in BLK_TRANSFER_SIZE sized units */ 26 | uint16_t block_size; 27 | uint16_t queue_depth; 28 | /* geometry to guide FS layout */ 29 | uint16_t cylinders, heads, blocks; 30 | /* total capacity of the device, specified in BLK_TRANSFER_SIZE sized units. */ 31 | uint64_t capacity; 32 | } blk_storage_info_t; 33 | _Static_assert(sizeof(blk_storage_info_t) <= BLK_STORAGE_INFO_REGION_SIZE, 34 | "struct blk_storage_info must be smaller than the region size"); 35 | 36 | /** 37 | * Load from shared memory whether the block storage device is ready. 38 | * This does an atomic acquire operation. 39 | * 40 | * @param storage_info the block storage device to check 41 | * @return true the block storage device is ready to use 42 | * @return false the block storage device is not ready (removed, or initialising) 43 | */ 44 | static inline bool blk_storage_is_ready(blk_storage_info_t *storage_info) 45 | { 46 | return __atomic_load_n(&storage_info->ready, __ATOMIC_ACQUIRE); 47 | } 48 | 49 | /** 50 | * Set shared memory whether the block storage device is ready. 51 | * This does an atomic release operation. 52 | */ 53 | static inline void blk_storage_set_ready(blk_storage_info_t *storage_info, bool ready) 54 | { 55 | __atomic_store_n(&storage_info->ready, ready, __ATOMIC_RELEASE); 56 | } 57 | -------------------------------------------------------------------------------- /include/sddf/gpu/events.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #define GPU_EVENTS_REGION_SIZE 0x1000 12 | 13 | typedef struct gpu_events_t { 14 | bool display_info; 15 | } gpu_events_t; 16 | 17 | /** 18 | * Set a display info event. 19 | * 20 | * @param h queue handle containing events. 21 | */ 22 | static inline void gpu_events_set_display_info(gpu_events_t *events) 23 | { 24 | __atomic_store_n(&events->display_info, true, __ATOMIC_RELEASE); 25 | } 26 | 27 | /** 28 | * Clear a display info event. 29 | * 30 | * @param h queue handle containing events. 31 | */ 32 | static inline void gpu_events_clear_display_info(gpu_events_t *events) 33 | { 34 | __atomic_store_n(&events->display_info, false, __ATOMIC_RELEASE); 35 | } 36 | 37 | /** 38 | * Check if a display info event is set. 39 | * 40 | * @param h queue handle containing events. 41 | * 42 | * @return true if display info event is set, false otherwise. 43 | */ 44 | static inline bool gpu_events_check_display_info(gpu_events_t *events) 45 | { 46 | return __atomic_load_n(&events->display_info, __ATOMIC_ACQUIRE); 47 | } 48 | -------------------------------------------------------------------------------- /include/sddf/i2c/client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /* By default we assume a 7-bit bus address. */ 13 | #ifndef I2C_BUS_ADDRESS_MAX 14 | #define I2C_BUS_ADDRESS_MAX (0x7f) 15 | #endif 16 | 17 | #define I2C_BUS_SLOT (0) 18 | 19 | /* Protected-Procedure-Call function idenitifers */ 20 | #define I2C_BUS_CLAIM (1) 21 | #define I2C_BUS_RELEASE (2) 22 | 23 | /* This is the label of the PPC response from the virtualiser */ 24 | #define I2C_SUCCESS (0) 25 | #define I2C_FAILURE (1) 26 | 27 | /* Helpers for interacting with the virutaliser. */ 28 | static inline bool i2c_bus_claim(microkit_channel virt_ch, size_t bus_address) 29 | { 30 | microkit_msginfo msginfo = microkit_msginfo_new(I2C_BUS_CLAIM, 1); 31 | microkit_mr_set(I2C_BUS_SLOT, bus_address); 32 | msginfo = microkit_ppcall(virt_ch, msginfo); 33 | 34 | return microkit_msginfo_get_label(msginfo) == I2C_SUCCESS; 35 | } 36 | 37 | static inline bool i2c_bus_release(microkit_channel virt_ch, size_t bus_address) 38 | { 39 | microkit_msginfo msginfo = microkit_msginfo_new(I2C_BUS_RELEASE, 1); 40 | microkit_mr_set(I2C_BUS_SLOT, bus_address); 41 | msginfo = microkit_ppcall(virt_ch, msginfo); 42 | 43 | return microkit_msginfo_get_label(msginfo) == I2C_SUCCESS; 44 | } 45 | -------------------------------------------------------------------------------- /include/sddf/i2c/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define SDDF_I2C_MAX_CLIENTS 64 16 | 17 | #define SDDF_I2C_MAGIC_LEN 5 18 | static char SDDF_I2C_MAGIC[SDDF_I2C_MAGIC_LEN] = { 's', 'D', 'D', 'F', 0x4 }; 19 | 20 | typedef struct i2c_connection_resource { 21 | region_resource_t data; 22 | region_resource_t req_queue; 23 | region_resource_t resp_queue; 24 | uint16_t num_buffers; 25 | uint8_t id; 26 | } i2c_connection_resource_t; 27 | 28 | typedef struct i2c_driver_config { 29 | char magic[SDDF_I2C_MAGIC_LEN]; 30 | i2c_connection_resource_t virt; 31 | } i2c_driver_config_t; 32 | 33 | typedef struct i2c_virt_client_config { 34 | i2c_connection_resource_t conn; 35 | uint64_t driver_data_offset; 36 | } i2c_virt_client_config_t; 37 | 38 | typedef struct i2c_virt_driver_config { 39 | i2c_connection_resource_t conn; 40 | } i2c_virt_driver_config_t; 41 | 42 | typedef struct i2c_virt_config { 43 | char magic[SDDF_I2C_MAGIC_LEN]; 44 | uint64_t num_clients; 45 | i2c_virt_driver_config_t driver; 46 | i2c_virt_client_config_t clients[SDDF_I2C_MAX_CLIENTS]; 47 | } i2c_virt_config_t; 48 | 49 | typedef struct i2c_client_config { 50 | char magic[SDDF_I2C_MAGIC_LEN]; 51 | i2c_connection_resource_t virt; 52 | } i2c_client_config_t; 53 | 54 | static bool i2c_config_check_magic(void *config) 55 | { 56 | char *magic = (char *)config; 57 | for (int i = 0; i < SDDF_I2C_MAGIC_LEN; i++) { 58 | if (magic[i] != SDDF_I2C_MAGIC[i]) { 59 | return false; 60 | } 61 | } 62 | 63 | return true; 64 | } 65 | -------------------------------------------------------------------------------- /include/sddf/i2c/devices/pn532/pn532.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define PN532_I2C_BUS_ADDRESS (0x48 >> 1) 13 | 14 | #define PN532_PREAMBLE (0x00) 15 | #define PN532_STARTCODE1 (0x00) 16 | #define PN532_STARTCODE2 (0xFF) 17 | #define PN532_POSTAMBLE (0x00) 18 | #define PN532_PREAMBLE_LEN (3) 19 | #define PN532_DATA_CHK_LEN (2) 20 | #define PN532_POSTAMBLE_LEN (1) 21 | 22 | #define PN532_HOSTTOPN532 (0xD4) 23 | #define PN532_PN532TOHOST (0xD5) 24 | 25 | #define PN532_CMD_GETFIRMWAREVERSION (0x02) 26 | #define PN532_CMD_SAMCONFIGURATION (0x14) 27 | #define PN532_CMD_RFCONFIGURATION (0x32) 28 | #define PN532_CMD_INLISTPASSIVETARGET (0x4A) 29 | 30 | #define PN532_MIFARE_ISO14443A (0x00) 31 | 32 | uint8_t pn532_write_command(uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen, size_t retries); 33 | uint8_t pn532_read_response(uint8_t *buffer, uint8_t buffer_len, size_t retries); 34 | -------------------------------------------------------------------------------- /include/sddf/network/arp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | bool arp_register_ipv4(microkit_channel arp_ch, uint32_t ipv4_addr, uint8_t mac[6]) 11 | { 12 | microkit_mr_set(0, ipv4_addr); 13 | microkit_mr_set(1, (mac[0] << 8) | mac[1]); 14 | microkit_mr_set(2, (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]); 15 | microkit_ppcall(arp_ch, microkit_msginfo_new(0, 3)); 16 | 17 | return true; 18 | } 19 | -------------------------------------------------------------------------------- /include/sddf/network/constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #define ETH_TYPE_ARP 0x0806U 12 | #define ETH_TYPE_IP 0x0800U 13 | #define ETH_HWADDR_LEN 6 14 | #define ETHARP_OPCODE_REQUEST 1 15 | #define ETHARP_OPCODE_REPLY 2 16 | 17 | #define NET_BUFFER_SIZE 2048 18 | 19 | struct ethernet_address { 20 | uint8_t addr[6]; 21 | } __attribute__((packed)); 22 | 23 | struct ethernet_header { 24 | struct ethernet_address dest; 25 | struct ethernet_address src; 26 | uint16_t type; 27 | } __attribute__((packed)); 28 | 29 | /* 30 | * By default we assume that the hardware we are dealing with 31 | * cannot generate checksums on transmit. We use this macro 32 | * to know whether to calculate it in the IP stack. 33 | */ 34 | #if defined(CONFIG_PLAT_IMX8MM_EVK) || defined(CONFIG_PLAT_MAAXBOARD) || defined(CONFIG_PLAT_IMX8MP_EVK) 35 | #define NETWORK_HW_HAS_CHECKSUM 36 | #endif 37 | -------------------------------------------------------------------------------- /include/sddf/network/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #if BYTE_ORDER == BIG_ENDIAN 12 | #define HTONS(x) ((uint16_t)(x)) 13 | #else 14 | #define HTONS(x) ((uint16_t)((((x) & (uint16_t)0x00ffU) << 8) | (((x) & (uint16_t)0xff00U) >> 8))) 15 | #endif 16 | 17 | static void net_set_mac_addr(uint8_t *mac, uint64_t val) 18 | { 19 | mac[0] = val >> 40 & 0xff; 20 | mac[1] = val >> 32 & 0xff; 21 | mac[2] = val >> 24 & 0xff; 22 | mac[3] = val >> 16 & 0xff; 23 | mac[4] = val >> 8 & 0xff; 24 | mac[5] = val & 0xff; 25 | } -------------------------------------------------------------------------------- /include/sddf/resources/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | typedef struct region_resource { 12 | void *vaddr; 13 | uint64_t size; 14 | } region_resource_t; 15 | -------------------------------------------------------------------------------- /include/sddf/resources/device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #define DEVICE_MAGIC_LEN 5 14 | static char DEVICE_MAGIC[DEVICE_MAGIC_LEN] = { 's', 'D', 'D', 'F', 0x1 }; 15 | 16 | #define DEVICE_MAX_REGIONS 64 17 | #define DEVICE_MAX_IRQS 64 18 | 19 | typedef struct device_region_resource { 20 | region_resource_t region; 21 | uintptr_t io_addr; 22 | } device_region_resource_t; 23 | 24 | typedef struct device_irq_resource { 25 | uint8_t id; 26 | } device_irq_resource_t; 27 | 28 | typedef struct device_resources { 29 | char magic[5]; 30 | uint8_t num_regions; 31 | uint8_t num_irqs; 32 | device_region_resource_t regions[DEVICE_MAX_REGIONS]; 33 | device_irq_resource_t irqs[DEVICE_MAX_IRQS]; 34 | } device_resources_t; 35 | 36 | static bool device_resources_check_magic(device_resources_t *device) 37 | { 38 | for (int i = 0; i < DEVICE_MAGIC_LEN; i++) { 39 | if (device->magic[i] != DEVICE_MAGIC[i]) { 40 | return false; 41 | } 42 | } 43 | 44 | return true; 45 | } 46 | -------------------------------------------------------------------------------- /include/sddf/serial/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define SDDF_SERIAL_MAX_CLIENTS 64 14 | #define SDDF_SERIAL_BEGIN_STR_MAX_LEN 128 15 | 16 | #define SDDF_SERIAL_MAGIC_LEN 5 17 | static char SDDF_SERIAL_MAGIC[SDDF_SERIAL_MAGIC_LEN] = { 's', 'D', 'D', 'F', 0x3 }; 18 | 19 | typedef struct serial_connection_resource { 20 | region_resource_t queue; 21 | region_resource_t data; 22 | uint8_t id; 23 | } serial_connection_resource_t; 24 | 25 | typedef struct serial_driver_config { 26 | char magic[SDDF_SERIAL_MAGIC_LEN]; 27 | serial_connection_resource_t rx; 28 | serial_connection_resource_t tx; 29 | uint64_t default_baud; 30 | bool rx_enabled; 31 | } serial_driver_config_t; 32 | 33 | typedef struct serial_virt_rx_config { 34 | char magic[SDDF_SERIAL_MAGIC_LEN]; 35 | serial_connection_resource_t driver; 36 | serial_connection_resource_t clients[SDDF_SERIAL_MAX_CLIENTS]; 37 | uint8_t num_clients; 38 | char switch_char; 39 | char terminate_num_char; 40 | } serial_virt_rx_config_t; 41 | 42 | typedef struct serial_virt_tx_client_config { 43 | serial_connection_resource_t conn; 44 | char name[SDDF_NAME_LENGTH]; 45 | } serial_virt_tx_client_config_t; 46 | 47 | typedef struct serial_virt_tx_config { 48 | char magic[SDDF_SERIAL_MAGIC_LEN]; 49 | serial_connection_resource_t driver; 50 | serial_virt_tx_client_config_t clients[SDDF_SERIAL_MAX_CLIENTS]; 51 | uint8_t num_clients; 52 | char begin_str[SDDF_SERIAL_BEGIN_STR_MAX_LEN]; 53 | bool enable_colour; 54 | bool enable_rx; 55 | } serial_virt_tx_config_t; 56 | 57 | typedef struct serial_client_config { 58 | char magic[SDDF_SERIAL_MAGIC_LEN]; 59 | serial_connection_resource_t rx; 60 | serial_connection_resource_t tx; 61 | } serial_client_config_t; 62 | 63 | static bool serial_config_check_magic(void *config) 64 | { 65 | char *magic = (char *)config; 66 | for (int i = 0; i < SDDF_SERIAL_MAGIC_LEN; i++) { 67 | if (magic[i] != SDDF_SERIAL_MAGIC[i]) { 68 | return false; 69 | } 70 | } 71 | 72 | return true; 73 | } 74 | -------------------------------------------------------------------------------- /include/sddf/sound/sound.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | typedef enum { 12 | SOUND_D_OUTPUT = 0, 13 | SOUND_D_INPUT 14 | } sound_direction_t; 15 | 16 | // Supported PCM sample formats 17 | typedef enum { 18 | // Analog formats (width / physical width) 19 | SOUND_PCM_FMT_IMA_ADPCM = 0, /* 4 / 4 bits */ 20 | SOUND_PCM_FMT_MU_LAW, /* 8 / 8 bits */ 21 | SOUND_PCM_FMT_A_LAW, /* 8 / 8 bits */ 22 | SOUND_PCM_FMT_S8, /* 8 / 8 bits */ 23 | SOUND_PCM_FMT_U8, /* 8 / 8 bits */ 24 | SOUND_PCM_FMT_S16, /* 16 / 16 bits */ 25 | SOUND_PCM_FMT_U16, /* 16 / 16 bits */ 26 | SOUND_PCM_FMT_S18_3, /* 18 / 24 bits */ 27 | SOUND_PCM_FMT_U18_3, /* 18 / 24 bits */ 28 | SOUND_PCM_FMT_S20_3, /* 20 / 24 bits */ 29 | SOUND_PCM_FMT_U20_3, /* 20 / 24 bits */ 30 | SOUND_PCM_FMT_S24_3, /* 24 / 24 bits */ 31 | SOUND_PCM_FMT_U24_3, /* 24 / 24 bits */ 32 | SOUND_PCM_FMT_S20, /* 20 / 32 bits */ 33 | SOUND_PCM_FMT_U20, /* 20 / 32 bits */ 34 | SOUND_PCM_FMT_S24, /* 24 / 32 bits */ 35 | SOUND_PCM_FMT_U24, /* 24 / 32 bits */ 36 | SOUND_PCM_FMT_S32, /* 32 / 32 bits */ 37 | SOUND_PCM_FMT_U32, /* 32 / 32 bits */ 38 | SOUND_PCM_FMT_FLOAT, /* 32 / 32 bits */ 39 | SOUND_PCM_FMT_FLOAT64, /* 64 / 64 bits */ 40 | // Digital formats (width / physical width) 41 | SOUND_PCM_FMT_DSD_U8, /* 8 / 8 bits */ 42 | SOUND_PCM_FMT_DSD_U16, /* 16 / 16 bits */ 43 | SOUND_PCM_FMT_DSD_U32, /* 32 / 32 bits */ 44 | SOUND_PCM_FMT_IEC958_SUBFRAME /* 32 / 32 bits */ 45 | } sound_pcm_fmt_t; 46 | 47 | // Supported PCM frame rates 48 | typedef enum { 49 | SOUND_PCM_RATE_5512 = 0, 50 | SOUND_PCM_RATE_8000, 51 | SOUND_PCM_RATE_11025, 52 | SOUND_PCM_RATE_16000, 53 | SOUND_PCM_RATE_22050, 54 | SOUND_PCM_RATE_32000, 55 | SOUND_PCM_RATE_44100, 56 | SOUND_PCM_RATE_48000, 57 | SOUND_PCM_RATE_64000, 58 | SOUND_PCM_RATE_88200, 59 | SOUND_PCM_RATE_96000, 60 | SOUND_PCM_RATE_176400, 61 | SOUND_PCM_RATE_192000, 62 | SOUND_PCM_RATE_384000 63 | } sound_pcm_rate_t; 64 | 65 | typedef struct sound_pcm_info { 66 | uint64_t formats; /* 1 << SOUND_PCM_FMT_XXX */ 67 | uint64_t rates; /* 1 << SOUND_PCM_RATE_XXX */ 68 | uint8_t direction; 69 | uint8_t channels_min; 70 | uint8_t channels_max; 71 | } sound_pcm_info_t; 72 | 73 | #define SOUND_MAX_STREAM_COUNT 32 74 | 75 | typedef struct sound_shared_state { 76 | bool ready; 77 | uint32_t streams; 78 | sound_pcm_info_t stream_info[SOUND_MAX_STREAM_COUNT]; 79 | } sound_shared_state_t; 80 | -------------------------------------------------------------------------------- /include/sddf/timer/client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * Request a timeout via PPC into the passive timer driver. 14 | * Use the label to indicate this request. 15 | * @param microkit channel of timer driver. 16 | * @param timeout relative timeout in nanoseconds. 17 | */ 18 | static inline void sddf_timer_set_timeout(unsigned int channel, uint64_t timeout) 19 | { 20 | sddf_set_mr(0, timeout); 21 | sddf_ppcall(channel, seL4_MessageInfo_new(SDDF_TIMER_SET_TIMEOUT, 0, 0, 1)); 22 | } 23 | 24 | /** 25 | * Request the time since start up via PPC into the passive timer driver. 26 | * Use the label to indicate this request. 27 | * @param microkit channel of timer driver. 28 | * @return the time in nanoseconds since start up. 29 | */ 30 | static inline uint64_t sddf_timer_time_now(unsigned int channel) 31 | { 32 | sddf_ppcall(channel, seL4_MessageInfo_new(SDDF_TIMER_GET_TIME, 0, 0, 0)); 33 | uint64_t time_now = sddf_get_mr(0); 34 | return time_now; 35 | } 36 | -------------------------------------------------------------------------------- /include/sddf/timer/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025, UNSW 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define SDDF_TIMER_MAX_CLIENTS 64 13 | #define SDDF_TIMER_MAGIC_LEN 5 14 | static char SDDF_TIMER_MAGIC[SDDF_TIMER_MAGIC_LEN] = { 's', 'D', 'D', 'F', 0x6 }; 15 | 16 | typedef struct timer_client_config { 17 | char magic[SDDF_TIMER_MAGIC_LEN]; 18 | uint8_t driver_id; 19 | } timer_client_config_t; 20 | 21 | static bool timer_config_check_magic(void *config) 22 | { 23 | char *magic = (char *)config; 24 | for (int i = 0; i < SDDF_TIMER_MAGIC_LEN; i++) { 25 | if (magic[i] != SDDF_TIMER_MAGIC[i]) { 26 | return false; 27 | } 28 | } 29 | 30 | return true; 31 | } 32 | -------------------------------------------------------------------------------- /include/sddf/timer/protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | /* Shared functionality/definitions between timer drivers and clients */ 9 | 10 | #define SDDF_TIMER_GET_TIME 0 11 | #define SDDF_TIMER_SET_TIMEOUT 1 12 | 13 | /* Number of nanoseconds in a second */ 14 | #define NS_IN_S 1000000000ULL 15 | /* Number of nanoseconds in a millisecond */ 16 | #define NS_IN_MS 1000000ULL 17 | /* Number of nanoseconds in a microsecond */ 18 | #define NS_IN_US 1000ULL 19 | 20 | /* Number of microseconds in a millisecond */ 21 | #define US_IN_MS 1000ULL 22 | /* Number of microseconds in a second */ 23 | #define US_IN_S 1000000ULL 24 | 25 | /* Number of milliseconds in a second */ 26 | #define MS_IN_S 1000ULL 27 | -------------------------------------------------------------------------------- /include/sddf/util/cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #pragma once 7 | 8 | /* 9 | * This is a small utility library for performing cache operations in order 10 | * to deal with DMA cache coherency. On DMA coherent architectures/platforms 11 | * (such as certain RISC-V platforms and x86), these operations are no-ops. 12 | * 13 | * This library currently has the assumption that all RISC-V platforms are 14 | * DMA coherent, it does not support platforms with the Zicbom extension. 15 | */ 16 | 17 | /* 18 | * Cleans and invalidates the from start to end. This is not inclusive. 19 | * If end is on a cache line boundary, the cache line starting at end 20 | * will not be cleaned/invalidated. 21 | * 22 | * On ARM, this operation ultimately performs the 'dc civac' instruction. 23 | * On RISC-V, this is a no-op. 24 | */ 25 | void cache_clean_and_invalidate(unsigned long start, unsigned long end); 26 | 27 | /* 28 | * Cleans from start to end. This is not inclusive. 29 | * If end is on a cache line boundary, the cache line starting at end 30 | * will not be cleanend. 31 | * 32 | * On ARM, this operation ultimately performs the 'dc cvac' instruction. 33 | * On RISC-V, this is a no-op. 34 | */ 35 | void cache_clean(unsigned long start, unsigned long end); 36 | -------------------------------------------------------------------------------- /include/sddf/util/fence.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #pragma once 8 | 9 | /* Prevent the compiler from re-ordering any read or write across the fence. */ 10 | #define COMPILER_MEMORY_FENCE() __atomic_signal_fence(__ATOMIC_ACQ_REL) 11 | 12 | /* Prevent the compiler from re-ordering any write which follows the fence 13 | * in program order with any read or write which preceeds the fence in 14 | * program order. */ 15 | #define COMPILER_MEMORY_RELEASE() __atomic_signal_fence(__ATOMIC_RELEASE) 16 | 17 | /* Prevent the compiler from re-ordering any read which preceeds the fence 18 | * in program order with any read or write which follows the fence in 19 | * program order. */ 20 | #define COMPILER_MEMORY_ACQUIRE() __atomic_signal_fence(__ATOMIC_ACQUIRE) 21 | 22 | /* THREAD_MEMORY_FENCE: Implements a full processor memory barrier. 23 | * All stores before this point are completed, and all loads after this 24 | * point are delayed until after it. 25 | */ 26 | #define THREAD_MEMORY_FENCE() __atomic_thread_fence(__ATOMIC_ACQ_REL) 27 | 28 | /* THREAD_MEMORY_RELEASE: Implements a fence which has the effect of 29 | * forcing all stores before this point to complete. 30 | */ 31 | #define THREAD_MEMORY_RELEASE() __atomic_thread_fence(__ATOMIC_RELEASE) 32 | 33 | /* THREAD_MEMORY_ACQUIRE: Implements a fence which has the effect of 34 | * forcing all loads beyond this point to occur after this point. 35 | */ 36 | #define THREAD_MEMORY_ACQUIRE() __atomic_thread_fence(__ATOMIC_ACQUIRE) 37 | -------------------------------------------------------------------------------- /libco/LICENSE.txt: -------------------------------------------------------------------------------- 1 | ISC License (ISC) 2 | 3 | Copyright byuu and the higan team 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 8 | 9 | The above applies to all files in this project except valgrind.h which is licensed under a BSD-style license. See the license text and copyright notice contained within that file. 10 | -------------------------------------------------------------------------------- /libco/arm.c: -------------------------------------------------------------------------------- 1 | #define LIBCO_C 2 | #include "libco.h" 3 | #include "settings.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | static thread_local unsigned long co_active_buffer[64]; 10 | static thread_local cothread_t co_active_handle = 0; 11 | static void (*co_swap)(cothread_t, cothread_t) = 0; 12 | 13 | section(text) 14 | static const unsigned long co_swap_function[1024] = { 15 | 0xe8a16ff0, /* stmia r1!, {r4-r11,sp,lr} */ 16 | 0xe8b0aff0, /* ldmia r0!, {r4-r11,sp,pc} */ 17 | 0xe12fff1e, /* bx lr */ 18 | }; 19 | 20 | cothread_t co_active() { 21 | if(!co_active_handle) co_active_handle = &co_active_buffer; 22 | return co_active_handle; 23 | } 24 | 25 | cothread_t co_derive(void* memory, unsigned int size, void (*entrypoint)(void)) { 26 | unsigned long* handle; 27 | if(!co_swap) { 28 | co_swap = (void (*)(cothread_t, cothread_t))co_swap_function; 29 | } 30 | if(!co_active_handle) co_active_handle = &co_active_buffer; 31 | 32 | if(handle = (unsigned long*)memory) { 33 | unsigned int offset = (size & ~15); 34 | unsigned long* p = (unsigned long*)((unsigned char*)handle + offset); 35 | handle[8] = (unsigned long)p; 36 | handle[9] = (unsigned long)entrypoint; 37 | } 38 | 39 | return handle; 40 | } 41 | 42 | void co_switch(cothread_t handle) { 43 | cothread_t co_previous_handle = co_active_handle; 44 | co_swap(co_active_handle = handle, co_previous_handle); 45 | } 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /libco/libco.c: -------------------------------------------------------------------------------- 1 | #if defined(__clang__) 2 | #pragma clang diagnostic ignored "-Wparentheses" 3 | 4 | /* placing code in section(text) does not mark it executable with Clang. */ 5 | #undef LIBCO_MPROTECT 6 | #define LIBCO_MPROTECT 7 | #endif 8 | 9 | #if defined(__clang__) || defined(__GNUC__) 10 | #if defined(__amd64__) 11 | #include "amd64.c" 12 | #elif defined(__arm__) 13 | #include "arm.c" 14 | #elif defined(__aarch64__) 15 | #include "aarch64.c" 16 | #else 17 | #error "libco: unsupported processor, compiler or operating system" 18 | #endif 19 | #else 20 | #error "libco: unsupported processor, compiler or operating system" 21 | #endif 22 | -------------------------------------------------------------------------------- /libco/libco.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBCO_H 2 | #define LIBCO_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | typedef void* cothread_t; 9 | 10 | cothread_t co_active(void); 11 | cothread_t co_derive(void*, unsigned int, void (*)(void)); 12 | void co_switch(cothread_t); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | /* ifndef LIBCO_H */ 19 | #endif 20 | -------------------------------------------------------------------------------- /libco/libco.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # Include this make snippet to buid libco,a, a simple coroutine library. 7 | 8 | LIBCO_DIR := $(abspath $(dir $(lastword ${MAKEFILE_LIST}))) 9 | 10 | libco/libco.o: $(LIBCO_DIR)/libco.c ${CHECK_FLAGS_BOARD_MD5} |libco 11 | ${CC} ${CFLAGS} -c -o $@ $< 12 | 13 | libco.a: libco/libco.o 14 | ${AR} crv $@ $^ 15 | ${RANLIB} $@ 16 | 17 | libco: 18 | mkdir -p $@ 19 | 20 | -include libco/libco.d 21 | -------------------------------------------------------------------------------- /libco/settings.h: -------------------------------------------------------------------------------- 1 | #if defined(LIBCO_C) 2 | 3 | #if defined(LIBCO_C) 4 | #if defined(LIBCO_MP) 5 | #define thread_local __thread 6 | #else 7 | #define thread_local 8 | #endif 9 | #endif 10 | 11 | #if __STDC_VERSION__ >= 201112L 12 | #include 13 | #else 14 | #define alignas(bytes) 15 | #endif 16 | 17 | #define section(name) __attribute__((section("." #name "#"))) 18 | 19 | 20 | /* if defined(LIBCO_C) */ 21 | #endif 22 | -------------------------------------------------------------------------------- /network/components/network_components.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # This Makefile snippet builds the network components 7 | # (for example, simple RX and TX virtualisers) 8 | # it should be included into your project Makefile 9 | # 10 | # NOTES: 11 | # Generates network_virt_rx.elf network_virt_tx.elf network_arp.elf network_copy.elf 12 | # Requires ${SDDF}/util/util.mk to build the utility library for debug output 13 | 14 | NETWORK_COMPONENTS_DIR := $(abspath $(dir $(lastword ${MAKEFILE_LIST}))) 15 | NETWORK_IMAGES:= network_virt_rx.elf network_virt_tx.elf network_arp.elf network_copy.elf 16 | network/components/%.o: ${SDDF}/network/components/%.c 17 | ${CC} ${CFLAGS} -c -o $@ $< 18 | 19 | NETWORK_COMPONENT_OBJ := $(addprefix network/components/, network_copy.o network_arp.o network_virt_tx.o network_virt_rx.o) 20 | 21 | CHECK_NETWORK_FLAGS_MD5:=.network_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_network} | shasum | sed 's/ *-//') 22 | 23 | ${CHECK_NETWORK_FLAGS_MD5}: 24 | -rm -f .network_cflags-* 25 | touch $@ 26 | 27 | #vpath %.c ${SDDF}/network/components 28 | 29 | 30 | ${NETWORK_IMAGES}: LIBS := libsddf_util_debug.a ${LIBS} 31 | 32 | ${NETWORK_COMPONENT_OBJ}: |network/components 33 | ${NETWORK_COMPONENT_OBJ}: ${CHECK_NETWORK_FLAGS_MD5} 34 | ${NETWORK_COMPONENT_OBJ}: CFLAGS+=${CFLAGS_network} 35 | 36 | network/components/network_virt_%.o: ${SDDF}/network/components/virt_%.c 37 | ${CC} ${CFLAGS} -c -o $@ $< 38 | 39 | network/components/network_copy.o: ${SDDF}/network/components/copy.c 40 | ${CC} ${CFLAGS} -c -o $@ $< 41 | 42 | network/components/network_arp.o: ${SDDF}/network/components/arp.c 43 | ${CC} ${CFLAGS} -c -o $@ $< 44 | 45 | %.elf: network/components/%.o 46 | ${LD} ${LDFLAGS} -o $@ $< ${LIBS} 47 | 48 | clean:: 49 | ${RM} -f network_virt_[rt]x.[od] network_copy.[od] network_arp.[od] 50 | 51 | clobber:: 52 | ${RM} -f ${NETWORK_IMAGES} 53 | rmdir network/components 54 | 55 | network/components: 56 | mkdir -p $@ 57 | 58 | -include ${NETWORK_COMPONENTS_OBJS:.o=.d} 59 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | project(lwIP) 4 | 5 | set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 6 | include(src/Filelists.cmake) 7 | 8 | # Package generation 9 | set(CPACK_SOURCE_GENERATOR "ZIP") 10 | set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack") 11 | set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}") 12 | set(CPACK_PACKAGE_VERSION_MINOR "${LWIP_VERSION_MINOR}") 13 | set(CPACK_PACKAGE_VERSION_PATCH "${LWIP_VERSION_REVISION}") 14 | set(CPACK_SOURCE_IGNORE_FILES "/build/;${CPACK_SOURCE_IGNORE_FILES};.git") 15 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "lwip-${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}") 16 | include(CPack) 17 | 18 | # Target for package generation 19 | add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) 20 | add_dependencies(dist lwipdocs) 21 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | 34 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/FEATURES: -------------------------------------------------------------------------------- 1 | lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems. 2 | 3 | The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM. 4 | 5 | Main features include: 6 | - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0) 7 | - DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler) 8 | - APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API 9 | - Extended features: IP forwarding over multiple network interfaces 10 | - Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0) 11 | - Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart 12 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/FILES: -------------------------------------------------------------------------------- 1 | src/ - The source code for the lwIP TCP/IP stack. 2 | doc/ - The documentation for lwIP. 3 | test/ - Some code to test whether the sources do what they should. 4 | 5 | See also the FILES file in each subdirectory. 6 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/doc/FILES: -------------------------------------------------------------------------------- 1 | doxygen/ - Configuration files and scripts to create the lwIP doxygen source 2 | documentation (found at http://www.nongnu.org/lwip/) 3 | 4 | savannah.txt - How to obtain the current development source code. 5 | contrib.txt - How to contribute to lwIP as a developer. 6 | rawapi.txt - The documentation for the core API of lwIP. 7 | Also provides an overview about the other APIs and multithreading. 8 | sys_arch.txt - The documentation for a system abstraction layer of lwIP. 9 | ppp.txt - Documentation of the PPP interface for lwIP. 10 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/doc/ZeroCopyRx.c: -------------------------------------------------------------------------------- 1 | typedef struct my_custom_pbuf 2 | { 3 | struct pbuf_custom p; 4 | void* dma_descriptor; 5 | } my_custom_pbuf_t; 6 | 7 | LWIP_MEMPOOL_DECLARE(RX_POOL, 10, sizeof(my_custom_pbuf_t), "Zero-copy RX PBUF pool"); 8 | 9 | void my_pbuf_free_custom(void* p) 10 | { 11 | SYS_ARCH_DECL_PROTECT(old_level); 12 | 13 | my_custom_pbuf_t* my_puf = (my_custom_pbuf_t*)p; 14 | 15 | // invalidate data cache here - lwIP and/or application may have written into buffer! 16 | // (invalidate is faster than flushing, and noone needs the correct data in the buffer) 17 | invalidate_cpu_cache(p->payload, p->tot_len); 18 | 19 | SYS_ARCH_PROTECT(old_level); 20 | free_rx_dma_descriptor(my_pbuf->dma_descriptor); 21 | LWIP_MEMPOOL_FREE(RX_POOL, my_pbuf); 22 | SYS_ARCH_UNPROTECT(old_level); 23 | } 24 | 25 | void eth_rx_irq() 26 | { 27 | dma_descriptor* dma_desc = get_RX_DMA_descriptor_from_ethernet(); 28 | my_custom_pbuf_t* my_pbuf = (my_custom_pbuf_t*)LWIP_MEMPOOL_ALLOC(RX_POOL); 29 | 30 | my_pbuf->p.custom_free_function = my_pbuf_free_custom; 31 | my_pbuf->dma_descriptor = dma_desc; 32 | 33 | invalidate_cpu_cache(dma_desc->rx_data, dma_desc->rx_length); 34 | 35 | struct pbuf* p = pbuf_alloced_custom(PBUF_RAW, 36 | dma_desc->rx_length, 37 | PBUF_REF, 38 | &my_pbuf->p, 39 | dma_desc->rx_data, 40 | dma_desc->max_buffer_size); 41 | 42 | if(netif->input(p, netif) != ERR_OK) { 43 | pbuf_free(p); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/doc/doxygen/generate.bat: -------------------------------------------------------------------------------- 1 | doxygen lwip.Doxyfile 2 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/doc/doxygen/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | doxygen lwip.Doxyfile 4 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/doc/doxygen/output/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirection 5 | 6 | 7 | 8 | index.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/FILES: -------------------------------------------------------------------------------- 1 | api/ - The code for the high-level wrapper API. Not needed if 2 | you use the lowel-level call-back/raw API. 3 | 4 | apps/ - Higher layer applications that are specifically programmed 5 | with the lwIP low-level raw API. 6 | 7 | core/ - The core of the TPC/IP stack; protocol implementations, 8 | memory and buffer management, and the low-level raw API. 9 | 10 | include/ - lwIP include files. 11 | 12 | netif/ - Generic network interface device drivers are kept here. 13 | 14 | For more information on the various subdirectories, check the FILES 15 | file in each directory. 16 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/apps/http/fs/404.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 19 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

404 - Page not found

12 |

13 | Sorry, the page you are requesting was not found on this 14 | server. 15 |

16 |
17 |   18 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/apps/http/fs/img/sics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/src/apps/http/fs/img/sics.gif -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/apps/http/fs/index.html: -------------------------------------------------------------------------------- 1 | 2 | lwIP - A Lightweight TCP/IP Stack 3 | 4 | 5 | 6 | 44 |
7 | SICS logo 9 | 10 |

lwIP - A Lightweight TCP/IP Stack

11 |

12 | The web page you are watching was served by a simple web 13 | server running on top of the lightweight TCP/IP stack lwIP. 15 |

16 |

17 | lwIP is an open source implementation of the TCP/IP 18 | protocol suite that was originally written by Adam Dunkels 20 | of the Swedish Institute of Computer Science but now is 21 | being actively developed by a team of developers 22 | distributed world-wide. Since it's release, lwIP has 23 | spurred a lot of interest and has been ported to several 24 | platforms and operating systems. lwIP can be used either 25 | with or without an underlying OS. 26 |

27 |

28 | The focus of the lwIP TCP/IP implementation is to reduce 29 | the RAM usage while still having a full scale TCP. This 30 | makes lwIP suitable for use in embedded systems with tens 31 | of kilobytes of free RAM and room for around 40 kilobytes 32 | of code ROM. 33 |

34 |

35 | More information about lwIP can be found at the lwIP 36 | homepage at http://savannah.nongnu.org/projects/lwip/ 38 | or at the lwIP wiki at http://lwip.wikia.com/. 40 |

41 |
42 |   43 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/apps/http/fsdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef LWIP_FSDATA_H 33 | #define LWIP_FSDATA_H 34 | 35 | #include "lwip/apps/httpd_opts.h" 36 | #include "lwip/apps/fs.h" 37 | 38 | /* THIS FILE IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE */ 39 | /* content was moved to fs.h to simplify #include structure */ 40 | 41 | #endif /* LWIP_FSDATA_H */ 42 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/apps/http/makefsdata/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains a script ('makefsdata') to create C code suitable for 2 | httpd for given html pages (or other files) in a directory. 3 | 4 | There is also a plain C console application doing the same and extended a bit. 5 | 6 | Usage: htmlgen [targetdir] [-s] [-i]s 7 | targetdir: relative or absolute path to files to convert 8 | switch -s: toggle processing of subdirectories (default is on) 9 | switch -e: exclude HTTP header from file (header is created at runtime, default is on) 10 | switch -11: include HTTP 1.1 header (1.0 is default) 11 | 12 | if targetdir not specified, makefsdata will attempt to 13 | process files in subdirectory 'fs'. 14 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/core/ipv6/inet6.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * INET v6 addresses. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #include "lwip/opt.h" 43 | 44 | #if LWIP_IPV6 && LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ 45 | 46 | #include "lwip/def.h" 47 | #include "lwip/inet.h" 48 | 49 | /** This variable is initialized by the system to contain the wildcard IPv6 address. 50 | */ 51 | const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; 52 | 53 | #endif /* LWIP_IPV6 */ 54 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/compat/posix/arpa/inet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/compat/posix/net/if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/if_api.h. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | */ 35 | 36 | #include "lwip/if_api.h" 37 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/compat/posix/netdb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/netdb.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/netdb.h" 34 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/compat/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix wrapper for lwip/sockets.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/sockets.h" 34 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/compat/stdc/errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * This file is a posix/stdc wrapper for lwip/errno.h. 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | 33 | #include "lwip/errno.h" 34 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/apps/FILES: -------------------------------------------------------------------------------- 1 | This directory contains application headers. 2 | Every application shall provide one api file APP.h and optionally one options file APP_opts.h 3 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/apps/netbiosns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * NETBIOS name service responder 4 | */ 5 | 6 | /* 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | */ 32 | #ifndef LWIP_HDR_APPS_NETBIOS_H 33 | #define LWIP_HDR_APPS_NETBIOS_H 34 | 35 | #include "lwip/apps/netbiosns_opts.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | void netbiosns_init(void); 42 | #ifndef NETBIOS_LWIP_NAME 43 | void netbiosns_set_name(const char* hostname); 44 | #endif 45 | void netbiosns_stop(void); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* LWIP_HDR_APPS_NETBIOS_H */ 52 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/apps/smtp_opts.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_APPS_SMTP_OPTS_H 2 | #define LWIP_HDR_APPS_SMTP_OPTS_H 3 | 4 | #include "lwip/opt.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /** 11 | * @defgroup smtp_opts Options 12 | * @ingroup smtp 13 | * 14 | * @{ 15 | */ 16 | 17 | /** Set this to 1 to enable data handler callback on BODY */ 18 | #ifndef SMTP_BODYDH 19 | #define SMTP_BODYDH 0 20 | #endif 21 | 22 | /** SMTP_DEBUG: Enable debugging for SNTP. */ 23 | #ifndef SMTP_DEBUG 24 | #define SMTP_DEBUG LWIP_DBG_OFF 25 | #endif 26 | 27 | /** Maximum length reserved for server name including terminating 0 byte */ 28 | #ifndef SMTP_MAX_SERVERNAME_LEN 29 | #define SMTP_MAX_SERVERNAME_LEN 256 30 | #endif 31 | 32 | /** Maximum length reserved for username */ 33 | #ifndef SMTP_MAX_USERNAME_LEN 34 | #define SMTP_MAX_USERNAME_LEN 32 35 | #endif 36 | 37 | /** Maximum length reserved for password */ 38 | #ifndef SMTP_MAX_PASS_LEN 39 | #define SMTP_MAX_PASS_LEN 32 40 | #endif 41 | 42 | /** Set this to 0 if you know the authentication data will not change 43 | * during the smtp session, which saves some heap space. */ 44 | #ifndef SMTP_COPY_AUTHDATA 45 | #define SMTP_COPY_AUTHDATA 1 46 | #endif 47 | 48 | /** Set this to 0 to save some code space if you know for sure that all data 49 | * passed to this module conforms to the requirements in the SMTP RFC. 50 | * WARNING: use this with care! 51 | */ 52 | #ifndef SMTP_CHECK_DATA 53 | #define SMTP_CHECK_DATA 1 54 | #endif 55 | 56 | /** Set this to 1 to enable AUTH PLAIN support */ 57 | #ifndef SMTP_SUPPORT_AUTH_PLAIN 58 | #define SMTP_SUPPORT_AUTH_PLAIN 1 59 | #endif 60 | 61 | /** Set this to 1 to enable AUTH LOGIN support */ 62 | #ifndef SMTP_SUPPORT_AUTH_LOGIN 63 | #define SMTP_SUPPORT_AUTH_LOGIN 1 64 | #endif 65 | 66 | /* Memory allocation/deallocation can be overridden... */ 67 | #ifndef SMTP_STATE_MALLOC 68 | #define SMTP_STATE_MALLOC(size) mem_malloc(size) 69 | #define SMTP_STATE_FREE(ptr) mem_free(ptr) 70 | #endif 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* SMTP_OPTS_H */ 81 | 82 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/apps/snmp_snmpv2_framework.h: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by LwipMibCompiler 3 | */ 4 | 5 | #ifndef LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H 6 | #define LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H 7 | 8 | #include "lwip/apps/snmp_opts.h" 9 | #if LWIP_SNMP 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #include "lwip/apps/snmp_core.h" 16 | 17 | extern const struct snmp_obj_id usmNoAuthProtocol; 18 | extern const struct snmp_obj_id usmHMACMD5AuthProtocol; 19 | extern const struct snmp_obj_id usmHMACSHAAuthProtocol; 20 | 21 | extern const struct snmp_obj_id usmNoPrivProtocol; 22 | extern const struct snmp_obj_id usmDESPrivProtocol; 23 | extern const struct snmp_obj_id usmAESPrivProtocol; 24 | 25 | extern const struct snmp_mib snmpframeworkmib; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif /* __cplusplus */ 30 | 31 | #endif /* LWIP_SNMP */ 32 | #endif /* LWIP_HDR_APPS_SNMP_FRAMEWORK_MIB_H */ 33 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/apps/snmp_snmpv2_usm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Generated by LwipMibCompiler 3 | */ 4 | 5 | #ifndef LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H 6 | #define LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H 7 | 8 | #include "lwip/apps/snmp_opts.h" 9 | #if LWIP_SNMP 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif /* __cplusplus */ 14 | 15 | #include "lwip/apps/snmp_core.h" 16 | 17 | extern const struct snmp_mib snmpusmmib; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif /* __cplusplus */ 22 | 23 | #endif /* LWIP_SNMP */ 24 | #endif /* LWIP_HDR_APPS_SNMP_USER_BASED_SM_MIB_H */ 25 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/ethip6.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * Ethernet output for IPv6. Uses ND tables for link-layer addressing. 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2010 Inico Technologies Ltd. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Ivan Delamer 36 | * 37 | * 38 | * Please coordinate changes and requests with Ivan Delamer 39 | * 40 | */ 41 | 42 | #ifndef LWIP_HDR_ETHIP6_H 43 | #define LWIP_HDR_ETHIP6_H 44 | 45 | #include "lwip/opt.h" 46 | 47 | #if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ 48 | 49 | #include "lwip/pbuf.h" 50 | #include "lwip/ip6.h" 51 | #include "lwip/ip6_addr.h" 52 | #include "lwip/netif.h" 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | 60 | err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* LWIP_IPV6 && LWIP_ETHERNET */ 67 | 68 | #endif /* LWIP_HDR_ETHIP6_H */ 69 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/prot/ip.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * IP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_IP_H 38 | #define LWIP_HDR_PROT_IP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define IP_PROTO_ICMP 1 47 | #define IP_PROTO_IGMP 2 48 | #define IP_PROTO_UDP 17 49 | #define IP_PROTO_UDPLITE 136 50 | #define IP_PROTO_TCP 6 51 | 52 | /** This operates on a void* by loading the first byte */ 53 | #define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4) 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* LWIP_HDR_PROT_IP_H */ 60 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/lwip/prot/udp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * UDP protocol definitions 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * This file is part of the lwIP TCP/IP stack. 33 | * 34 | * Author: Adam Dunkels 35 | * 36 | */ 37 | #ifndef LWIP_HDR_PROT_UDP_H 38 | #define LWIP_HDR_PROT_UDP_H 39 | 40 | #include "lwip/arch.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define UDP_HLEN 8 47 | 48 | /* Fields are (of course) in network byte order. */ 49 | #ifdef PACK_STRUCT_USE_INCLUDES 50 | # include "arch/bpstruct.h" 51 | #endif 52 | PACK_STRUCT_BEGIN 53 | struct udp_hdr { 54 | PACK_STRUCT_FIELD(u16_t src); 55 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ 56 | PACK_STRUCT_FIELD(u16_t len); 57 | PACK_STRUCT_FIELD(u16_t chksum); 58 | } PACK_STRUCT_STRUCT; 59 | PACK_STRUCT_END 60 | #ifdef PACK_STRUCT_USE_INCLUDES 61 | # include "arch/epstruct.h" 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* LWIP_HDR_PROT_UDP_H */ 69 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/netif/etharp.h: -------------------------------------------------------------------------------- 1 | /* ARP has been moved to core/ipv4, provide this #include for compatibility only */ 2 | #include "lwip/etharp.h" 3 | #include "netif/ethernet.h" 4 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/netif/ppp/chap-md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap-md5.h - New CHAP/MD5 implementation. 3 | * 4 | * Copyright (c) 2003 Paul Mackerras. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. The name(s) of the authors of this software must not be used to 14 | * endorse or promote products derived from this software without 15 | * prior written permission. 16 | * 17 | * 3. Redistributions of any form whatsoever must retain the following 18 | * acknowledgment: 19 | * "This product includes software developed by Paul Mackerras 20 | * ". 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | */ 30 | 31 | #include "netif/ppp/ppp_opts.h" 32 | #if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 33 | 34 | extern const struct chap_digest_type md5_digest; 35 | 36 | #endif /* PPP_SUPPORT && CHAP_SUPPORT */ 37 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/netif/ppp/chap_ms.h: -------------------------------------------------------------------------------- 1 | /* 2 | * chap_ms.h - Challenge Handshake Authentication Protocol definitions. 3 | * 4 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 23 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 24 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 25 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 26 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 27 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 28 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 35 | 36 | #ifndef CHAPMS_INCLUDE 37 | #define CHAPMS_INCLUDE 38 | 39 | extern const struct chap_digest_type chapms_digest; 40 | extern const struct chap_digest_type chapms2_digest; 41 | 42 | #endif /* CHAPMS_INCLUDE */ 43 | 44 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 45 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/include/netif/ppp/ecp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ecp.h - Definitions for PPP Encryption Control Protocol. 3 | * 4 | * Copyright (c) 2002 Google, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. The name(s) of the authors of this software must not be used to 20 | * endorse or promote products derived from this software without 21 | * prior written permission. 22 | * 23 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 24 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 25 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 27 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 28 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 29 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 30 | * 31 | * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ 32 | */ 33 | 34 | #include "netif/ppp/ppp_opts.h" 35 | #if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 36 | 37 | #ifndef ECP_H 38 | #define ECP_H 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef struct ecp_options { 45 | bool required; /* Is ECP required? */ 46 | unsigned enctype; /* Encryption type */ 47 | } ecp_options; 48 | 49 | extern fsm ecp_fsm[]; 50 | extern ecp_options ecp_wantoptions[]; 51 | extern ecp_options ecp_gotoptions[]; 52 | extern ecp_options ecp_allowoptions[]; 53 | extern ecp_options ecp_hisoptions[]; 54 | 55 | extern const struct protent ecp_protent; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* ECP_H */ 62 | #endif /* PPP_SUPPORT && ECP_SUPPORT */ 63 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/netif/FILES: -------------------------------------------------------------------------------- 1 | This directory contains generic network interface device drivers that 2 | do not contain any hardware or architecture specific code. The files 3 | are: 4 | 5 | ethernet.c 6 | Shared code for Ethernet based interfaces. 7 | 8 | lowpan6.c 9 | A 6LoWPAN implementation as a netif. 10 | 11 | lowpan6_ble.c 12 | A 6LoWPAN over Bluetooth Low Energy (BLE) implementation as netif, 13 | according to RFC-7668. 14 | 15 | slipif.c 16 | A generic implementation of the SLIP (Serial Line IP) 17 | protocol. It requires a sio (serial I/O) module to work. 18 | 19 | ppp/ Point-to-Point Protocol stack 20 | The lwIP PPP support is based from pppd (http://ppp.samba.org) with 21 | huge changes to match code size and memory requirements for embedded 22 | devices. Please read /doc/ppp.txt and ppp/PPPD_FOLLOWUP for a detailed 23 | explanation. 24 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/netif/ppp/eui64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * eui64.c - EUI64 routines for IPv6CP. 3 | * 4 | * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The name(s) of the authors of this software must not be used to 19 | * endorse or promote products derived from this software without 20 | * prior written permission. 21 | * 22 | * 4. Redistributions of any form whatsoever must retain the following 23 | * acknowledgment: 24 | * "This product includes software developed by Tommi Komulainen 25 | * ". 26 | * 27 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 28 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 29 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 30 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 31 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 32 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 33 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 34 | * 35 | * $Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $ 36 | */ 37 | 38 | #include "netif/ppp/ppp_opts.h" 39 | #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ 40 | 41 | #include "netif/ppp/ppp_impl.h" 42 | #include "netif/ppp/eui64.h" 43 | 44 | /* 45 | * eui64_ntoa - Make an ascii representation of an interface identifier 46 | */ 47 | char *eui64_ntoa(eui64_t e) { 48 | static char buf[20]; 49 | 50 | sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x", 51 | e.e8[0], e.e8[1], e.e8[2], e.e8[3], 52 | e.e8[4], e.e8[5], e.e8[6], e.e8[7]); 53 | return buf; 54 | } 55 | 56 | #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ 57 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/netif/ppp/polarssl/README: -------------------------------------------------------------------------------- 1 | About PolarSSL files into lwIP PPP support 2 | ------------------------------------------ 3 | 4 | This folder contains some files fetched from the latest BSD release of 5 | the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption 6 | methods we need for lwIP PPP support. 7 | 8 | The PolarSSL files were cleaned to contain only the necessary struct 9 | fields and functions needed for lwIP. 10 | 11 | The PolarSSL API was not changed at all, so if you are already using 12 | PolarSSL you can choose to skip the compilation of the included PolarSSL 13 | library into lwIP. 14 | 15 | If you are not using the embedded copy you must include external 16 | libraries into your arch/cc.h port file. 17 | 18 | Beware of the stack requirements which can be a lot larger if you are not 19 | using our cleaned PolarSSL library. 20 | 21 | 22 | PolarSSL project website: http://polarssl.org/ 23 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/src/netif/ppp/pppcrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1 3 | * 4 | * Extracted from chap_ms.c by James Carlson. 5 | * 6 | * Copyright (c) 1995 Eric Rosenquist. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. The name(s) of the authors of this software must not be used to 21 | * endorse or promote products derived from this software without 22 | * prior written permission. 23 | * 24 | * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 25 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 26 | * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 27 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 28 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 29 | * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 30 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 31 | */ 32 | 33 | #include "netif/ppp/ppp_opts.h" 34 | #if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not necessary */ 35 | 36 | #include "netif/ppp/ppp_impl.h" 37 | 38 | #include "netif/ppp/pppcrypt.h" 39 | 40 | 41 | static u_char pppcrypt_get_7bits(u_char *input, int startBit) { 42 | unsigned int word; 43 | 44 | word = (unsigned)input[startBit / 8] << 8; 45 | word |= (unsigned)input[startBit / 8 + 1]; 46 | 47 | word >>= 15 - (startBit % 8 + 7); 48 | 49 | return word & 0xFE; 50 | } 51 | 52 | /* IN 56 bit DES key missing parity bits 53 | * OUT 64 bit DES key with parity bits added 54 | */ 55 | void pppcrypt_56_to_64_bit_key(u_char *key, u_char * des_key) { 56 | des_key[0] = pppcrypt_get_7bits(key, 0); 57 | des_key[1] = pppcrypt_get_7bits(key, 7); 58 | des_key[2] = pppcrypt_get_7bits(key, 14); 59 | des_key[3] = pppcrypt_get_7bits(key, 21); 60 | des_key[4] = pppcrypt_get_7bits(key, 28); 61 | des_key[5] = pppcrypt_get_7bits(key, 35); 62 | des_key[6] = pppcrypt_get_7bits(key, 42); 63 | des_key[7] = pppcrypt_get_7bits(key, 49); 64 | } 65 | 66 | #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ 67 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without modification, 6 | # are permitted provided that the following conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 3. The name of the author may not be used to endorse or promote products 14 | # derived from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | # OF SUCH DAMAGE. 26 | # 27 | # This file is part of the lwIP TCP/IP stack. 28 | # 29 | # Author: Adam Dunkels 30 | # 31 | 32 | all compile: lwip_fuzz 33 | .PHONY: all clean 34 | 35 | CC=afl-gcc 36 | LDFLAGS=-lm 37 | # use 'make D=-DUSER_DEFINE' to pass a user define to gcc 38 | CFLAGS=-O0 $(D) 39 | 40 | CONTRIBDIR=../../../lwip-contrib 41 | include $(CONTRIBDIR)/ports/unix/Common.mk 42 | 43 | clean: 44 | rm -f *.o $(LWIPLIBCOMMON) $(APPLIB) lwip_fuzz *.s .depend* *.core core 45 | 46 | depend dep: .depend 47 | 48 | include .depend 49 | 50 | .depend: fuzz.c $(LWIPFILES) $(APPFILES) 51 | $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend 52 | 53 | lwip_fuzz: .depend $(LWIPLIBCOMMON) $(APPLIB) fuzz.o 54 | $(CC) $(CFLAGS) -o lwip_fuzz fuzz.o $(APPLIB) $(LWIPLIBCOMMON) $(LDFLAGS) 55 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/README: -------------------------------------------------------------------------------- 1 | 2 | Fuzzing the lwIP stack (afl-fuzz requires linux/unix or similar) 3 | 4 | This directory contains a small app that reads Ethernet frames from stdin and 5 | processes them. It is used together with the 'american fuzzy lop' tool (found 6 | at http://lcamtuf.coredump.cx/afl/) and the sample inputs to test how 7 | unexpected inputs are handled. The afl tool will read the known inputs, and 8 | try to modify them to exercise as many code paths as possible, by instrumenting 9 | the code and keeping track of which code is executed. 10 | 11 | Just running make will produce the test program. 12 | 13 | Running make with parameter 'D=-DLWIP_FUZZ_MULTI_PACKET' will produce a binary 14 | that parses the input data as multiple packets (experimental!). 15 | 16 | Then run afl with: 17 | 18 | afl-fuzz -i inputs/ -o output ./lwip_fuzz 19 | 20 | and it should start working. It will probably complain about CPU scheduler, 21 | set AFL_SKIP_CPUFREQ=1 to ignore it. 22 | If it complains about invalid "/proc/sys/kernel/core_pattern" setting, try 23 | executing "sudo bash -c 'echo core > /proc/sys/kernel/core_pattern'". 24 | 25 | The input is split into different subdirectories since they test different 26 | parts of the code, and since you want to run one instance of afl-fuzz on each 27 | core. 28 | 29 | When afl finds a crash or a hang, the input that caused it will be placed in 30 | the output directory. If you have hexdump and text2pcap tools installed, 31 | running output_to_pcap.sh will create pcap files for each input 32 | file to simplify viewing in wireshark. 33 | 34 | The lwipopts.h file needs to have checksum checking off, otherwise almost every 35 | packet will be discarded because of that. The other options can be tuned to 36 | expose different parts of the code. 37 | 38 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/config.h -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/inputs/arp/arp_req.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/inputs/arp/arp_req.bin -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/inputs/icmp/icmp_ping.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/inputs/icmp/icmp_ping.bin -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/inputs/ipv6/neighbor_solicitation.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/inputs/ipv6/neighbor_solicitation.bin -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/inputs/ipv6/router_adv.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/inputs/ipv6/router_adv.bin -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/inputs/tcp/tcp_syn.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/inputs/tcp/tcp_syn.bin -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/inputs/udp/udp_port_5000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/au-ts/sddf/597a539bd83d7e434b39b009335df4d21c45436d/network/ipstacks/lwip/test/fuzz/inputs/udp/udp_port_5000.bin -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/fuzz/output_to_pcap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ] 4 | then 5 | echo "This script will make pcap files from the afl-fuzz crash/hang files" 6 | echo "It needs hexdump and text2pcap" 7 | echo "Please give output directory as argument" 8 | exit 2 9 | fi 10 | 11 | for i in `ls $1/crashes/id*` 12 | do 13 | PCAPNAME=`echo $i | grep pcap` 14 | if [ -z "$PCAPNAME" ]; then 15 | hexdump -C $i > $1/$$.tmp 16 | text2pcap $1/$$.tmp ${i}.pcap 17 | fi 18 | done 19 | for i in `ls $1/hangs/id*` 20 | do 21 | PCAPNAME=`echo $i | grep pcap` 22 | if [ -z "$PCAPNAME" ]; then 23 | hexdump -C $i > $1/$$.tmp 24 | text2pcap $1/$$.tmp ${i}.pcap 25 | fi 26 | done 27 | rm -f $1/$$.tmp 28 | 29 | echo 30 | echo "Created pcap files:" 31 | ls $1/*/*.pcap 32 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/sockets/sockets_stresstest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Simon Goldschmidt 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Simon Goldschmidt 30 | * 31 | */ 32 | 33 | #ifndef LWIP_HDR_TEST_SOCKETS_STRESSTEST 34 | #define LWIP_HDR_TEST_SOCKETS_STRESSTEST 35 | 36 | void sockets_stresstest_init_loopback(int addr_family); 37 | void sockets_stresstest_init_server(int addr_family, u16_t server_port); 38 | void sockets_stresstest_init_client(const char *remote_ip, u16_t remote_port); 39 | 40 | #endif /* LWIP_HDR_TEST_SOCKETS_STRESSTEST */ 41 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/Filelists.cmake: -------------------------------------------------------------------------------- 1 | # This file is indended to be included in end-user CMakeLists.txt 2 | # include(/path/to/Filelists.cmake) 3 | # It assumes the variable LWIP_DIR is defined pointing to the 4 | # root path of lwIP sources. 5 | # 6 | # This file is NOT designed (on purpose) to be used as cmake 7 | # subdir via add_subdirectory() 8 | # The intention is to provide greater flexibility to users to 9 | # create their own targets using the *_SRCS variables. 10 | 11 | set(LWIP_TESTDIR ${LWIP_DIR}/test/unit) 12 | set(LWIP_TESTFILES 13 | ${LWIP_TESTDIR}/lwip_unittests.c 14 | ${LWIP_TESTDIR}/api/test_sockets.c 15 | ${LWIP_TESTDIR}/arch/sys_arch.c 16 | ${LWIP_TESTDIR}/core/test_def.c 17 | ${LWIP_TESTDIR}/core/test_mem.c 18 | ${LWIP_TESTDIR}/core/test_netif.c 19 | ${LWIP_TESTDIR}/core/test_pbuf.c 20 | ${LWIP_TESTDIR}/core/test_timers.c 21 | ${LWIP_TESTDIR}/dhcp/test_dhcp.c 22 | ${LWIP_TESTDIR}/etharp/test_etharp.c 23 | ${LWIP_TESTDIR}/ip4/test_ip4.c 24 | ${LWIP_TESTDIR}/ip6/test_ip6.c 25 | ${LWIP_TESTDIR}/mdns/test_mdns.c 26 | ${LWIP_TESTDIR}/mqtt/test_mqtt.c 27 | ${LWIP_TESTDIR}/tcp/tcp_helper.c 28 | ${LWIP_TESTDIR}/tcp/test_tcp_oos.c 29 | ${LWIP_TESTDIR}/tcp/test_tcp.c 30 | ${LWIP_TESTDIR}/udp/test_udp.c 31 | ) 32 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/Filelists.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without modification, 6 | # are permitted provided that the following conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 3. The name of the author may not be used to endorse or promote products 14 | # derived from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | # OF SUCH DAMAGE. 26 | # 27 | # This file is part of the lwIP TCP/IP stack. 28 | # 29 | # Author: Adam Dunkels 30 | # 31 | 32 | TESTDIR=$(LWIPDIR)/../test/unit 33 | TESTFILES=$(TESTDIR)/lwip_unittests.c \ 34 | $(TESTDIR)/api/test_sockets.c \ 35 | $(TESTDIR)/arch/sys_arch.c \ 36 | $(TESTDIR)/core/test_def.c \ 37 | $(TESTDIR)/core/test_mem.c \ 38 | $(TESTDIR)/core/test_netif.c \ 39 | $(TESTDIR)/core/test_pbuf.c \ 40 | $(TESTDIR)/core/test_timers.c \ 41 | $(TESTDIR)/dhcp/test_dhcp.c \ 42 | $(TESTDIR)/etharp/test_etharp.c \ 43 | $(TESTDIR)/ip4/test_ip4.c \ 44 | $(TESTDIR)/ip6/test_ip6.c \ 45 | $(TESTDIR)/mdns/test_mdns.c \ 46 | $(TESTDIR)/mqtt/test_mqtt.c \ 47 | $(TESTDIR)/tcp/tcp_helper.c \ 48 | $(TESTDIR)/tcp/test_tcp_oos.c \ 49 | $(TESTDIR)/tcp/test_tcp.c \ 50 | $(TESTDIR)/udp/test_udp.c 51 | 52 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/api/test_sockets.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_SOCKETS_H 2 | #define LWIP_HDR_TEST_SOCKETS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *sockets_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/core/test_def.c: -------------------------------------------------------------------------------- 1 | #include "test_def.h" 2 | 3 | #include "lwip/def.h" 4 | 5 | #define MAGIC_UNTOUCHED_BYTE 0x7a 6 | #define TEST_BUFSIZE 32 7 | #define GUARD_SIZE 4 8 | 9 | /* Setups/teardown functions */ 10 | 11 | static void 12 | def_setup(void) 13 | { 14 | } 15 | 16 | static void 17 | def_teardown(void) 18 | { 19 | } 20 | 21 | static void 22 | def_check_range_untouched(const char *buf, size_t len) 23 | { 24 | size_t i; 25 | 26 | for (i = 0; i < len; i++) { 27 | fail_unless(buf[i] == (char)MAGIC_UNTOUCHED_BYTE); 28 | } 29 | } 30 | 31 | static void test_def_itoa(int number, const char *expected) 32 | { 33 | char buf[TEST_BUFSIZE]; 34 | char *test_buf = &buf[GUARD_SIZE]; 35 | 36 | size_t exp_len = strlen(expected); 37 | fail_unless(exp_len + 4 < (TEST_BUFSIZE - (2 * GUARD_SIZE))); 38 | 39 | memset(buf, MAGIC_UNTOUCHED_BYTE, sizeof(buf)); 40 | lwip_itoa(test_buf, exp_len + 1, number); 41 | def_check_range_untouched(buf, GUARD_SIZE); 42 | fail_unless(test_buf[exp_len] == 0); 43 | fail_unless(!memcmp(test_buf, expected, exp_len)); 44 | def_check_range_untouched(&test_buf[exp_len + 1], TEST_BUFSIZE - GUARD_SIZE - exp_len - 1); 45 | 46 | /* check with too small buffer */ 47 | memset(buf, MAGIC_UNTOUCHED_BYTE, sizeof(buf)); 48 | lwip_itoa(test_buf, exp_len, number); 49 | def_check_range_untouched(buf, GUARD_SIZE); 50 | def_check_range_untouched(&test_buf[exp_len + 1], TEST_BUFSIZE - GUARD_SIZE - exp_len - 1); 51 | 52 | /* check with too large buffer */ 53 | memset(buf, MAGIC_UNTOUCHED_BYTE, sizeof(buf)); 54 | lwip_itoa(test_buf, exp_len + 4, number); 55 | def_check_range_untouched(buf, GUARD_SIZE); 56 | fail_unless(test_buf[exp_len] == 0); 57 | fail_unless(!memcmp(test_buf, expected, exp_len)); 58 | def_check_range_untouched(&test_buf[exp_len + 4], TEST_BUFSIZE - GUARD_SIZE - exp_len - 4); 59 | } 60 | 61 | START_TEST(test_def_lwip_itoa) 62 | { 63 | LWIP_UNUSED_ARG(_i); 64 | 65 | test_def_itoa(0, "0"); 66 | test_def_itoa(1, "1"); 67 | test_def_itoa(-1, "-1"); 68 | test_def_itoa(15, "15"); 69 | test_def_itoa(-15, "-15"); 70 | test_def_itoa(156, "156"); 71 | test_def_itoa(1192, "1192"); 72 | test_def_itoa(-156, "-156"); 73 | } 74 | END_TEST 75 | 76 | /** Create the suite including all tests for this module */ 77 | Suite * 78 | def_suite(void) 79 | { 80 | testfunc tests[] = { 81 | TESTFUNC(test_def_lwip_itoa) 82 | }; 83 | return create_suite("DEF", tests, sizeof(tests)/sizeof(testfunc), def_setup, def_teardown); 84 | } 85 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/core/test_def.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_DEF_H 2 | #define LWIP_HDR_TEST_DEF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *def_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/core/test_mem.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MEM_H 2 | #define LWIP_HDR_TEST_MEM_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *mem_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/core/test_netif.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_NETIF_H 2 | #define LWIP_HDR_TEST_NETIF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *netif_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/core/test_pbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_PBUF_H 2 | #define LWIP_HDR_TEST_PBUF_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *pbuf_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/core/test_timers.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TIMERS_H 2 | #define LWIP_HDR_TEST_TIMERS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *timers_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/dhcp/test_dhcp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_DHCP_H 2 | #define LWIP_HDR_TEST_DHCP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* dhcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/etharp/test_etharp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_ETHARP_H 2 | #define LWIP_HDR_TEST_ETHARP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* etharp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/ip4/test_ip4.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_IP4_H 2 | #define LWIP_HDR_TEST_IP4_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* ip4_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/ip6/test_ip6.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_IP6_H 2 | #define LWIP_HDR_TEST_IP6_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* ip6_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/lwip_check.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_LWIP_CHECK_H 2 | #define LWIP_HDR_LWIP_CHECK_H 3 | 4 | /* Common header file for lwIP unit tests using the check framework */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define FAIL_RET() do { fail(); return; } while(0) 11 | #define EXPECT(x) fail_unless(x) 12 | #define EXPECT_RET(x) do { fail_unless(x); if(!(x)) { return; }} while(0) 13 | #define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0) 14 | #define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL) 15 | 16 | #if (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13) 17 | typedef struct { 18 | TFun func; 19 | const char *name; 20 | } testfunc; 21 | 22 | #define TESTFUNC(x) {(x), "" # x "" } 23 | 24 | /* Modified function from check.h, supplying function name */ 25 | #define tcase_add_named_test(tc,tf) \ 26 | _tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1) 27 | 28 | #else 29 | /* From 0.13.0 check keeps track of the method name internally */ 30 | typedef const TTest * testfunc; 31 | 32 | #define TESTFUNC(x) x 33 | 34 | #define tcase_add_named_test(tc,tf) tcase_add_test(tc,tf) 35 | #endif 36 | 37 | /** typedef for a function returning a test suite */ 38 | typedef Suite* (suite_getter_fn)(void); 39 | 40 | /** Create a test suite */ 41 | Suite* create_suite(const char* name, testfunc *tests, size_t num_tests, SFun setup, SFun teardown); 42 | 43 | #ifdef LWIP_UNITTESTS_LIB 44 | int lwip_unittests_run(void) 45 | #endif 46 | 47 | /* helper functions */ 48 | #define SKIP_POOL(x) (1 << x) 49 | #define SKIP_HEAP (1 << MEMP_MAX) 50 | void lwip_check_ensure_no_alloc(unsigned int skip); 51 | 52 | #endif /* LWIP_HDR_LWIP_CHECK_H */ 53 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/mdns/test_mdns.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MDNS_H__ 2 | #define LWIP_HDR_TEST_MDNS_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* mdns_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/mqtt/test_mqtt.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_MQTT_H__ 2 | #define LWIP_HDR_TEST_MQTT_H__ 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* mqtt_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/tcp/tcp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TCP_HELPER_H 2 | #define LWIP_HDR_TCP_HELPER_H 3 | 4 | #include "../lwip_check.h" 5 | #include "lwip/arch.h" 6 | #include "lwip/tcp.h" 7 | #include "lwip/netif.h" 8 | 9 | /* counters used for test_tcp_counters_* callback functions */ 10 | struct test_tcp_counters { 11 | u32_t recv_calls; 12 | u32_t recved_bytes; 13 | u32_t recv_calls_after_close; 14 | u32_t recved_bytes_after_close; 15 | u32_t close_calls; 16 | u32_t err_calls; 17 | err_t last_err; 18 | char* expected_data; 19 | u32_t expected_data_len; 20 | }; 21 | 22 | struct test_tcp_txcounters { 23 | u32_t num_tx_calls; 24 | u32_t num_tx_bytes; 25 | u8_t copy_tx_packets; 26 | struct pbuf *tx_packets; 27 | }; 28 | 29 | extern const ip_addr_t test_local_ip; 30 | extern const ip_addr_t test_remote_ip; 31 | extern const ip_addr_t test_netmask; 32 | #define TEST_REMOTE_PORT 0x100 33 | #define TEST_LOCAL_PORT 0x101 34 | 35 | /* Helper functions */ 36 | void tcp_remove_all(void); 37 | 38 | struct pbuf* tcp_create_segment(ip_addr_t* src_ip, ip_addr_t* dst_ip, 39 | u16_t src_port, u16_t dst_port, void* data, size_t data_len, 40 | u32_t seqno, u32_t ackno, u8_t headerflags); 41 | struct pbuf* tcp_create_rx_segment(struct tcp_pcb* pcb, void* data, size_t data_len, 42 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags); 43 | struct pbuf* tcp_create_rx_segment_wnd(struct tcp_pcb* pcb, void* data, size_t data_len, 44 | u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd); 45 | void tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, const ip_addr_t* local_ip, 46 | const ip_addr_t* remote_ip, u16_t local_port, u16_t remote_port); 47 | void test_tcp_counters_err(void* arg, err_t err); 48 | err_t test_tcp_counters_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); 49 | 50 | struct tcp_pcb* test_tcp_new_counters_pcb(struct test_tcp_counters* counters); 51 | 52 | void test_tcp_input(struct pbuf *p, struct netif *inp); 53 | 54 | void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, 55 | const ip_addr_t *ip_addr, const ip_addr_t *netmask); 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/tcp/test_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TCP_H 2 | #define LWIP_HDR_TEST_TCP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/tcp/test_tcp_oos.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_TCP_OOS_H 2 | #define LWIP_HDR_TEST_TCP_OOS_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite *tcp_oos_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /network/ipstacks/lwip/test/unit/udp/test_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_HDR_TEST_UDP_H 2 | #define LWIP_HDR_TEST_UDP_H 3 | 4 | #include "../lwip_check.h" 5 | 6 | Suite* udp_suite(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /serial/components/serial_components.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # This Makefile snippet builds the serial RX and TX virtualisers 7 | # it should be included into your project Makefile 8 | # 9 | # NOTES: 10 | # Generates serial_virt_rx.elf serial_virt_tx.elf 11 | # 12 | 13 | SERIAL_IMAGES:= serial_virt_rx.elf serial_virt_tx.elf 14 | SERIAL_COMPONENT_OBJ := $(addprefix serial/components/, serial_virt_tx.o serial_virt_rx.o) 15 | 16 | CFLAGS_serial := -I ${SDDF}/include 17 | 18 | CHECK_SERIAL_FLAGS_MD5:=.serial_cflags-$(shell echo -- ${CFLAGS} ${CFLAGS_serial} | shasum | sed 's/ *-//') 19 | 20 | ${CHECK_SERIAL_FLAGS_MD5}: 21 | -rm -f .serial_cflags-* 22 | touch $@ 23 | 24 | ${SERIAL_COMPONENT_OBJ}: |serial/components 25 | ${SERIAL_COMPONENT_OBJ}: ${CHECK_SERIAL_FLAGS_MD5} 26 | 27 | serial/components/serial_virt_%.o: ${SDDF}/serial/components/virt_%.c 28 | ${CC} ${CFLAGS} ${CFLAGS_serial} -o $@ -c $< 29 | 30 | %.elf: serial/components/%.o libsddf_util_debug.a 31 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 32 | 33 | serial/components: 34 | mkdir -p $@ 35 | 36 | clean:: 37 | rm -f serial_virt_[rt]x.[od] .serial_cflags-* 38 | 39 | clobber:: 40 | rm -f ${SERIAL_IMAGES} 41 | 42 | -include serial/components/serial_virt_rx.d 43 | -include serial/components/serial_virt_tx.d 44 | -------------------------------------------------------------------------------- /sound/components/sound_components.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024, UNSW 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | # This Makefile snippet builds the sound virtualiser 7 | # it should be included into your project Makefile 8 | # 9 | # NOTES: 10 | # Generates sound_virt.elf 11 | # 12 | 13 | 14 | SND_IMAGES := sound_virt.elf 15 | 16 | CFLAGS_sound ?= 17 | 18 | CHECK_SND_FLAGS_MD5:=.sound_cflags-$(shell echo -- $(CFLAGS) $(CFLAGS_sound) | shasum | sed 's/ *-//') 19 | 20 | $(CHECK_SND_FLAGS_MD5): 21 | -rm -f .sound_cflags-* 22 | touch $@ 23 | 24 | 25 | sound_virt.elf: sound_virt.o 26 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ 27 | 28 | sound_virt.o: $(CHECK_SND_FLAGS_MD5) 29 | sound_virt.o: $(SDDF)/sound/components/virt.c 30 | $(CC) $(CFLAGS) $(CFLAGS_sound) -o $@ -c $< 31 | 32 | clean:: 33 | rm -f sound_virt.[od] .sound_cflags-* 34 | 35 | clobber:: 36 | rm -f $(SND_IMAGES) 37 | 38 | 39 | -include sound_virt.d 40 | -------------------------------------------------------------------------------- /util/assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | 8 | void _assert_fail(const char *assertion, const char *file, unsigned int line, const char *function) 9 | { 10 | sddf_dprintf("Failed assertion '%s' at %s:%u in function %s\n", assertion, file, line, function); 11 | __builtin_trap(); 12 | } -------------------------------------------------------------------------------- /util/newlibc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | /* 10 | * This source file is intended to be compiled with other code 11 | * that links with the newlib C library. Newlib expects these 12 | * function definitions to exist. At the time of writing, we do 13 | * not depend on any of the OS-level calls and hence leave them 14 | * unimplemented. 15 | */ 16 | 17 | void _close(void) 18 | { 19 | sddf_dprintf("NEWLIB ERROR: calling unimplemented _close()"); 20 | } 21 | 22 | void _lseek(void) 23 | { 24 | sddf_dprintf("NEWLIB ERROR: calling unimplemented _lseek()"); 25 | } 26 | 27 | void _read(void) 28 | { 29 | sddf_dprintf("NEWLIB ERROR: calling unimplemented _read()"); 30 | } 31 | 32 | void _write(void) 33 | { 34 | sddf_dprintf("NEWLIB ERROR: calling unimplemented _write()"); 35 | } 36 | 37 | void _sbrk(void) 38 | { 39 | sddf_dprintf("NEWLIB ERROR: calling unimplemented _sbrk()"); 40 | } 41 | -------------------------------------------------------------------------------- /util/putchar_debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define MAX_STRING_LENGTH 0x1000 11 | #define FLUSH_CHAR '\n' 12 | 13 | static char string_buffer[MAX_STRING_LENGTH + 1] = { 0 }; 14 | static uint32_t local_tail = 0; 15 | 16 | void _sddf_dbg_puts(const char *s) 17 | { 18 | #ifdef CONFIG_PRINTING 19 | while (*s) { 20 | seL4_DebugPutChar(*s); 21 | s++; 22 | } 23 | #endif 24 | } 25 | 26 | void _sddf_putchar(char character) 27 | { 28 | string_buffer[local_tail] = character; 29 | local_tail++; 30 | 31 | if (character == FLUSH_CHAR || local_tail == MAX_STRING_LENGTH) { 32 | string_buffer[local_tail] = '\0'; 33 | _sddf_dbg_puts(string_buffer); 34 | local_tail = 0; 35 | } 36 | } -------------------------------------------------------------------------------- /util/putchar_serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024, UNSW 3 | * SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define FLUSH_CHAR '\n' 11 | 12 | static sddf_channel tx_ch; 13 | static serial_queue_handle_t *tx_queue_handle; 14 | 15 | static uint32_t local_tail; 16 | 17 | /* Ensure to call serial_putchar_init during initialisation. Multiplexes output based on \n or when buffer is full. */ 18 | void _sddf_putchar(char character) 19 | { 20 | if (serial_queue_full(tx_queue_handle, local_tail) || serial_queue_full(tx_queue_handle, local_tail + 1)) { 21 | return; 22 | } 23 | 24 | if (character == '\n') { 25 | serial_enqueue_local(tx_queue_handle, &local_tail, '\r'); 26 | } 27 | serial_enqueue_local(tx_queue_handle, &local_tail, character); 28 | 29 | /* Make changes visible to virtualiser if character is flush or if queue is now filled */ 30 | if (serial_queue_full(tx_queue_handle, local_tail) || serial_queue_full(tx_queue_handle, local_tail + 1) 31 | || character == FLUSH_CHAR) { 32 | serial_update_shared_tail(tx_queue_handle, local_tail); 33 | sddf_notify(tx_ch); 34 | } 35 | } 36 | 37 | void sddf_putchar_unbuffered(char character) 38 | { 39 | if (serial_queue_full(tx_queue_handle, local_tail)) { 40 | return; 41 | } 42 | 43 | serial_enqueue_local(tx_queue_handle, &local_tail, character); 44 | serial_update_shared_tail(tx_queue_handle, local_tail); 45 | sddf_notify(tx_ch); 46 | } 47 | 48 | /* Initialise the serial putchar library. */ 49 | void serial_putchar_init(sddf_channel serial_tx_ch, serial_queue_handle_t *serial_tx_queue_handle) 50 | { 51 | tx_ch = serial_tx_ch; 52 | tx_queue_handle = serial_tx_queue_handle; 53 | local_tail = serial_tx_queue_handle->queue->tail; 54 | } 55 | -------------------------------------------------------------------------------- /util/util.mk: -------------------------------------------------------------------------------- 1 | # Snippet to build util library 2 | # 3 | # Copyright 2024, UNSW 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | # Include this snippet in your project Makefile to build 8 | # sddf_libutil.a and sddf_libutil_debug.a 9 | # sddf_libutil.a needs the component to have channels and queues 10 | # with the the serial_tx_virt and for putchar to be initialised. 11 | # sddf_libutil_debug.a uses the microkit_dbg_putc function. 12 | # Both are character at a time polling (i.e., slow, and only for debugging) 13 | 14 | OBJS_LIBUTIL := cache.o sddf_printf.o newlibc.o assert.o bitarray.o fsmalloc.o 15 | 16 | ALL_OBJS_LIBUTIL := $(addprefix util/, ${OBJS_LIBUTIL} putchar_debug.o putchar_serial.o) 17 | 18 | BASE_OBJS_LIBUTIL := $(addprefix util/, ${OBJS_LIBUTIL}) 19 | ${ALL_OBJS_LIBUTIL}: ${CHECK_FLAGS_BOARD_MD5} |util 20 | 21 | libsddf_util_debug.a: ${BASE_OBJS_LIBUTIL} util/putchar_debug.o 22 | ${AR} crv $@ $^ 23 | ${RANLIB} $@ 24 | 25 | libsddf_util.a: ${BASE_OBJS_LIBUTIL} util/putchar_serial.o 26 | ${AR} crv $@ $^ 27 | ${RANLIB} $@ 28 | 29 | util/sddf_printf.o: ${SDDF}/util/printf.c 30 | ${CC} ${CFLAGS} -c -o $@ $< 31 | 32 | util/%.o: ${SDDF}/util/%.c 33 | ${CC} ${CFLAGS} -c -o $@ $< 34 | 35 | util: 36 | mkdir -p $@ 37 | 38 | clean:: 39 | ${RM} -f ${ALL_OBJS_LIBUTIL} ${ALL_OBJS_LIBUTIL:.o=.d} 40 | 41 | clobber:: clean 42 | ${RM} -f libsddf_util.a libsddf_util_debug.a 43 | rmdir util 44 | 45 | -include ${ALL_OBJS_LIBUTIL:.o=.d} 46 | --------------------------------------------------------------------------------