Index: head/share/man/man4/aw_sid.4 =================================================================== --- head/share/man/man4/aw_sid.4 (revision 333417) +++ head/share/man/man4/aw_sid.4 (revision 333418) @@ -1,76 +1,75 @@ .\"- .\" Copyright (c) 2018 Kyle Evans -.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd January 6, 2018 .Dt AW_SID 4 .Os .Sh NAME .Nm aw_sid .Nd driver for the SID controller in Allwinner SoC .Sh DESCRIPTION The .Nm device driver provides support for the Allwinner SID (Security ID) controller. This controller provides root security keys that may be used as either a device unique ID or to generate a MAC address. .Sh HARDWARE The .Nm driver supports the SID controller with one of the following compatible strings: .Pp .Bl -bullet -compact .It allwinner,sun4i-a10-sid .It allwinner,sun7i-a20-sid .It allwinner,sun50i-a64-sid .It allwinner,sun8i-a83t-sid .It allwinner,sun8i-h3-sid .El .Sh SYSCTL VARIABLES The following read-only variables are available via .Xr sysctl 8 : .Bl -tag -width indent .It Va dev.aw_sid.rootkey Root security key for this device. .El .Sh HISTORY The .Nm device driver first appeared in .Fx 11.0 . .Sh AUTHORS The .Nm device driver was written by .An Jared McNeill Aq Mt jmcneill@invisible.ca . This manual page was written by .An Kyle Evans Aq Mt kevans@FreeBSD.org . Index: head/share/man/man4/aw_syscon.4 =================================================================== --- head/share/man/man4/aw_syscon.4 (revision 333417) +++ head/share/man/man4/aw_syscon.4 (revision 333418) @@ -1,60 +1,59 @@ .\"- .\" Copyright (c) 2018 Kyle Evans -.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd January 7, 2018 .Dt AW_SYSCON 4 .Os .Sh NAME .Nm aw_syscon .Nd driver for the system controller in Allwinner SoC .Sh DESCRIPTION The .Nm device driver provides support for the Allwinner system controller. This controller provides registers for tying together related functionality in a common space. .Nm is required for ethernet functionality on supported devices. .Sh HARDWARE The .Nm driver supports the system controller with one of the following compatible strings: .Pp .Bl -bullet -compact .It allwinner,sun50i-a64-system-controller .It allwinner,sun8i-a83t-system-controller .It allwinner,sun8i-h3-system-controller .El .Sh AUTHORS The .Nm device driver was written by .An Kyle Evans Aq Mt kevans@FreeBSD.org . Index: head/share/man/man9/style.lua.9 =================================================================== --- head/share/man/man9/style.lua.9 (revision 333417) +++ head/share/man/man9/style.lua.9 (revision 333418) @@ -1,127 +1,126 @@ .\"- .\" Copyright (c) 2018 Kyle Evans -.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 [your name] 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. .\" .\" $FreeBSD$ .\" .Dd February 25, 2018 .Dt STYLE.LUA 9 .Os .Sh NAME .Nm style.lua .Nd .Fx lua file style guide .Sh DESCRIPTION This file specifies the preferred style for lua source files in the .Fx source tree. Many of the style rules are implicit in the examples. Be careful to check the examples before assuming that .Nm is silent on an issue. .Pp The copyright header should be a series of single-line comments. Use the single-line comment style for every line in a multi-line comment. .Pp After any copyright header, there is a blank line, and the .Li $\&FreeBSD$ comment for non-C/C++ source files. .Pp The preferred method of including other files and modules is with .Fn require name , such as: .Bd -literal -- $FreeBSD$ config = require("config"); menu = require("menu"); password = require("password"); -- One blank line following the module require block .Ed .Pp .Fn include is generally avoided. .Pp Indentation and wrapping should match the guidelines provided by .Xr style 9 . Do note that it is ok to wrap much earlier than 80 columns if readability would otherwise suffer. .Pp Where possible, .Fn s:method ... is preferred to .Fn method s ... . This is applicable to objects with methods. String are a commonly-used example of objects with methods. .Pp Testing for .Va nil should be done explicitly, rather than as a boolean expression. Single-line conditional statements and loops should be avoided. .Pp .Ic local variables should be preferred to global variables in module scope. internal_underscores tend to be preferred for variable identifiers, while camelCase tends to be preferred for function identifiers. .Pp If a table definition spans multiple lines, then the final value in the table should include the optional terminating comma. For example: .Bd -literal -- No terminating comma needed for trivial table definitions local trivial_table = {1, 2, 3, 4} local complex_table = { { id = "foo", func = foo_function, -- Trailing comma preferred }, { id = "bar", func = bar_function, }, -- Trailing comma preferred } .Ed .Pp This reduces the chance for errors to be introduced when modifying more complex tables. .Pp Multiple local variables should not be declared .Sy and initialized on a single line. Lines containing multiple variable declarations without initialization are ok. Lines containing multiple variable declarations initialized to a single function call returning a tuple with the same number of values is also ok. .Pp Initialization .Sy should be done at declaration time as appropriate. .Sh SEE ALSO .Xr style 9 .Sh HISTORY This manual page is inspired from the same source as .Xr style 9 manual page in .Fx . Index: head/stand/lua/cli.lua =================================================================== --- head/stand/lua/cli.lua (revision 333417) +++ head/stand/lua/cli.lua (revision 333418) @@ -1,127 +1,126 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local config = require("config") local core = require("core") local cli = {} -- Internal function -- Parses arguments to boot and returns two values: kernel_name, argstr -- Defaults to nil and "" respectively. -- This will also parse arguments to autoboot, but the with_kernel argument -- will need to be explicitly overwritten to false local function parseBootArgs(argv, with_kernel) if with_kernel == nil then with_kernel = true end if #argv == 0 then if with_kernel then return nil, "" else return "" end end local kernel_name local argstr = "" for _, v in ipairs(argv) do if with_kernel and v:sub(1,1) ~= "-" then kernel_name = v else argstr = argstr .. " " .. v end end if with_kernel then return kernel_name, argstr else return argstr end end -- Declares a global function cli_execute that attempts to dispatch the -- arguments passed as a lua function. This gives lua a chance to intercept -- builtin CLI commands like "boot" -- This function intentionally does not follow our general naming guideline for -- functions. This is global pollution, but the clearly separated 'cli' looks -- more like a module indicator to serve as a hint of where to look for the -- corresponding definition. function cli_execute(...) local argv = {...} -- Just in case... if #argv == 0 then return loader.command(...) end local cmd_name = argv[1] local cmd = cli[cmd_name] if cmd ~= nil and type(cmd) == "function" then -- Pass argv wholesale into cmd. We could omit argv[0] since the -- traditional reasons for including it don't necessarily apply, -- it may not be totally redundant if we want to have one global -- handling multiple commands return cmd(...) else return loader.command(...) end end function cli_execute_unparsed(str) return cli_execute(loader.parse(str)) end -- Module exports function cli.boot(...) local _, argv = cli.arguments(...) local kernel, argstr = parseBootArgs(argv) if kernel ~= nil then loader.perform("unload") config.selectKernel(kernel) end core.boot(argstr) end function cli.autoboot(...) local _, argv = cli.arguments(...) local argstr = parseBootArgs(argv, false) core.autoboot(argstr) end -- Used for splitting cli varargs into cmd_name and the rest of argv function cli.arguments(...) local argv = {...} local cmd_name cmd_name, argv = core.popFrontTable(argv) return cmd_name, argv end return cli Index: head/stand/lua/core.lua.8 =================================================================== --- head/stand/lua/core.lua.8 (revision 333417) +++ head/stand/lua/core.lua.8 (revision 333418) @@ -1,234 +1,233 @@ .\" .\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD .\" .\" Copyright (c) 2018 Kyle Evans -.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd March 21, 2018 .Dt CORE.LUA 8 .Os .Sh NAME .Nm core.lua .Nd FreeBSD core module .Sh DESCRIPTION .Nm contains core functionality that does not have a more fitting module. .Pp Before hooking into or using the functionality provided by .Nm , it must be included with a statement such as the following: .Pp .Dl local core = require("core") .Ss CONSTANTS The following raw key code constants are defined in .Nm : .Bl -tag -width KEY_BACKSPACE -compact -offset indent .It Ic KEY_BACKSPACE The backspace code. Should generally be checked along with .Ic KEY_DELETE for backspace functionality. .It Ic KEY_ENTER The enter key, or hard return. .It Ic KEY_DELETE The delete code. Should generally be checked along with .Ic KEY_BACKSPACE for backspace functionality. .El .Pp The following key-string constants are defined in .Nm : .Bl -tag -width KEYSTR_ESCAPE -compact -offset indent .It Ic KEYSTR_ESCAPE The escape key. .It Ic KEYSTR_CSI The ANSI CSI sequence. .El .Pp The following menu entry type constants are defined in .Nm : .Bl -tag -width MENU_CAROUSEL_ENTRY -compact -offset indent .It Ic MENU_RETURN Return to the parent menu. .It Ic MENU_ENTRY A normal menu entry. .It Ic MENU_SEPARATOR A menu entry that serves as a separator. .It Ic MENU_SUBMENU A menu entry that opens a submenu when selected. .It Ic MENU_CAROUSEL_ENTRY A menu entry that rotates through items like a carousel upon selection of the menu entry. .El .Pp Please see .Xr menu.lua 8 for extended descriptions and usage of the .Ic MENU_* constants. .Ss Exported functions The following functions are exported from .Nm : .Bl -tag -width core.getACPIPresent -offset indent .It Fn core.setVerbose verbose Sets or unsets .Ev boot_verbose . If .Fa verbose is omitted, toggle the current verbose setting. .It Fn core.setSingleUser singleUser Sets or unsets .Ev boot_single . If .Fa singleUser is omitted, toggle the current single user setting. .It Fn core.getACPIPresent checkingSystemDefaults Check whether ACPI is present. This will only be accurate for i386-compatible loaders, including non-UEFI loaders on amd64 systems. If .Fa checkingSystemDefaults is true, ignore the current value of .Ev hint.acpi.0.disabled . Otherwise, return true only if ACPI is both present and not disabled. .It Fn core.setACPI acpi Sets or unsets .Ev acpi_load , .Ev hint.acpi.0.disabled , and .Ev loader.acpi_disabled_by_user . If .Fa acpi is omitted, toggle the current ACPI setting. .It Fn core.setSafeMode safeMode Set the safe mode setting. Sets or unsets .Ev kern.smp.disabled , .Ev hw.ata.ata_dma , .Ev hw.ata.atapi_dma , .Ev hw.ata.wc , .Ev hw.eisa_slots , .Ev kern.eventtimer.periodic , and .Ev kern.geom.part.check_integrity . If .Fa safeMode is omitted, toggle the current safe mode setting. .It Fn core.clearCachedKernels Clears out the cache of kernels to be displayed on the boot menu. This function is registered as a .Ev config.reloaded hook. It is used to invalidate the kernel list whenever it may have changed, either due to a boot environment change or a potential change in either .Ic kernel or .Ic kernels . .It Fn core.kernelList Returns a table of kernels to display on the boot menu. This will combine .Ic kernel and .Ic kernels from .Xr loader.conf 5 . If .Ic kernels_autodetect is set in .Xr loader.conf 5 , kernels will be autodetected from the current system. .It Fn core.bootenvDefault Returns the default boot environment, nil if unset. .It Fn core.bootenvList Returns a table of boot environments, or an empty table. These will be picked up using the .Ev bootenvs and .Ev bootenvs_count variables set by .Xr zfsloader 8 . .It Fn core.setDefaults Resets ACPI, safe mode, single user, and verbose settings to their system defauilts. .It Fn core.autoboot argstr Loads the kernel and specified modules, then invokes the .Ic autoboot .Xr loader 8 command with .Fa argstr as-is. .It Fn core.boot argstr Loads the kernel and specified modules, then invokes the .Ic boot .Xr loader 8 command with .Fa argstr as-is. .It Fn core.isSingleUserBoot Returns true if .Ev boot_single is set to yes. .It Fn core.isZFSBoot Returns true if .Ev currdev is set to a .Xr zfs 8 dataset. .It Fn core.isSerialBoot Returns true if we are booting over serial. This checks .Ev console , .Ev boot_serial , and .Ev boot_multicons . .It Fn core.isSystem386 Returns true if this bootloader was compiled as an i386 binary. This generally applies to i386 loaders as well as non-UEFI loaders on amd64. .It Fn core.deepCopyTable tbl Recursively deep copies .Fa tbl and returns the result. .It Fn core.popFrontTable tbl Pops the front element off of .Fa tbl , and returns two return values: the front element, and the rest of the table. If there are no elements, this returns nil and nil. If there is one element, this returns the front element and an empty table. This will not operate on truly associative tables; numeric indices are required. .El .Sh SEE ALSO .Xr loader.conf 5 , .Xr loader 8 , .Xr menu.lua 8 .Sh AUTHORS The .Nm file was originally written by .An Pedro Souza Aq Mt pedrosouza@FreeBSD.org . Later work and this manual page was done by .An Kyle Evans Aq Mt kevans@FreeBSD.org . Index: head/stand/lua/hook.lua =================================================================== --- head/stand/lua/hook.lua (revision 333417) +++ head/stand/lua/hook.lua (revision 333418) @@ -1,84 +1,83 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local hook = {} local registered_hooks = {} -- Module exports -- Register a hook type; these are the names that hooks may be registered for. -- It is expected that modules will register all of their hook types upon -- initial load. Other modules may then, at any time, register a hook for these -- types. -- -- Naming convention: hook types should be sensible named, preferably prefixed -- with the name of the module that registered them. They would also ideally -- describe an action that may or may not match a function name. -- e.g. config.reloaded which takes place after config has been reloaded, -- possibly from a different source. function hook.registerType(hooktype) registered_hooks[hooktype] = {} end function hook.register(hooktype, hookfunc) local selected_hooks = registered_hooks[hooktype] if selected_hooks == nil then print("Tried registering a hook for an unknown hook type: " .. hooktype) return end selected_hooks[#selected_hooks + 1] = hookfunc registered_hooks[hooktype] = selected_hooks end -- Takes a hooktype and runs all functions associated with that specific hook -- type in the order that they were registered in. This ordering should likely -- not be relied upon. function hook.runAll(hooktype) local selected_hooks = registered_hooks[hooktype] if selected_hooks == nil then -- This message, and the print() above, should only be seen by -- developers. Hook type registration should have happened at -- module load, so if this hasn't happened then we have messed -- up the order in which we've loaded modules and we need to -- catch that as soon as possible. print("Tried to run hooks for an unknown hook type: " .. hooktype) return 0 end if #selected_hooks > 0 then for _, func in ipairs(selected_hooks) do func() end end return #selected_hooks end return hook Index: head/stand/lua/logo-beastie.lua =================================================================== --- head/stand/lua/logo-beastie.lua (revision 333417) +++ head/stand/lua/logo-beastie.lua (revision 333418) @@ -1,60 +1,59 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local drawer = require("drawer") local beastie_color = { " \027[31m, ,", " /( )`", " \\ \\___ / |", " /- \027[37m_\027[31m `-/ '", " (\027[37m/\\/ \\\027[31m \\ /\\", " \027[37m/ / |\027[31m ` \\", " \027[34mO O \027[37m) \027[31m/ |", " \027[37m`-^--'\027[31m`< '", " (_.) _ ) /", " `.___/` /", " `-----' /", " \027[33m<----.\027[31m __ / __ \\", " \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", " \027[33m<----'\027[31m `--' `.__,' \\", " | |", " \\ / /\\", " \027[36m______\027[31m( (_ / \\______/", " \027[36m,' ,-----' |", " `--{__________)\027[37m" } drawer.addLogo("beastie", { requires_color = true, graphic = beastie_color, }) return true Index: head/stand/lua/logo-beastiebw.lua =================================================================== --- head/stand/lua/logo-beastiebw.lua (revision 333417) +++ head/stand/lua/logo-beastiebw.lua (revision 333418) @@ -1,59 +1,58 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local drawer = require("drawer") local beastiebw = { " , ,", " /( )`", " \\ \\___ / |", " /- _ `-/ '", " (/\\/ \\ \\ /\\", " / / | ` \\", " O O ) / |", " `-^--'`< '", " (_.) _ ) /", " `.___/` /", " `-----' /", " <----. __ / __ \\", " <----|====O)))==) \\) /====|", " <----' `--' `.__,' \\", " | |", " \\ / /\\", " ______( (_ / \\______/", " ,' ,-----' |", " `--{__________)" } drawer.addLogo("beastiebw", { graphic = beastiebw, }) return true Index: head/stand/lua/logo-fbsdbw.lua =================================================================== --- head/stand/lua/logo-fbsdbw.lua (revision 333417) +++ head/stand/lua/logo-fbsdbw.lua (revision 333418) @@ -1,54 +1,53 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local drawer = require("drawer") local fbsd_logo = { " ______", " | ____| __ ___ ___ ", " | |__ | '__/ _ \\/ _ \\", " | __|| | | __/ __/", " | | | | | | |", " |_| |_| \\___|\\___|", " ____ _____ _____", " | _ \\ / ____| __ \\", " | |_) | (___ | | | |", " | _ < \\___ \\| | | |", " | |_) |____) | |__| |", " | | | |", " |____/|_____/|_____/" } drawer.addLogo("fbsdbw", { graphic = fbsd_logo, shift = {x = 5, y = 4}, }) return true Index: head/stand/lua/logo-orb.lua =================================================================== --- head/stand/lua/logo-orb.lua (revision 333417) +++ head/stand/lua/logo-orb.lua (revision 333418) @@ -1,57 +1,56 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local drawer = require("drawer") local orb_color = { " \027[31m``` \027[31;1m`\027[31m", " s` `.....---...\027[31;1m....--.``` -/\027[31m", " +o .--` \027[31;1m/y:` +.\027[31m", " yo`:. \027[31;1m:o `+-\027[31m", " y/ \027[31;1m-/` -o/\027[31m", " .- \027[31;1m::/sy+:.\027[31m", " / \027[31;1m`-- /\027[31m", " `: \027[31;1m:`\027[31m", " `: \027[31;1m:`\027[31m", " / \027[31;1m/\027[31m", " .- \027[31;1m-.\027[31m", " -- \027[31;1m-.\027[31m", " `:` \027[31;1m`:`", " \027[31;1m.-- `--.", " .---.....----.\027[37m" } drawer.addLogo("orb", { requires_color = true, graphic = orb_color, shift = {x = 2, y = 4}, }) return true Index: head/stand/lua/logo-orbbw.lua =================================================================== --- head/stand/lua/logo-orbbw.lua (revision 333417) +++ head/stand/lua/logo-orbbw.lua (revision 333418) @@ -1,56 +1,55 @@ -- -- SPDX-License-Identifier: BSD-2-Clause-FreeBSD -- -- Copyright (c) 2018 Kyle Evans --- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -- -- $FreeBSD$ -- local drawer = require("drawer") local orbbw = { " ``` `", " s` `.....---.......--.``` -/", " +o .--` /y:` +.", " yo`:. :o `+-", " y/ -/` -o/", " .- ::/sy+:.", " / `-- /", " `: :`", " `: :`", " / /", " .- -.", " -- -.", " `:` `:`", " .-- `--.", " .---.....----." } drawer.addLogo("orbbw", { graphic = orbbw, shift = {x = 2, y = 4}, }) return true Index: head/stand/lua/menu.lua.8 =================================================================== --- head/stand/lua/menu.lua.8 (revision 333417) +++ head/stand/lua/menu.lua.8 (revision 333418) @@ -1,236 +1,235 @@ .\" .\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD .\" .\" Copyright (c) 2018 Kyle Evans -.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. .\" .\" $FreeBSD$ .\" .Dd February 23, 2018 .Dt MENU.LUA 8 .Os .Sh NAME .Nm menu.lua .Nd FreeBSD dynamic menu boot module .Sh DESCRIPTION .Nm contains the main functionality required to build a dynamic menu system. It also contains definitions for the built-in menus, some of which are influenced by .Xr loader 8 environment variables. .Pp Before hooking into the functionality provided by .Nm , it must be included with a statement such as the following: .Pp .Dl local menu = require("menu") .Ss MENU DEFINITIONS Menus are represented in .Nm as a table. That table .Sy must contain an .Va entries key. .Pp If the value of the .Va entries key is itself a table, then each value in this table defines a single entry in this menu. See .Sx MENU ITEM DEFINITIONS for the structure of each entry. .Pp .Va entries may also be a function. This function must return a table, each value of which defines a single entry in this menu. See .Sx MENU ITEM DEFINITIONS . .Ss MENU ITEM DEFINITIONS The following keys may be defined for a menu item: .Bl -tag -width disable-module_module -offset indent .It Ic entry_type The type of this menu entry. See .Sx MENU ITEM TYPES . .It Ic carousel_id A unique string id for this carousel. A carousel is a menu entry that rotates through a selection of items. Used for storage of the carousel's current setting. .It Ic visible A lambda that returns .Dv true if this menu item should be visible and .Dv false if it should not be visible. .It Ic items A table (or a lambda that returns a table) of the possible choices for this carousel. .It Ic name A string (or a lambda that returns a string) containing the current name of this item. .It Ic func The function executed when this entry is selected. Every type except for .Ic core.MENU_SEPARATOR may have a .Ic func . .It Ic submenu The submenu menu definition to draw when this entry is selected. .It Ic alias A table of case-sensitive aliases for this menu entry. All menu entries that can be selected may have any number of .Ic alias entries. .El .Pp .Ic entry_type is the only required key for every entry type. .Ic name is required for all entry types except for .Ic core.MENU_SEPARATOR . .Ss MENU ITEM TYPES The menu item type constants are defined in .Xr core.lua 8 . The following types are available: .Bl -tag -width core.MENU_CAROUSEL_ENTRY -offset indent .It Ic core.MENU_RETURN Return to the parent menu. If the current menu is the default menu, .Nm will exit the menu and begin the autoboot sequence (if applicable). This type of menu entry may execute .Ic func , when selected, and has a .Ic name . .It Ic core.MENU_ENTRY A normal menu entry that executes .Ic func when selected, and has a .Ic name . .It Ic core.MENU_SEPARATOR A menu entry that serves as a separator. It may have a .Ic name . .It Ic core.MENU_SUBMENU A menu entry that opens .Ic submenu when selected. It may have a .Ic name . .It Ic core.MENU_CAROUSEL_ENTRY A menu entry that rotates through .Ic items like a carousel. .Ic func is executed when selected, and the callback is passed the choice index, name of the current choice, and the table of choices. .El .Ss EXPORTED MENUS The following menus are exported by .Nm : .Bl -tag -width menu.boot_environments -offset indent .It Ic menu.default The default menu to draw. Set to .Ic menu.welcome by default. .It Ic menu.welcome The welcome menu. Contains single and multi user boot options, as well as entries to access other menus. .It Ic menu.boot_options The "Boot Options" menu. .It Ic menu.boot_environments The "Boot Environments" menu. This menu is only visible if the system is booted on a ZFS partition and more than one boot environment was detected at boot. .El .Sh EXAMPLES To replace the default boot menu with a simple boot menu: .Pp .Bd -literal -offset indent -compact local core = require("core") local menu = require("menu") menu.default = { entries = { { entry_type = core.MENU_ENTRY, name = "Boot", func = core.boot, }, { entry_type = core.MENU_CAROUSEL_ENTRY, carousel_id = "unique_boot_entry_name", items = {"NO", "YES"}, name = function(_, choice, _) return "Option: " .. choice end, func = function(_, _, _) loader.setenv("some_envvar", "some_value") end, }, }, } .Ed .Pp To add another option to the welcome menu: .Pp .Bd -literal -offset indent -compact local core = require("core") local menu = require("menu") local welcome_entries = menu.welcome.all_entries welcome_entries[#welcome_entries + 1] = { entry_type = core.MENU_CAROUSEL_ENTRY, carousel_id = "unique_boot_entry_name", items = {"NO", "YES"}, name = function(_, choice, _) return "Option: " .. choice end, func = function(_, _, _) loader.setenv("some_envvar", "some_value") end, } .Ed .Sh SEE ALSO .Xr loader.conf 5 , .Xr core.lua 8 , .Xr loader 8 .Sh HISTORY The .Nm file first appeared in .Fx 12.0 . .Sh AUTHORS The .Nm file was originally written by .An Pedro Souza Aq Mt pedrosouza@FreeBSD.org . Later work and this manual page was done by .An Kyle Evans Aq Mt kevans@FreeBSD.org . Index: head/sys/arm/allwinner/aw_syscon.c =================================================================== --- head/sys/arm/allwinner/aw_syscon.c (revision 333417) +++ head/sys/arm/allwinner/aw_syscon.c (revision 333418) @@ -1,84 +1,83 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2018 Kyle Evans - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ /* * Allwinner syscon driver */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include static struct ofw_compat_data compat_data[] = { {"allwinner,sun50i-a64-system-controller", 1}, {"allwinner,sun8i-a83t-system-controller", 1}, {"allwinner,sun8i-h3-system-controller", 1}, {NULL, 0} }; static int aw_syscon_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) return (ENXIO); if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "Allwinner syscon"); return (BUS_PROBE_DEFAULT); } static device_method_t aw_syscon_methods[] = { DEVMETHOD(device_probe, aw_syscon_probe), DEVMETHOD_END }; DEFINE_CLASS_1(aw_syscon, aw_syscon_driver, aw_syscon_methods, sizeof(struct syscon_generic_softc), syscon_generic_driver); static devclass_t aw_syscon_devclass; /* aw_syscon needs to attach prior to if_awg */ EARLY_DRIVER_MODULE(aw_syscon, simplebus, aw_syscon_driver, aw_syscon_devclass, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); MODULE_VERSION(aw_syscon, 1); Index: head/sys/arm/allwinner/clkng/ccu_a83t.c =================================================================== --- head/sys/arm/allwinner/clkng/ccu_a83t.c (revision 333417) +++ head/sys/arm/allwinner/clkng/ccu_a83t.c (revision 333418) @@ -1,779 +1,778 @@ /*- * Copyright (c) 2017 Kyle Evans - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ccu_a83t.h" /* Non-exported resets */ /* #define RST_BUS_SCR 53 */ /* Non-exported clocks */ #define CLK_PLL_C0CPUX 0 #define CLK_PLL_C1CPUX 1 #define CLK_PLL_AUDIO 2 #define CLK_PLL_VIDEO0 3 #define CLK_PLL_VE 4 #define CLK_PLL_DDR 5 #define CLK_PLL_GPU 7 #define CLK_PLL_HSIC 8 #define CLK_PLL_VIDEO1 10 #define CLK_AXI0 13 #define CLK_AXI1 14 #define CLK_AHB1 15 #define CLK_APB1 16 #define CLK_APB2 17 #define CLK_AHB2 18 #define CLK_CCI400 58 #define CLK_DRAM 82 #define CLK_MBUS 95 /* Non-exported fixed clocks */ #define CLK_OSC_12M 150 static struct aw_ccung_reset a83t_ccu_resets[] = { CCU_RESET(RST_USB_PHY0, 0xcc, 0) CCU_RESET(RST_USB_PHY1, 0xcc, 1) CCU_RESET(RST_USB_HSIC, 0xcc, 2) CCU_RESET(RST_DRAM, 0xf4, 31) CCU_RESET(RST_MBUS, 0xfc, 31) CCU_RESET(RST_BUS_MIPI_DSI, 0x2c0, 1) CCU_RESET(RST_BUS_SS, 0x2c0, 5) CCU_RESET(RST_BUS_DMA, 0x2c0, 6) CCU_RESET(RST_BUS_MMC0, 0x2c0, 8) CCU_RESET(RST_BUS_MMC1, 0x2c0, 9) CCU_RESET(RST_BUS_MMC2, 0x2c0, 10) CCU_RESET(RST_BUS_NAND, 0x2c0, 13) CCU_RESET(RST_BUS_DRAM, 0x2c0, 14) CCU_RESET(RST_BUS_EMAC, 0x2c0, 17) CCU_RESET(RST_BUS_HSTIMER, 0x2c0, 19) CCU_RESET(RST_BUS_SPI0, 0x2c0, 20) CCU_RESET(RST_BUS_SPI1, 0x2c0, 21) CCU_RESET(RST_BUS_OTG, 0x2c0, 24) CCU_RESET(RST_BUS_EHCI0, 0x2c0, 26) CCU_RESET(RST_BUS_EHCI1, 0x2c0, 27) CCU_RESET(RST_BUS_OHCI0, 0x2c0, 29) CCU_RESET(RST_BUS_VE, 0x2c4, 0) CCU_RESET(RST_BUS_TCON0, 0x2c4, 4) CCU_RESET(RST_BUS_TCON1, 0x2c4, 5) CCU_RESET(RST_BUS_CSI, 0x2c4, 8) CCU_RESET(RST_BUS_HDMI0, 0x2c4, 10) CCU_RESET(RST_BUS_HDMI1, 0x2c4, 11) CCU_RESET(RST_BUS_DE, 0x2c4, 12) CCU_RESET(RST_BUS_GPU, 0x2c4, 20) CCU_RESET(RST_BUS_MSGBOX, 0x2c4, 21) CCU_RESET(RST_BUS_SPINLOCK, 0x2c4, 22) CCU_RESET(RST_BUS_LVDS, 0x2c8, 0) CCU_RESET(RST_BUS_SPDIF, 0x2d0, 1) CCU_RESET(RST_BUS_I2S0, 0x2d0, 12) CCU_RESET(RST_BUS_I2S1, 0x2d0, 13) CCU_RESET(RST_BUS_I2S2, 0x2d0, 14) CCU_RESET(RST_BUS_TDM, 0x2d0, 15) CCU_RESET(RST_BUS_I2C0, 0x2d8, 0) CCU_RESET(RST_BUS_I2C1, 0x2d8, 1) CCU_RESET(RST_BUS_I2C2, 0x2d8, 2) CCU_RESET(RST_BUS_UART0, 0x2d8, 16) CCU_RESET(RST_BUS_UART1, 0x2d8, 17) CCU_RESET(RST_BUS_UART2, 0x2d8, 18) CCU_RESET(RST_BUS_UART3, 0x2d8, 19) CCU_RESET(RST_BUS_UART4, 0x2d8, 20) }; static struct aw_ccung_gate a83t_ccu_gates[] = { CCU_GATE(CLK_BUS_MIPI_DSI, "bus-mipi-dsi", "ahb1", 0x60, 1) CCU_GATE(CLK_BUS_SS, "bus-ss", "ahb1", 0x60, 5) CCU_GATE(CLK_BUS_DMA, "bus-dma", "ahb1", 0x60, 6) CCU_GATE(CLK_BUS_MMC0, "bus-mmc0", "ahb1", 0x60, 8) CCU_GATE(CLK_BUS_MMC1, "bus-mmc1", "ahb1", 0x60, 9) CCU_GATE(CLK_BUS_MMC2, "bus-mmc2", "ahb1", 0x60, 10) CCU_GATE(CLK_BUS_NAND, "bus-nand", "ahb1", 0x60, 13) CCU_GATE(CLK_BUS_DRAM, "bus-dram", "ahb1", 0x60, 14) CCU_GATE(CLK_BUS_EMAC, "bus-emac", "ahb1", 0x60, 17) CCU_GATE(CLK_BUS_HSTIMER, "bus-hstimer", "ahb1", 0x60, 19) CCU_GATE(CLK_BUS_SPI0, "bus-spi0", "ahb1", 0x60, 20) CCU_GATE(CLK_BUS_SPI1, "bus-spi1", "ahb1", 0x60, 21) CCU_GATE(CLK_BUS_OTG, "bus-otg", "ahb1", 0x60, 24) CCU_GATE(CLK_BUS_EHCI0, "bus-ehci0", "ahb2", 0x60, 26) CCU_GATE(CLK_BUS_EHCI1, "bus-ehci1", "ahb2", 0x60, 27) CCU_GATE(CLK_BUS_OHCI0, "bus-ohci0", "ahb2", 0x60, 29) CCU_GATE(CLK_BUS_VE, "bus-ve", "ahb1", 0x64, 0) CCU_GATE(CLK_BUS_TCON0, "bus-tcon0", "ahb1", 0x64, 4) CCU_GATE(CLK_BUS_TCON1, "bus-tcon1", "ahb1", 0x64, 5) CCU_GATE(CLK_BUS_CSI, "bus-csi", "ahb1", 0x64, 8) CCU_GATE(CLK_BUS_HDMI, "bus-hdmi", "ahb1", 0x64, 11) CCU_GATE(CLK_BUS_DE, "bus-de", "ahb1", 0x64, 12) CCU_GATE(CLK_BUS_GPU, "bus-gpu", "ahb1", 0x64, 20) CCU_GATE(CLK_BUS_MSGBOX, "bus-msgbox", "ahb1", 0x64, 21) CCU_GATE(CLK_BUS_SPINLOCK, "bus-spinlock", "ahb1", 0x64, 22) CCU_GATE(CLK_BUS_SPDIF, "bus-spdif", "apb1", 0x68, 1) CCU_GATE(CLK_BUS_PIO, "bus-pio", "apb1", 0x68, 5) CCU_GATE(CLK_BUS_I2S0, "bus-i2s0", "apb1", 0x68, 12) CCU_GATE(CLK_BUS_I2S1, "bus-i2s1", "apb1", 0x68, 13) CCU_GATE(CLK_BUS_I2S2, "bus-i2s2", "apb1", 0x68, 14) CCU_GATE(CLK_BUS_TDM, "bus-tdm", "apb1", 0x68, 15) CCU_GATE(CLK_BUS_I2C0, "bus-i2c0", "apb2", 0x6c, 0) CCU_GATE(CLK_BUS_I2C1, "bus-i2c1", "apb2", 0x6c, 1) CCU_GATE(CLK_BUS_I2C2, "bus-i2c2", "apb2", 0x6c, 2) CCU_GATE(CLK_BUS_UART0, "bus-uart0", "apb2", 0x6c, 16) CCU_GATE(CLK_BUS_UART1, "bus-uart1", "apb2", 0x6c, 17) CCU_GATE(CLK_BUS_UART2, "bus-uart2", "apb2", 0x6c, 18) CCU_GATE(CLK_BUS_UART3, "bus-uart3", "apb2", 0x6c, 19) CCU_GATE(CLK_BUS_UART4, "bus-uart4", "apb2", 0x6c, 20) CCU_GATE(CLK_USB_PHY0, "usb-phy0", "osc24M", 0xcc, 8) CCU_GATE(CLK_USB_PHY1, "usb-phy1", "osc24M", 0xcc, 9) CCU_GATE(CLK_USB_HSIC, "usb-hsic", "pll_hsic", 0xcc, 10) CCU_GATE(CLK_USB_HSIC_12M, "usb-hsic-12M", "osc12M", 0xcc, 11) CCU_GATE(CLK_USB_OHCI0, "usb-ohci0", "osc12M", 0xcc, 16) CCU_GATE(CLK_DRAM_VE, "dram-ve", "dram", 0x100, 0) CCU_GATE(CLK_DRAM_CSI, "dram-csi", "dram", 0x100, 1) CCU_GATE(CLK_CSI_MISC, "csi-misc", "osc24M", 0x130, 16) CCU_GATE(CLK_MIPI_CSI, "mipi-csi", "osc24M", 0x130, 31) CCU_GATE(CLK_AVS, "avs", "osc24M", 0x144, 31) CCU_GATE(CLK_HDMI_SLOW, "hdmi-ddc", "osc24M", 0x154, 31) }; static const char *osc12m_parents[] = {"osc24M"}; FIXED_CLK(osc12m_clk, CLK_OSC_12M, /* id */ "osc12M", osc12m_parents, /* name, parents */ 0, /* freq */ 1, /* mult */ 2, /* div */ 0); /* flags */ static const char *pll_c0cpux_parents[] = {"osc24M"}; static const char *pll_c1cpux_parents[] = {"osc24M"}; NM_CLK(pll_c0cpux_clk, CLK_PLL_C0CPUX, /* id */ "pll_c0cpux", pll_c0cpux_parents, /* name, parents */ 0x00, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_SCALE_CHANGE); /* flags */ NM_CLK(pll_c1cpux_clk, CLK_PLL_C1CPUX, /* id */ "pll_c1cpux", pll_c1cpux_parents, /* name, parents */ 0x04, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* m factor (fake) */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_SCALE_CHANGE); /* flags */ static const char *pll_audio_parents[] = {"osc24M"}; NKMP_CLK(pll_audio_clk, CLK_PLL_AUDIO, /* id */ "pll_audio", pll_audio_parents, /* name, parents */ 0x08, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 0, 0, /* m factor */ 18, 1, 0, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_video0_parents[] = {"osc24M"}; NKMP_CLK(pll_video0_clk, CLK_PLL_VIDEO0, /* id */ "pll_video0", pll_video0_parents, /* name, parents */ 0x10, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 0, 0, /* m factor */ 0, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_ve_parents[] = {"osc24M"}; NKMP_CLK(pll_ve_clk, CLK_PLL_VE, /* id */ "pll_ve", pll_ve_parents, /* name, parents */ 0x18, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 0, 0, /* m factor */ 18, 1, 0, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_ddr_parents[] = {"osc24M"}; NKMP_CLK(pll_ddr_clk, CLK_PLL_DDR, /* id */ "pll_ddr", pll_ddr_parents, /* name, parents */ 0x20, /* offset */ 8, 5, 0, 0, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 0, 0, /* m factor */ 18, 1, 0, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_periph_parents[] = {"osc24M"}; NKMP_CLK(pll_periph_clk, CLK_PLL_PERIPH, /* id */ "pll_periph", pll_periph_parents, /* name, parents */ 0x28, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 1, 0, /* m factor */ 18, 1, 1, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_gpu_parents[] = {"osc24M"}; NKMP_CLK(pll_gpu_clk, CLK_PLL_GPU, /* id */ "pll_gpu", pll_gpu_parents, /* name, parents */ 0x38, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 1, 0, /* m factor */ 18, 1, 1, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_hsic_parents[] = {"osc24M"}; NKMP_CLK(pll_hsic_clk, CLK_PLL_HSIC, /* id */ "pll_hsic", pll_hsic_parents, /* name, parents */ 0x44, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 1, 0, /* m factor */ 18, 1, 1, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_de_parents[] = {"osc24M"}; NKMP_CLK(pll_de_clk, CLK_PLL_DE, /* id */ "pll_de", pll_de_parents, /* name, parents */ 0x48, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 1, 0, /* m factor */ 18, 1, 1, 0, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *pll_video1_parents[] = {"osc24M"}; NKMP_CLK(pll_video1_clk, CLK_PLL_VIDEO1, /* id */ "pll_video1", pll_video1_parents, /* name, parents */ 0x4c, /* offset */ 8, 8, 0, AW_CLK_FACTOR_ZERO_BASED, /* n factor */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* k factor (fake) */ 16, 1, 1, 0, /* m factor */ 0, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* p factor */ 31, /* gate */ 0, 0, /* lock */ AW_CLK_HAS_GATE); /* flags */ static const char *c0cpux_parents[] = {"osc24M", "pll_c0cpux"}; MUX_CLK(c0cpux_clk, CLK_C0CPUX, /* id */ "c0cpux", c0cpux_parents, /* name, parents */ 0x50, 12, 1); /* offset, shift, width */ static const char *c1cpux_parents[] = {"osc24M", "pll_c1cpux"}; MUX_CLK(c1cpux_clk, CLK_C1CPUX, /* id */ "c1cpux", c1cpux_parents, /* name, parents */ 0x50, 28, 1); /* offset, shift, width */ static const char *axi0_parents[] = {"c0cpux"}; DIV_CLK(axi0_clk, CLK_AXI0, /* id */ "axi0", axi0_parents, /* name, parents */ 0x50, /* offset */ 0, 2, /* shift, width */ 0, NULL); /* flags, div table */ static const char *axi1_parents[] = {"c1cpux"}; DIV_CLK(axi1_clk, CLK_AXI1, /* id */ "axi1", axi1_parents, /* name, parents */ 0x50, /* offset */ 16, 2, /* shift, width */ 0, NULL); /* flags, div table */ static const char *ahb1_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "pll_periph"}; PREDIV_CLK_WITH_MASK(ahb1_clk, CLK_AHB1, /* id */ "ahb1", ahb1_parents, /* name, parents */ 0x54, /* offset */ 12, 2, /* mux */ 4, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* div */ 6, 2, 0, AW_CLK_FACTOR_HAS_COND, /* prediv */ (2 << 12), (2 << 12)); /* prediv condition */ static const char *apb1_parents[] = {"ahb1"}; DIV_CLK(apb1_clk, CLK_APB1, /* id */ "apb1", apb1_parents, /* name, parents */ 0x54, /* offset */ 8, 2, /* shift, width */ 0, NULL); /* flags, div table */ static const char *apb2_parents[] = {"osc16M-d512", "osc24M", "pll_periph", "pll_periph"}; NM_CLK(apb2_clk, CLK_APB2, /* id */ "apb2", apb2_parents, /* name, parents */ 0x58, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 5, 0, 0, /* m factor */ 24, 2, /* mux */ 0, /* gate */ AW_CLK_HAS_MUX); static const char *ahb2_parents[] = {"ahb1", "pll_periph"}; PREDIV_CLK(ahb2_clk, CLK_AHB2, /* id */ "ahb2", ahb2_parents, /* name, parents */ 0x5c, 0, 2, /* mux */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* div (fake) */ 0, 0, 2, AW_CLK_FACTOR_HAS_COND | AW_CLK_FACTOR_FIXED, /* prediv */ 0, 2, 1); /* prediv cond */ /* Actually has a divider, but we don't use it */ static const char *cci400_parents[] = {"osc24M", "pll_periph", "pll_hsic"}; MUX_CLK(cci400_clk, CLK_CCI400, /* id */ "cci400", cci400_parents, /* name, parents */ 0x78, 24, 2); /* offset, shift, width */ static const char *mod_parents[] = {"osc24M", "pll_periph"}; NM_CLK(nand_clk, CLK_NAND, /* id */ "nand", mod_parents, /* name, parents */ 0x80, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); NM_CLK(mmc0_clk, CLK_MMC0, /* id */ "mmc0", mod_parents, /* name, parents */ 0x88, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX | AW_CLK_REPARENT); NM_CLK(mmc1_clk, CLK_MMC1, /* id */ "mmc1", mod_parents, /* name, parents */ 0x8c, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX | AW_CLK_REPARENT); NM_CLK(mmc2_clk, CLK_MMC2, /* id */ "mmc2", mod_parents, /* name, parents */ 0x90, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX | AW_CLK_REPARENT); NM_CLK(ss_clk, CLK_SS, /* id */ "ss", mod_parents, /* name, parents */ 0x9c, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); NM_CLK(spi0_clk, CLK_SPI0, /* id */ "spi0", mod_parents, /* name, parents */ 0xa0, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); NM_CLK(spi1_clk, CLK_SPI1, /* id */ "spi1", mod_parents, /* name, parents */ 0xa4, /* offset */ 16, 2, 0, AW_CLK_FACTOR_POWER_OF_TWO, /* n factor */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE | AW_CLK_HAS_MUX); static const char *daudio_parents[] = {"pll_audio"}; NM_CLK(i2s0_clk, CLK_I2S0, /* id */ "i2s0", daudio_parents, /* name, parents */ 0xb0, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); NM_CLK(i2s1_clk, CLK_I2S1, /* id */ "i2s1", daudio_parents, /* name, parents */ 0xb4, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); NM_CLK(i2s2_clk, CLK_I2S2, /* id */ "i2s2", daudio_parents, /* name, parents */ 0xb8, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static const char *tdm_parents[] = {"pll_audio"}; NM_CLK(tdm_clk, CLK_TDM, /* id */ "tdm", tdm_parents, /* name, parents */ 0xbc, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static const char *spdif_parents[] = {"pll_audio"}; NM_CLK(spdif_clk, CLK_SPDIF, /* id */ "spdif", spdif_parents, /* name, parents */ 0xc0, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static const char *dram_parents[] = {"pll_ddr"}; NM_CLK(dram_clk, CLK_DRAM, /* id */ "dram", dram_parents, /* name, parents */ 0xf4, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 0, /* gate */ 0); static const char *tcon0_parents[] = {"pll_video0"}; MUX_CLK(tcon0_clk, CLK_TCON0, /* id */ "tcon0", tcon0_parents, /* name, parents */ 0x118, 24, 2); /* offset, shift, width */ static const char *tcon1_parents[] = {"pll_video1"}; NM_CLK(tcon1_clk, CLK_TCON1, /* id */ "tcon1", tcon1_parents, /* name, parents */ 0x11c, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static const char *csi_mclk_parents[] = {"pll_de", "osc24M"}; NM_CLK(csi_mclk_clk, CLK_CSI_MCLK, /* id */ "csi-mclk", csi_mclk_parents, /* name, parents */ 0x134, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 8, 3, /* mux */ 15, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *csi_sclk_parents[] = {"pll_periph", "pll_ve"}; NM_CLK(csi_sclk_clk, CLK_CSI_SCLK, /* id */ "csi-sclk", csi_sclk_parents, /* name, parents */ 0x134, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 16, 4, 0, 0, /* m factor */ 24, 3, /* mux */ 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *ve_parents[] = {"pll_ve"}; NM_CLK(ve_clk, CLK_VE, /* id */ "ve", ve_parents, /* name, parents */ 0x13c, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 16, 3, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static const char *hdmi_parents[] = {"pll_video1"}; NM_CLK(hdmi_clk, CLK_HDMI, /* id */ "hdmi", hdmi_parents, /* name, parents */ 0x150, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *mbus_parents[] = {"osc24M", "pll_periph", "pll_ddr"}; NM_CLK(mbus_clk, CLK_MBUS, /* id */ "mbus", mbus_parents, /* name, parents */ 0x15c, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 3, 0, 0, /* m factor */ 24, 2, /* mux */ 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *mipi_dsi0_parents[] = {"pll_video0"}; NM_CLK(mipi_dsi0_clk, CLK_MIPI_DSI0, /* id */ "mipi-dsi0", mipi_dsi0_parents, /* name, parents */ 0x168, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 24, 4, /* mux */ 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *mipi_dsi1_parents[] = {"osc24M", "pll_video0"}; NM_CLK(mipi_dsi1_clk, CLK_MIPI_DSI1, /* id */ "mipi-dsi1", mipi_dsi1_parents, /* name, parents */ 0x16c, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 4, 0, 0, /* m factor */ 24, 4, /* mux */ 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *gpu_core_parents[] = {"pll_gpu"}; NM_CLK(gpu_core_clk, CLK_GPU_CORE, /* id */ "gpu-core", gpu_core_parents, /* name, parents */ 0x1a0, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 3, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static const char *gpu_memory_parents[] = {"pll_gpu", "pll_periph"}; NM_CLK(gpu_memory_clk, CLK_GPU_MEMORY, /* id */ "gpu-memory", gpu_memory_parents, /* name, parents */ 0x1a4, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 3, 0, 0, /* m factor */ 24, 1, /* mux */ 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_HAS_GATE); static const char *gpu_hyd_parents[] = {"pll_gpu"}; NM_CLK(gpu_hyd_clk, CLK_GPU_HYD, /* id */ "gpu-hyd", gpu_hyd_parents, /* name, parents */ 0x1a0, /* offset */ 0, 0, 1, AW_CLK_FACTOR_FIXED, /* n factor (fake) */ 0, 3, 0, 0, /* m factor */ 0, 0, /* mux */ 31, /* gate */ AW_CLK_HAS_GATE); static struct aw_clk_nkmp_def *nkmp_clks[] = { &pll_audio_clk, &pll_video0_clk, &pll_ve_clk, &pll_ddr_clk, &pll_periph_clk, &pll_gpu_clk, &pll_hsic_clk, &pll_de_clk, &pll_video1_clk, }; static struct aw_clk_nm_def *nm_clks[] = { &pll_c0cpux_clk, &pll_c1cpux_clk, &apb2_clk, &nand_clk, &mmc0_clk, &mmc1_clk, &mmc2_clk, &ss_clk, &spi0_clk, &spi1_clk, &i2s0_clk, &i2s1_clk, &i2s2_clk, &tdm_clk, &spdif_clk, &dram_clk, &tcon1_clk, &csi_mclk_clk, &csi_sclk_clk, &ve_clk, &hdmi_clk, &mbus_clk, &mipi_dsi0_clk, &mipi_dsi1_clk, &gpu_core_clk, &gpu_memory_clk, &gpu_hyd_clk, }; static struct aw_clk_prediv_mux_def *prediv_mux_clks[] = { &ahb1_clk, &ahb2_clk, }; static struct clk_mux_def *mux_clks[] = { &c0cpux_clk, &c1cpux_clk, &cci400_clk, &tcon0_clk, }; static struct clk_div_def *div_clks[] = { &axi0_clk, &axi1_clk, &apb1_clk, }; static struct clk_fixed_def *fixed_factor_clks[] = { &osc12m_clk, }; static struct aw_clk_init init_clks[] = { {"ahb1", "pll_periph", 0, false}, {"ahb2", "ahb1", 0, false}, {"dram", "pll_ddr", 0, false}, }; void ccu_a83t_register_clocks(struct aw_ccung_softc *sc) { int i; sc->resets = a83t_ccu_resets; sc->nresets = nitems(a83t_ccu_resets); sc->gates = a83t_ccu_gates; sc->ngates = nitems(a83t_ccu_gates); sc->clk_init = init_clks; sc->n_clk_init = nitems(init_clks); for (i = 0; i < nitems(nkmp_clks); i++) aw_clk_nkmp_register(sc->clkdom, nkmp_clks[i]); for (i = 0; i < nitems(nm_clks); i++) aw_clk_nm_register(sc->clkdom, nm_clks[i]); for (i = 0; i < nitems(prediv_mux_clks); i++) aw_clk_prediv_mux_register(sc->clkdom, prediv_mux_clks[i]); for (i = 0; i < nitems(mux_clks); i++) clknode_mux_register(sc->clkdom, mux_clks[i]); for (i = 0; i < nitems(div_clks); i++) clknode_div_register(sc->clkdom, div_clks[i]); for (i = 0; i < nitems(fixed_factor_clks); i++) clknode_fixed_register(sc->clkdom, fixed_factor_clks[i]); } Index: head/sys/arm/allwinner/clkng/ccu_a83t.h =================================================================== --- head/sys/arm/allwinner/clkng/ccu_a83t.h (revision 333417) +++ head/sys/arm/allwinner/clkng/ccu_a83t.h (revision 333418) @@ -1,34 +1,33 @@ /*- * Copyright (c) 2017 Kyle Evans - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #ifndef __CCU_A83T_H__ #define __CCU_A83T_H__ void ccu_a83t_register_clocks(struct aw_ccung_softc *sc); #endif /* __CCU_A83T_H__ */ Index: head/sys/dev/extres/syscon/syscon.c =================================================================== --- head/sys/dev/extres/syscon/syscon.c (revision 333417) +++ head/sys/dev/extres/syscon/syscon.c (revision 333418) @@ -1,257 +1,256 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2017 Kyle Evans - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ /* * This is a generic syscon driver, whose purpose is to provide access to * various unrelated bits packed in a single register space. It is usually used * as a fallback to more specific driver, but works well enough for simple * access. */ #include __FBSDID("$FreeBSD$"); #include "opt_platform.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef FDT #include #include #endif #include "syscon_if.h" #include "syscon.h" /* * Syscon interface details */ typedef TAILQ_HEAD(syscon_list, syscon) syscon_list_t; /* * Declarations */ static int syscon_method_init(struct syscon *syscon); static int syscon_method_uninit(struct syscon *syscon); MALLOC_DEFINE(M_SYSCON, "syscon", "Syscon driver"); static syscon_list_t syscon_list = TAILQ_HEAD_INITIALIZER(syscon_list); static struct sx syscon_topo_lock; SX_SYSINIT(syscon_topology, &syscon_topo_lock, "Syscon topology lock"); /* * Syscon methods. */ static syscon_method_t syscon_methods[] = { SYSCONMETHOD(syscon_init, syscon_method_init), SYSCONMETHOD(syscon_uninit, syscon_method_uninit), SYSCONMETHOD_END }; DEFINE_CLASS_0(syscon, syscon_class, syscon_methods, 0); #define SYSCON_TOPO_SLOCK() sx_slock(&syscon_topo_lock) #define SYSCON_TOPO_XLOCK() sx_xlock(&syscon_topo_lock) #define SYSCON_TOPO_UNLOCK() sx_unlock(&syscon_topo_lock) #define SYSCON_TOPO_ASSERT() sx_assert(&syscon_topo_lock, SA_LOCKED) #define SYSCON_TOPO_XASSERT() sx_assert(&syscon_topo_lock, SA_XLOCKED) /* * Default syscon methods for base class. */ static int syscon_method_init(struct syscon *syscon) { return (0); }; static int syscon_method_uninit(struct syscon *syscon) { return (0); }; void * syscon_get_softc(struct syscon *syscon) { return (syscon->softc); }; /* * Create and initialize syscon object, but do not register it. */ struct syscon * syscon_create(device_t pdev, syscon_class_t syscon_class) { struct syscon *syscon; /* Create object and initialize it. */ syscon = malloc(sizeof(struct syscon), M_SYSCON, M_WAITOK | M_ZERO); kobj_init((kobj_t)syscon, (kobj_class_t)syscon_class); /* Allocate softc if required. */ if (syscon_class->size > 0) syscon->softc = malloc(syscon_class->size, M_SYSCON, M_WAITOK | M_ZERO); /* Rest of init. */ syscon->pdev = pdev; return (syscon); } /* Register syscon object. */ struct syscon * syscon_register(struct syscon *syscon) { int rv; #ifdef FDT if (syscon->ofw_node <= 0) syscon->ofw_node = ofw_bus_get_node(syscon->pdev); if (syscon->ofw_node <= 0) return (NULL); #endif rv = SYSCON_INIT(syscon); if (rv != 0) { printf("SYSCON_INIT failed: %d\n", rv); return (NULL); } #ifdef FDT OF_device_register_xref(OF_xref_from_node(syscon->ofw_node), syscon->pdev); #endif SYSCON_TOPO_XLOCK(); TAILQ_INSERT_TAIL(&syscon_list, syscon, syscon_link); SYSCON_TOPO_UNLOCK(); return (syscon); } int syscon_unregister(struct syscon *syscon) { SYSCON_TOPO_XLOCK(); TAILQ_REMOVE(&syscon_list, syscon, syscon_link); SYSCON_TOPO_UNLOCK(); #ifdef FDT OF_device_register_xref(OF_xref_from_node(syscon->ofw_node), NULL); #endif return (SYSCON_UNINIT(syscon)); } /** * Provider methods */ #ifdef FDT static struct syscon * syscon_find_by_ofw_node(phandle_t node) { struct syscon *entry; SYSCON_TOPO_ASSERT(); TAILQ_FOREACH(entry, &syscon_list, syscon_link) { if (entry->ofw_node == node) return (entry); } return (NULL); } struct syscon * syscon_create_ofw_node(device_t pdev, syscon_class_t syscon_class, phandle_t node) { struct syscon *syscon; syscon = syscon_create(pdev, syscon_class); if (syscon == NULL) return (NULL); syscon->ofw_node = node; if (syscon_register(syscon) == NULL) return (NULL); return (syscon); } phandle_t syscon_get_ofw_node(struct syscon *syscon) { return (syscon->ofw_node); } int syscon_get_by_ofw_property(device_t cdev, phandle_t cnode, char *name, struct syscon **syscon) { pcell_t *cells; int ncells; if (cnode <= 0) cnode = ofw_bus_get_node(cdev); if (cnode <= 0) { device_printf(cdev, "%s called on not ofw based device\n", __func__); return (ENXIO); } ncells = OF_getencprop_alloc_multi(cnode, name, sizeof(pcell_t), (void **)&cells); if (ncells < 1) return (ENXIO); /* Translate to syscon node. */ SYSCON_TOPO_SLOCK(); *syscon = syscon_find_by_ofw_node(OF_node_from_xref(cells[0])); if (*syscon == NULL) { SYSCON_TOPO_UNLOCK(); device_printf(cdev, "Failed to find syscon node\n"); OF_prop_free(cells); return (ENODEV); } SYSCON_TOPO_UNLOCK(); OF_prop_free(cells); return (0); } #endif Index: head/sys/dev/extres/syscon/syscon.h =================================================================== --- head/sys/dev/extres/syscon/syscon.h (revision 333417) +++ head/sys/dev/extres/syscon/syscon.h (revision 333418) @@ -1,79 +1,78 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2017 Kyle Evans - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #ifndef DEV_SYSCON_H #define DEV_SYSCON_H #include "opt_platform.h" #include #include #ifdef FDT #include #endif struct syscon { KOBJ_FIELDS; TAILQ_ENTRY(syscon) syscon_link; /* Global list entry */ device_t pdev; /* provider device */ #ifdef FDT phandle_t ofw_node; /* OFW node for syscon */ #endif void *softc; /* provider softc */ }; /* * Shorthands for constructing method tables. */ #define SYSCONMETHOD KOBJMETHOD #define SYSCONMETHOD_END KOBJMETHOD_END #define syscon_method_t kobj_method_t #define syscon_class_t kobj_class_t DECLARE_CLASS(syscon_class); void *syscon_get_softc(struct syscon *syscon); /* * Provider interface */ struct syscon *syscon_create(device_t pdev, syscon_class_t syscon_class); struct syscon *syscon_register(struct syscon *syscon); int syscon_unregister(struct syscon *syscon); #ifdef FDT struct syscon *syscon_create_ofw_node(device_t pdev, syscon_class_t syscon_class, phandle_t node); phandle_t syscon_get_ofw_node(struct syscon *syscon); int syscon_get_by_ofw_property(device_t consumer, phandle_t node, char *name, struct syscon **syscon); #endif #endif /* DEV_SYSCON_H */ Index: head/sys/dev/extres/syscon/syscon_generic.h =================================================================== --- head/sys/dev/extres/syscon/syscon_generic.h (revision 333417) +++ head/sys/dev/extres/syscon/syscon_generic.h (revision 333418) @@ -1,42 +1,41 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2018 Kyle Evans - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #ifndef DEV_SYSCON_GENERIC_H #define DEV_SYSCON_GENERIC_H struct syscon_generic_softc { device_t dev; struct syscon *syscon; struct resource *mem_res; struct mtx mtx; }; DECLARE_CLASS(syscon_generic_driver); #endif /* DEV_SYSCON_GENERIC_H */ Index: head/usr.bin/grep/tests/grep_freebsd_test.sh =================================================================== --- head/usr.bin/grep/tests/grep_freebsd_test.sh (revision 333417) +++ head/usr.bin/grep/tests/grep_freebsd_test.sh (revision 333418) @@ -1,88 +1,87 @@ # # Copyright (c) 2017 Kyle Evans -# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 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. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. # # $FreeBSD$ # What grep(1) are we working with? # - 0 : bsdgrep # - 1 : gnu grep 2.51 (base) # - 2 : gnu grep (ports) GREP_TYPE_BSD=0 GREP_TYPE_GNU_FREEBSD=1 GREP_TYPE_GNU=2 GREP_TYPE_UNKNOWN=3 grep_type() { local grep_version=$(grep --version) case "$grep_version" in *"BSD grep"*) return $GREP_TYPE_BSD ;; *"GNU grep"*) case "$grep_version" in *2.5.1-FreeBSD*) return $GREP_TYPE_GNU_FREEBSD ;; *) return $GREP_TYPE_GNU ;; esac ;; esac atf_fail "unknown grep type: $grep_version" } atf_test_case grep_r_implied grep_r_implied_body() { grep_type if [ $? -ne $GREP_TYPE_BSD ]; then atf_skip "this test only works with bsdgrep(1)" fi (cd "$(atf_get_srcdir)" && grep -r --exclude="*.out" -e "test" .) > d_grep_r_implied.out atf_check -s exit:0 -x \ "(cd $(atf_get_srcdir) && grep -r --exclude=\"*.out\" -e \"test\") | diff d_grep_r_implied.out -" } atf_test_case rgrep rgrep_head() { atf_set "require.progs" "rgrep" } rgrep_body() { atf_check -o save:d_grep_r_implied.out grep -r --exclude="*.out" -e "test" "$(atf_get_srcdir)" atf_check -o file:d_grep_r_implied.out rgrep --exclude="*.out" -e "test" "$(atf_get_srcdir)" } atf_init_test_cases() { atf_add_test_case grep_r_implied atf_add_test_case rgrep }