[Midnightbsd-cvs] src [10107] trunk/sys/dev: sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun May 27 19:50:56 EDT 2018
Revision: 10107
http://svnweb.midnightbsd.org/src/?rev=10107
Author: laffer1
Date: 2018-05-27 19:50:56 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/sys/dev/fb/boot_font.c
trunk/sys/dev/fb/creator.c
trunk/sys/dev/fb/creatorreg.h
trunk/sys/dev/fb/fb.c
trunk/sys/dev/fb/fbreg.h
trunk/sys/dev/fb/gallant12x22.c
trunk/sys/dev/fb/gfb.h
trunk/sys/dev/fb/machfb.c
trunk/sys/dev/fb/machfbreg.h
trunk/sys/dev/fb/s3_pci.c
trunk/sys/dev/fb/splash.c
trunk/sys/dev/fb/splash_bmp.c
trunk/sys/dev/fb/splash_pcx.c
trunk/sys/dev/fb/splash_txt.c
trunk/sys/dev/fb/splashreg.h
trunk/sys/dev/fb/vesa.c
trunk/sys/dev/fb/vesa.h
trunk/sys/dev/fb/vga.c
trunk/sys/dev/fb/vgareg.h
trunk/sys/dev/fdc/fdc.c
trunk/sys/dev/fdc/fdc_acpi.c
trunk/sys/dev/fdc/fdc_isa.c
trunk/sys/dev/fdc/fdc_pccard.c
trunk/sys/dev/fdc/fdcvar.h
trunk/sys/dev/fe/if_fe.c
trunk/sys/dev/fe/if_fe_cbus.c
trunk/sys/dev/fe/if_fe_isa.c
trunk/sys/dev/fe/if_fe_pccard.c
trunk/sys/dev/fe/if_fereg.h
trunk/sys/dev/fe/if_fevar.h
trunk/sys/dev/fe/mb86960.h
trunk/sys/dev/filemon/filemon.c
trunk/sys/dev/filemon/filemon.h
trunk/sys/dev/filemon/filemon_wrapper.c
trunk/sys/dev/firewire/00README
trunk/sys/dev/firewire/firewire.c
trunk/sys/dev/firewire/firewire.h
trunk/sys/dev/firewire/firewire_phy.h
trunk/sys/dev/firewire/firewirereg.h
trunk/sys/dev/firewire/fwcrom.c
trunk/sys/dev/firewire/fwdev.c
trunk/sys/dev/firewire/fwdma.c
trunk/sys/dev/firewire/fwdma.h
trunk/sys/dev/firewire/fwmem.c
trunk/sys/dev/firewire/fwmem.h
trunk/sys/dev/firewire/fwohci.c
trunk/sys/dev/firewire/fwohci_pci.c
trunk/sys/dev/firewire/fwohcireg.h
trunk/sys/dev/firewire/fwohcivar.h
trunk/sys/dev/firewire/fwphyreg.h
trunk/sys/dev/firewire/iec13213.h
trunk/sys/dev/firewire/iec68113.h
trunk/sys/dev/firewire/if_fwe.c
trunk/sys/dev/firewire/if_fwevar.h
trunk/sys/dev/firewire/if_fwip.c
trunk/sys/dev/firewire/if_fwipvar.h
trunk/sys/dev/firewire/sbp.c
trunk/sys/dev/firewire/sbp.h
trunk/sys/dev/firewire/sbp_targ.c
trunk/sys/dev/flash/at45d.c
trunk/sys/dev/flash/mx25l.c
trunk/sys/dev/flash/mx25lreg.h
trunk/sys/dev/fxp/if_fxp.c
trunk/sys/dev/fxp/if_fxpreg.h
trunk/sys/dev/fxp/if_fxpvar.h
trunk/sys/dev/fxp/inphy.c
trunk/sys/dev/fxp/inphyreg.h
trunk/sys/dev/fxp/rcvbundl.h
trunk/sys/dev/hifn/hifn7751.c
trunk/sys/dev/hifn/hifn7751reg.h
trunk/sys/dev/hifn/hifn7751var.h
trunk/sys/dev/hptiop/hptiop.c
trunk/sys/dev/hptiop/hptiop.h
Added Paths:
-----------
trunk/sys/dev/fb/creator_vt.c
trunk/sys/dev/fb/fb_if.m
trunk/sys/dev/fb/fbd.c
trunk/sys/dev/fdt/
trunk/sys/dev/fdt/fdt_clock.c
trunk/sys/dev/fdt/fdt_clock.h
trunk/sys/dev/fdt/fdt_clock_if.m
trunk/sys/dev/fdt/fdt_common.c
trunk/sys/dev/fdt/fdt_common.h
trunk/sys/dev/fdt/fdt_mips.c
trunk/sys/dev/fdt/fdt_pinctrl.c
trunk/sys/dev/fdt/fdt_pinctrl.h
trunk/sys/dev/fdt/fdt_pinctrl_if.m
trunk/sys/dev/fdt/fdt_powerpc.c
trunk/sys/dev/fdt/fdt_slicer.c
trunk/sys/dev/fdt/fdt_static_dtb.S
trunk/sys/dev/fdt/fdt_x86.c
trunk/sys/dev/fdt/simplebus.c
trunk/sys/dev/fdt/simplebus.h
trunk/sys/dev/gxemul/
trunk/sys/dev/gxemul/cons/
trunk/sys/dev/gxemul/cons/gxemul_cons.c
trunk/sys/dev/gxemul/disk/
trunk/sys/dev/gxemul/disk/gxemul_disk.c
trunk/sys/dev/gxemul/disk/gxemul_diskreg.h
trunk/sys/dev/gxemul/ether/
trunk/sys/dev/gxemul/ether/gxreg.h
trunk/sys/dev/gxemul/ether/if_gx.c
Property Changed:
----------------
trunk/sys/dev/firewire/00README
Modified: trunk/sys/dev/fb/boot_font.c
===================================================================
--- trunk/sys/dev/fb/boot_font.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/boot_font.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -13,13 +14,6 @@
* 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -34,14 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
- * This font lives in the public domain. It is a PC font, IBM encoding,
- * which was designed for use with syscons.
+ * This font lives in the public domain. It is a PC font, IBM encoding
+ * (CP437), which was designed for use with syscons.
*
* Copyright (c) 2000 Andrew Miklic
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/boot_font.c 271105 2014-09-04 16:51:45Z emaste $");
#include <sys/param.h>
@@ -2931,7 +2925,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA0 */
+ /* á */
0x00, /* ........ */
0x06, /* .....**. */
0x0c, /* ....**.. */
@@ -2949,7 +2943,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA1 */
+ /* í */
0x00, /* ........ */
0x06, /* .....**. */
0x0c, /* ....**.. */
@@ -2967,7 +2961,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA2 */
+ /* ó */
0x00, /* ........ */
0x06, /* .....**. */
0x0c, /* ....**.. */
@@ -2985,7 +2979,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA3 */
+ /* ú */
0x00, /* ........ */
0x0c, /* ....**.. */
0x18, /* ...**... */
@@ -3003,7 +2997,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA4 */
+ /* ñ */
0x00, /* ........ */
0x00, /* ........ */
0x76, /* .***.**. */
@@ -3021,7 +3015,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA5 */
+ /* Ñ */
0x76, /* .***.**. */
0xdc, /* **.***.. */
0x00, /* ........ */
@@ -3039,7 +3033,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA6 */
+ /* ª */
0x00, /* ........ */
0x00, /* ........ */
0x7c, /* .*****.. */
@@ -3057,7 +3051,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA7 */
+ /* º */
0x00, /* ........ */
0x00, /* ........ */
0x7c, /* .*****.. */
@@ -3075,7 +3069,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA8 */
+ /* ¿ */
0x00, /* ........ */
0x00, /* ........ */
0x18, /* ...**... */
@@ -3093,7 +3087,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xA9 */
+ /* ⌐ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3111,7 +3105,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xAA */
+ /* ¬ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3129,7 +3123,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xAB */
+ /* ½ */
0x00, /* ........ */
0x18, /* ...**... */
0x38, /* ..***... */
@@ -3147,7 +3141,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xAC */
+ /* ¼ */
0x00, /* ........ */
0x18, /* ...**... */
0x38, /* ..***... */
@@ -3165,7 +3159,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xAD */
+ /* ¡ */
0x00, /* ........ */
0x00, /* ........ */
0x18, /* ...**... */
@@ -3183,7 +3177,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xAE */
+ /* « */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3201,7 +3195,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xAF */
+ /* » */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3219,7 +3213,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xB0 */
+ /* ░ */
0x82, /* *.....*. */
0x10, /* ...*.... */
0x82, /* *.....*. */
@@ -3237,7 +3231,7 @@
0x82, /* *.....*. */
0x10, /* ...*.... */
- /* \xB1 */
+ /* ▒ */
0x00, /* ........ */
0x95, /* *..*.*.* */
0x00, /* ........ */
@@ -3255,7 +3249,7 @@
0x00, /* ........ */
0xa9, /* *.*.*..* */
- /* \xB2 */
+ /* ▓ */
0x92, /* *..*..*. */
0x49, /* .*..*..* */
0x92, /* *..*..*. */
@@ -3273,7 +3267,7 @@
0x92, /* *..*..*. */
0x49, /* .*..*..* */
- /* \xB3 */
+ /* │ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3291,7 +3285,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xB4 */
+ /* ┤ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3309,7 +3303,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xB5 */
+ /* ╡ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3327,7 +3321,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xB6 */
+ /* ╢ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3345,7 +3339,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xB7 */
+ /* ╖ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3363,7 +3357,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xB8 */
+ /* ╕ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3381,7 +3375,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xB9 */
+ /* ╣ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3399,7 +3393,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xBA */
+ /* ║ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3417,7 +3411,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xBB */
+ /* ╗ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3435,7 +3429,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xBC */
+ /* ╝ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3453,7 +3447,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xBD */
+ /* ╜ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3471,7 +3465,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xBE */
+ /* ╛ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3489,7 +3483,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xBF */
+ /* ┐ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3507,7 +3501,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xC0 */
+ /* └ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3525,7 +3519,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xC1 */
+ /* ┴ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3543,7 +3537,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xC2 */
+ /* ┬ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3561,7 +3555,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xC3 */
+ /* ├ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3579,7 +3573,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xC4 */
+ /* ─ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3597,7 +3591,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xC5 */
+ /* ┼ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3615,7 +3609,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xC6 */
+ /* ╞ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3633,7 +3627,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xC7 */
+ /* ╟ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3651,7 +3645,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xC8 */
+ /* ╚ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3669,7 +3663,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xC9 */
+ /* ╔ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3687,7 +3681,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xCA */
+ /* ╩ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3705,7 +3699,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xCB */
+ /* ╦ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3723,7 +3717,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xCC */
+ /* ╠ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3741,7 +3735,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xCD */
+ /* ═ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3759,7 +3753,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xCE */
+ /* ╬ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3777,7 +3771,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xCF */
+ /* ╧ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3795,7 +3789,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xD0 */
+ /* ╨ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3813,7 +3807,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xD1 */
+ /* ╤ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3831,7 +3825,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xD2 */
+ /* ╥ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3849,7 +3843,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xD3 */
+ /* ╙ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3867,7 +3861,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xD4 */
+ /* ╘ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3885,7 +3879,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xD5 */
+ /* ╒ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3903,7 +3897,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xD6 */
+ /* ╓ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3921,7 +3915,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xD7 */
+ /* ╫ */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
0x3c, /* ..****.. */
@@ -3939,7 +3933,7 @@
0x3c, /* ..****.. */
0x3c, /* ..****.. */
- /* \xD8 */
+ /* ╪ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3957,7 +3951,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xD9 */
+ /* ┘ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -3975,7 +3969,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xDA */
+ /* ┌ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -3993,7 +3987,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xDB */
+ /* █ */
0xff, /* ******** */
0xff, /* ******** */
0xff, /* ******** */
@@ -4011,7 +4005,7 @@
0xff, /* ******** */
0xff, /* ******** */
- /* \xDC */
+ /* ▄ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4029,7 +4023,7 @@
0xff, /* ******** */
0xff, /* ******** */
- /* \xDD */
+ /* ▌ */
0xf0, /* ****.... */
0xf0, /* ****.... */
0xf0, /* ****.... */
@@ -4047,7 +4041,7 @@
0xf0, /* ****.... */
0xf0, /* ****.... */
- /* \xDE */
+ /* ▐ */
0x0f, /* ....**** */
0x0f, /* ....**** */
0x0f, /* ....**** */
@@ -4065,7 +4059,7 @@
0x0f, /* ....**** */
0x0f, /* ....**** */
- /* \xDF */
+ /* ▀ */
0xff, /* ******** */
0xff, /* ******** */
0xff, /* ******** */
@@ -4083,7 +4077,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE0 */
+ /* α */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4101,7 +4095,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE1 */
+ /* ß */
0x00, /* ........ */
0x00, /* ........ */
0x7c, /* .*****.. */
@@ -4119,7 +4113,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE2 */
+ /* Γ */
0x00, /* ........ */
0x00, /* ........ */
0xfe, /* *******. */
@@ -4137,7 +4131,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE3 */
+ /* π */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4155,7 +4149,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE4 */
+ /* Σ */
0x00, /* ........ */
0x00, /* ........ */
0xfe, /* *******. */
@@ -4173,7 +4167,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE5 */
+ /* σ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4191,7 +4185,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE6 */
+ /* µ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4209,7 +4203,7 @@
0xc0, /* **...... */
0x00, /* ........ */
- /* \xE7 */
+ /* τ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4227,7 +4221,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE8 */
+ /* Φ */
0x00, /* ........ */
0x00, /* ........ */
0x18, /* ...**... */
@@ -4245,7 +4239,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xE9 */
+ /* Θ */
0x00, /* ........ */
0x00, /* ........ */
0x38, /* ..***... */
@@ -4263,7 +4257,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xEA */
+ /* Ω */
0x00, /* ........ */
0x00, /* ........ */
0x3c, /* ..****.. */
@@ -4281,7 +4275,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xEB */
+ /* δ */
0x00, /* ........ */
0x00, /* ........ */
0x1e, /* ...****. */
@@ -4299,7 +4293,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xEC */
+ /* ∞ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4317,7 +4311,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xED */
+ /* φ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4335,7 +4329,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xEE */
+ /* ε */
0x00, /* ........ */
0x00, /* ........ */
0x1c, /* ...***.. */
@@ -4353,7 +4347,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xEF */
+ /* ∩ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4371,7 +4365,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF0 */
+ /* ≡ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4389,7 +4383,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF1 */
+ /* ± */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4407,7 +4401,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF2 */
+ /* ≥ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4425,7 +4419,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF3 */
+ /* ≤ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4443,7 +4437,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF4 */
+ /* ⌠ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4461,7 +4455,7 @@
0x18, /* ...**... */
0x18, /* ...**... */
- /* \xF5 */
+ /* ⌡ */
0x18, /* ...**... */
0x18, /* ...**... */
0x18, /* ...**... */
@@ -4479,7 +4473,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF6 */
+ /* ÷ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4497,7 +4491,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF7 */
+ /* ≈ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4515,7 +4509,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF8 */
+ /* ° */
0x00, /* ........ */
0x00, /* ........ */
0x38, /* ..***... */
@@ -4533,7 +4527,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xF9 */
+ /* ∙ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4551,7 +4545,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xFA */
+ /* · */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
@@ -4569,7 +4563,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xFB */
+ /* √ */
0x00, /* ........ */
0x00, /* ........ */
0x03, /* ......** */
@@ -4587,7 +4581,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xFC */
+ /* ⁿ */
0x00, /* ........ */
0x00, /* ........ */
0xd8, /* **.**... */
@@ -4605,7 +4599,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xFD */
+ /* ² */
0x00, /* ........ */
0x00, /* ........ */
0x78, /* .****... */
@@ -4623,7 +4617,7 @@
0x00, /* ........ */
0x00, /* ........ */
- /* \xFE */
+ /* ■ */
0x00, /* ........ */
0x00, /* ........ */
0x00, /* ........ */
Modified: trunk/sys/dev/fb/creator.c
===================================================================
--- trunk/sys/dev/fb/creator.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/creator.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Jake Burkholder.
* Copyright (c) 2005 - 2006 Marius Strobl <marius at FreeBSD.org>
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/creator.c 263763 2014-03-26 07:31:57Z dim $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -97,7 +98,7 @@
bus_space_write_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off), (val))
#define C(r, g, b) ((b << 16) | (g << 8) | (r))
-static const uint32_t const creator_cmap[] = {
+static const uint32_t creator_cmap[] = {
C(0x00, 0x00, 0x00), /* black */
C(0x00, 0x00, 0xff), /* blue */
C(0x00, 0xff, 0x00), /* green */
@@ -121,7 +122,7 @@
vm_offset_t virt;
vm_paddr_t phys;
vm_size_t size;
-} const creator_fb_map[] = {
+} creator_fb_map[] = {
{ FFB_VIRT_SFB8R, FFB_PHYS_SFB8R, FFB_SIZE_SFB8R },
{ FFB_VIRT_SFB8G, FFB_PHYS_SFB8G, FFB_SIZE_SFB8G },
{ FFB_VIRT_SFB8B, FFB_PHYS_SFB8B, FFB_SIZE_SFB8B },
@@ -270,7 +271,7 @@
RENDERER_MODULE(creator, gfb_set);
-static const u_char const creator_mouse_pointer[64][8] __aligned(8) = {
+static const u_char creator_mouse_pointer[64][8] __aligned(8) = {
{ 0x00, 0x00, }, /* ............ */
{ 0x80, 0x00, }, /* *........... */
{ 0xc0, 0x00, }, /* **.......... */
Added: trunk/sys/dev/fb/creator_vt.c
===================================================================
--- trunk/sys/dev/fb/creator_vt.c (rev 0)
+++ trunk/sys/dev/fb/creator_vt.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,275 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014 Nathan Whitehorn
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/creator_vt.c 271128 2014-09-04 20:18:08Z emaste $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/fbio.h>
+
+#include <dev/vt/vt.h>
+#include <dev/vt/hw/fb/vt_fb.h>
+#include <dev/vt/colors/vt_termcolors.h>
+
+#include <machine/bus.h>
+#include <machine/bus_private.h>
+
+#include <dev/ofw/openfirm.h>
+#include "creatorreg.h"
+
+static vd_probe_t creatorfb_probe;
+static vd_init_t creatorfb_init;
+static vd_blank_t creatorfb_blank;
+static vd_bitblt_text_t creatorfb_bitblt_text;
+static vd_bitblt_bmp_t creatorfb_bitblt_bitmap;
+
+static const struct vt_driver vt_creatorfb_driver = {
+ .vd_name = "creatorfb",
+ .vd_probe = creatorfb_probe,
+ .vd_init = creatorfb_init,
+ .vd_blank = creatorfb_blank,
+ .vd_bitblt_text = creatorfb_bitblt_text,
+ .vd_bitblt_bmp = creatorfb_bitblt_bitmap,
+ .vd_fb_ioctl = vt_fb_ioctl,
+ .vd_fb_mmap = vt_fb_mmap,
+ .vd_priority = VD_PRIORITY_SPECIFIC
+};
+
+struct creatorfb_softc {
+ struct fb_info fb;
+ struct bus_space_tag memt[1];
+ bus_space_handle_t memh;
+};
+
+static struct creatorfb_softc creatorfb_conssoftc;
+VT_DRIVER_DECLARE(vt_creatorfb, vt_creatorfb_driver);
+
+static int
+creatorfb_probe(struct vt_device *vd)
+{
+ phandle_t chosen, node;
+ ihandle_t stdout;
+ char type[64], name[64];
+
+ chosen = OF_finddevice("/chosen");
+ OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
+ node = OF_instance_to_package(stdout);
+ if (node == -1) {
+ /*
+ * The "/chosen/stdout" does not exist try
+ * using "screen" directly.
+ */
+ node = OF_finddevice("screen");
+ }
+ OF_getprop(node, "device_type", type, sizeof(type));
+ if (strcmp(type, "display") != 0)
+ return (CN_DEAD);
+
+ OF_getprop(node, "name", name, sizeof(name));
+ if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0)
+ return (CN_DEAD);
+
+ /* Looks OK... */
+ return (CN_INTERNAL);
+}
+
+static int
+creatorfb_init(struct vt_device *vd)
+{
+ struct creatorfb_softc *sc;
+ phandle_t chosen;
+ phandle_t node;
+ ihandle_t handle;
+ uint32_t height, width;
+ char type[64], name[64];
+ bus_addr_t phys;
+ int space;
+
+ /* Initialize softc */
+ vd->vd_softc = sc = &creatorfb_conssoftc;
+
+ chosen = OF_finddevice("/chosen");
+ OF_getprop(chosen, "stdout", &handle, sizeof(ihandle_t));
+ node = OF_instance_to_package(handle);
+ if (node == -1) {
+ /*
+ * The "/chosen/stdout" does not exist try
+ * using "screen" directly.
+ */
+ node = OF_finddevice("screen");
+ handle = OF_open("screen");
+ }
+ OF_getprop(node, "device_type", type, sizeof(type));
+ if (strcmp(type, "display") != 0)
+ return (CN_DEAD);
+
+ OF_getprop(node, "name", name, sizeof(name));
+ if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0)
+ return (CN_DEAD);
+
+ /* Make sure we have needed properties */
+ if (OF_getproplen(node, "height") != sizeof(height) ||
+ OF_getproplen(node, "width") != sizeof(width))
+ return (CN_DEAD);
+
+ OF_getprop(node, "height", &height, sizeof(height));
+ OF_getprop(node, "width", &width, sizeof(width));
+
+ sc->fb.fb_height = height;
+ sc->fb.fb_width = width;
+ sc->fb.fb_bpp = sc->fb.fb_depth = 32;
+ sc->fb.fb_stride = 8192; /* Fixed */
+ sc->fb.fb_size = sc->fb.fb_height * sc->fb.fb_stride;
+
+ /* Map linear framebuffer */
+ if (OF_decode_addr(node, FFB_DFB24, &space, &phys) != 0)
+ return (CN_DEAD);
+ sc->fb.fb_pbase = phys;
+ sc->memh = sparc64_fake_bustag(space, phys, &sc->memt[0]);
+
+ /* 32-bit VGA palette */
+ vt_generate_cons_palette(sc->fb.fb_cmap, COLOR_FORMAT_RGB,
+ 255, 0, 255, 8, 255, 16);
+ sc->fb.fb_cmsize = 16;
+
+ vt_fb_init(vd);
+
+ return (CN_INTERNAL);
+}
+
+static void
+creatorfb_blank(struct vt_device *vd, term_color_t color)
+{
+ struct creatorfb_softc *sc;
+ uint32_t c;
+ int i;
+
+ sc = vd->vd_softc;
+ c = sc->fb.fb_cmap[color];
+
+ for (i = 0; i < sc->fb.fb_height; i++)
+ bus_space_set_region_4(sc->memt, sc->memh, i*sc->fb.fb_stride,
+ c, sc->fb.fb_width);
+}
+
+static void
+creatorfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
+ const uint8_t *pattern, const uint8_t *mask,
+ unsigned int width, unsigned int height,
+ unsigned int x, unsigned int y, term_color_t fg, term_color_t bg)
+{
+ struct creatorfb_softc *sc = vd->vd_softc;
+ u_long line;
+ uint32_t fgc, bgc;
+ int c, l;
+ uint8_t b, m;
+
+ fgc = sc->fb.fb_cmap[fg];
+ bgc = sc->fb.fb_cmap[bg];
+ b = m = 0;
+
+ line = (sc->fb.fb_stride * y) + 4*x;
+ for (l = 0;
+ l < height && y + l < vw->vw_draw_area.tr_end.tp_row;
+ l++) {
+ for (c = 0;
+ c < width && x + c < vw->vw_draw_area.tr_end.tp_col;
+ c++) {
+ if (c % 8 == 0)
+ b = *pattern++;
+ else
+ b <<= 1;
+ if (mask != NULL) {
+ if (c % 8 == 0)
+ m = *mask++;
+ else
+ m <<= 1;
+ /* Skip pixel write if mask not set. */
+ if ((m & 0x80) == 0)
+ continue;
+ }
+ bus_space_write_4(sc->memt, sc->memh, line + 4*c,
+ (b & 0x80) ? fgc : bgc);
+ }
+ line += sc->fb.fb_stride;
+ }
+}
+
+void
+creatorfb_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
+ const term_rect_t *area)
+{
+ unsigned int col, row, x, y;
+ struct vt_font *vf;
+ term_char_t c;
+ term_color_t fg, bg;
+ const uint8_t *pattern;
+
+ vf = vw->vw_font;
+
+ for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) {
+ for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col;
+ ++col) {
+ x = col * vf->vf_width +
+ vw->vw_draw_area.tr_begin.tp_col;
+ y = row * vf->vf_height +
+ vw->vw_draw_area.tr_begin.tp_row;
+
+ c = VTBUF_GET_FIELD(&vw->vw_buf, row, col);
+ pattern = vtfont_lookup(vf, c);
+ vt_determine_colors(c,
+ VTBUF_ISCURSOR(&vw->vw_buf, row, col), &fg, &bg);
+
+ creatorfb_bitblt_bitmap(vd, vw,
+ pattern, NULL, vf->vf_width, vf->vf_height,
+ x, y, fg, bg);
+ }
+ }
+
+#ifndef SC_NO_CUTPASTE
+ if (!vd->vd_mshown)
+ return;
+
+ term_rect_t drawn_area;
+
+ drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width;
+ drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height;
+ drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width;
+ drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height;
+
+ if (vt_is_cursor_in_area(vd, &drawn_area)) {
+ creatorfb_bitblt_bitmap(vd, vw,
+ vd->vd_mcursor->map, vd->vd_mcursor->mask,
+ vd->vd_mcursor->width, vd->vd_mcursor->height,
+ vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col,
+ vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row,
+ vd->vd_mcursor_fg, vd->vd_mcursor_bg);
+ }
+#endif
+}
Property changes on: trunk/sys/dev/fb/creator_vt.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/fb/creatorreg.h
===================================================================
--- trunk/sys/dev/fb/creatorreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/creatorreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (C) 2000 David S. Miller (davem at redhat.com)
*
@@ -45,7 +46,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/fb/creatorreg.h 166059 2007-01-16 21:08:22Z marius $
*/
#ifndef _DEV_FB_CREATORREG_H_
Modified: trunk/sys/dev/fb/fb.c
===================================================================
--- trunk/sys/dev/fb/fb.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/fb.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
* All rights reserved.
@@ -27,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/fb.c 227843 2011-11-22 21:28:20Z marius $");
#include "opt_fb.h"
Added: trunk/sys/dev/fb/fb_if.m
===================================================================
--- trunk/sys/dev/fb/fb_if.m (rev 0)
+++ trunk/sys/dev/fb/fb_if.m 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,14 @@
+/* $MidnightBSD$ */
+#include <sys/bus.h>
+#include <sys/fbio.h>
+
+INTERFACE fb;
+
+METHOD int pin_max {
+ device_t dev;
+ int *npins;
+};
+
+METHOD struct fb_info * getinfo {
+ device_t dev;
+};
Property changes on: trunk/sys/dev/fb/fb_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/sys/dev/fb/fbd.c
===================================================================
--- trunk/sys/dev/fb/fbd.c (rev 0)
+++ trunk/sys/dev/fb/fbd.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,358 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Aleksandr Rybalko under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * 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: stable/10/sys/dev/fb/fbd.c 282749 2015-05-11 08:00:16Z avg $
+ */
+
+/* Generic framebuffer */
+/* TODO unlink from VT(9) */
+/* TODO done normal /dev/fb methods */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/fbd.c 282749 2015-05-11 08:00:16Z avg $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/queue.h>
+#include <sys/fbio.h>
+
+#include <machine/bus.h>
+
+#include <dev/vt/vt.h>
+#include <dev/vt/hw/fb/vt_fb.h>
+
+#include "fb_if.h"
+
+LIST_HEAD(fb_list_head_t, fb_list_entry) fb_list_head =
+ LIST_HEAD_INITIALIZER(fb_list_head);
+struct fb_list_entry {
+ struct fb_info *fb_info;
+ struct cdev *fb_si;
+ LIST_ENTRY(fb_list_entry) fb_list;
+};
+
+struct fbd_softc {
+ device_t sc_dev;
+ struct fb_info *sc_info;
+};
+
+static void fbd_evh_init(void *);
+/* SI_ORDER_SECOND, just after EVENTHANDLERs initialized. */
+SYSINIT(fbd_evh_init, SI_SUB_CONFIGURE, SI_ORDER_SECOND, fbd_evh_init, NULL);
+
+static d_open_t fb_open;
+static d_close_t fb_close;
+static d_read_t fb_read;
+static d_write_t fb_write;
+static d_ioctl_t fb_ioctl;
+static d_mmap_t fb_mmap;
+
+static struct cdevsw fb_cdevsw = {
+ .d_version = D_VERSION,
+ .d_flags = D_NEEDGIANT,
+ .d_open = fb_open,
+ .d_close = fb_close,
+ .d_read = fb_read,
+ .d_write = fb_write,
+ .d_ioctl = fb_ioctl,
+ .d_mmap = fb_mmap,
+ .d_name = "fb",
+};
+
+static int framebuffer_dev_unit = 0;
+
+static int
+fb_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
+{
+
+ return (0);
+}
+
+static int
+fb_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
+{
+
+ return (0);
+}
+
+static int
+fb_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
+ struct thread *td)
+{
+ struct fb_info *info;
+ int error;
+
+ error = 0;
+ info = dev->si_drv1;
+
+ switch (cmd) {
+ case FBIOGTYPE:
+ bcopy(info, (struct fbtype *)data, sizeof(struct fbtype));
+ break;
+
+ case FBIO_GETWINORG: /* get frame buffer window origin */
+ *(u_int *)data = 0;
+ break;
+
+ case FBIO_GETDISPSTART: /* get display start address */
+ ((video_display_start_t *)data)->x = 0;
+ ((video_display_start_t *)data)->y = 0;
+ break;
+
+ case FBIO_GETLINEWIDTH: /* get scan line width in bytes */
+ *(u_int *)data = info->fb_stride;
+ break;
+
+ case FBIO_BLANK: /* blank display */
+ error = 0; /* TODO */
+ break;
+
+ default:
+ error = ENOIOCTL;
+ break;
+ }
+ return (error);
+}
+
+static int
+fb_read(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+ return (0); /* XXX nothing to read, yet */
+}
+
+static int
+fb_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+ return (0); /* XXX nothing written */
+}
+
+static int
+fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
+ vm_memattr_t *memattr)
+{
+ struct fb_info *info;
+
+ info = dev->si_drv1;
+
+ if ((info->fb_flags & FB_FLAG_NOMMAP) || info->fb_pbase == 0)
+ return (ENODEV);
+
+ if (offset < info->fb_size) {
+ *paddr = info->fb_pbase + offset;
+ return (0);
+ }
+ return (EINVAL);
+}
+
+static int
+fb_init(struct fb_list_entry *entry, int unit)
+{
+ struct fb_info *info;
+
+ info = entry->fb_info;
+ entry->fb_si = make_dev(&fb_cdevsw, unit, UID_ROOT, GID_WHEEL,
+ 0600, "fb%d", unit);
+ entry->fb_si->si_drv1 = info;
+ info->fb_cdev = entry->fb_si;
+
+ return (0);
+}
+
+int
+fbd_list()
+{
+ struct fb_list_entry *entry;
+
+ if (LIST_EMPTY(&fb_list_head))
+ return (ENOENT);
+
+ LIST_FOREACH(entry, &fb_list_head, fb_list) {
+ printf("FB %s @%p\n", entry->fb_info->fb_name,
+ (void *)entry->fb_info->fb_pbase);
+ }
+
+ return (0);
+}
+
+static struct fb_list_entry *
+fbd_find(struct fb_info* info)
+{
+ struct fb_list_entry *entry, *tmp;
+
+ LIST_FOREACH_SAFE(entry, &fb_list_head, fb_list, tmp) {
+ if (entry->fb_info == info) {
+ return (entry);
+ }
+ }
+
+ return (NULL);
+}
+
+int
+fbd_register(struct fb_info* info)
+{
+ struct fb_list_entry *entry;
+ int err, first;
+
+ first = 0;
+ if (LIST_EMPTY(&fb_list_head))
+ first++;
+
+ entry = fbd_find(info);
+ if (entry != NULL) {
+ /* XXX Update framebuffer params */
+ return (0);
+ }
+
+ entry = malloc(sizeof(struct fb_list_entry), M_DEVBUF, M_WAITOK|M_ZERO);
+ entry->fb_info = info;
+
+ LIST_INSERT_HEAD(&fb_list_head, entry, fb_list);
+
+ err = fb_init(entry, framebuffer_dev_unit++);
+ if (err)
+ return (err);
+
+ if (first) {
+ err = vt_fb_attach(info);
+ if (err)
+ return (err);
+ }
+
+ return (0);
+}
+
+int
+fbd_unregister(struct fb_info* info)
+{
+ struct fb_list_entry *entry, *tmp;
+
+ LIST_FOREACH_SAFE(entry, &fb_list_head, fb_list, tmp) {
+ if (entry->fb_info == info) {
+ LIST_REMOVE(entry, fb_list);
+ free(entry, M_DEVBUF);
+ return (0);
+ }
+ }
+
+ return (ENOENT);
+}
+
+static void
+register_fb_wrap(void *arg, void *ptr)
+{
+
+ fbd_register((struct fb_info *)ptr);
+}
+
+static void
+unregister_fb_wrap(void *arg, void *ptr)
+{
+
+ fbd_unregister((struct fb_info *)ptr);
+}
+
+static void
+fbd_evh_init(void *ctx)
+{
+
+ EVENTHANDLER_REGISTER(register_framebuffer, register_fb_wrap, NULL,
+ EVENTHANDLER_PRI_ANY);
+ EVENTHANDLER_REGISTER(unregister_framebuffer, unregister_fb_wrap, NULL,
+ EVENTHANDLER_PRI_ANY);
+}
+
+/* Newbus methods. */
+static int
+fbd_probe(device_t dev)
+{
+
+ return (BUS_PROBE_NOWILDCARD);
+}
+
+static int
+fbd_attach(device_t dev)
+{
+ struct fbd_softc *sc;
+ int err;
+
+ sc = device_get_softc(dev);
+
+ sc->sc_dev = dev;
+ sc->sc_info = FB_GETINFO(device_get_parent(dev));
+ if (sc->sc_info == NULL)
+ return (ENXIO);
+ err = fbd_register(sc->sc_info);
+
+ return (err);
+}
+
+static int
+fbd_detach(device_t dev)
+{
+ struct fbd_softc *sc;
+ int err;
+
+ sc = device_get_softc(dev);
+
+ err = fbd_unregister(sc->sc_info);
+
+ return (err);
+}
+
+static device_method_t fbd_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, fbd_probe),
+ DEVMETHOD(device_attach, fbd_attach),
+ DEVMETHOD(device_detach, fbd_detach),
+
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+
+ { 0, 0 }
+};
+
+driver_t fbd_driver = {
+ "fbd",
+ fbd_methods,
+ sizeof(struct fbd_softc)
+};
+
+devclass_t fbd_devclass;
+
+DRIVER_MODULE(fbd, fb, fbd_driver, fbd_devclass, 0, 0);
+DRIVER_MODULE(fbd, drmn, fbd_driver, fbd_devclass, 0, 0);
+MODULE_VERSION(fbd, 1);
+
Property changes on: trunk/sys/dev/fb/fbd.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/fb/fbreg.h
===================================================================
--- trunk/sys/dev/fb/fbreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/fbreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
* All rights reserved.
@@ -23,7 +24,7 @@
* (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$
+ * $FreeBSD: stable/10/sys/dev/fb/fbreg.h 239696 2012-08-25 23:59:31Z gonzo $
*/
#ifndef _DEV_FB_FBREG_H_
@@ -35,13 +36,41 @@
/* some macros */
#if defined(__amd64__) || defined(__i386__)
-#define bcopy_io(s, d, c) bcopy((void *)(s), (void *)(d), (c))
-#define bcopy_toio(s, d, c) bcopy((void *)(s), (void *)(d), (c))
-#define bcopy_fromio(s, d, c) bcopy((void *)(s), (void *)(d), (c))
+
+static __inline void
+copyw(uint16_t *src, uint16_t *dst, size_t size)
+{
+ size >>= 1;
+ while (size--)
+ *dst++ = *src++;
+}
+#define bcopy_io(s, d, c) copyw((void*)(s), (void*)(d), (c))
+#define bcopy_toio(s, d, c) copyw((void*)(s), (void*)(d), (c))
+#define bcopy_fromio(s, d, c) copyw((void*)(s), (void*)(d), (c))
#define bzero_io(d, c) bzero((void *)(d), (c))
#define fill_io(p, d, c) fill((p), (void *)(d), (c))
#define fillw_io(p, d, c) fillw((p), (void *)(d), (c))
-#elif defined(__sparc64__)
+#elif defined(__ia64__) || defined(__sparc64__)
+#if defined(__ia64__)
+#include <machine/bus.h>
+#define bcopy_fromio(s, d, c) \
+ bus_space_read_region_1(IA64_BUS_SPACE_MEM, s, 0, (void*)(d), c)
+#define bcopy_io(s, d, c) \
+ bus_space_copy_region_1(IA64_BUS_SPACE_MEM, s, 0, d, 0, c)
+#define bcopy_toio(s, d, c) \
+ bus_space_write_region_1(IA64_BUS_SPACE_MEM, d, 0, (void*)(s), c)
+#define bzero_io(d, c) \
+ bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, 0, c)
+#define fill_io(p, d, c) \
+ bus_space_set_region_1(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c)
+#define fillw_io(p, d, c) \
+ bus_space_set_region_2(IA64_BUS_SPACE_MEM, (intptr_t)(d), 0, p, c)
+#define readb(a) bus_space_read_1(IA64_BUS_SPACE_MEM, a, 0)
+#define readw(a) bus_space_read_2(IA64_BUS_SPACE_MEM, a, 0)
+#define writeb(a, v) bus_space_write_1(IA64_BUS_SPACE_MEM, a, 0, v)
+#define writew(a, v) bus_space_write_2(IA64_BUS_SPACE_MEM, a, 0, v)
+#define writel(a, v) bus_space_write_4(IA64_BUS_SPACE_MEM, a, 0, v)
+#endif /* __ia64__ */
static __inline void
fillw(int val, uint16_t *buf, size_t size)
{
@@ -48,7 +77,51 @@
while (size--)
*buf++ = val;
}
-#else /* !__i386__ && !__amd64__ && !__sparc64__ */
+#elif defined(__powerpc__)
+
+#define bcopy_io(s, d, c) ofwfb_bcopy((void *)(s), (void *)(d), (c))
+#define bcopy_toio(s, d, c) ofwfb_bcopy((void *)(s), (void *)(d), (c))
+#define bcopy_fromio(s, d, c) ofwfb_bcopy((void *)(s), (void *)(d), (c))
+#define bzero_io(d, c) ofwfb_bzero((void *)(d), (c))
+#define fillw(p, d, c) ofwfb_fillw((p), (void *)(d), (c))
+#define fillw_io(p, d, c) ofwfb_fillw((p), (void *)(d), (c))
+#define readw(a) ofwfb_readw((u_int16_t *)(a))
+#define writew(a, v) ofwfb_writew((u_int16_t *)(a), (v))
+void ofwfb_bcopy(const void *s, void *d, size_t c);
+void ofwfb_bzero(void *d, size_t c);
+void ofwfb_fillw(int pat, void *base, size_t cnt);
+u_int16_t ofwfb_readw(u_int16_t *addr);
+void ofwfb_writew(u_int16_t *addr, u_int16_t val);
+
+#elif defined(__mips__) || defined(__arm__)
+
+/*
+ * Use amd64/i386-like settings under the assumption that MIPS-based display
+ * drivers will have to add a level of indirection between a syscons-managed
+ * frame buffer and the actual video hardware. We are forced to do this
+ * because syscons doesn't carry around required busspace handles and tags to
+ * use here. This is only really a problem for true VGA devices hooked up to
+ * MIPS, as others will be performing a translation anyway.
+ */
+#define bcopy_io(s, d, c) memcpy((void *)(d), (void *)(s), (c))
+#define bcopy_toio(s, d, c) memcpy((void *)(d), (void *)(s), (c))
+#define bcopy_fromio(s, d, c) memcpy((void *)(d), (void *)(s), (c))
+#define bzero_io(d, c) memset((void *)(d), 0, (c))
+#define fill_io(p, d, c) memset((void *)(d), (p), (c))
+static __inline void
+fillw(int val, uint16_t *buf, size_t size)
+{
+ while (size--)
+ *buf++ = val;
+}
+#define fillw_io(p, d, c) fillw((p), (void *)(d), (c))
+
+#if defined(__arm__)
+#define readw(a) (*(uint16_t*)(a))
+#define writew(a, v) (*(uint16_t*)(a) = (v))
+#endif
+
+#else /* !__i386__ && !__amd64__ && !__ia64__ && !__sparc64__ && !__powerpc__ */
#define bcopy_io(s, d, c) memcpy_io((d), (s), (c))
#define bcopy_toio(s, d, c) memcpy_toio((d), (void *)(s), (c))
#define bcopy_fromio(s, d, c) memcpy_fromio((void *)(d), (s), (c))
Modified: trunk/sys/dev/fb/gallant12x22.c
===================================================================
--- trunk/sys/dev/fb/gallant12x22.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/gallant12x22.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $OpenBSD: gallant12x22.h,v 1.2 2002/05/09 08:59:03 maja Exp $ */
/* $NetBSD: gallant12x22.h,v 1.2 1999/05/18 21:51:58 ad Exp $ */
@@ -17,7 +18,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.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -37,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/gallant12x22.c 271105 2014-09-04 16:51:45Z emaste $");
#include <sys/param.h>
Modified: trunk/sys/dev/fb/gfb.h
===================================================================
--- trunk/sys/dev/fb/gfb.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/gfb.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
* All rights reserved.
@@ -26,7 +27,7 @@
*
* Copyright (c) 2000 Andrew Miklic
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/fb/gfb.h 170837 2007-06-16 21:31:53Z marius $
*/
#ifndef _FB_GFB_H_
Modified: trunk/sys/dev/fb/machfb.c
===================================================================
--- trunk/sys/dev/fb/machfb.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/machfb.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002 Bang Jun-Young
* Copyright (c) 2005 Marius Strobl <marius at FreeBSD.org>
@@ -29,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/machfb.c 263763 2014-03-26 07:31:57Z dim $");
/*
* Driver for ATI Mach64 graphics chips. Some code is derived from the
@@ -131,7 +132,7 @@
uint16_t chip_id;
const char *name;
uint32_t ramdac_freq;
-} const machfb_info[] = {
+} machfb_info[] = {
{ ATI_MACH64_CT, "ATI Mach64 CT", 135000 },
{ ATI_RAGE_PRO_AGP, "ATI 3D Rage Pro (AGP)", 230000 },
{ ATI_RAGE_PRO_AGP1X, "ATI 3D Rage Pro (AGP 1x)", 230000 },
@@ -169,7 +170,7 @@
uint8_t red;
uint8_t green;
uint8_t blue;
-} const machfb_default_cmap[16] = {
+} machfb_default_cmap[16] = {
{0x00, 0x00, 0x00}, /* black */
{0x00, 0x00, 0xff}, /* blue */
{0x00, 0xff, 0x00}, /* green */
@@ -190,7 +191,7 @@
#define MACHFB_CMAP_OFF 16
-static const u_char const machfb_mouse_pointer_bits[64][8] = {
+static const u_char machfb_mouse_pointer_bits[64][8] = {
{ 0x00, 0x00, }, /* ............ */
{ 0x80, 0x00, }, /* *........... */
{ 0xc0, 0x00, }, /* **.......... */
@@ -219,7 +220,7 @@
* Lookup table to perform a bit-swap of the mouse pointer bits,
* map set bits to CUR_CLR0 and unset bits to transparent.
*/
-static const u_char const machfb_mouse_pointer_lut[] = {
+static const u_char machfb_mouse_pointer_lut[] = {
0xaa, 0x2a, 0x8a, 0x0a, 0xa2, 0x22, 0x82, 0x02,
0xa8, 0x28, 0x88, 0x08, 0xa0, 0x20, 0x80, 0x00
};
@@ -1418,7 +1419,7 @@
machfb_get_memsize(struct machfb_softc *sc)
{
int tmp, memsize;
- const int const mem_tab[] = {
+ const int mem_tab[] = {
512, 1024, 2048, 4096, 6144, 8192, 12288, 16384
};
Modified: trunk/sys/dev/fb/machfbreg.h
===================================================================
--- trunk/sys/dev/fb/machfbreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/machfbreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright 1992,1993,1994,1995,1996,1997 by Kevin E. Martin, Chapel Hill, North Carolina.
*
@@ -26,7 +27,7 @@
*
* from: NetBSD: machfbreg.h,v 1.1 2002/10/24 18:15:57 junyoung Exp
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/fb/machfbreg.h 146482 2005-05-21 20:47:38Z marius $
*/
#ifndef _DEV_FB_MACHFB_H_
Modified: trunk/sys/dev/fb/s3_pci.c
===================================================================
--- trunk/sys/dev/fb/s3_pci.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/s3_pci.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2000 Alcove - Nicolas Souchu <nsouch at freebsd.org>
* All rights reserved.
@@ -27,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/s3_pci.c 234362 2012-04-16 23:29:12Z jkim $");
/* Enable LFB on S3 cards that has only VESA 1.2 BIOS */
@@ -513,7 +514,7 @@
/* Attach the driver to the VGA/VESA framework
*/
for (i = 0; (adp = vid_get_adapter(i)) != NULL; ++i) {
- if ((adp->va_type == KD_VGA))
+ if (adp->va_type == KD_VGA)
break;
}
Modified: trunk/sys/dev/fb/splash.c
===================================================================
--- trunk/sys/dev/fb/splash.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/splash.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
* All rights reserved.
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/splash.c 218661 2011-02-13 19:25:48Z marcel $");
#include "opt_splash.h"
Modified: trunk/sys/dev/fb/splash_bmp.c
===================================================================
--- trunk/sys/dev/fb/splash_bmp.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/splash_bmp.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Michael Smith <msmith at freebsd.org>
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at freebsd.org>
@@ -24,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/fb/splash_bmp.c 174985 2007-12-29 23:26:59Z wkoszek $
*/
#include <sys/param.h>
Modified: trunk/sys/dev/fb/splash_pcx.c
===================================================================
--- trunk/sys/dev/fb/splash_pcx.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/splash_pcx.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Michael Smith <msmith at freebsd.org>
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at freebsd.org>
- * Copyright (c) 1999 Dag-Erling Co\xEFdan Sm\xF8rgrav
+ * Copyright (c) 1999 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +28,7 @@
* (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$
+ * $FreeBSD: stable/10/sys/dev/fb/splash_pcx.c 230132 2012-01-15 13:23:18Z uqs $
*/
#include <sys/param.h>
Modified: trunk/sys/dev/fb/splash_txt.c
===================================================================
--- trunk/sys/dev/fb/splash_txt.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/splash_txt.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Michael Smith <msmith at freebsd.org>
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at freebsd.org>
@@ -25,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/dev/fb/splash_txt.c 228445 2011-12-12 21:12:07Z eadler $
*/
#include <sys/param.h>
Modified: trunk/sys/dev/fb/splashreg.h
===================================================================
--- trunk/sys/dev/fb/splashreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/splashreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
* All rights reserved.
@@ -23,7 +24,7 @@
* (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$
+ * $FreeBSD: stable/10/sys/dev/fb/splashreg.h 132199 2004-07-15 08:26:07Z phk $
*/
#ifndef _DEV_FB_SPLASHREG_H_
Modified: trunk/sys/dev/fb/vesa.c
===================================================================
--- trunk/sys/dev/fb/vesa.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/vesa.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,6 +1,7 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1998 Kazutaka YOKOTA and Michael Smith
- * Copyright (c) 2009-2012 Jung-uk Kim <jkim at FreeBSD.org>
+ * Copyright (c) 2009-2013 Jung-uk Kim <jkim at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/vesa.c 317501 2017-04-27 12:15:15Z kib $");
#include "opt_vga.h"
#include "opt_vesa.h"
@@ -79,11 +80,12 @@
typedef struct adp_state adp_state_t;
static struct mtx vesa_lock;
+MTX_SYSINIT(vesa_lock, &vesa_lock, "VESA lock", MTX_DEF);
static int vesa_state;
static void *vesa_state_buf;
static uint32_t vesa_state_buf_offs;
-static ssize_t vesa_state_buf_size;
+static size_t vesa_state_buf_size;
static u_char *vesa_palette;
static uint32_t vesa_palette_offs;
@@ -207,7 +209,7 @@
#define STATE_SIZE 0
#define STATE_SAVE 1
#define STATE_LOAD 2
-static ssize_t vesa_bios_state_buf_size(int);
+static size_t vesa_bios_state_buf_size(int);
static int vesa_bios_save_restore(int code, void *p);
#ifdef MODE_TABLE_BROKEN
static int vesa_bios_get_line_length(void);
@@ -505,7 +507,7 @@
return (regs.R_AX != 0x004f);
}
-static ssize_t
+static size_t
vesa_bios_state_buf_size(int state)
{
x86regs_t regs;
@@ -543,7 +545,8 @@
switch (code) {
case STATE_SAVE:
x86bios_intr(®s, 0x10);
- bcopy(vesa_state_buf, p, vesa_state_buf_size);
+ if (regs.R_AX == 0x004f)
+ bcopy(vesa_state_buf, p, vesa_state_buf_size);
break;
case STATE_LOAD:
bcopy(p, vesa_state_buf, vesa_state_buf_size);
@@ -1025,7 +1028,8 @@
++modes;
}
- vesa_vmode[modes].vi_mode = EOT;
+ if (vesa_vmode != NULL)
+ vesa_vmode[modes].vi_mode = EOT;
if (bootverbose)
printf("VESA: %d mode(s) found\n", modes);
@@ -1462,27 +1466,34 @@
static int
vesa_save_state(video_adapter_t *adp, void *p, size_t size)
{
- vm_offset_t buf;
+ void *buf;
size_t bsize;
- if (adp != vesa_adp || vesa_state_buf_size == 0)
+ if (adp != vesa_adp || (size == 0 && vesa_state_buf_size == 0))
return ((*prevvidsw->save_state)(adp, p, size));
+ bsize = offsetof(adp_state_t, regs) + vesa_state_buf_size;
if (size == 0)
- return (offsetof(adp_state_t, regs) + vesa_state_buf_size);
- if (size < (offsetof(adp_state_t, regs) + vesa_state_buf_size))
+ return (bsize);
+ if (vesa_state_buf_size > 0 && size < bsize)
return (EINVAL);
- buf = adp->va_buffer;
- if (buf != 0) {
- bsize = adp->va_buffer_size;
- vesa_vmem_buf = malloc(bsize, M_DEVBUF, M_NOWAIT);
- if (vesa_vmem_buf != NULL)
- bcopy((void *)buf, vesa_vmem_buf, bsize);
- } else
+ if (vesa_vmem_buf != NULL) {
+ free(vesa_vmem_buf, M_DEVBUF);
vesa_vmem_buf = NULL;
+ }
+ if (VESA_MODE(adp->va_mode)) {
+ buf = (void *)adp->va_buffer;
+ if (buf != NULL) {
+ bsize = adp->va_buffer_size;
+ vesa_vmem_buf = malloc(bsize, M_DEVBUF, M_NOWAIT);
+ if (vesa_vmem_buf != NULL)
+ bcopy(buf, vesa_vmem_buf, bsize);
+ }
+ }
+ if (vesa_state_buf_size == 0)
+ return ((*prevvidsw->save_state)(adp, p, size));
((adp_state_t *)p)->sig = V_STATE_SIG;
- bzero(((adp_state_t *)p)->regs, vesa_state_buf_size);
return (vesa_bios_save_restore(STATE_SAVE, ((adp_state_t *)p)->regs));
}
@@ -1489,9 +1500,9 @@
static int
vesa_load_state(video_adapter_t *adp, void *p)
{
- vm_offset_t buf;
+ void *buf;
size_t bsize;
- int mode;
+ int error, mode;
if (adp != vesa_adp)
return ((*prevvidsw->load_state)(adp, p));
@@ -1500,18 +1511,21 @@
(void)vesa_bios_post();
bsize = adp->va_buffer_size;
mode = adp->va_mode;
- (void)vesa_set_mode(adp, adp->va_initial_mode);
+ error = vesa_set_mode(adp, adp->va_initial_mode);
if (mode != adp->va_initial_mode)
- (void)vesa_set_mode(adp, mode);
+ error = vesa_set_mode(adp, mode);
- if (((adp_state_t *)p)->sig != V_STATE_SIG)
- return ((*prevvidsw->load_state)(adp, p));
if (vesa_vmem_buf != NULL) {
- buf = adp->va_buffer;
- if (buf != 0)
- bcopy(vesa_vmem_buf, (void *)buf, bsize);
+ if (error == 0 && VESA_MODE(mode)) {
+ buf = (void *)adp->va_buffer;
+ if (buf != NULL)
+ bcopy(vesa_vmem_buf, buf, bsize);
+ }
free(vesa_vmem_buf, M_DEVBUF);
+ vesa_vmem_buf = NULL;
}
+ if (((adp_state_t *)p)->sig != V_STATE_SIG)
+ return ((*prevvidsw->load_state)(adp, p));
return (vesa_bios_save_restore(STATE_LOAD, ((adp_state_t *)p)->regs));
}
@@ -1623,6 +1637,9 @@
if (offset > adp->va_window_size - PAGE_SIZE)
return (-1);
*paddr = adp->va_info.vi_buffer + offset;
+#ifdef VM_MEMATTR_WRITE_COMBINING
+ *memattr = VM_MEMATTR_WRITE_COMBINING;
+#endif
return (0);
}
return ((*prevvidsw->mmap)(adp, offset, paddr, prot, memattr));
@@ -1903,8 +1920,6 @@
if (vesa_init_done)
return (0);
- mtx_init(&vesa_lock, "VESA lock", NULL, MTX_DEF);
-
/* locate a VGA adapter */
vesa_adp = NULL;
error = vesa_configure(0);
@@ -1943,7 +1958,6 @@
}
vesa_bios_uninit();
- mtx_destroy(&vesa_lock);
return (error);
}
Modified: trunk/sys/dev/fb/vesa.h
===================================================================
--- trunk/sys/dev/fb/vesa.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/vesa.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1998 Michael Smith and Kazutaka YOKOTA
* All rights reserved.
@@ -23,7 +24,7 @@
* (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$
+ * $FreeBSD: stable/10/sys/dev/fb/vesa.h 231841 2012-02-16 22:33:53Z jkim $
*/
#ifndef _DEV_FB_VESA_H_
Modified: trunk/sys/dev/fb/vga.c
===================================================================
--- trunk/sys/dev/fb/vga.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/vga.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,6 +1,7 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
- * Copyright (c) 1992-1998 S\xF8ren Schmidt
+ * Copyright (c) 1992-1998 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fb/vga.c 233892 2012-04-04 21:19:55Z jkim $");
#include "opt_vga.h"
#include "opt_fb.h"
@@ -2160,10 +2161,6 @@
buf[1] = info.vi_height - 1; /* ROWS */
}
buf[2] = info.vi_cheight; /* POINTS */
- } else {
- /* XXX: shouldn't be happening... */
- printf("vga%d: %s: failed to obtain mode info. (vga_save_state())\n",
- adp->va_unit, adp->va_name);
}
#else
buf[0] = readb(BIOS_PADDRTOVADDR(0x44a)); /* COLS */
Modified: trunk/sys/dev/fb/vgareg.h
===================================================================
--- trunk/sys/dev/fb/vgareg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fb/vgareg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1999 Kazutaka YOKOTA <yokota at zodiac.mech.utsunomiya-u.ac.jp>
* All rights reserved.
@@ -23,7 +24,7 @@
* (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$
+ * $FreeBSD: stable/10/sys/dev/fb/vgareg.h 201223 2009-12-29 21:51:28Z rnoland $
*/
#ifndef _DEV_FB_VGAREG_H_
Modified: trunk/sys/dev/fdc/fdc.c
===================================================================
--- trunk/sys/dev/fdc/fdc.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fdc/fdc.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Poul-Henning Kamp
* Copyright (c) 1990 The Regents of the University of California.
@@ -51,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdc/fdc.c 254937 2013-08-26 21:15:50Z joerg $");
#include "opt_fdc.h"
@@ -314,7 +315,7 @@
/*
* Bus space handling (access to low-level IO).
*/
-__inline static void
+static inline void
fdregwr(struct fdc_data *fdc, int reg, uint8_t v)
{
@@ -321,7 +322,7 @@
bus_space_write_1(fdc->iot, fdc->ioh[reg], fdc->ioff[reg], v);
}
-__inline static uint8_t
+static inline uint8_t
fdregrd(struct fdc_data *fdc, int reg)
{
@@ -528,7 +529,8 @@
if (fdc_cmd(fdc, 4,
I8207X_CONFIG,
0,
- 0x40 | /* Enable Implied Seek */
+ /* 0x40 | */ /* Enable Implied Seek -
+ * breaks 2step! */
0x10 | /* Polling disabled */
(fifo_threshold - 1), /* Fifo threshold */
0x00, /* Precomp track */
@@ -760,10 +762,13 @@
int i, nsect;
int st0, st3, cyl, mfm, steptrac, cylinder, descyl, sec;
int head;
+ int override_error;
static int need_recal;
struct fdc_readid *idp;
struct fd_formb *finfo;
+ override_error = 0;
+
/* Have we exhausted our retries ? */
bp = fdc->bp;
fd = fdc->fd;
@@ -922,14 +927,8 @@
/*
* SEEK to where we want to be
- *
- * Enhanced controllers do implied seeks for read&write as long as
- * we do not need multiple steps per track.
*/
- if (cylinder != fd->track && (
- fdc->fdct != FDC_ENHANCED ||
- descyl != cylinder ||
- (bp->bio_cmd & (BIO_RDID|BIO_FMT)))) {
+ if (cylinder != fd->track) {
retry_line = __LINE__;
if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, descyl, 0))
return (1);
@@ -1095,7 +1094,10 @@
fdc->status[3], fdc->status[4], fdc->status[5]);
}
retry_line = __LINE__;
- return (1);
+ if (fd->options & FDOPT_NOERROR)
+ override_error = 1;
+ else
+ return (1);
}
/* All OK */
switch(bp->bio_cmd) {
@@ -1116,10 +1118,16 @@
bp->bio_resid -= fd->fd_iosize;
bp->bio_completed += fd->fd_iosize;
fd->fd_ioptr += fd->fd_iosize;
- /* Since we managed to get something done, reset the retry */
- fdc->retry = 0;
- if (bp->bio_resid > 0)
- return (0);
+ if (override_error) {
+ if ((debugflags & 4))
+ printf("FDOPT_NOERROR: returning bad data\n");
+ } else {
+ /* Since we managed to get something done,
+ * reset the retry */
+ fdc->retry = 0;
+ if (bp->bio_resid > 0)
+ return (0);
+ }
break;
case BIO_FMT:
break;
@@ -1411,6 +1419,7 @@
ae = e + pp->ace;
if (ar == 0 && aw == 0 && ae == 0) {
+ fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR);
device_unbusy(fd->dev);
return (0);
}
Modified: trunk/sys/dev/fdc/fdc_acpi.c
===================================================================
--- trunk/sys/dev/fdc/fdc_acpi.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fdc/fdc_acpi.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004 Nate Lawson (SDG)
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdc/fdc_acpi.c 246128 2013-01-30 18:01:20Z sbz $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -258,7 +259,7 @@
DEVMETHOD(bus_read_ivar, fdc_read_ivar),
DEVMETHOD(bus_write_ivar, fdc_write_ivar),
- {0, 0}
+ DEVMETHOD_END
};
static driver_t fdc_acpi_driver = {
Modified: trunk/sys/dev/fdc/fdc_isa.c
===================================================================
--- trunk/sys/dev/fdc/fdc_isa.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fdc/fdc_isa.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004-2005 M. Warner Losh.
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdc/fdc_isa.c 143618 2005-03-15 08:02:47Z imp $");
#include <sys/param.h>
#include <sys/bio.h>
Modified: trunk/sys/dev/fdc/fdc_pccard.c
===================================================================
--- trunk/sys/dev/fdc/fdc_pccard.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fdc/fdc_pccard.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004-2005 M. Warner Losh.
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdc/fdc_pccard.c 223624 2011-06-28 08:36:48Z kevlo $");
#include <sys/param.h>
#include <sys/bio.h>
Modified: trunk/sys/dev/fdc/fdcvar.h
===================================================================
--- trunk/sys/dev/fdc/fdcvar.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fdc/fdcvar.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004-2005 M. Warner Losh.
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fdc/fdcvar.h 140469 2005-01-19 07:46:38Z imp $
*/
/* XXX should audit this file to see if additional copyrights needed */
Added: trunk/sys/dev/fdt/fdt_clock.c
===================================================================
--- trunk/sys/dev/fdt/fdt_clock.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_clock.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,163 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014 Ian Lepore <ian at freebsd.org>
+ * 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: stable/10/sys/dev/fdt/fdt_clock.c 278734 2015-02-13 23:37:11Z ian $
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/queue.h>
+#include <sys/systm.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "fdt_clock_if.h"
+#include <dev/fdt/fdt_clock.h>
+
+/*
+ * Loop through all the tuples in the clocks= property for a device, enabling or
+ * disabling each clock.
+ *
+ * Be liberal about errors for now: warn about a failure to enable but keep
+ * trying with any other clocks in the list. Return ENXIO if any errors were
+ * found, and let the caller decide whether the problem is fatal.
+ */
+static int
+enable_disable_all(device_t consumer, boolean_t enable)
+{
+ phandle_t cnode;
+ device_t clockdev;
+ int clocknum, err, i, ncells;
+ uint32_t *clks;
+ boolean_t anyerrors;
+
+ cnode = ofw_bus_get_node(consumer);
+ ncells = OF_getencprop_alloc(cnode, "clocks", sizeof(*clks),
+ (void **)&clks);
+ if (enable && ncells < 2) {
+ device_printf(consumer, "Warning: No clocks specified in fdt "
+ "data; device may not function.");
+ return (ENXIO);
+ }
+ anyerrors = false;
+ for (i = 0; i < ncells; i += 2) {
+ clockdev = OF_device_from_xref(clks[i]);
+ clocknum = clks[i + 1];
+ if (clockdev == NULL) {
+ if (enable)
+ device_printf(consumer, "Warning: can not find "
+ "driver for clock number %u; device may not "
+ "function\n", clocknum);
+ anyerrors = true;
+ continue;
+ }
+ if (enable)
+ err = FDT_CLOCK_ENABLE(clockdev, clocknum);
+ else
+ err = FDT_CLOCK_DISABLE(clockdev, clocknum);
+ if (err != 0) {
+ if (enable)
+ device_printf(consumer, "Warning: failed to "
+ "enable clock number %u; device may not "
+ "function\n", clocknum);
+ anyerrors = true;
+ }
+ }
+ free(clks, M_OFWPROP);
+ return (anyerrors ? ENXIO : 0);
+}
+
+int
+fdt_clock_get_info(device_t consumer, int n, struct fdt_clock_info *info)
+{
+ phandle_t cnode;
+ device_t clockdev;
+ int clocknum, err, ncells;
+ uint32_t *clks;
+
+ cnode = ofw_bus_get_node(consumer);
+ ncells = OF_getencprop_alloc(cnode, "clocks", sizeof(*clks),
+ (void **)&clks);
+ if (ncells <= 0)
+ return (ENXIO);
+ n *= 2;
+ if (ncells <= n)
+ err = ENXIO;
+ else {
+ clockdev = OF_device_from_xref(clks[n]);
+ if (clockdev == NULL)
+ err = ENXIO;
+ else {
+ /*
+ * Make struct contents minimally valid, then call
+ * provider to fill in what it knows (provider can
+ * override anything it wants to).
+ */
+ clocknum = clks[n + 1];
+ bzero(info, sizeof(*info));
+ info->provider = clockdev;
+ info->index = clocknum;
+ info->name = "";
+ err = FDT_CLOCK_GET_INFO(clockdev, clocknum, info);
+ }
+ }
+ free(clks, M_OFWPROP);
+ return (err);
+}
+
+int
+fdt_clock_enable_all(device_t consumer)
+{
+
+ return (enable_disable_all(consumer, true));
+}
+
+int
+fdt_clock_disable_all(device_t consumer)
+{
+
+ return (enable_disable_all(consumer, false));
+}
+
+void
+fdt_clock_register_provider(device_t provider)
+{
+
+ OF_device_register_xref(
+ OF_xref_from_node(ofw_bus_get_node(provider)), provider);
+}
+
+void
+fdt_clock_unregister_provider(device_t provider)
+{
+
+ OF_device_register_xref(OF_xref_from_device(provider), NULL);
+}
+
Property changes on: trunk/sys/dev/fdt/fdt_clock.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_clock.h
===================================================================
--- trunk/sys/dev/fdt/fdt_clock.h (rev 0)
+++ trunk/sys/dev/fdt/fdt_clock.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,56 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014 Ian Lepore <ian at freebsd.org>
+ * 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: stable/10/sys/dev/fdt/fdt_clock.h 273657 2014-10-26 02:19:03Z ian $
+ */
+
+#ifndef DEV_FDT_CLOCK_H
+#define DEV_FDT_CLOCK_H
+
+#include "fdt_clock_if.h"
+
+/*
+ * Get info about the Nth clock listed in consumer's "clocks" property.
+ *
+ * Returns 0 on success, ENXIO if clock #n not found.
+ */
+int fdt_clock_get_info(device_t consumer, int n, struct fdt_clock_info *info);
+
+/*
+ * Look up "clocks" property in consumer's fdt data and enable or disable all
+ * configured clocks.
+ */
+int fdt_clock_enable_all(device_t consumer);
+int fdt_clock_disable_all(device_t consumer);
+
+/*
+ * [Un]register the given device instance as a driver that implements the
+ * fdt_clock interface.
+ */
+void fdt_clock_register_provider(device_t provider);
+void fdt_clock_unregister_provider(device_t provider);
+
+#endif /* DEV_FDT_CLOCK_H */
+
Property changes on: trunk/sys/dev/fdt/fdt_clock.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_clock_if.m
===================================================================
--- trunk/sys/dev/fdt/fdt_clock_if.m (rev 0)
+++ trunk/sys/dev/fdt/fdt_clock_if.m 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,82 @@
+/* $MidnightBSD$ */
+#-
+# Copyright (c) 2014 Ian Lepore
+# 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: stable/10/sys/dev/fdt/fdt_clock_if.m 273657 2014-10-26 02:19:03Z ian $
+#
+
+#include <sys/types.h>
+
+#
+# This is the interface that fdt_clock drivers provide to other drivers.
+# In this context, clock refers to a clock signal provided to some other
+# hardware component within the system. They are most often found within
+# embedded processors that have on-chip IO controllers.
+#
+
+INTERFACE fdt_clock;
+
+HEADER {
+
+ enum {
+ FDT_CIFLAG_RUNNING = 0x01,
+ };
+
+ struct fdt_clock_info {
+ device_t provider;
+ uint32_t index;
+ const char * name; /* May be "", will not be NULL. */
+ uint32_t flags;
+ uint64_t frequency; /* In Hz. */
+ };
+}
+
+#
+# Enable the specified clock.
+# Returns 0 on success or a standard errno value.
+#
+METHOD int enable {
+ device_t provider;
+ int index;
+};
+
+#
+# Disable the specified clock.
+# Returns 0 on success or a standard errno value.
+#
+METHOD int disable {
+ device_t provider;
+ int index;
+};
+
+#
+# Returns information about the current operational state of specified clock.
+#
+METHOD int get_info {
+ device_t provider;
+ int index;
+ struct fdt_clock_info *info;
+};
+
Property changes on: trunk/sys/dev/fdt/fdt_clock_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_common.c
===================================================================
--- trunk/sys/dev/fdt/fdt_common.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_common.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,694 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009-2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdt/fdt_common.c 273675 2014-10-26 04:01:57Z ian $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/limits.h>
+
+#include <machine/resource.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/openfirm.h>
+
+#include "ofw_bus_if.h"
+
+#ifdef DEBUG
+#define debugf(fmt, args...) do { printf("%s(): ", __func__); \
+ printf(fmt,##args); } while (0)
+#else
+#define debugf(fmt, args...)
+#endif
+
+#define FDT_COMPAT_LEN 255
+#define FDT_TYPE_LEN 64
+
+#define FDT_REG_CELLS 4
+
+vm_paddr_t fdt_immr_pa;
+vm_offset_t fdt_immr_va;
+vm_offset_t fdt_immr_size;
+
+struct fdt_ic_list fdt_ic_list_head = SLIST_HEAD_INITIALIZER(fdt_ic_list_head);
+
+int
+fdt_get_range(phandle_t node, int range_id, u_long *base, u_long *size)
+{
+ pcell_t ranges[6], *rangesptr;
+ pcell_t addr_cells, size_cells, par_addr_cells;
+ int len, tuple_size, tuples;
+
+ if ((fdt_addrsize_cells(node, &addr_cells, &size_cells)) != 0)
+ return (ENXIO);
+ /*
+ * Process 'ranges' property.
+ */
+ par_addr_cells = fdt_parent_addr_cells(node);
+ if (par_addr_cells > 2)
+ return (ERANGE);
+
+ len = OF_getproplen(node, "ranges");
+ if (len > sizeof(ranges))
+ return (ENOMEM);
+ if (len == 0) {
+ *base = 0;
+ *size = ULONG_MAX;
+ return (0);
+ }
+
+ if (!(range_id < len))
+ return (ERANGE);
+
+ if (OF_getprop(node, "ranges", ranges, sizeof(ranges)) <= 0)
+ return (EINVAL);
+
+ tuple_size = sizeof(pcell_t) * (addr_cells + par_addr_cells +
+ size_cells);
+ tuples = len / tuple_size;
+
+ if (fdt_ranges_verify(ranges, tuples, par_addr_cells,
+ addr_cells, size_cells)) {
+ return (ERANGE);
+ }
+ *base = 0;
+ *size = 0;
+ rangesptr = &ranges[range_id];
+
+ *base = fdt_data_get((void *)rangesptr, addr_cells);
+ rangesptr += addr_cells;
+ *base += fdt_data_get((void *)rangesptr, par_addr_cells);
+ rangesptr += par_addr_cells;
+ *size = fdt_data_get((void *)rangesptr, size_cells);
+ return (0);
+}
+
+int
+fdt_immr_addr(vm_offset_t immr_va)
+{
+ phandle_t node;
+ u_long base, size;
+ int r;
+
+ /*
+ * Try to access the SOC node directly i.e. through /aliases/.
+ */
+ if ((node = OF_finddevice("soc")) != 0)
+ if (fdt_is_compatible_strict(node, "simple-bus"))
+ goto moveon;
+ /*
+ * Find the node the long way.
+ */
+ if ((node = OF_finddevice("/")) == 0)
+ return (ENXIO);
+
+ if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
+ return (ENXIO);
+
+moveon:
+ if ((r = fdt_get_range(node, 0, &base, &size)) == 0) {
+ fdt_immr_pa = base;
+ fdt_immr_va = immr_va;
+ fdt_immr_size = size;
+ }
+
+ return (r);
+}
+
+/*
+ * This routine is an early-usage version of the ofw_bus_is_compatible() when
+ * the ofw_bus I/F is not available (like early console routines and similar).
+ * Note the buffer has to be on the stack since malloc() is usually not
+ * available in such cases either.
+ */
+int
+fdt_is_compatible(phandle_t node, const char *compatstr)
+{
+ char buf[FDT_COMPAT_LEN];
+ char *compat;
+ int len, onelen, l, rv;
+
+ if ((len = OF_getproplen(node, "compatible")) <= 0)
+ return (0);
+
+ compat = (char *)&buf;
+ bzero(compat, FDT_COMPAT_LEN);
+
+ if (OF_getprop(node, "compatible", compat, FDT_COMPAT_LEN) < 0)
+ return (0);
+
+ onelen = strlen(compatstr);
+ rv = 0;
+ while (len > 0) {
+ if (strncasecmp(compat, compatstr, onelen) == 0) {
+ /* Found it. */
+ rv = 1;
+ break;
+ }
+ /* Slide to the next sub-string. */
+ l = strlen(compat) + 1;
+ compat += l;
+ len -= l;
+ }
+
+ return (rv);
+}
+
+int
+fdt_is_compatible_strict(phandle_t node, const char *compatible)
+{
+ char compat[FDT_COMPAT_LEN];
+
+ if (OF_getproplen(node, "compatible") <= 0)
+ return (0);
+
+ if (OF_getprop(node, "compatible", compat, FDT_COMPAT_LEN) < 0)
+ return (0);
+
+ if (strncasecmp(compat, compatible, FDT_COMPAT_LEN) == 0)
+ /* This fits. */
+ return (1);
+
+ return (0);
+}
+
+phandle_t
+fdt_find_compatible(phandle_t start, const char *compat, int strict)
+{
+ phandle_t child;
+
+ /*
+ * Traverse all children of 'start' node, and find first with
+ * matching 'compatible' property.
+ */
+ for (child = OF_child(start); child != 0; child = OF_peer(child))
+ if (fdt_is_compatible(child, compat)) {
+ if (strict)
+ if (!fdt_is_compatible_strict(child, compat))
+ continue;
+ return (child);
+ }
+ return (0);
+}
+
+phandle_t
+fdt_depth_search_compatible(phandle_t start, const char *compat, int strict)
+{
+ phandle_t child, node;
+
+ /*
+ * Depth-search all descendants of 'start' node, and find first with
+ * matching 'compatible' property.
+ */
+ for (node = OF_child(start); node != 0; node = OF_peer(node)) {
+ if (fdt_is_compatible(node, compat) &&
+ (strict == 0 || fdt_is_compatible_strict(node, compat))) {
+ return (node);
+ }
+ child = fdt_depth_search_compatible(node, compat, strict);
+ if (child != 0)
+ return (child);
+ }
+ return (0);
+}
+
+int
+fdt_is_enabled(phandle_t node)
+{
+ char *stat;
+ int ena, len;
+
+ len = OF_getprop_alloc(node, "status", sizeof(char),
+ (void **)&stat);
+
+ if (len <= 0)
+ /* It is OK if no 'status' property. */
+ return (1);
+
+ /* Anything other than 'okay' means disabled. */
+ ena = 0;
+ if (strncmp((char *)stat, "okay", len) == 0)
+ ena = 1;
+
+ free(stat, M_OFWPROP);
+ return (ena);
+}
+
+int
+fdt_is_type(phandle_t node, const char *typestr)
+{
+ char type[FDT_TYPE_LEN];
+
+ if (OF_getproplen(node, "device_type") <= 0)
+ return (0);
+
+ if (OF_getprop(node, "device_type", type, FDT_TYPE_LEN) < 0)
+ return (0);
+
+ if (strncasecmp(type, typestr, FDT_TYPE_LEN) == 0)
+ /* This fits. */
+ return (1);
+
+ return (0);
+}
+
+int
+fdt_parent_addr_cells(phandle_t node)
+{
+ pcell_t addr_cells;
+
+ /* Find out #address-cells of the superior bus. */
+ if (OF_searchprop(OF_parent(node), "#address-cells", &addr_cells,
+ sizeof(addr_cells)) <= 0)
+ addr_cells = 2;
+
+ return ((int)fdt32_to_cpu(addr_cells));
+}
+
+int
+fdt_data_verify(void *data, int cells)
+{
+ uint64_t d64;
+
+ if (cells > 1) {
+ d64 = fdt64_to_cpu(*((uint64_t *)data));
+ if (((d64 >> 32) & 0xffffffffull) != 0 || cells > 2)
+ return (ERANGE);
+ }
+
+ return (0);
+}
+
+int
+fdt_pm_is_enabled(phandle_t node)
+{
+ int ret;
+
+ ret = 1;
+
+#if defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DISCOVERY)
+ ret = fdt_pm(node);
+#endif
+ return (ret);
+}
+
+u_long
+fdt_data_get(void *data, int cells)
+{
+
+ if (cells == 1)
+ return (fdt32_to_cpu(*((uint32_t *)data)));
+
+ return (fdt64_to_cpu(*((uint64_t *)data)));
+}
+
+int
+fdt_addrsize_cells(phandle_t node, int *addr_cells, int *size_cells)
+{
+ pcell_t cell;
+ int cell_size;
+
+ /*
+ * Retrieve #{address,size}-cells.
+ */
+ cell_size = sizeof(cell);
+ if (OF_getprop(node, "#address-cells", &cell, cell_size) < cell_size)
+ cell = 2;
+ *addr_cells = fdt32_to_cpu((int)cell);
+
+ if (OF_getprop(node, "#size-cells", &cell, cell_size) < cell_size)
+ cell = 1;
+ *size_cells = fdt32_to_cpu((int)cell);
+
+ if (*addr_cells > 3 || *size_cells > 2)
+ return (ERANGE);
+ return (0);
+}
+
+int
+fdt_ranges_verify(pcell_t *ranges, int tuples, int par_addr_cells,
+ int this_addr_cells, int this_size_cells)
+{
+ int i, rv, ulsz;
+
+ if (par_addr_cells > 2 || this_addr_cells > 2 || this_size_cells > 2)
+ return (ERANGE);
+
+ /*
+ * This is the max size the resource manager can handle for addresses
+ * and sizes.
+ */
+ ulsz = sizeof(u_long);
+ if (par_addr_cells <= ulsz && this_addr_cells <= ulsz &&
+ this_size_cells <= ulsz)
+ /* We can handle everything */
+ return (0);
+
+ rv = 0;
+ for (i = 0; i < tuples; i++) {
+
+ if (fdt_data_verify((void *)ranges, par_addr_cells))
+ goto err;
+ ranges += par_addr_cells;
+
+ if (fdt_data_verify((void *)ranges, this_addr_cells))
+ goto err;
+ ranges += this_addr_cells;
+
+ if (fdt_data_verify((void *)ranges, this_size_cells))
+ goto err;
+ ranges += this_size_cells;
+ }
+
+ return (0);
+
+err:
+ debugf("using address range >%d-bit not supported\n", ulsz * 8);
+ return (ERANGE);
+}
+
+int
+fdt_data_to_res(pcell_t *data, int addr_cells, int size_cells, u_long *start,
+ u_long *count)
+{
+
+ /* Address portion. */
+ if (fdt_data_verify((void *)data, addr_cells))
+ return (ERANGE);
+
+ *start = fdt_data_get((void *)data, addr_cells);
+ data += addr_cells;
+
+ /* Size portion. */
+ if (fdt_data_verify((void *)data, size_cells))
+ return (ERANGE);
+
+ *count = fdt_data_get((void *)data, size_cells);
+ return (0);
+}
+
+int
+fdt_regsize(phandle_t node, u_long *base, u_long *size)
+{
+ pcell_t reg[4];
+ int addr_cells, len, size_cells;
+
+ if (fdt_addrsize_cells(OF_parent(node), &addr_cells, &size_cells))
+ return (ENXIO);
+
+ if ((sizeof(pcell_t) * (addr_cells + size_cells)) > sizeof(reg))
+ return (ENOMEM);
+
+ len = OF_getprop(node, "reg", ®, sizeof(reg));
+ if (len <= 0)
+ return (EINVAL);
+
+ *base = fdt_data_get(®[0], addr_cells);
+ *size = fdt_data_get(®[addr_cells], size_cells);
+ return (0);
+}
+
+int
+fdt_reg_to_rl(phandle_t node, struct resource_list *rl)
+{
+ u_long end, count, start;
+ pcell_t *reg, *regptr;
+ pcell_t addr_cells, size_cells;
+ int tuple_size, tuples;
+ int i, rv;
+ long busaddr, bussize;
+
+ if (fdt_addrsize_cells(OF_parent(node), &addr_cells, &size_cells) != 0)
+ return (ENXIO);
+ if (fdt_get_range(OF_parent(node), 0, &busaddr, &bussize)) {
+ busaddr = 0;
+ bussize = 0;
+ }
+
+ tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
+ tuples = OF_getprop_alloc(node, "reg", tuple_size, (void **)®);
+ debugf("addr_cells = %d, size_cells = %d\n", addr_cells, size_cells);
+ debugf("tuples = %d, tuple size = %d\n", tuples, tuple_size);
+ if (tuples <= 0)
+ /* No 'reg' property in this node. */
+ return (0);
+
+ regptr = reg;
+ for (i = 0; i < tuples; i++) {
+
+ rv = fdt_data_to_res(reg, addr_cells, size_cells, &start,
+ &count);
+ if (rv != 0) {
+ resource_list_free(rl);
+ goto out;
+ }
+ reg += addr_cells + size_cells;
+
+ /* Calculate address range relative to base. */
+ start += busaddr;
+ end = start + count - 1;
+
+ debugf("reg addr start = %lx, end = %lx, count = %lx\n", start,
+ end, count);
+
+ resource_list_add(rl, SYS_RES_MEMORY, i, start, end,
+ count);
+ }
+ rv = 0;
+
+out:
+ free(regptr, M_OFWPROP);
+ return (rv);
+}
+
+int
+fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc)
+{
+ phandle_t phy_node;
+ pcell_t phy_handle, phy_reg;
+ uint32_t i;
+ device_t parent, child;
+
+ if (OF_getencprop(node, "phy-handle", (void *)&phy_handle,
+ sizeof(phy_handle)) <= 0)
+ return (ENXIO);
+
+ phy_node = OF_node_from_xref(phy_handle);
+
+ if (OF_getprop(phy_node, "reg", (void *)&phy_reg,
+ sizeof(phy_reg)) <= 0)
+ return (ENXIO);
+
+ *phy_addr = fdt32_to_cpu(phy_reg);
+
+ /*
+ * Search for softc used to communicate with phy.
+ */
+
+ /*
+ * Step 1: Search for ancestor of the phy-node with a "phy-handle"
+ * property set.
+ */
+ phy_node = OF_parent(phy_node);
+ while (phy_node != 0) {
+ if (OF_getprop(phy_node, "phy-handle", (void *)&phy_handle,
+ sizeof(phy_handle)) > 0)
+ break;
+ phy_node = OF_parent(phy_node);
+ }
+ if (phy_node == 0)
+ return (ENXIO);
+
+ /*
+ * Step 2: For each device with the same parent and name as ours
+ * compare its node with the one found in step 1, ancestor of phy
+ * node (stored in phy_node).
+ */
+ parent = device_get_parent(dev);
+ i = 0;
+ child = device_find_child(parent, device_get_name(dev), i);
+ while (child != NULL) {
+ if (ofw_bus_get_node(child) == phy_node)
+ break;
+ i++;
+ child = device_find_child(parent, device_get_name(dev), i);
+ }
+ if (child == NULL)
+ return (ENXIO);
+
+ /*
+ * Use softc of the device found.
+ */
+ *phy_sc = (void *)device_get_softc(child);
+
+ return (0);
+}
+
+int
+fdt_get_reserved_regions(struct mem_region *mr, int *mrcnt)
+{
+ pcell_t reserve[FDT_REG_CELLS * FDT_MEM_REGIONS];
+ pcell_t *reservep;
+ phandle_t memory, root;
+ uint32_t memory_size;
+ int addr_cells, size_cells;
+ int i, max_size, res_len, rv, tuple_size, tuples;
+
+ max_size = sizeof(reserve);
+ root = OF_finddevice("/");
+ memory = OF_finddevice("/memory");
+ if (memory == -1) {
+ rv = ENXIO;
+ goto out;
+ }
+
+ if ((rv = fdt_addrsize_cells(OF_parent(memory), &addr_cells,
+ &size_cells)) != 0)
+ goto out;
+
+ if (addr_cells > 2) {
+ rv = ERANGE;
+ goto out;
+ }
+
+ tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
+
+ res_len = OF_getproplen(root, "memreserve");
+ if (res_len <= 0 || res_len > sizeof(reserve)) {
+ rv = ERANGE;
+ goto out;
+ }
+
+ if (OF_getprop(root, "memreserve", reserve, res_len) <= 0) {
+ rv = ENXIO;
+ goto out;
+ }
+
+ memory_size = 0;
+ tuples = res_len / tuple_size;
+ reservep = (pcell_t *)&reserve;
+ for (i = 0; i < tuples; i++) {
+
+ rv = fdt_data_to_res(reservep, addr_cells, size_cells,
+ (u_long *)&mr[i].mr_start, (u_long *)&mr[i].mr_size);
+
+ if (rv != 0)
+ goto out;
+
+ reservep += addr_cells + size_cells;
+ }
+
+ *mrcnt = i;
+ rv = 0;
+out:
+ return (rv);
+}
+
+int
+fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, uint32_t *memsize)
+{
+ pcell_t reg[FDT_REG_CELLS * FDT_MEM_REGIONS];
+ pcell_t *regp;
+ phandle_t memory;
+ uint32_t memory_size;
+ int addr_cells, size_cells;
+ int i, max_size, reg_len, rv, tuple_size, tuples;
+
+ max_size = sizeof(reg);
+ memory = OF_finddevice("/memory");
+ if (memory == -1) {
+ rv = ENXIO;
+ goto out;
+ }
+
+ if ((rv = fdt_addrsize_cells(OF_parent(memory), &addr_cells,
+ &size_cells)) != 0)
+ goto out;
+
+ if (addr_cells > 2) {
+ rv = ERANGE;
+ goto out;
+ }
+
+ tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
+ reg_len = OF_getproplen(memory, "reg");
+ if (reg_len <= 0 || reg_len > sizeof(reg)) {
+ rv = ERANGE;
+ goto out;
+ }
+
+ if (OF_getprop(memory, "reg", reg, reg_len) <= 0) {
+ rv = ENXIO;
+ goto out;
+ }
+
+ memory_size = 0;
+ tuples = reg_len / tuple_size;
+ regp = (pcell_t *)®
+ for (i = 0; i < tuples; i++) {
+
+ rv = fdt_data_to_res(regp, addr_cells, size_cells,
+ (u_long *)&mr[i].mr_start, (u_long *)&mr[i].mr_size);
+
+ if (rv != 0)
+ goto out;
+
+ regp += addr_cells + size_cells;
+ memory_size += mr[i].mr_size;
+ }
+
+ if (memory_size == 0) {
+ rv = ERANGE;
+ goto out;
+ }
+
+ *mrcnt = i;
+ *memsize = memory_size;
+ rv = 0;
+out:
+ return (rv);
+}
+
+int
+fdt_get_unit(device_t dev)
+{
+ const char * name;
+
+ name = ofw_bus_get_name(dev);
+ name = strchr(name, '@') + 1;
+
+ return (strtol(name,NULL,0));
+}
Property changes on: trunk/sys/dev/fdt/fdt_common.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_common.h
===================================================================
--- trunk/sys/dev/fdt/fdt_common.h (rev 0)
+++ trunk/sys/dev/fdt/fdt_common.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,103 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009-2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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: stable/10/sys/dev/fdt/fdt_common.h 273675 2014-10-26 04:01:57Z ian $
+ */
+
+#ifndef _FDT_COMMON_H_
+#define _FDT_COMMON_H_
+
+#include <sys/slicer.h>
+#include <contrib/libfdt/libfdt_env.h>
+#include <dev/ofw/ofw_bus.h>
+
+#define FDT_MEM_REGIONS 8
+
+#define DI_MAX_INTR_NUM 32
+
+struct fdt_sense_level {
+ enum intr_trigger trig;
+ enum intr_polarity pol;
+};
+
+typedef int (*fdt_pic_decode_t)(phandle_t, pcell_t *, int *, int *, int *);
+extern fdt_pic_decode_t fdt_pic_table[];
+
+typedef void (*fdt_fixup_t)(phandle_t);
+struct fdt_fixup_entry {
+ char *model;
+ fdt_fixup_t handler;
+};
+extern struct fdt_fixup_entry fdt_fixup_table[];
+
+extern SLIST_HEAD(fdt_ic_list, fdt_ic) fdt_ic_list_head;
+struct fdt_ic {
+ SLIST_ENTRY(fdt_ic) fdt_ics;
+ ihandle_t iph;
+ device_t dev;
+};
+
+extern vm_paddr_t fdt_immr_pa;
+extern vm_offset_t fdt_immr_va;
+extern vm_offset_t fdt_immr_size;
+
+struct fdt_pm_mask_entry {
+ char *compat;
+ uint32_t mask;
+};
+extern struct fdt_pm_mask_entry fdt_pm_mask_table[];
+
+#if defined(FDT_DTB_STATIC)
+extern u_char fdt_static_dtb;
+#endif
+
+int fdt_addrsize_cells(phandle_t, int *, int *);
+u_long fdt_data_get(void *, int);
+int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
+int fdt_data_verify(void *, int);
+phandle_t fdt_find_compatible(phandle_t, const char *, int);
+phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
+int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
+int fdt_get_reserved_regions(struct mem_region *, int *);
+int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
+int fdt_get_range(phandle_t, int, u_long *, u_long *);
+int fdt_immr_addr(vm_offset_t);
+int fdt_regsize(phandle_t, u_long *, u_long *);
+int fdt_is_compatible(phandle_t, const char *);
+int fdt_is_compatible_strict(phandle_t, const char *);
+int fdt_is_enabled(phandle_t);
+int fdt_pm_is_enabled(phandle_t);
+int fdt_is_type(phandle_t, const char *);
+int fdt_parent_addr_cells(phandle_t);
+int fdt_ranges_verify(pcell_t *, int, int, int, int);
+int fdt_reg_to_rl(phandle_t, struct resource_list *);
+int fdt_pm(phandle_t);
+int fdt_get_unit(device_t);
+
+#endif /* _FDT_COMMON_H_ */
Property changes on: trunk/sys/dev/fdt/fdt_common.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_mips.c
===================================================================
--- trunk/sys/dev/fdt/fdt_mips.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_mips.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,52 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009-2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdt/fdt_mips.c 266079 2014-05-14 18:54:34Z ian $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+
+#include <machine/intr_machdep.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/openfirm.h>
+
+#include "ofw_bus_if.h"
+#include "fdt_common.h"
+
+struct fdt_fixup_entry fdt_fixup_table[] = {
+ { NULL, NULL }
+};
+
Property changes on: trunk/sys/dev/fdt/fdt_mips.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_pinctrl.c
===================================================================
--- trunk/sys/dev/fdt/fdt_pinctrl.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_pinctrl.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,151 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014 Ian Lepore <ian at freebsd.org>
+ * 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: stable/10/sys/dev/fdt/fdt_pinctrl.c 283485 2015-05-24 18:00:29Z ian $
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "fdt_pinctrl_if.h"
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/fdt/fdt_pinctrl.h>
+
+int
+fdt_pinctrl_configure(device_t client, u_int index)
+{
+ device_t pinctrl;
+ phandle_t *configs;
+ int i, nconfigs;
+ char name[16];
+
+ snprintf(name, sizeof(name), "pinctrl-%u", index);
+ nconfigs = OF_getencprop_alloc(ofw_bus_get_node(client), name,
+ sizeof(*configs), (void **)&configs);
+ if (nconfigs < 0)
+ return (ENOENT);
+ if (nconfigs == 0)
+ return (0); /* Empty property is documented as valid. */
+ for (i = 0; i < nconfigs; i++) {
+ if ((pinctrl = OF_device_from_xref(configs[i])) != NULL)
+ FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]);
+ }
+ free(configs, M_OFWPROP);
+ return (0);
+}
+
+int
+fdt_pinctrl_configure_by_name(device_t client, const char * name)
+{
+ char * names;
+ int i, offset, nameslen;
+
+ nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names",
+ sizeof(*names), (void **)&names);
+ if (nameslen <= 0)
+ return (ENOENT);
+ for (i = 0, offset = 0; offset < nameslen; i++) {
+ if (strcmp(name, &names[offset]) == 0)
+ break;
+ offset += strlen(&names[offset]) + 1;
+ }
+ free(names, M_OFWPROP);
+ if (offset < nameslen)
+ return (fdt_pinctrl_configure(client, i));
+ else
+ return (ENOENT);
+}
+
+static int
+pinctrl_register_children(device_t pinctrl, phandle_t parent,
+ const char *pinprop)
+{
+ phandle_t node;
+
+ /*
+ * Recursively descend from parent, looking for nodes that have the
+ * given property, and associate the pinctrl device_t with each one.
+ */
+ for (node = OF_child(parent); node != 0; node = OF_peer(node)) {
+ pinctrl_register_children(pinctrl, node, pinprop);
+ if (pinprop == NULL || OF_hasprop(node, pinprop)) {
+ OF_device_register_xref(OF_xref_from_node(node),
+ pinctrl);
+ }
+ }
+ return (0);
+}
+
+int
+fdt_pinctrl_register(device_t pinctrl, const char *pinprop)
+{
+ phandle_t node;
+
+ node = ofw_bus_get_node(pinctrl);
+ OF_device_register_xref(OF_xref_from_node(node), pinctrl);
+ return (pinctrl_register_children(pinctrl, node, pinprop));
+}
+
+static int
+pinctrl_configure_children(device_t pinctrl, phandle_t parent)
+{
+ phandle_t node, *configs;
+ int i, nconfigs;
+
+ for (node = OF_child(parent); node != 0; node = OF_peer(node)) {
+ if (!fdt_is_enabled(node))
+ continue;
+ pinctrl_configure_children(pinctrl, node);
+ nconfigs = OF_getencprop_alloc(node, "pinctrl-0",
+ sizeof(*configs), (void **)&configs);
+ if (nconfigs <= 0)
+ continue;
+ if (bootverbose) {
+ char name[32];
+ OF_getprop(node, "name", &name, sizeof(name));
+ printf("Processing %d pin-config node(s) in pinctrl-0 for %s\n",
+ nconfigs, name);
+ }
+ for (i = 0; i < nconfigs; i++) {
+ if (OF_device_from_xref(configs[i]) == pinctrl)
+ FDT_PINCTRL_CONFIGURE(pinctrl, configs[i]);
+ }
+ free(configs, M_OFWPROP);
+ }
+ return (0);
+}
+
+int
+fdt_pinctrl_configure_tree(device_t pinctrl)
+{
+
+ return (pinctrl_configure_children(pinctrl, OF_peer(0)));
+}
+
Property changes on: trunk/sys/dev/fdt/fdt_pinctrl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_pinctrl.h
===================================================================
--- trunk/sys/dev/fdt/fdt_pinctrl.h (rev 0)
+++ trunk/sys/dev/fdt/fdt_pinctrl.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,59 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014 Ian Lepore <ian at freebsd.org>
+ * 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: stable/10/sys/dev/fdt/fdt_pinctrl.h 273669 2014-10-26 03:41:27Z ian $
+ */
+
+#ifndef DEV_FDT_PINCTRL_H
+#define DEV_FDT_PINCTRL_H
+
+#include "fdt_pinctrl_if.h"
+
+/*
+ * Configure pins by name or index. This looks up the pinctrl-N property in
+ * client's fdt data by index or name, and passes each handle in it to the
+ * pinctrl driver for configuration.
+ */
+int fdt_pinctrl_configure(device_t client, u_int index);
+int fdt_pinctrl_configure_by_name(device_t client, const char * name);
+
+/*
+ * Register a pinctrl driver so that it can be used by other devices which call
+ * fdt_pinctrl_configure(). The pinprop argument is the name of a property that
+ * identifies each descendent of the pinctrl node which is a pin configuration
+ * node whose xref phandle can be passed to FDT_PINCTRL_CONFIGURE(). If this is
+ * NULL, every descendant node is registered.
+ */
+int fdt_pinctrl_register(device_t pinctrl, const char *pinprop);
+
+/*
+ * Walk the device tree and configure pins for each enabled device whose
+ * pinctrl-0 property contains references to nodes which are children of the
+ * given pinctrl device. This helper routine is for use by pinctrl drivers.
+ */
+int fdt_pinctrl_configure_tree(device_t pinctrl);
+
+#endif /* DEV_FDT_PINCTRL_H */
+
Property changes on: trunk/sys/dev/fdt/fdt_pinctrl.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_pinctrl_if.m
===================================================================
--- trunk/sys/dev/fdt/fdt_pinctrl_if.m (rev 0)
+++ trunk/sys/dev/fdt/fdt_pinctrl_if.m 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,48 @@
+/* $MidnightBSD$ */
+#-
+# Copyright (c) 2014 Ian Lepore
+# 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: stable/10/sys/dev/fdt/fdt_pinctrl_if.m 273669 2014-10-26 03:41:27Z ian $
+#
+
+#include <sys/types.h>
+#include <dev/ofw/openfirm.h>
+
+#
+# This is the interface that fdt_pinctrl drivers provide to other drivers.
+#
+
+INTERFACE fdt_pinctrl;
+
+#
+# Set pins to the specified configuration. The cfgxref arg is an xref phandle
+# to a descendent node (child, grandchild, ...) of the pinctrl device node.
+# Returns 0 on success or a standard errno value.
+#
+METHOD int configure {
+ device_t pinctrl;
+ phandle_t cfgxref;
+};
+
Property changes on: trunk/sys/dev/fdt/fdt_pinctrl_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_powerpc.c
===================================================================
--- trunk/sys/dev/fdt/fdt_powerpc.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_powerpc.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,84 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009-2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdt/fdt_powerpc.c 266079 2014-05-14 18:54:34Z ian $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+
+#include <machine/intr_machdep.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/openfirm.h>
+
+#include "ofw_bus_if.h"
+#include "fdt_common.h"
+
+static void
+fdt_fixup_busfreq(phandle_t root)
+{
+ phandle_t sb, cpus, child;
+ pcell_t freq;
+
+ /*
+ * Do a strict check so as to skip non-SOC nodes, which also claim
+ * simple-bus compatibility such as eLBC etc.
+ */
+ if ((sb = fdt_find_compatible(root, "simple-bus", 1)) == 0)
+ return;
+
+ /*
+ * This fixup uses /cpus/ bus-frequency prop value to set simple-bus
+ * bus-frequency property.
+ */
+ if ((cpus = OF_finddevice("/cpus")) == -1)
+ return;
+
+ if ((child = OF_child(cpus)) == 0)
+ return;
+
+ if (OF_getprop(child, "bus-frequency", (void *)&freq,
+ sizeof(freq)) <= 0)
+ return;
+
+ OF_setprop(sb, "bus-frequency", (void *)&freq, sizeof(freq));
+}
+
+struct fdt_fixup_entry fdt_fixup_table[] = {
+ { "fsl,MPC8572DS", &fdt_fixup_busfreq },
+ { "MPC8555CDS", &fdt_fixup_busfreq },
+ { NULL, NULL }
+};
+
Property changes on: trunk/sys/dev/fdt/fdt_powerpc.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_slicer.c
===================================================================
--- trunk/sys/dev/fdt/fdt_slicer.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_slicer.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,139 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2012 Semihalf.
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdt/fdt_slicer.c 318159 2017-05-10 21:42:16Z marius $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/slicer.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
+#ifdef DEBUG
+#define debugf(fmt, args...) do { printf("%s(): ", __func__); \
+ printf(fmt,##args); } while (0)
+#else
+#define debugf(fmt, args...)
+#endif
+
+static int fdt_flash_fill_slices(device_t dev, const char *provider,
+ struct flash_slice *slices, int *slices_num);
+static void fdt_slicer_init(void);
+
+static int
+fdt_flash_fill_slices(device_t dev, const char *provider __unused,
+ struct flash_slice *slices, int *slices_num)
+{
+ char *slice_name;
+ phandle_t dt_node, dt_child;
+ u_long base, size;
+ int i;
+ ssize_t name_len;
+
+ /*
+ * We assume the caller provides buffer for FLASH_SLICES_MAX_NUM
+ * flash_slice structures.
+ */
+ if (slices == NULL) {
+ *slices_num = 0;
+ return (ENOMEM);
+ }
+
+ dt_node = ofw_bus_get_node(dev);
+ for (dt_child = OF_child(dt_node), i = 0; dt_child != 0;
+ dt_child = OF_peer(dt_child)) {
+
+ if (i == FLASH_SLICES_MAX_NUM) {
+ debugf("not enough buffer for slice i=%d\n", i);
+ break;
+ }
+
+ /*
+ * Retrieve start and size of the slice.
+ */
+ if (fdt_regsize(dt_child, &base, &size) != 0) {
+ debugf("error during processing reg property, i=%d\n",
+ i);
+ continue;
+ }
+
+ if (size == 0) {
+ debugf("slice i=%d with no size\n", i);
+ continue;
+ }
+
+ /*
+ * Retrieve label.
+ */
+ name_len = OF_getprop_alloc(dt_child, "label", sizeof(char),
+ (void **)&slice_name);
+ if (name_len <= 0) {
+ /* Use node name if no label defined */
+ name_len = OF_getprop_alloc(dt_child, "name",
+ sizeof(char), (void **)&slice_name);
+ if (name_len <= 0) {
+ debugf("slice i=%d with no name\n", i);
+ slice_name = NULL;
+ }
+ }
+
+ /*
+ * Fill slice entry data.
+ */
+ slices[i].base = base;
+ slices[i].size = size;
+ slices[i].label = slice_name;
+ i++;
+ }
+
+ *slices_num = i;
+ return (0);
+}
+
+static void
+fdt_slicer_init(void)
+{
+
+ flash_register_slicer(fdt_flash_fill_slices, FLASH_SLICES_TYPE_NAND,
+ FALSE);
+ flash_register_slicer(fdt_flash_fill_slices, FLASH_SLICES_TYPE_CFI,
+ FALSE);
+ flash_register_slicer(fdt_flash_fill_slices, FLASH_SLICES_TYPE_SPI,
+ FALSE);
+}
+
+/*
+ * Must be initialized after GEOM classes (SI_SUB_DRIVERS/SI_ORDER_FIRST),
+ * i. e. after g_init() is called, due to the use of the GEOM topology_lock
+ * in flash_register_slicer(). However, must be before SI_SUB_CONFIGURE.
+ */
+SYSINIT(fdt_slicer_rootconf, SI_SUB_DRIVERS, SI_ORDER_SECOND, fdt_slicer_init,
+ NULL);
Property changes on: trunk/sys/dev/fdt/fdt_slicer.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_static_dtb.S
===================================================================
--- trunk/sys/dev/fdt/fdt_static_dtb.S (rev 0)
+++ trunk/sys/dev/fdt/fdt_static_dtb.S 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,48 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * 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: stable/10/sys/dev/fdt/fdt_static_dtb.S 208747 2010-06-02 17:17:45Z raj $
+ */
+
+#include "fdt_static_dtb.h"
+
+.data
+.ascii "Device Tree Blob STARTS here"
+.global fdt_static_dtb
+
+/*
+ * The device tree blob must be aligned at 8-bytes boundary. Use
+ * gas-specific 'balign' extension to ensure the same alignment behaviour on
+ * all archs (the .align directive meaning can vary accross gas arch
+ * variations).
+ */
+.balign 8
+fdt_static_dtb:
+.incbin FDT_DTB_FILE
+.ascii "Device Tree Blob STOPS here"
Property changes on: trunk/sys/dev/fdt/fdt_static_dtb.S
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/fdt_x86.c
===================================================================
--- trunk/sys/dev/fdt/fdt_x86.c (rev 0)
+++ trunk/sys/dev/fdt/fdt_x86.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,49 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Juniper Networks, Inc.
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdt/fdt_x86.c 266079 2014-05-14 18:54:34Z ian $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+
+#include <machine/intr_machdep.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/openfirm.h>
+
+#include "ofw_bus_if.h"
+#include "fdt_common.h"
+
+struct fdt_fixup_entry fdt_fixup_table[] = {
+ { NULL, NULL }
+};
+
Property changes on: trunk/sys/dev/fdt/fdt_x86.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/simplebus.c
===================================================================
--- trunk/sys/dev/fdt/simplebus.c (rev 0)
+++ trunk/sys/dev/fdt/simplebus.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,424 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Nathan Whitehorn
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/fdt/simplebus.c 283477 2015-05-24 17:51:57Z ian $");
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/rman.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <dev/fdt/simplebus.h>
+
+/*
+ * Bus interface.
+ */
+static int simplebus_probe(device_t dev);
+static int simplebus_attach(device_t dev);
+static struct resource *simplebus_alloc_resource(device_t, device_t, int,
+ int *, u_long, u_long, u_long, u_int);
+static void simplebus_probe_nomatch(device_t bus, device_t child);
+static int simplebus_print_child(device_t bus, device_t child);
+static device_t simplebus_add_child(device_t dev, u_int order,
+ const char *name, int unit);
+static struct resource_list *simplebus_get_resource_list(device_t bus,
+ device_t child);
+/*
+ * ofw_bus interface
+ */
+static const struct ofw_bus_devinfo *simplebus_get_devinfo(device_t bus,
+ device_t child);
+
+/*
+ * local methods
+ */
+
+static int simplebus_fill_ranges(phandle_t node,
+ struct simplebus_softc *sc);
+
+/*
+ * Driver methods.
+ */
+static device_method_t simplebus_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, simplebus_probe),
+ DEVMETHOD(device_attach, simplebus_attach),
+ DEVMETHOD(device_detach, bus_generic_detach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+
+ /* Bus interface */
+ DEVMETHOD(bus_add_child, simplebus_add_child),
+ DEVMETHOD(bus_print_child, simplebus_print_child),
+ DEVMETHOD(bus_probe_nomatch, simplebus_probe_nomatch),
+ DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
+ DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+ DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
+ DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
+ DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),
+ DEVMETHOD(bus_get_resource_list, simplebus_get_resource_list),
+
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_devinfo, simplebus_get_devinfo),
+ DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
+ DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
+ DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
+ DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
+ DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
+
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(simplebus, simplebus_driver, simplebus_methods,
+ sizeof(struct simplebus_softc));
+
+static devclass_t simplebus_devclass;
+EARLY_DRIVER_MODULE(simplebus, ofwbus, simplebus_driver, simplebus_devclass,
+ 0, 0, BUS_PASS_BUS);
+EARLY_DRIVER_MODULE(simplebus, simplebus, simplebus_driver, simplebus_devclass,
+ 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
+
+static int
+simplebus_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ /*
+ * FDT data puts a "simple-bus" compatible string on many things that
+ * have children but aren't really busses in our world. Without a
+ * ranges property we will fail to attach, so just fail to probe too.
+ */
+ if (!(ofw_bus_is_compatible(dev, "simple-bus") &&
+ ofw_bus_has_prop(dev, "ranges")) &&
+ (ofw_bus_get_type(dev) == NULL || strcmp(ofw_bus_get_type(dev),
+ "soc") != 0))
+ return (ENXIO);
+
+ device_set_desc(dev, "Flattened device tree simple bus");
+
+ return (BUS_PROBE_GENERIC);
+}
+
+static int
+simplebus_attach(device_t dev)
+{
+ struct simplebus_softc *sc;
+ phandle_t node;
+
+ sc = device_get_softc(dev);
+ simplebus_init(dev, 0);
+ if (simplebus_fill_ranges(sc->node, sc) < 0) {
+ device_printf(dev, "could not get ranges\n");
+ return (ENXIO);
+ }
+
+ /*
+ * In principle, simplebus could have an interrupt map, but ignore that
+ * for now
+ */
+
+ for (node = OF_child(sc->node); node > 0; node = OF_peer(node))
+ simplebus_add_device(dev, node, 0, NULL, -1, NULL);
+ return (bus_generic_attach(dev));
+}
+
+void
+simplebus_init(device_t dev, phandle_t node)
+{
+ struct simplebus_softc *sc;
+
+ sc = device_get_softc(dev);
+ if (node == 0)
+ node = ofw_bus_get_node(dev);
+ sc->dev = dev;
+ sc->node = node;
+
+ /*
+ * Some important numbers
+ */
+ sc->acells = 2;
+ OF_getencprop(node, "#address-cells", &sc->acells, sizeof(sc->acells));
+ sc->scells = 1;
+ OF_getencprop(node, "#size-cells", &sc->scells, sizeof(sc->scells));
+}
+
+static int
+simplebus_fill_ranges(phandle_t node, struct simplebus_softc *sc)
+{
+ int host_address_cells;
+ cell_t *base_ranges;
+ ssize_t nbase_ranges;
+ int err;
+ int i, j, k;
+
+ err = OF_searchencprop(OF_parent(node), "#address-cells",
+ &host_address_cells, sizeof(host_address_cells));
+ if (err <= 0)
+ return (-1);
+
+ nbase_ranges = OF_getproplen(node, "ranges");
+ if (nbase_ranges < 0)
+ return (-1);
+ sc->nranges = nbase_ranges / sizeof(cell_t) /
+ (sc->acells + host_address_cells + sc->scells);
+ if (sc->nranges == 0)
+ return (0);
+
+ sc->ranges = malloc(sc->nranges * sizeof(sc->ranges[0]),
+ M_DEVBUF, M_WAITOK);
+ base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK);
+ OF_getencprop(node, "ranges", base_ranges, nbase_ranges);
+
+ for (i = 0, j = 0; i < sc->nranges; i++) {
+ sc->ranges[i].bus = 0;
+ for (k = 0; k < sc->acells; k++) {
+ sc->ranges[i].bus <<= 32;
+ sc->ranges[i].bus |= base_ranges[j++];
+ }
+ sc->ranges[i].host = 0;
+ for (k = 0; k < host_address_cells; k++) {
+ sc->ranges[i].host <<= 32;
+ sc->ranges[i].host |= base_ranges[j++];
+ }
+ sc->ranges[i].size = 0;
+ for (k = 0; k < sc->scells; k++) {
+ sc->ranges[i].size <<= 32;
+ sc->ranges[i].size |= base_ranges[j++];
+ }
+ }
+
+ free(base_ranges, M_DEVBUF);
+ return (sc->nranges);
+}
+
+struct simplebus_devinfo *
+simplebus_setup_dinfo(device_t dev, phandle_t node,
+ struct simplebus_devinfo *di)
+{
+ struct simplebus_softc *sc;
+ struct simplebus_devinfo *ndi;
+
+ sc = device_get_softc(dev);
+ if (di == NULL)
+ ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO);
+ else
+ ndi = di;
+ if (ofw_bus_gen_setup_devinfo(&ndi->obdinfo, node) != 0) {
+ if (di == NULL)
+ free(ndi, M_DEVBUF);
+ return (NULL);
+ }
+
+ resource_list_init(&ndi->rl);
+ ofw_bus_reg_to_rl(dev, node, sc->acells, sc->scells, &ndi->rl);
+ ofw_bus_intr_to_rl(dev, node, &ndi->rl);
+
+ return (ndi);
+}
+
+device_t
+simplebus_add_device(device_t dev, phandle_t node, u_int order,
+ const char *name, int unit, struct simplebus_devinfo *di)
+{
+ struct simplebus_devinfo *ndi;
+ device_t cdev;
+
+ if ((ndi = simplebus_setup_dinfo(dev, node, di)) == NULL)
+ return (NULL);
+ cdev = device_add_child_ordered(dev, order, name, unit);
+ if (cdev == NULL) {
+ device_printf(dev, "<%s>: device_add_child failed\n",
+ ndi->obdinfo.obd_name);
+ resource_list_free(&ndi->rl);
+ ofw_bus_gen_destroy_devinfo(&ndi->obdinfo);
+ if (di == NULL)
+ free(ndi, M_DEVBUF);
+ return (NULL);
+ }
+ device_set_ivars(cdev, ndi);
+
+ return(cdev);
+}
+
+static device_t
+simplebus_add_child(device_t dev, u_int order, const char *name, int unit)
+{
+ device_t cdev;
+ struct simplebus_devinfo *ndi;
+
+ cdev = device_add_child_ordered(dev, order, name, unit);
+ if (cdev == NULL)
+ return (NULL);
+
+ ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO);
+ ndi->obdinfo.obd_node = -1;
+ resource_list_init(&ndi->rl);
+ device_set_ivars(cdev, ndi);
+
+ return (cdev);
+}
+
+static const struct ofw_bus_devinfo *
+simplebus_get_devinfo(device_t bus __unused, device_t child)
+{
+ struct simplebus_devinfo *ndi;
+
+ ndi = device_get_ivars(child);
+ return (&ndi->obdinfo);
+}
+
+static struct resource_list *
+simplebus_get_resource_list(device_t bus __unused, device_t child)
+{
+ struct simplebus_devinfo *ndi;
+
+ ndi = device_get_ivars(child);
+ return (&ndi->rl);
+}
+
+static struct resource *
+simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count, u_int flags)
+{
+ struct simplebus_softc *sc;
+ struct simplebus_devinfo *di;
+ struct resource_list_entry *rle;
+ int j;
+
+ sc = device_get_softc(bus);
+
+ /*
+ * Request for the default allocation with a given rid: use resource
+ * list stored in the local device info.
+ */
+ if ((start == 0UL) && (end == ~0UL)) {
+ if ((di = device_get_ivars(child)) == NULL)
+ return (NULL);
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+
+ rle = resource_list_find(&di->rl, type, *rid);
+ if (rle == NULL) {
+ if (bootverbose)
+ device_printf(bus, "no default resources for "
+ "rid = %d, type = %d\n", *rid, type);
+ return (NULL);
+ }
+ start = rle->start;
+ end = rle->end;
+ count = rle->count;
+ }
+
+ if (type == SYS_RES_MEMORY) {
+ /* Remap through ranges property */
+ for (j = 0; j < sc->nranges; j++) {
+ if (start >= sc->ranges[j].bus && end <
+ sc->ranges[j].bus + sc->ranges[j].size) {
+ start -= sc->ranges[j].bus;
+ start += sc->ranges[j].host;
+ end -= sc->ranges[j].bus;
+ end += sc->ranges[j].host;
+ break;
+ }
+ }
+ if (j == sc->nranges && sc->nranges != 0) {
+ if (bootverbose)
+ device_printf(bus, "Could not map resource "
+ "%#lx-%#lx\n", start, end);
+
+ return (NULL);
+ }
+ }
+
+ return (bus_generic_alloc_resource(bus, child, type, rid, start, end,
+ count, flags));
+}
+
+static int
+simplebus_print_res(struct simplebus_devinfo *di)
+{
+ int rv;
+
+ rv = 0;
+ rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#lx");
+ rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%ld");
+ return (rv);
+}
+
+static void
+simplebus_probe_nomatch(device_t bus, device_t child)
+{
+ const char *name, *type, *compat;
+
+ if (!bootverbose)
+ return;
+
+ compat = ofw_bus_get_compat(child);
+ if (compat == NULL)
+ return;
+ name = ofw_bus_get_name(child);
+ type = ofw_bus_get_type(child);
+
+ device_printf(bus, "<%s>", name != NULL ? name : "unknown");
+ simplebus_print_res(device_get_ivars(child));
+ if (!ofw_bus_status_okay(child))
+ printf(" disabled");
+ if (type)
+ printf(" type %s", type);
+ printf(" compat %s (no driver attached)\n", compat);
+}
+
+static int
+simplebus_print_child(device_t bus, device_t child)
+{
+ int rv;
+
+ rv = bus_print_child_header(bus, child);
+ rv += simplebus_print_res(device_get_ivars(child));
+ if (!ofw_bus_status_okay(child))
+ rv += printf(" disabled");
+ rv += bus_print_child_footer(bus, child);
+ return (rv);
+}
Property changes on: trunk/sys/dev/fdt/simplebus.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/fdt/simplebus.h
===================================================================
--- trunk/sys/dev/fdt/simplebus.h (rev 0)
+++ trunk/sys/dev/fdt/simplebus.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,65 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Nathan Whitehorn
+ * 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: stable/10/sys/dev/fdt/simplebus.h 283477 2015-05-24 17:51:57Z ian $
+ */
+
+#ifndef _FDT_SIMPLEBUS_H
+#define _FDT_SIMPLEBUS_H
+
+#include <dev/ofw/ofw_bus.h>
+
+/* FDT simplebus */
+DECLARE_CLASS(simplebus_driver);
+
+struct simplebus_range {
+ uint64_t bus;
+ uint64_t host;
+ uint64_t size;
+};
+
+/* devinfo and softc */
+struct simplebus_softc {
+ device_t dev;
+ phandle_t node;
+
+ struct simplebus_range *ranges;
+ int nranges;
+
+ pcell_t acells, scells;
+};
+
+struct simplebus_devinfo {
+ struct ofw_bus_devinfo obdinfo;
+ struct resource_list rl;
+};
+
+void simplebus_init(device_t dev, phandle_t node);
+device_t simplebus_add_device(device_t dev, phandle_t node, u_int order,
+ const char *name, int unit, struct simplebus_devinfo *di);
+struct simplebus_devinfo *simplebus_setup_dinfo(device_t dev, phandle_t node,
+ struct simplebus_devinfo *di);
+#endif /* _FDT_SIMPLEBUS_H */
Property changes on: trunk/sys/dev/fdt/simplebus.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/fe/if_fe.c
===================================================================
--- trunk/sys/dev/fe/if_fe.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/if_fe.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
@@ -21,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fe/if_fe.c 243857 2012-12-04 09:32:43Z glebius $");
/*
*
@@ -2255,6 +2256,7 @@
static void
fe_medstat (struct ifnet *ifp, struct ifmediareq *ifmr)
{
- (void)ifp;
- (void)ifmr;
+ struct fe_softc *sc = ifp->if_softc;
+
+ ifmr->ifm_active = sc->media.ifm_media;
}
Modified: trunk/sys/dev/fe/if_fe_cbus.c
===================================================================
--- trunk/sys/dev/fe/if_fe_cbus.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/if_fe_cbus.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
@@ -22,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fe/if_fe_cbus.c 179959 2008-06-23 18:16:25Z jhb $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/dev/fe/if_fe_isa.c
===================================================================
--- trunk/sys/dev/fe/if_fe_isa.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/if_fe_isa.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
@@ -22,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fe/if_fe_isa.c 179959 2008-06-23 18:16:25Z jhb $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/dev/fe/if_fe_pccard.c
===================================================================
--- trunk/sys/dev/fe/if_fe_pccard.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/if_fe_pccard.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
@@ -22,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fe/if_fe_pccard.c 199798 2009-11-25 13:31:17Z rwatson $");
#include <sys/param.h>
#include <sys/kernel.h>
Modified: trunk/sys/dev/fe/if_fereg.h
===================================================================
--- trunk/sys/dev/fe/if_fereg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/if_fereg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Hardware specification of various 8696x based Ethernet cards.
* Contributed by M. Sekiguchi <seki at sysrap.cs.fujitsu.co.jp>
@@ -24,7 +25,7 @@
* SUCH DAMAGE.
*/
-/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/fe/if_fereg.h 142135 2005-02-20 19:33:13Z imp $ */
/*
* Registers on FMV-180 series' ISA bus interface ASIC.
Modified: trunk/sys/dev/fe/if_fevar.h
===================================================================
--- trunk/sys/dev/fe/if_fevar.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/if_fevar.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
@@ -19,7 +20,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fe/if_fevar.h 179959 2008-06-23 18:16:25Z jhb $
*/
/* How many registers does an fe-supported adapter have at maximum? */
Modified: trunk/sys/dev/fe/mb86960.h
===================================================================
--- trunk/sys/dev/fe/mb86960.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fe/mb86960.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
*
@@ -19,7 +20,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fe/mb86960.h 142135 2005-02-20 19:33:13Z imp $
*/
/*
Modified: trunk/sys/dev/filemon/filemon.c
===================================================================
--- trunk/sys/dev/filemon/filemon.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/filemon/filemon.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,6 +1,8 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011, David E. O'Brien.
* Copyright (c) 2009-2011, Juniper Networks, Inc.
+ * Copyright (c) 2015-2016, EMC Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/filemon/filemon.c 304473 2016-08-19 17:02:05Z bdrewery $");
#include "opt_compat.h"
@@ -34,43 +36,34 @@
#include <sys/file.h>
#include <sys/systm.h>
#include <sys/buf.h>
+#include <sys/capsicum.h>
#include <sys/condvar.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/ioccom.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/proc.h>
-#include <sys/queue.h>
+#include <sys/sx.h>
#include <sys/syscall.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/uio.h>
-#if __FreeBSD_version >= 900041
-#include <sys/capability.h>
-#endif
-
#include "filemon.h"
-#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
+#if defined(COMPAT_FREEBSD32)
#include <compat/freebsd32/freebsd32_syscall.h>
#include <compat/freebsd32/freebsd32_proto.h>
-
-extern struct sysentvec ia32_freebsd_sysvec;
+#include <compat/freebsd32/freebsd32_util.h>
#endif
-extern struct sysentvec elf32_freebsd_sysvec;
-extern struct sysentvec elf64_freebsd_sysvec;
-
static d_close_t filemon_close;
static d_ioctl_t filemon_ioctl;
static d_open_t filemon_open;
-static int filemon_unload(void);
-static void filemon_load(void *);
static struct cdevsw filemon_cdevsw = {
.d_version = D_VERSION,
@@ -83,95 +76,283 @@
MALLOC_DECLARE(M_FILEMON);
MALLOC_DEFINE(M_FILEMON, "filemon", "File access monitor");
+/*
+ * The filemon->lock protects several things currently:
+ * - fname1/fname2/msgbufr are pre-allocated and used per syscall
+ * for logging and copyins rather than stack variables.
+ * - Serializing the filemon's log output.
+ * - Preventing inheritance or removal of the filemon into proc.p_filemon.
+ */
struct filemon {
- TAILQ_ENTRY(filemon) link; /* Link into the in-use list. */
- struct mtx mtx; /* Lock mutex for this filemon. */
- struct cv cv; /* Lock condition variable for this
- filemon. */
+ struct sx lock; /* Lock for this filemon. */
struct file *fp; /* Output file pointer. */
- struct thread *locker; /* Ptr to the thread locking this
- filemon. */
- pid_t pid; /* The process ID being monitored. */
+ struct ucred *cred; /* Credential of tracer. */
char fname1[MAXPATHLEN]; /* Temporary filename buffer. */
char fname2[MAXPATHLEN]; /* Temporary filename buffer. */
char msgbufr[1024]; /* Output message buffer. */
+ int error; /* Log write error, returned on close(2). */
+ u_int refcnt; /* Pointer reference count. */
+ u_int proccnt; /* Process count. */
};
-static TAILQ_HEAD(, filemon) filemons_inuse = TAILQ_HEAD_INITIALIZER(filemons_inuse);
-static TAILQ_HEAD(, filemon) filemons_free = TAILQ_HEAD_INITIALIZER(filemons_free);
-static int n_readers = 0;
-static struct mtx access_mtx;
-static struct cv access_cv;
-static struct thread *access_owner = NULL;
-static struct thread *access_requester = NULL;
-
-#if __FreeBSD_version < 701000
-static struct clonedevs *filemon_clones;
-static eventhandler_tag eh_tag;
-#else
static struct cdev *filemon_dev;
-#endif
+static void filemon_output(struct filemon *filemon, char *msg, size_t len);
-#include "filemon_lock.c"
-#include "filemon_wrapper.c"
+static __inline struct filemon *
+filemon_acquire(struct filemon *filemon)
+{
-#if __FreeBSD_version < 701000
+ if (filemon != NULL)
+ refcount_acquire(&filemon->refcnt);
+ return (filemon);
+}
+
+/*
+ * Release a reference and free on the last one.
+ */
static void
-filemon_clone(void *arg, struct ucred *cred, char *name, int namelen,
- struct cdev **dev)
+filemon_release(struct filemon *filemon)
{
- int u = -1;
- size_t len;
- if (*dev != NULL)
+ if (refcount_release(&filemon->refcnt) == 0)
return;
+ /*
+ * There are valid cases of releasing while locked, such as in
+ * filemon_untrack_processes, but none which are done where there
+ * is not at least 1 reference remaining.
+ */
+ sx_assert(&filemon->lock, SA_UNLOCKED);
- len = strlen(name);
+ if (filemon->cred != NULL)
+ crfree(filemon->cred);
+ sx_destroy(&filemon->lock);
+ free(filemon, M_FILEMON);
+}
- if (len != 7)
- return;
+/*
+ * Acquire the proc's p_filemon reference and lock the filemon.
+ * The proc's p_filemon may not match this filemon on return.
+ */
+static struct filemon *
+filemon_proc_get(struct proc *p)
+{
+ struct filemon *filemon;
- if (bcmp(name,"filemon", 7) != 0)
+ if (p->p_filemon == NULL)
+ return (NULL);
+ PROC_LOCK(p);
+ filemon = filemon_acquire(p->p_filemon);
+ PROC_UNLOCK(p);
+
+ if (filemon == NULL)
+ return (NULL);
+ /*
+ * The p->p_filemon may have changed by now. That case is handled
+ * by the exit and fork hooks and filemon_attach_proc specially.
+ */
+ sx_xlock(&filemon->lock);
+ return (filemon);
+}
+
+/* Remove and release the filemon on the given process. */
+static void
+filemon_proc_drop(struct proc *p)
+{
+ struct filemon *filemon;
+
+ KASSERT(p->p_filemon != NULL, ("%s: proc %p NULL p_filemon",
+ __func__, p));
+ sx_assert(&p->p_filemon->lock, SA_XLOCKED);
+ PROC_LOCK(p);
+ filemon = p->p_filemon;
+ p->p_filemon = NULL;
+ --filemon->proccnt;
+ PROC_UNLOCK(p);
+ /*
+ * This should not be the last reference yet. filemon_release()
+ * cannot be called with filemon locked, which the caller expects
+ * will stay locked.
+ */
+ KASSERT(filemon->refcnt > 1, ("%s: proc %p dropping filemon %p "
+ "with last reference", __func__, p, filemon));
+ filemon_release(filemon);
+}
+
+/* Unlock and release the filemon. */
+static __inline void
+filemon_drop(struct filemon *filemon)
+{
+
+ sx_xunlock(&filemon->lock);
+ filemon_release(filemon);
+}
+
+#include "filemon_wrapper.c"
+
+static void
+filemon_write_header(struct filemon *filemon)
+{
+ int len;
+ struct timeval now;
+
+ getmicrotime(&now);
+
+ len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr),
+ "# filemon version %d\n# Target pid %d\n# Start %ju.%06ju\nV %d\n",
+ FILEMON_VERSION, curproc->p_pid, (uintmax_t)now.tv_sec,
+ (uintmax_t)now.tv_usec, FILEMON_VERSION);
+
+ filemon_output(filemon, filemon->msgbufr, len);
+}
+
+/*
+ * Invalidate the passed filemon in all processes.
+ */
+static void
+filemon_untrack_processes(struct filemon *filemon)
+{
+ struct proc *p;
+
+ sx_assert(&filemon->lock, SA_XLOCKED);
+
+ /* Avoid allproc loop if there is no need. */
+ if (filemon->proccnt == 0)
return;
- /* Clone the device to the new minor number. */
- if (clone_create(&filemon_clones, &filemon_cdevsw, &u, dev, 0) != 0)
- /* Create the /dev/filemonNN entry. */
- *dev = make_dev_cred(&filemon_cdevsw, u, cred, UID_ROOT,
- GID_WHEEL, 0666, "filemon%d", u);
- if (*dev != NULL) {
- dev_ref(*dev);
- (*dev)->si_flags |= SI_CHEAPCLONE;
+ /*
+ * Processes in this list won't go away while here since
+ * filemon_event_process_exit() will lock on filemon->lock
+ * which we hold.
+ */
+ sx_slock(&allproc_lock);
+ FOREACH_PROC_IN_SYSTEM(p) {
+ /*
+ * No PROC_LOCK is needed to compare here since it is
+ * guaranteed to not change since we have its filemon
+ * locked. Everything that changes this p_filemon will
+ * be locked on it.
+ */
+ if (p->p_filemon == filemon)
+ filemon_proc_drop(p);
}
+ sx_sunlock(&allproc_lock);
+
+ /*
+ * It's possible some references were acquired but will be
+ * dropped shortly as they are restricted from being
+ * inherited. There is at least the reference in cdevpriv remaining.
+ */
+ KASSERT(filemon->refcnt > 0, ("%s: filemon %p should have "
+ "references still.", __func__, filemon));
+ KASSERT(filemon->proccnt == 0, ("%s: filemon %p should not have "
+ "attached procs still.", __func__, filemon));
}
-#endif
+/*
+ * Close out the log.
+ */
static void
+filemon_close_log(struct filemon *filemon)
+{
+ struct file *fp;
+ struct timeval now;
+ size_t len;
+
+ sx_assert(&filemon->lock, SA_XLOCKED);
+ if (filemon->fp == NULL)
+ return;
+
+ getmicrotime(&now);
+
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr),
+ "# Stop %ju.%06ju\n# Bye bye\n",
+ (uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec);
+
+ filemon_output(filemon, filemon->msgbufr, len);
+ fp = filemon->fp;
+ filemon->fp = NULL;
+
+ sx_xunlock(&filemon->lock);
+ fdrop(fp, curthread);
+ sx_xlock(&filemon->lock);
+}
+
+/*
+ * The devfs file is being closed. Untrace all processes. It is possible
+ * filemon_close/close(2) was not called.
+ */
+static void
filemon_dtr(void *data)
{
struct filemon *filemon = data;
- if (filemon != NULL) {
- struct file *fp = filemon->fp;
+ if (filemon == NULL)
+ return;
- /* Get exclusive write access. */
- filemon_lock_write();
+ sx_xlock(&filemon->lock);
+ /*
+ * Detach the filemon. It cannot be inherited after this.
+ */
+ filemon_untrack_processes(filemon);
+ filemon_close_log(filemon);
+ filemon_drop(filemon);
+}
- /* Remove from the in-use list. */
- TAILQ_REMOVE(&filemons_inuse, filemon, link);
+/* Attach the filemon to the process. */
+static int
+filemon_attach_proc(struct filemon *filemon, struct proc *p)
+{
+ struct filemon *filemon2;
- filemon->fp = NULL;
- filemon->pid = -1;
+ sx_assert(&filemon->lock, SA_XLOCKED);
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ KASSERT((p->p_flag & P_WEXIT) == 0,
+ ("%s: filemon %p attaching to exiting process %p",
+ __func__, filemon, p));
+ KASSERT((p->p_flag & P_INEXEC) == 0,
+ ("%s: filemon %p attaching to execing process %p",
+ __func__, filemon, p));
- /* Add to the free list. */
- TAILQ_INSERT_TAIL(&filemons_free, filemon, link);
+ if (p->p_filemon == filemon)
+ return (0);
+ /*
+ * Don't allow truncating other process traces. It is
+ * not really intended to trace procs other than curproc
+ * anyhow.
+ */
+ if (p->p_filemon != NULL && p != curproc)
+ return (EBUSY);
+ /*
+ * Historic behavior of filemon has been to let a child initiate
+ * tracing on itself and cease existing tracing. Bmake
+ * .META + .MAKE relies on this. It is only relevant for attaching to
+ * curproc.
+ */
+ while (p->p_filemon != NULL) {
+ PROC_UNLOCK(p);
+ sx_xunlock(&filemon->lock);
+ while ((filemon2 = filemon_proc_get(p)) != NULL) {
+ /* It may have changed. */
+ if (p->p_filemon == filemon2)
+ filemon_proc_drop(p);
+ filemon_drop(filemon2);
+ }
+ sx_xlock(&filemon->lock);
+ PROC_LOCK(p);
+ /*
+ * It may have been attached to, though unlikely.
+ * Try again if needed.
+ */
+ }
- /* Give up write access. */
- filemon_unlock_write();
+ KASSERT(p->p_filemon == NULL,
+ ("%s: proc %p didn't detach filemon %p", __func__, p,
+ p->p_filemon));
+ p->p_filemon = filemon_acquire(filemon);
+ ++filemon->proccnt;
- if (fp != NULL)
- fdrop(fp, curthread);
- }
+ return (0);
}
static int
@@ -181,32 +362,41 @@
int error = 0;
struct filemon *filemon;
struct proc *p;
+ cap_rights_t rights;
-#if __FreeBSD_version < 701000
- filemon = dev->si_drv1;
-#else
- devfs_get_cdevpriv((void **) &filemon);
-#endif
+ if ((error = devfs_get_cdevpriv((void **) &filemon)) != 0)
+ return (error);
+ sx_xlock(&filemon->lock);
+
switch (cmd) {
/* Set the output file descriptor. */
case FILEMON_SET_FD:
-#if __FreeBSD_version < 900041
-#define FGET_WRITE(a1, a2, a3) fget_write((a1), (a2), (a3))
-#else
-#define FGET_WRITE(a1, a2, a3) fget_write((a1), (a2), CAP_WRITE | CAP_SEEK, (a3))
-#endif
- if ((error = FGET_WRITE(td, *(int *)data, &filemon->fp)) == 0)
+ if (filemon->fp != NULL) {
+ error = EEXIST;
+ break;
+ }
+
+ error = fget_write(td, *(int *)data,
+ cap_rights_init(&rights, CAP_PWRITE),
+ &filemon->fp);
+ if (error == 0)
/* Write the file header. */
- filemon_comment(filemon);
+ filemon_write_header(filemon);
break;
/* Set the monitored process ID. */
case FILEMON_SET_PID:
- error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT,
- &p);
+ /* Invalidate any existing processes already set. */
+ filemon_untrack_processes(filemon);
+
+ error = pget(*((pid_t *)data),
+ PGET_CANDEBUG | PGET_NOTWEXIT | PGET_NOTINEXEC, &p);
if (error == 0) {
- filemon->pid = p->p_pid;
+ KASSERT(p->p_filemon != filemon,
+ ("%s: proc %p didn't untrack filemon %p",
+ __func__, p, filemon));
+ error = filemon_attach_proc(filemon, p);
PROC_UNLOCK(p);
}
break;
@@ -216,143 +406,73 @@
break;
}
+ sx_xunlock(&filemon->lock);
return (error);
}
static int
filemon_open(struct cdev *dev, int oflags __unused, int devtype __unused,
- struct thread *td __unused)
+ struct thread *td)
{
+ int error;
struct filemon *filemon;
- /* Get exclusive write access. */
- filemon_lock_write();
+ filemon = malloc(sizeof(*filemon), M_FILEMON,
+ M_WAITOK | M_ZERO);
+ sx_init(&filemon->lock, "filemon");
+ refcount_init(&filemon->refcnt, 1);
+ filemon->cred = crhold(td->td_ucred);
- if ((filemon = TAILQ_FIRST(&filemons_free)) != NULL)
- TAILQ_REMOVE(&filemons_free, filemon, link);
+ error = devfs_set_cdevpriv(filemon, filemon_dtr);
+ if (error != 0)
+ filemon_release(filemon);
- /* Give up write access. */
- filemon_unlock_write();
-
- if (filemon == NULL) {
- filemon = malloc(sizeof(struct filemon), M_FILEMON,
- M_WAITOK | M_ZERO);
-
- filemon->fp = NULL;
-
- mtx_init(&filemon->mtx, "filemon", "filemon", MTX_DEF);
- cv_init(&filemon->cv, "filemon");
- }
-
- filemon->pid = curproc->p_pid;
-
-#if __FreeBSD_version < 701000
- dev->si_drv1 = filemon;
-#else
- devfs_set_cdevpriv(filemon, filemon_dtr);
-#endif
-
- /* Get exclusive write access. */
- filemon_lock_write();
-
- /* Add to the in-use list. */
- TAILQ_INSERT_TAIL(&filemons_inuse, filemon, link);
-
- /* Give up write access. */
- filemon_unlock_write();
-
- return (0);
+ return (error);
}
+/* Called on close of last devfs file handle, before filemon_dtr(). */
static int
filemon_close(struct cdev *dev __unused, int flag __unused, int fmt __unused,
struct thread *td __unused)
{
-#if __FreeBSD_version < 701000
- filemon_dtr(dev->si_drv1);
+ struct filemon *filemon;
+ int error;
- dev->si_drv1 = NULL;
+ if ((error = devfs_get_cdevpriv((void **) &filemon)) != 0)
+ return (error);
- /* Schedule this cloned device to be destroyed. */
- destroy_dev_sched(dev);
-#endif
+ sx_xlock(&filemon->lock);
+ filemon_close_log(filemon);
+ error = filemon->error;
+ sx_xunlock(&filemon->lock);
+ /*
+ * Processes are still being traced but won't log anything
+ * now. After this call returns filemon_dtr() is called which
+ * will detach processes.
+ */
- return (0);
+ return (error);
}
static void
filemon_load(void *dummy __unused)
{
- mtx_init(&access_mtx, "filemon", "filemon", MTX_DEF);
- cv_init(&access_cv, "filemon");
/* Install the syscall wrappers. */
filemon_wrapper_install();
-#if __FreeBSD_version < 701000
- /* Enable device cloning. */
- clone_setup(&filemon_clones);
-
- /* Setup device cloning events. */
- eh_tag = EVENTHANDLER_REGISTER(dev_clone, filemon_clone, 0, 1000);
-#else
filemon_dev = make_dev(&filemon_cdevsw, 0, UID_ROOT, GID_WHEEL, 0666,
"filemon");
-#endif
}
static int
filemon_unload(void)
{
- struct filemon *filemon;
- int error = 0;
- /* Get exclusive write access. */
- filemon_lock_write();
+ destroy_dev(filemon_dev);
+ filemon_wrapper_deinstall();
- if (TAILQ_FIRST(&filemons_inuse) != NULL)
- error = EBUSY;
- else {
-#if __FreeBSD_version >= 701000
- destroy_dev(filemon_dev);
-#endif
-
- /* Deinstall the syscall wrappers. */
- filemon_wrapper_deinstall();
- }
-
- /* Give up write access. */
- filemon_unlock_write();
-
- if (error == 0) {
-#if __FreeBSD_version < 701000
- /*
- * Check if there is still an event handler callback registered.
- */
- if (eh_tag != 0) {
- /* De-register the device cloning event handler. */
- EVENTHANDLER_DEREGISTER(dev_clone, eh_tag);
- eh_tag = 0;
-
- /* Stop device cloning. */
- clone_cleanup(&filemon_clones);
- }
-#endif
- /* free() filemon structs free list. */
- filemon_lock_write();
- while ((filemon = TAILQ_FIRST(&filemons_free)) != NULL) {
- TAILQ_REMOVE(&filemons_free, filemon, link);
- mtx_destroy(&filemon->mtx);
- cv_destroy(&filemon->cv);
- free(filemon, M_FILEMON);
- }
- filemon_unlock_write();
-
- mtx_destroy(&access_mtx);
- cv_destroy(&access_cv);
- }
-
- return (error);
+ return (0);
}
static int
@@ -369,6 +489,14 @@
error = filemon_unload();
break;
+ case MOD_QUIESCE:
+ /*
+ * The wrapper implementation is unsafe for reliable unload.
+ * Require forcing an unload.
+ */
+ error = EBUSY;
+ break;
+
case MOD_SHUTDOWN:
break;
Modified: trunk/sys/dev/filemon/filemon.h
===================================================================
--- trunk/sys/dev/filemon/filemon.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/filemon/filemon.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011, David E. O'Brien.
* Copyright (c) 2009-2011, Juniper Networks, Inc.
@@ -24,11 +25,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/filemon/filemon.h 285112 2015-07-03 20:43:31Z sjg $
*/
#define FILEMON_SET_FD _IOWR('S', 1, int)
#define FILEMON_SET_PID _IOWR('S', 2, pid_t)
-#define FILEMON_VERSION 4 /* output format
+#define FILEMON_VERSION 5 /* output format
(bump when adding record types) */
Modified: trunk/sys/dev/filemon/filemon_wrapper.c
===================================================================
--- trunk/sys/dev/filemon/filemon_wrapper.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/filemon/filemon_wrapper.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,6 +1,8 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2011, David E. O'Brien.
* Copyright (c) 2009-2011, Juniper Networks, Inc.
+ * Copyright (c) 2015-2016, EMC Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,40 +28,28 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/filemon/filemon_wrapper.c 302241 2016-06-27 22:21:29Z bdrewery $");
+#include <sys/eventhandler.h>
+#include <sys/filedesc.h>
+#include <sys/imgact.h>
+#include <sys/priv.h>
+#include <sys/sx.h>
+#include <sys/sysent.h>
+#include <sys/vnode.h>
+
#include "opt_compat.h"
-#if __FreeBSD_version > 800032
-#define FILEMON_HAS_LINKAT
-#endif
+static eventhandler_tag filemon_exec_tag;
+static eventhandler_tag filemon_exit_tag;
+static eventhandler_tag filemon_fork_tag;
-#if __FreeBSD_version < 900044 /* r225617 (2011-09-16) failed to bump
- __FreeBSD_version. This really should
- be based on "900045". "900044" is r225469
- (2011-09-10) so this code is broken for
- 9-CURRENT September 10th-16th. */
-#define sys_chdir chdir
-#define sys_execve execve
-#define sys_fork fork
-#define sys_link link
-#define sys_open open
-#define sys_rename rename
-#define sys_stat stat
-#define sys_symlink symlink
-#define sys_unlink unlink
-#define sys_vfork vfork
-#define sys_sys_exit sys_exit
-#ifdef FILEMON_HAS_LINKAT
-#define sys_linkat linkat
-#endif
-#endif /* __FreeBSD_version */
-
static void
filemon_output(struct filemon *filemon, char *msg, size_t len)
{
struct uio auio;
struct iovec aiov;
+ int error;
if (filemon->fp == NULL)
return;
@@ -74,244 +64,170 @@
auio.uio_td = curthread;
auio.uio_offset = (off_t) -1;
- bwillwrite();
+ if (filemon->fp->f_type == DTYPE_VNODE)
+ bwillwrite();
- fo_write(filemon->fp, &auio, curthread->td_ucred, 0, curthread);
+ error = fo_write(filemon->fp, &auio, filemon->cred, 0, curthread);
+ if (error != 0 && filemon->error == 0)
+ filemon->error = error;
}
-static struct filemon *
-filemon_pid_check(struct proc *p)
-{
- struct filemon *filemon;
-
- while (p->p_pptr) {
- TAILQ_FOREACH(filemon, &filemons_inuse, link) {
- if (p->p_pid == filemon->pid)
- return (filemon);
- }
- p = p->p_pptr;
- }
- return (NULL);
-}
-
-static void
-filemon_comment(struct filemon *filemon)
-{
- int len;
- struct timeval now;
-
- /* Load timestamp before locking. Less accurate but less contention. */
- getmicrotime(&now);
-
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
-
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr),
- "# filemon version %d\n# Target pid %d\n# Start %ju.%06ju\nV %d\n",
- FILEMON_VERSION, curproc->p_pid, (uintmax_t)now.tv_sec,
- (uintmax_t)now.tv_usec, FILEMON_VERSION);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
-
- /* Release the read lock. */
- filemon_unlock_read();
-}
-
static int
filemon_wrapper_chdir(struct thread *td, struct chdir_args *uap)
{
- int ret;
- size_t done;
+ int error, ret;
size_t len;
struct filemon *filemon;
if ((ret = sys_chdir(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((filemon = filemon_proc_get(curproc)) != NULL) {
+ if ((error = copyinstr(uap->path, filemon->fname1,
+ sizeof(filemon->fname1), NULL)) != 0) {
+ filemon->error = error;
+ goto copyfail;
+ }
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
-
len = snprintf(filemon->msgbufr,
sizeof(filemon->msgbufr), "C %d %s\n",
curproc->p_pid, filemon->fname1);
filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+copyfail:
+ filemon_drop(filemon);
}
-
- /* Release the read lock. */
- filemon_unlock_read();
}
return (ret);
}
-static int
-filemon_wrapper_execve(struct thread *td, struct execve_args *uap)
+static void
+filemon_event_process_exec(void *arg __unused, struct proc *p,
+ struct image_params *imgp)
{
- char fname[MAXPATHLEN];
- int ret;
- size_t done;
+ struct filemon *filemon;
size_t len;
- struct filemon *filemon;
- copyinstr(uap->fname, fname, sizeof(fname), &done);
+ if ((filemon = filemon_proc_get(p)) != NULL) {
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr), "E %d %s\n",
+ p->p_pid,
+ imgp->execpath != NULL ? imgp->execpath : "<unknown>");
- if ((ret = sys_execve(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ filemon_output(filemon, filemon->msgbufr, len);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
+ /* If the credentials changed then cease tracing. */
+ if (imgp->newcred != NULL &&
+ imgp->credential_setid &&
+ priv_check_cred(filemon->cred,
+ PRIV_DEBUG_DIFFCRED, 0) != 0) {
+ /*
+ * It may have changed to NULL already, but
+ * will not be re-attached by anything else.
+ */
+ if (p->p_filemon != NULL) {
+ KASSERT(p->p_filemon == filemon,
+ ("%s: proc %p didn't have expected"
+ " filemon %p", __func__, p, filemon));
+ filemon_proc_drop(p);
+ }
+ }
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "E %d %s\n",
- curproc->p_pid, fname);
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
+ filemon_drop(filemon);
}
-
- return (ret);
}
-#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
-static int
-filemon_wrapper_freebsd32_execve(struct thread *td,
- struct freebsd32_execve_args *uap)
+static void
+_filemon_wrapper_openat(struct thread *td, char *upath, int flags, int fd)
{
- char fname[MAXPATHLEN];
- int ret;
- size_t done;
+ int error;
size_t len;
+ struct file *fp;
struct filemon *filemon;
+ char *atpath, *freepath;
+ cap_rights_t rights;
- copyinstr(uap->fname, fname, sizeof(fname), &done);
+ if ((filemon = filemon_proc_get(curproc)) != NULL) {
+ atpath = "";
+ freepath = NULL;
+ fp = NULL;
- if ((ret = freebsd32_execve(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((error = copyinstr(upath, filemon->fname1,
+ sizeof(filemon->fname1), NULL)) != 0) {
+ filemon->error = error;
+ goto copyfail;
+ }
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
+ if (filemon->fname1[0] != '/' && fd != AT_FDCWD) {
+ /*
+ * rats - we cannot do too much about this.
+ * the trace should show a dir we read
+ * recently.. output an A record as a clue
+ * until we can do better.
+ * XXX: This may be able to come out with
+ * the namecache lookup now.
+ */
len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "E %d %s\n",
- curproc->p_pid, fname);
-
+ sizeof(filemon->msgbufr), "A %d %s\n",
+ curproc->p_pid, filemon->fname1);
filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+ /*
+ * Try to resolve the path from the vnode using the
+ * namecache. It may be inaccurate, but better
+ * than nothing.
+ */
+ if (getvnode(td->td_proc->p_fd, fd,
+ cap_rights_init(&rights, CAP_LOOKUP), &fp) == 0) {
+ vn_fullpath(td, fp->f_vnode, &atpath,
+ &freepath);
+ }
}
+ if (flags & O_RDWR) {
+ /*
+ * We'll get the W record below, but need
+ * to also output an R to distinguish from
+ * O_WRONLY.
+ */
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr), "R %d %s%s%s\n",
+ curproc->p_pid, atpath,
+ atpath[0] != '\0' ? "/" : "", filemon->fname1);
+ filemon_output(filemon, filemon->msgbufr, len);
+ }
- /* Release the read lock. */
- filemon_unlock_read();
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr), "%c %d %s%s%s\n",
+ (flags & O_ACCMODE) ? 'W':'R',
+ curproc->p_pid, atpath,
+ atpath[0] != '\0' ? "/" : "", filemon->fname1);
+ filemon_output(filemon, filemon->msgbufr, len);
+copyfail:
+ filemon_drop(filemon);
+ if (fp != NULL)
+ fdrop(fp, td);
+ free(freepath, M_TEMP);
}
-
- return (ret);
}
-#endif
static int
-filemon_wrapper_fork(struct thread *td, struct fork_args *uap)
+filemon_wrapper_open(struct thread *td, struct open_args *uap)
{
int ret;
- size_t len;
- struct filemon *filemon;
- if ((ret = sys_fork(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((ret = sys_open(td, uap)) == 0)
+ _filemon_wrapper_openat(td, uap->path, uap->flags, AT_FDCWD);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "F %d %ld\n",
- curproc->p_pid, (long)curthread->td_retval[0]);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
- }
-
return (ret);
}
static int
-filemon_wrapper_open(struct thread *td, struct open_args *uap)
+filemon_wrapper_openat(struct thread *td, struct openat_args *uap)
{
int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
- if ((ret = sys_open(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((ret = sys_openat(td, uap)) == 0)
+ _filemon_wrapper_openat(td, uap->path, uap->flag, uap->fd);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
-
- if (uap->flags & O_RDWR) {
- /*
- * We'll get the W record below, but need
- * to also output an R to distingish from
- * O_WRONLY.
- */
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "R %d %s\n",
- curproc->p_pid, filemon->fname1);
- filemon_output(filemon, filemon->msgbufr, len);
- }
-
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "%c %d %s\n",
- (uap->flags & O_ACCMODE) ? 'W':'R',
- curproc->p_pid, filemon->fname1);
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
- }
-
return (ret);
}
@@ -318,431 +234,242 @@
static int
filemon_wrapper_rename(struct thread *td, struct rename_args *uap)
{
- int ret;
- size_t done;
+ int error, ret;
size_t len;
struct filemon *filemon;
if ((ret = sys_rename(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((filemon = filemon_proc_get(curproc)) != NULL) {
+ if (((error = copyinstr(uap->from, filemon->fname1,
+ sizeof(filemon->fname1), NULL)) != 0) ||
+ ((error = copyinstr(uap->to, filemon->fname2,
+ sizeof(filemon->fname2), NULL)) != 0)) {
+ filemon->error = error;
+ goto copyfail;
+ }
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->from, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->to, filemon->fname2,
- sizeof(filemon->fname2), &done);
-
len = snprintf(filemon->msgbufr,
sizeof(filemon->msgbufr), "M %d '%s' '%s'\n",
curproc->p_pid, filemon->fname1, filemon->fname2);
filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+copyfail:
+ filemon_drop(filemon);
}
-
- /* Release the read lock. */
- filemon_unlock_read();
}
return (ret);
}
-static int
-filemon_wrapper_link(struct thread *td, struct link_args *uap)
+static void
+_filemon_wrapper_link(struct thread *td, char *upath1, char *upath2)
{
- int ret;
- size_t done;
+ struct filemon *filemon;
size_t len;
- struct filemon *filemon;
+ int error;
- if ((ret = sys_link(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
-
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->link, filemon->fname2,
- sizeof(filemon->fname2), &done);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
- curproc->p_pid, filemon->fname1, filemon->fname2);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+ if ((filemon = filemon_proc_get(curproc)) != NULL) {
+ if (((error = copyinstr(upath1, filemon->fname1,
+ sizeof(filemon->fname1), NULL)) != 0) ||
+ ((error = copyinstr(upath2, filemon->fname2,
+ sizeof(filemon->fname2), NULL)) != 0)) {
+ filemon->error = error;
+ goto copyfail;
}
- /* Release the read lock. */
- filemon_unlock_read();
- }
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
+ curproc->p_pid, filemon->fname1, filemon->fname2);
- return (ret);
-}
-
-static int
-filemon_wrapper_symlink(struct thread *td, struct symlink_args *uap)
-{
- int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
-
- if ((ret = sys_symlink(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
-
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->link, filemon->fname2,
- sizeof(filemon->fname2), &done);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
- curproc->p_pid, filemon->fname1, filemon->fname2);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
+ filemon_output(filemon, filemon->msgbufr, len);
+copyfail:
+ filemon_drop(filemon);
}
-
- return (ret);
}
-#ifdef FILEMON_HAS_LINKAT
static int
-filemon_wrapper_linkat(struct thread *td, struct linkat_args *uap)
+filemon_wrapper_link(struct thread *td, struct link_args *uap)
{
int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
- if ((ret = sys_linkat(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((ret = sys_link(td, uap)) == 0)
+ _filemon_wrapper_link(td, uap->path, uap->link);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path1, filemon->fname1,
- sizeof(filemon->fname1), &done);
- copyinstr(uap->path2, filemon->fname2,
- sizeof(filemon->fname2), &done);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "L %d '%s' '%s'\n",
- curproc->p_pid, filemon->fname1, filemon->fname2);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
- }
-
return (ret);
}
-#endif
static int
-filemon_wrapper_stat(struct thread *td, struct stat_args *uap)
+filemon_wrapper_symlink(struct thread *td, struct symlink_args *uap)
{
int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
- if ((ret = sys_stat(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((ret = sys_symlink(td, uap)) == 0)
+ _filemon_wrapper_link(td, uap->path, uap->link);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "S %d %s\n",
- curproc->p_pid, filemon->fname1);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
- }
-
return (ret);
}
-#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
static int
-filemon_wrapper_freebsd32_stat(struct thread *td,
- struct freebsd32_stat_args *uap)
+filemon_wrapper_linkat(struct thread *td, struct linkat_args *uap)
{
int ret;
- size_t done;
- size_t len;
- struct filemon *filemon;
- if ((ret = freebsd32_stat(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((ret = sys_linkat(td, uap)) == 0)
+ _filemon_wrapper_link(td, uap->path1, uap->path2);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
-
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "S %d %s\n",
- curproc->p_pid, filemon->fname1);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
- }
-
- /* Release the read lock. */
- filemon_unlock_read();
- }
-
return (ret);
}
-#endif
static void
-filemon_wrapper_sys_exit(struct thread *td, struct sys_exit_args *uap)
+filemon_event_process_exit(void *arg __unused, struct proc *p)
{
size_t len;
struct filemon *filemon;
- struct timeval now;
- /* Get timestamp before locking. */
- getmicrotime(&now);
-
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
-
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
+ if ((filemon = filemon_proc_get(p)) != NULL) {
len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr),
- "X %d %d\n", curproc->p_pid, uap->rval);
+ "X %d %d\n", p->p_pid, W_EXITCODE(p->p_xstat, 0));
filemon_output(filemon, filemon->msgbufr, len);
- /* Check if the monitored process is about to exit. */
- if (filemon->pid == curproc->p_pid) {
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr),
- "# Stop %ju.%06ju\n# Bye bye\n",
- (uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec);
+ /*
+ * filemon_untrack_processes() may have dropped this p_filemon
+ * already while in filemon_proc_get() before acquiring the
+ * filemon lock.
+ */
+ KASSERT(p->p_filemon == NULL || p->p_filemon == filemon,
+ ("%s: p %p was attached while exiting, expected "
+ "filemon %p or NULL", __func__, p, filemon));
+ if (p->p_filemon == filemon)
+ filemon_proc_drop(p);
- filemon_output(filemon, filemon->msgbufr, len);
- filemon->pid = -1;
- }
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+ filemon_drop(filemon);
}
-
- /* Release the read lock. */
- filemon_unlock_read();
-
- sys_sys_exit(td, uap);
}
static int
filemon_wrapper_unlink(struct thread *td, struct unlink_args *uap)
{
- int ret;
- size_t done;
+ int error, ret;
size_t len;
struct filemon *filemon;
if ((ret = sys_unlink(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((filemon = filemon_proc_get(curproc)) != NULL) {
+ if ((error = copyinstr(uap->path, filemon->fname1,
+ sizeof(filemon->fname1), NULL)) != 0) {
+ filemon->error = error;
+ goto copyfail;
+ }
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
-
- copyinstr(uap->path, filemon->fname1,
- sizeof(filemon->fname1), &done);
-
len = snprintf(filemon->msgbufr,
sizeof(filemon->msgbufr), "D %d %s\n",
curproc->p_pid, filemon->fname1);
filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+copyfail:
+ filemon_drop(filemon);
}
-
- /* Release the read lock. */
- filemon_unlock_read();
}
return (ret);
}
-static int
-filemon_wrapper_vfork(struct thread *td, struct vfork_args *uap)
+static void
+filemon_event_process_fork(void *arg __unused, struct proc *p1,
+ struct proc *p2, int flags __unused)
{
- int ret;
size_t len;
struct filemon *filemon;
- if ((ret = sys_vfork(td, uap)) == 0) {
- /* Grab a read lock on the filemon inuse list. */
- filemon_lock_read();
+ if ((filemon = filemon_proc_get(p1)) != NULL) {
+ len = snprintf(filemon->msgbufr,
+ sizeof(filemon->msgbufr), "F %d %d\n",
+ p1->p_pid, p2->p_pid);
- if ((filemon = filemon_pid_check(curproc)) != NULL) {
- /* Lock the found filemon structure. */
- filemon_filemon_lock(filemon);
+ filemon_output(filemon, filemon->msgbufr, len);
- len = snprintf(filemon->msgbufr,
- sizeof(filemon->msgbufr), "F %d %ld\n",
- curproc->p_pid, (long)curthread->td_retval[0]);
-
- filemon_output(filemon, filemon->msgbufr, len);
-
- /* Unlock the found filemon structure. */
- filemon_filemon_unlock(filemon);
+ /*
+ * filemon_untrack_processes() or
+ * filemon_ioctl(FILEMON_SET_PID) may have changed the parent's
+ * p_filemon while in filemon_proc_get() before acquiring the
+ * filemon lock. Only inherit if the parent is still traced by
+ * this filemon.
+ */
+ if (p1->p_filemon == filemon) {
+ PROC_LOCK(p2);
+ /*
+ * It may have been attached to already by a new
+ * filemon.
+ */
+ if (p2->p_filemon == NULL) {
+ p2->p_filemon = filemon_acquire(filemon);
+ ++filemon->proccnt;
+ }
+ PROC_UNLOCK(p2);
}
- /* Release the read lock. */
- filemon_unlock_read();
+ filemon_drop(filemon);
}
-
- return (ret);
}
static void
filemon_wrapper_install(void)
{
-#if defined(__i386__)
- struct sysent *sv_table = elf32_freebsd_sysvec.sv_table;
-#elif defined(__amd64__)
- struct sysent *sv_table = elf64_freebsd_sysvec.sv_table;
-#else
-#error Machine type not supported
-#endif
- sv_table[SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
- sv_table[SYS_exit].sy_call = (sy_call_t *) filemon_wrapper_sys_exit;
- sv_table[SYS_execve].sy_call = (sy_call_t *) filemon_wrapper_execve;
- sv_table[SYS_fork].sy_call = (sy_call_t *) filemon_wrapper_fork;
- sv_table[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
- sv_table[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
- sv_table[SYS_stat].sy_call = (sy_call_t *) filemon_wrapper_stat;
- sv_table[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
- sv_table[SYS_vfork].sy_call = (sy_call_t *) filemon_wrapper_vfork;
- sv_table[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
- sv_table[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
-#ifdef FILEMON_HAS_LINKAT
- sv_table[SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
-#endif
+ sysent[SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
+ sysent[SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
+ sysent[SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
+ sysent[SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
+ sysent[SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
+ sysent[SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
+ sysent[SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
+ sysent[SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
-#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
- sv_table = ia32_freebsd_sysvec.sv_table;
+#if defined(COMPAT_FREEBSD32)
+ freebsd32_sysent[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
+ freebsd32_sysent[FREEBSD32_SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
+ freebsd32_sysent[FREEBSD32_SYS_openat].sy_call = (sy_call_t *) filemon_wrapper_openat;
+ freebsd32_sysent[FREEBSD32_SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
+ freebsd32_sysent[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
+ freebsd32_sysent[FREEBSD32_SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
+ freebsd32_sysent[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
+ freebsd32_sysent[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
+#endif /* COMPAT_FREEBSD32 */
- sv_table[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *) filemon_wrapper_chdir;
- sv_table[FREEBSD32_SYS_exit].sy_call = (sy_call_t *) filemon_wrapper_sys_exit;
- sv_table[FREEBSD32_SYS_freebsd32_execve].sy_call = (sy_call_t *) filemon_wrapper_freebsd32_execve;
- sv_table[FREEBSD32_SYS_fork].sy_call = (sy_call_t *) filemon_wrapper_fork;
- sv_table[FREEBSD32_SYS_open].sy_call = (sy_call_t *) filemon_wrapper_open;
- sv_table[FREEBSD32_SYS_rename].sy_call = (sy_call_t *) filemon_wrapper_rename;
- sv_table[FREEBSD32_SYS_freebsd32_stat].sy_call = (sy_call_t *) filemon_wrapper_freebsd32_stat;
- sv_table[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *) filemon_wrapper_unlink;
- sv_table[FREEBSD32_SYS_vfork].sy_call = (sy_call_t *) filemon_wrapper_vfork;
- sv_table[FREEBSD32_SYS_link].sy_call = (sy_call_t *) filemon_wrapper_link;
- sv_table[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *) filemon_wrapper_symlink;
-#ifdef FILEMON_HAS_LINKAT
- sv_table[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
-#endif
-#endif /* COMPAT_ARCH32 */
+ filemon_exec_tag = EVENTHANDLER_REGISTER(process_exec,
+ filemon_event_process_exec, NULL, EVENTHANDLER_PRI_LAST);
+ filemon_exit_tag = EVENTHANDLER_REGISTER(process_exit,
+ filemon_event_process_exit, NULL, EVENTHANDLER_PRI_LAST);
+ filemon_fork_tag = EVENTHANDLER_REGISTER(process_fork,
+ filemon_event_process_fork, NULL, EVENTHANDLER_PRI_LAST);
}
static void
filemon_wrapper_deinstall(void)
{
-#if defined(__i386__)
- struct sysent *sv_table = elf32_freebsd_sysvec.sv_table;
-#elif defined(__amd64__)
- struct sysent *sv_table = elf64_freebsd_sysvec.sv_table;
-#else
-#error Machine type not supported
-#endif
- sv_table[SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
- sv_table[SYS_exit].sy_call = (sy_call_t *)sys_sys_exit;
- sv_table[SYS_execve].sy_call = (sy_call_t *)sys_execve;
- sv_table[SYS_fork].sy_call = (sy_call_t *)sys_fork;
- sv_table[SYS_open].sy_call = (sy_call_t *)sys_open;
- sv_table[SYS_rename].sy_call = (sy_call_t *)sys_rename;
- sv_table[SYS_stat].sy_call = (sy_call_t *)sys_stat;
- sv_table[SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
- sv_table[SYS_vfork].sy_call = (sy_call_t *)sys_vfork;
- sv_table[SYS_link].sy_call = (sy_call_t *)sys_link;
- sv_table[SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
-#ifdef FILEMON_HAS_LINKAT
- sv_table[SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
-#endif
+ sysent[SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
+ sysent[SYS_open].sy_call = (sy_call_t *)sys_open;
+ sysent[SYS_openat].sy_call = (sy_call_t *)sys_openat;
+ sysent[SYS_rename].sy_call = (sy_call_t *)sys_rename;
+ sysent[SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
+ sysent[SYS_link].sy_call = (sy_call_t *)sys_link;
+ sysent[SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
+ sysent[SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
-#if defined(COMPAT_IA32) || defined(COMPAT_FREEBSD32) || defined(COMPAT_ARCH32)
- sv_table = ia32_freebsd_sysvec.sv_table;
+#if defined(COMPAT_FREEBSD32)
+ freebsd32_sysent[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
+ freebsd32_sysent[FREEBSD32_SYS_open].sy_call = (sy_call_t *)sys_open;
+ freebsd32_sysent[FREEBSD32_SYS_openat].sy_call = (sy_call_t *)sys_openat;
+ freebsd32_sysent[FREEBSD32_SYS_rename].sy_call = (sy_call_t *)sys_rename;
+ freebsd32_sysent[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
+ freebsd32_sysent[FREEBSD32_SYS_link].sy_call = (sy_call_t *)sys_link;
+ freebsd32_sysent[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
+ freebsd32_sysent[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
+#endif /* COMPAT_FREEBSD32 */
- sv_table[FREEBSD32_SYS_chdir].sy_call = (sy_call_t *)sys_chdir;
- sv_table[FREEBSD32_SYS_exit].sy_call = (sy_call_t *)sys_sys_exit;
- sv_table[FREEBSD32_SYS_freebsd32_execve].sy_call = (sy_call_t *)freebsd32_execve;
- sv_table[FREEBSD32_SYS_fork].sy_call = (sy_call_t *)sys_fork;
- sv_table[FREEBSD32_SYS_open].sy_call = (sy_call_t *)sys_open;
- sv_table[FREEBSD32_SYS_rename].sy_call = (sy_call_t *)sys_rename;
- sv_table[FREEBSD32_SYS_freebsd32_stat].sy_call = (sy_call_t *)freebsd32_stat;
- sv_table[FREEBSD32_SYS_unlink].sy_call = (sy_call_t *)sys_unlink;
- sv_table[FREEBSD32_SYS_vfork].sy_call = (sy_call_t *)sys_vfork;
- sv_table[FREEBSD32_SYS_link].sy_call = (sy_call_t *)sys_link;
- sv_table[FREEBSD32_SYS_symlink].sy_call = (sy_call_t *)sys_symlink;
-#ifdef FILEMON_HAS_LINKAT
- sv_table[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
-#endif
-#endif /* COMPAT_ARCH32 */
+ EVENTHANDLER_DEREGISTER(process_exec, filemon_exec_tag);
+ EVENTHANDLER_DEREGISTER(process_exit, filemon_exit_tag);
+ EVENTHANDLER_DEREGISTER(process_fork, filemon_fork_tag);
}
Modified: trunk/sys/dev/firewire/00README
===================================================================
--- trunk/sys/dev/firewire/00README 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/00README 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,4 +1,4 @@
-$MidnightBSD$
+$FreeBSD: stable/10/sys/dev/firewire/00README 215334 2010-11-15 05:25:51Z dougb $
IEEE 1394 support for FreeBSD-5.X and 4.X.
Property changes on: trunk/sys/dev/firewire/00README
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/firewire/firewire.c
===================================================================
--- trunk/sys/dev/firewire/firewire.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/firewire.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -33,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/firewire/firewire.c 310078 2016-12-14 16:43:09Z avg $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -374,6 +375,7 @@
"tl=0x%x flag=0x%02x\n", i, xfer->flag);
fw_dump_hdr(&xfer->send.hdr, "send");
xfer->resp = ETIMEDOUT;
+ xfer->tl = -1;
STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel);
STAILQ_INSERT_TAIL(&xfer_timeout, xfer, tlabel);
}
@@ -608,6 +610,7 @@
while ((xfer = STAILQ_FIRST(&fc->tlabels[i])) != NULL) {
if (firewire_debug)
printf("tl=%d flag=%d\n", i, xfer->flag);
+ xfer->tl = -1;
xfer->resp = EAGAIN;
STAILQ_REMOVE_HEAD(&fc->tlabels[i], tlabel);
STAILQ_INSERT_TAIL(&xfer_drain, xfer, tlabel);
@@ -647,7 +650,7 @@
CSRARC(fc, BANDWIDTH_AV) = 4915;
CSRARC(fc, CHANNELS_AV_HI) = 0xffffffff;
CSRARC(fc, CHANNELS_AV_LO) = 0xffffffff;
- CSRARC(fc, IP_CHANNELS) = (1 << 31);
+ CSRARC(fc, IP_CHANNELS) = (1U << 31);
CSRARC(fc, CONF_ROM) = 0x04 << 24;
CSRARC(fc, CONF_ROM + 4) = 0x31333934; /* means strings 1394 */
@@ -1044,11 +1047,12 @@
struct fw_xfer *txfer;
int s;
- if (xfer->tl < 0)
- return;
-
s = splfw();
mtx_lock(&fc->tlabel_lock);
+ if (xfer->tl < 0) {
+ mtx_unlock(&fc->tlabel_lock);
+ return;
+ }
#if 1 /* make sure the label is allocated */
STAILQ_FOREACH(txfer, &fc->tlabels[xfer->tl], tlabel)
if(txfer == xfer)
@@ -1067,6 +1071,7 @@
#endif
STAILQ_REMOVE(&fc->tlabels[xfer->tl], xfer, fw_xfer, tlabel);
+ xfer->tl = -1;
mtx_unlock(&fc->tlabel_lock);
splx(s);
return;
@@ -1122,6 +1127,7 @@
return xfer;
xfer->malloc = type;
+ xfer->tl = -1;
return xfer;
}
@@ -1191,6 +1197,11 @@
splx(s);
}
if (xfer->fc != NULL) {
+ /*
+ * Ensure that any tlabel owner can't access this
+ * xfer after it's freed.
+ */
+ fw_tl_free(xfer->fc, xfer);
#if 1
if(xfer->flag & FWXF_START)
/*
Modified: trunk/sys/dev/firewire/firewire.h
===================================================================
--- trunk/sys/dev/firewire/firewire.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/firewire.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/firewire.h 188726 2009-02-17 19:37:04Z sbruno $
*
*/
Modified: trunk/sys/dev/firewire/firewire_phy.h
===================================================================
--- trunk/sys/dev/firewire/firewire_phy.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/firewire_phy.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
* All rights reserved.
@@ -30,7 +31,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/firewire_phy.h 139749 2005-01-06 01:43:34Z imp $
*
*/
Modified: trunk/sys/dev/firewire/firewirereg.h
===================================================================
--- trunk/sys/dev/firewire/firewirereg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/firewirereg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/firewirereg.h 171513 2007-07-20 03:42:57Z simokawa $
*
*/
Modified: trunk/sys/dev/firewire/fwcrom.c
===================================================================
--- trunk/sys/dev/firewire/fwcrom.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwcrom.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -34,7 +35,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/firewire/fwcrom.c 196970 2009-09-08 13:19:05Z phk $");
#endif
#include <sys/param.h>
Modified: trunk/sys/dev/firewire/fwdev.c
===================================================================
--- trunk/sys/dev/firewire/fwdev.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwdev.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwdev.c 299230 2016-05-08 09:02:51Z kib $
*
*/
@@ -98,7 +99,6 @@
.d_mmap = fw_mmap,
.d_strategy = fw_strategy,
.d_name = "fw",
- .d_flags = D_MEM
#else
#define CDEV_MAJOR 127
fw_open, fw_close, fw_read, fw_write, fw_ioctl,
@@ -992,11 +992,9 @@
sc = devclass_get_softc(firewire_devclass, unit);
if (sc == NULL)
return;
- *dev = make_dev(&firewire_cdevsw, MAKEMINOR(devflag[i], unit, sub),
- UID_ROOT, GID_OPERATOR, 0660,
- "%s%d.%d", devnames[i], unit, sub);
- dev_ref(*dev);
- (*dev)->si_flags |= SI_CHEAPCLONE;
+ *dev = make_dev_credf(MAKEDEV_REF, &firewire_cdevsw,
+ MAKEMINOR(devflag[i], unit, sub), cred, UID_ROOT, GID_OPERATOR,
+ 0660, "%s%d.%d", devnames[i], unit, sub);
dev_depends(sc->dev, *dev);
return;
}
Modified: trunk/sys/dev/firewire/fwdma.c
===================================================================
--- trunk/sys/dev/firewire/fwdma.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwdma.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -35,7 +36,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/firewire/fwdma.c 170374 2007-06-06 14:31:36Z simokawa $");
#endif
#include <sys/param.h>
Modified: trunk/sys/dev/firewire/fwdma.h
===================================================================
--- trunk/sys/dev/firewire/fwdma.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwdma.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -31,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwdma.h 139749 2005-01-06 01:43:34Z imp $
*/
struct fwdma_alloc {
Modified: trunk/sys/dev/firewire/fwmem.c
===================================================================
--- trunk/sys/dev/firewire/fwmem.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwmem.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -35,7 +36,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/firewire/fwmem.c 227309 2011-11-07 15:43:11Z ed $");
#endif
#include <sys/param.h>
Modified: trunk/sys/dev/firewire/fwmem.h
===================================================================
--- trunk/sys/dev/firewire/fwmem.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwmem.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (C) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -31,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwmem.h 139749 2005-01-06 01:43:34Z imp $
*/
struct fw_xfer *fwmem_read_quad(struct fw_device *, caddr_t, uint8_t,
Modified: trunk/sys/dev/firewire/fwohci.c
===================================================================
--- trunk/sys/dev/firewire/fwohci.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwohci.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwohci.c 310081 2016-12-14 17:17:07Z avg $
*
*/
@@ -55,6 +56,7 @@
#include <sys/kdb.h>
#include <machine/bus.h>
+#include <machine/md_var.h>
#if defined(__DragonFly__) || __FreeBSD_version < 500000
#include <machine/clock.h> /* for DELAY() */
@@ -179,7 +181,7 @@
#define OHCI_ATRETRY 0x08
#define OHCI_CROMHDR 0x18
#define OHCI_BUS_OPT 0x20
-#define OHCI_BUSIRMC (1 << 31)
+#define OHCI_BUSIRMC (1U << 31)
#define OHCI_BUSCMC (1 << 30)
#define OHCI_BUSISC (1 << 29)
#define OHCI_BUSBMC (1 << 28)
@@ -202,10 +204,11 @@
#define OHCI_PREQLO 0x118
#define OHCI_PREQLOCLR 0x11c
#define OHCI_PREQUPPER 0x120
+#define OHCI_PREQUPPER_MAX 0xffff0000
#define OHCI_SID_BUF 0x64
#define OHCI_SID_CNT 0x68
-#define OHCI_SID_ERR (1 << 31)
+#define OHCI_SID_ERR (1U << 31)
#define OHCI_SID_CNT_MASK 0xffc
#define OHCI_IT_STAT 0x90
@@ -869,7 +872,7 @@
static void
fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch)
{
- int i, s;
+ int i;
int tcode, hdr_len, pl_off;
int fsegment = -1;
uint32_t off;
@@ -895,7 +898,6 @@
if (dbch->flags & FWOHCI_DBCH_FULL)
return;
- s = splfw();
db_tr = dbch->top;
txloop:
xfer = STAILQ_FIRST(&dbch->xferq.q);
@@ -1045,7 +1047,6 @@
}
dbch->top = db_tr;
- splx(s);
return;
}
@@ -1841,6 +1842,7 @@
fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count)
{
struct firewire_comm *fc = (struct firewire_comm *)sc;
+ uintmax_t prequpper;
uint32_t node_id, plen;
FW_GLOCK_ASSERT(fc);
@@ -1872,8 +1874,27 @@
/* allow from all nodes */
OWRITE(sc, OHCI_PREQHI, 0x7fffffff);
OWRITE(sc, OHCI_PREQLO, 0xffffffff);
- /* 0 to 4GB region */
- OWRITE(sc, OHCI_PREQUPPER, 0x10000);
+ prequpper = ((uintmax_t)Maxmem << PAGE_SHIFT) >> 16;
+ if (prequpper > OHCI_PREQUPPER_MAX) {
+ device_printf(fc->dev,
+ "Physical memory size of 0x%jx exceeds "
+ "fire wire address space. Limiting dma "
+ "to memory below 0x%jx\n",
+ (uintmax_t)Maxmem << PAGE_SHIFT,
+ (uintmax_t)OHCI_PREQUPPER_MAX << 16);
+ prequpper = OHCI_PREQUPPER_MAX;
+ }
+ OWRITE(sc, OHCI_PREQUPPER, prequpper & 0xffffffff);
+ if (OREAD(sc, OHCI_PREQUPPER) !=
+ (prequpper & 0xffffffff)) {
+ device_printf(fc->dev,
+ "PhysicalUpperBound register is not "
+ "implemented. Physical memory access "
+ "is limited to the first 4GB\n");
+ device_printf(fc->dev,
+ "PhysicalUpperBound = 0x%08x\n",
+ OREAD(sc, OHCI_PREQUPPER));
+ }
}
/* Set ATRetries register */
OWRITE(sc, OHCI_ATRETRY, 1<<(13+16) | 0xfff);
@@ -2193,7 +2214,7 @@
struct fw_bulkxfer *chunk;
struct fw_xferq *ir;
uint32_t stat;
- int s, w = 0, ldesc;
+ int w = 0, ldesc;
ir = fc->ir[dmach];
ldesc = sc->ir[dmach].ndesc - 1;
@@ -2201,7 +2222,6 @@
#if 0
dump_db(sc, dmach);
#endif
- s = splfw();
if ((ir->flag & FWXFERQ_HANDLER) == 0)
FW_GLOCK(fc);
fwdma_sync_multiseg_all(sc->ir[dmach].am, BUS_DMASYNC_POSTREAD);
@@ -2240,7 +2260,6 @@
}
if ((ir->flag & FWXFERQ_HANDLER) == 0)
FW_GUNLOCK(fc);
- splx(s);
if (w == 0)
return;
Modified: trunk/sys/dev/firewire/fwohci_pci.c
===================================================================
--- trunk/sys/dev/firewire/fwohci_pci.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwohci_pci.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -33,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/firewire/fwohci_pci.c 254263 2013-08-12 23:30:01Z scottl $");
#define BOUNCE_BUFFER_TEST 0
@@ -242,7 +243,7 @@
uint16_t cmd;
cmd = pci_read_config(self, PCIR_COMMAND, 2);
- cmd |= PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN;
+ cmd |= PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN;
#if 1 /* for broken hardware */
cmd &= ~PCIM_CMD_MWRICEN;
#endif
Modified: trunk/sys/dev/firewire/fwohcireg.h
===================================================================
--- trunk/sys/dev/firewire/fwohcireg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwohcireg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwohcireg.h 261455 2014-02-04 03:36:42Z eadler $
*
*/
#define PCI_CBMEM PCIR_BAR(0)
@@ -241,7 +242,7 @@
fwohcireg_t dummy1[3]; /* dummy 0x44-0x4c */
fwohcireg_t hcc_cntl_set; /* HCC control set 0x50 */
fwohcireg_t hcc_cntl_clr; /* HCC control clr 0x54 */
-#define OHCI_HCC_BIBIV (1 << 31) /* BIBimage Valid */
+#define OHCI_HCC_BIBIV (1U << 31) /* BIBimage Valid */
#define OHCI_HCC_BIGEND (1 << 30) /* noByteSwapData */
#define OHCI_HCC_PRPHY (1 << 23) /* programPhyEnable */
#define OHCI_HCC_PHYEN (1 << 22) /* aPhyEnhanceEnable */
@@ -280,7 +281,7 @@
fwohcireg_t link_cntl_clr; /* Chip control clear 0xe4*/
#define FWOHCI_NODEID 0xe8
fwohcireg_t node; /* Node ID 0xe8 */
-#define OHCI_NODE_VALID (1 << 31)
+#define OHCI_NODE_VALID (1U << 31)
#define OHCI_NODE_ROOT (1 << 30)
#define OHCI_ASYSRCBUS 1
Modified: trunk/sys/dev/firewire/fwohcivar.h
===================================================================
--- trunk/sys/dev/firewire/fwohcivar.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwohcivar.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi SHimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi SHimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwohcivar.h 188079 2009-02-03 17:13:37Z sbruno $
*
*/
Modified: trunk/sys/dev/firewire/fwphyreg.h
===================================================================
--- trunk/sys/dev/firewire/fwphyreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/fwphyreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -31,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/fwphyreg.h 188508 2009-02-12 03:05:42Z sbruno $
*/
/*
Modified: trunk/sys/dev/firewire/iec13213.h
===================================================================
--- trunk/sys/dev/firewire/iec13213.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/iec13213.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/iec13213.h 139749 2005-01-06 01:43:34Z imp $
*
*/
Modified: trunk/sys/dev/firewire/iec68113.h
===================================================================
--- trunk/sys/dev/firewire/iec68113.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/iec68113.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/iec68113.h 139749 2005-01-06 01:43:34Z imp $
*
*/
Modified: trunk/sys/dev/firewire/if_fwe.c
===================================================================
--- trunk/sys/dev/firewire/if_fwe.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/if_fwe.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -31,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/if_fwe.c 243857 2012-12-04 09:32:43Z glebius $
*/
#ifdef HAVE_KERNEL_OPTION_HEADERS
@@ -214,7 +215,6 @@
#endif
ifp->if_start = fwe_start;
ifp->if_ioctl = fwe_ioctl;
- ifp->if_mtu = ETHERMTU;
ifp->if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST);
ifp->if_snd.ifq_maxlen = TX_MAX_QUEUE;
Modified: trunk/sys/dev/firewire/if_fwevar.h
===================================================================
--- trunk/sys/dev/firewire/if_fwevar.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/if_fwevar.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -31,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/if_fwevar.h 170374 2007-06-06 14:31:36Z simokawa $
*/
#ifndef _NET_IF_FWEVAR_H_
Modified: trunk/sys/dev/firewire/if_fwip.c
===================================================================
--- trunk/sys/dev/firewire/if_fwip.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/if_fwip.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004
* Doug Rabson
@@ -33,7 +34,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/if_fwip.c 243857 2012-12-04 09:32:43Z glebius $
*/
#ifdef HAVE_KERNEL_OPTION_HEADERS
Modified: trunk/sys/dev/firewire/if_fwipvar.h
===================================================================
--- trunk/sys/dev/firewire/if_fwipvar.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/if_fwipvar.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2004
* Doug Rabson
@@ -33,7 +34,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/if_fwipvar.h 170374 2007-06-06 14:31:36Z simokawa $
*/
#ifndef _NET_IF_FWIPVAR_H_
Modified: trunk/sys/dev/firewire/sbp.c
===================================================================
--- trunk/sys/dev/firewire/sbp.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/sbp.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/sbp.c 315831 2017-03-23 07:56:13Z avg $
*
*/
@@ -177,6 +178,7 @@
struct sbp_dev *sdev;
int flags; /* XXX should be removed */
bus_dmamap_t dmamap;
+ struct callout timer;
};
#define OCB_ACT_MGM 0
@@ -249,8 +251,9 @@
int flags;
struct mtx mtx;
};
-#define SBP_LOCK(sbp) mtx_lock(&(sbp)->mtx)
-#define SBP_UNLOCK(sbp) mtx_unlock(&(sbp)->mtx)
+#define SBP_LOCK(sbp) mtx_lock(&(sbp)->mtx)
+#define SBP_UNLOCK(sbp) mtx_unlock(&(sbp)->mtx)
+#define SBP_LOCK_ASSERT(sbp) mtx_assert(&(sbp)->mtx, MA_OWNED)
static void sbp_post_explore (void *);
static void sbp_recv (struct fw_xfer *);
@@ -264,7 +267,6 @@
static void sbp_free_ocb (struct sbp_dev *, struct sbp_ocb *);
static void sbp_abort_ocb (struct sbp_ocb *, int);
static void sbp_abort_all_ocbs (struct sbp_dev *, int);
-static struct fw_xfer * sbp_write_cmd_locked (struct sbp_dev *, int, int);
static struct fw_xfer * sbp_write_cmd (struct sbp_dev *, int, int);
static struct sbp_ocb * sbp_get_ocb (struct sbp_dev *);
static struct sbp_ocb * sbp_enqueue_ocb (struct sbp_dev *, struct sbp_ocb *);
@@ -336,7 +338,8 @@
printf("sbp_identify\n");
END_DEBUG
- BUS_ADD_CHILD(parent, 0, "sbp", device_get_unit(parent));
+ if (device_find_child(parent, "sbp", -1) == NULL)
+ BUS_ADD_CHILD(parent, 0, "sbp", -1);
}
/*
@@ -345,17 +348,11 @@
static int
sbp_probe(device_t dev)
{
- device_t pa;
SBP_DEBUG(0)
printf("sbp_probe\n");
END_DEBUG
- pa = device_get_parent(dev);
- if(device_get_unit(dev) != device_get_unit(pa)){
- return(ENXIO);
- }
-
device_set_desc(dev, "SBP-2/SCSI over FireWire");
#if 0
@@ -475,8 +472,7 @@
crom_next(&cc);
}
if (maxlun < 0)
- printf("%s:%d no LUN found\n",
- device_get_nameunit(target->sbp->fd.dev),
+ device_printf(target->sbp->fd.dev, "%d no LUN found\n",
target->target_id);
maxlun ++;
@@ -547,7 +543,7 @@
sdev->lun_id = lun;
sdev->target = target;
STAILQ_INIT(&sdev->ocbs);
- CALLOUT_INIT(&sdev->login_callout);
+ callout_init_mtx(&sdev->login_callout, &sbp->mtx, 0);
sdev->status = SBP_DEV_RESET;
new = 1;
snprintf(sdev->bustgtlun, 32, "%s:%d:%d",
@@ -591,7 +587,10 @@
/* XXX */
goto next;
}
+ callout_init_mtx(&ocb->timer, &sbp->mtx, 0);
+ SBP_LOCK(sbp);
sbp_free_ocb(sdev, ocb);
+ SBP_UNLOCK(sbp);
}
next:
crom_next(&cc);
@@ -646,8 +645,8 @@
STAILQ_INIT(&target->xferlist);
target->n_xfer = 0;
STAILQ_INIT(&target->mgm_ocb_queue);
- CALLOUT_INIT(&target->mgm_ocb_timeout);
- CALLOUT_INIT(&target->scan_callout);
+ callout_init_mtx(&target->mgm_ocb_timeout, &sbp->mtx, 0);
+ callout_init_mtx(&target->scan_callout, &sbp->mtx, 0);
target->luns = NULL;
target->num_lun = 0;
@@ -691,6 +690,7 @@
sbp_login_callout(void *arg)
{
struct sbp_dev *sdev = (struct sbp_dev *)arg;
+ SBP_LOCK_ASSERT(sdev->target->sbp);
sbp_mgm_orb(sdev, ORB_FUN_LGI, NULL);
}
@@ -720,9 +720,8 @@
&& crom_has_specver((fwdev)->csrrom, CSRVAL_ANSIT10, CSRVAL_T10SBP2))
static void
-sbp_probe_target(void *arg)
+sbp_probe_target(struct sbp_target *target)
{
- struct sbp_target *target = (struct sbp_target *)arg;
struct sbp_softc *sbp = target->sbp;
struct sbp_dev *sdev;
int i, alive;
@@ -734,7 +733,6 @@
(!alive) ? " not " : "");
END_DEBUG
- sbp = target->sbp;
sbp_alloc_lun(target);
/* XXX untimeout mgm_ocb and dequeue */
@@ -744,15 +742,15 @@
continue;
if (alive && (sdev->status != SBP_DEV_DEAD)) {
if (sdev->path != NULL) {
- SBP_LOCK(sbp);
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
- SBP_UNLOCK(sbp);
}
sbp_probe_lun(sdev);
sbp_show_sdev_info(sdev);
+ SBP_LOCK(sbp);
sbp_abort_all_ocbs(sdev, CAM_SCSI_BUS_RESET);
+ SBP_UNLOCK(sbp);
switch (sdev->status) {
case SBP_DEV_RESET:
/* new or revived target */
@@ -776,10 +774,8 @@
__func__);
END_DEBUG
if (sdev->path) {
- SBP_LOCK(sbp);
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
- SBP_UNLOCK(sbp);
}
sdev->status = SBP_DEV_RETRY;
sbp_cam_detach_sdev(sdev);
@@ -808,13 +804,13 @@
SBP_DEBUG(0)
printf("sbp_post_busreset\n");
END_DEBUG
- if ((sbp->sim->flags & SIMQ_FREEZED) == 0) {
- SBP_LOCK(sbp);
+ SBP_LOCK(sbp);
+ if ((sbp->flags & SIMQ_FREEZED) == 0) {
xpt_freeze_simq(sbp->sim, /*count*/1);
- sbp->sim->flags |= SIMQ_FREEZED;
- SBP_UNLOCK(sbp);
+ sbp->flags |= SIMQ_FREEZED;
}
microtime(&sbp->last_busreset);
+ SBP_UNLOCK(sbp);
}
static void
@@ -835,19 +831,16 @@
if (sbp_cold > 0)
sbp_cold --;
-#if 0
- /*
- * XXX don't let CAM the bus rest.
- * CAM tries to do something with freezed (DEV_RETRY) devices.
- */
- xpt_async(AC_BUS_RESET, sbp->path, /*arg*/ NULL);
-#endif
+ SBP_LOCK(sbp);
/* Garbage Collection */
for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){
target = &sbp->targets[i];
+ if (target->fwdev == NULL)
+ continue;
+
STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link)
- if (target->fwdev == NULL || target->fwdev == fwdev)
+ if (target->fwdev == fwdev)
break;
if (fwdev == NULL) {
/* device has removed in lower driver */
@@ -855,6 +848,7 @@
sbp_free_target(target);
}
}
+
/* traverse device list */
STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) {
SBP_DEBUG(0)
@@ -881,13 +875,24 @@
continue;
}
}
- sbp_probe_target((void *)target);
+
+ /*
+ * It is safe to drop the lock here as the target is already
+ * reserved, so there should be no contenders for it.
+ * And the target is not yet exposed, so there should not be
+ * any other accesses to it.
+ * Finally, the list being iterated is protected somewhere else.
+ */
+ SBP_UNLOCK(sbp);
+ sbp_probe_target(target);
+ SBP_LOCK(sbp);
if (target->num_lun == 0)
sbp_free_target(target);
}
- SBP_LOCK(sbp);
- xpt_release_simq(sbp->sim, /*run queue*/TRUE);
- sbp->sim->flags &= ~SIMQ_FREEZED;
+ if ((sbp->flags & SIMQ_FREEZED) != 0) {
+ xpt_release_simq(sbp->sim, /*run queue*/TRUE);
+ sbp->flags &= ~SIMQ_FREEZED;
+ }
SBP_UNLOCK(sbp);
}
@@ -894,7 +899,6 @@
#if NEED_RESPONSE
static void
sbp_loginres_callback(struct fw_xfer *xfer){
- int s;
struct sbp_dev *sdev;
sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1)
@@ -901,9 +905,9 @@
device_printf(sdev->target->sbp->fd.dev,"%s\n", __func__);
END_DEBUG
/* recycle */
- s = splfw();
+ SBP_LOCK(sdev->target->sbp);
STAILQ_INSERT_TAIL(&sdev->target->sbp->fwb.xferlist, xfer, link);
- splx(s);
+ SBP_UNLOCK(sdev->target->sbp);
return;
}
#endif
@@ -912,15 +916,11 @@
sbp_xfer_free(struct fw_xfer *xfer)
{
struct sbp_dev *sdev;
- int s;
sdev = (struct sbp_dev *)xfer->sc;
fw_xfer_unload(xfer);
- s = splfw();
- SBP_LOCK(sdev->target->sbp);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
STAILQ_INSERT_TAIL(&sdev->target->xferlist, xfer, link);
- SBP_UNLOCK(sdev->target->sbp);
- splx(s);
}
static void
@@ -935,11 +935,13 @@
"%s: %s failed: resp=%d\n", __func__, sdev->bustgtlun, xfer->resp);
}
+ SBP_LOCK(target->sbp);
for (i = 0; i < target->num_lun; i++) {
tsdev = target->luns[i];
if (tsdev != NULL && tsdev->status == SBP_DEV_LOGIN)
sbp_login(tsdev);
}
+ SBP_UNLOCK(target->sbp);
}
static void
@@ -975,8 +977,9 @@
"%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG
resp = xfer->resp;
+ SBP_LOCK(sdev->target->sbp);
sbp_xfer_free(xfer);
- return;
+ SBP_UNLOCK(sdev->target->sbp);
}
static struct sbp_dev *
@@ -996,23 +999,27 @@
static void
sbp_cam_scan_lun(struct cam_periph *periph, union ccb *ccb)
{
+ struct sbp_softc *sbp;
struct sbp_target *target;
struct sbp_dev *sdev;
sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;
target = sdev->target;
+ sbp = target->sbp;
+ SBP_LOCK(sbp);
SBP_DEBUG(0)
- device_printf(sdev->target->sbp->fd.dev,
+ device_printf(sbp->fd.dev,
"%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG
if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
sdev->status = SBP_DEV_ATTACHED;
} else {
- device_printf(sdev->target->sbp->fd.dev,
+ device_printf(sbp->fd.dev,
"%s:%s failed\n", __func__, sdev->bustgtlun);
}
sdev = sbp_next_dev(target, sdev->lun_id + 1);
if (sdev == NULL) {
+ SBP_UNLOCK(sbp);
free(ccb, M_SBP);
return;
}
@@ -1019,6 +1026,9 @@
/* reuse ccb */
xpt_setup_ccb(&ccb->ccb_h, sdev->path, SCAN_PRI);
ccb->ccb_h.ccb_sdev_ptr = sdev;
+ ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
+ SBP_UNLOCK(sbp);
+
xpt_action(ccb);
xpt_release_devq(sdev->path, sdev->freeze, TRUE);
sdev->freeze = 1;
@@ -1031,6 +1041,7 @@
struct sbp_dev *sdev;
union ccb *ccb;
+ SBP_LOCK_ASSERT(target->sbp);
sdev = sbp_next_dev(target, 0);
if (sdev == NULL) {
printf("sbp_cam_scan_target: nothing to do for target%d\n",
@@ -1046,6 +1057,8 @@
printf("sbp_cam_scan_target: malloc failed\n");
return;
}
+ SBP_UNLOCK(target->sbp);
+
xpt_setup_ccb(&ccb->ccb_h, sdev->path, SCAN_PRI);
ccb->ccb_h.func_code = XPT_SCAN_LUN;
ccb->ccb_h.cbfcnp = sbp_cam_scan_lun;
@@ -1054,11 +1067,11 @@
ccb->ccb_h.ccb_sdev_ptr = sdev;
/* The scan is in progress now. */
+ xpt_action(ccb);
+
SBP_LOCK(target->sbp);
- xpt_action(ccb);
xpt_release_devq(sdev->path, sdev->freeze, TRUE);
sdev->freeze = 1;
- SBP_UNLOCK(target->sbp);
}
static __inline void
@@ -1065,8 +1078,8 @@
sbp_scan_dev(struct sbp_dev *sdev)
{
sdev->status = SBP_DEV_PROBE;
- callout_reset(&sdev->target->scan_callout, scan_delay * hz / 1000,
- sbp_cam_scan_target, (void *)sdev->target);
+ callout_reset_sbt(&sdev->target->scan_callout, SBT_1MS * scan_delay, 0,
+ sbp_cam_scan_target, (void *)sdev->target, 0);
}
static void
@@ -1079,6 +1092,7 @@
sdev = (struct sbp_dev *)xfer->sc;
target = sdev->target;
sbp = target->sbp;
+ SBP_LOCK(sbp);
SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
"%s:%s\n", __func__, sdev->bustgtlun);
@@ -1086,7 +1100,7 @@
sbp_xfer_free(xfer);
if (sdev->path == NULL)
- xpt_create_path(&sdev->path, xpt_periph,
+ xpt_create_path(&sdev->path, NULL,
cam_sim_path(target->sbp->sim),
target->target_id, sdev->lun_id);
@@ -1093,15 +1107,16 @@
/*
* Let CAM scan the bus if we are in the boot process.
* XXX xpt_scan_bus cannot detect LUN larger than 0
- * if LUN 0 doesn't exists.
+ * if LUN 0 doesn't exist.
*/
if (sbp_cold > 0) {
sdev->status = SBP_DEV_ATTACHED;
+ SBP_UNLOCK(sbp);
return;
}
sbp_scan_dev(sdev);
- return;
+ SBP_UNLOCK(sbp);
}
static void
@@ -1119,13 +1134,13 @@
"%s:%s resp=%d\n", __func__, sdev->bustgtlun, xfer->resp);
}
+ SBP_LOCK(sdev->target->sbp);
sbp_xfer_free(xfer);
if (sdev->path) {
- SBP_LOCK(sdev->target->sbp);
xpt_release_devq(sdev->path, sdev->freeze, TRUE);
sdev->freeze = 0;
- SBP_UNLOCK(sdev->target->sbp);
}
+ SBP_UNLOCK(sdev->target->sbp);
}
static void
@@ -1134,6 +1149,7 @@
struct fw_xfer *xfer;
struct fw_pkt *fp;
+ SBP_LOCK_ASSERT(sdev->target->sbp);
SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
"%s:%s\n", __func__, sdev->bustgtlun);
@@ -1161,8 +1177,10 @@
device_printf(sdev->target->sbp->fd.dev,
"%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG
+ SBP_LOCK(sdev->target->sbp);
sbp_xfer_free(xfer);
sbp_agent_reset(sdev);
+ SBP_UNLOCK(sdev->target->sbp);
}
static void
@@ -1198,9 +1216,9 @@
/* XXX */
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
}
+ SBP_LOCK(sdev->target->sbp);
sbp_xfer_free(xfer);
- SBP_LOCK(sdev->target->sbp);
sdev->flags &= ~ORB_POINTER_ACTIVE;
if ((sdev->flags & ORB_POINTER_NEED) != 0) {
@@ -1227,7 +1245,7 @@
(uint32_t)ocb->bus_addr);
END_DEBUG
- mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
if ((sdev->flags & ORB_POINTER_ACTIVE) != 0) {
SBP_DEBUG(0)
@@ -1238,7 +1256,7 @@
}
sdev->flags |= ORB_POINTER_ACTIVE;
- xfer = sbp_write_cmd_locked(sdev, FWTCODE_WREQB, 0x08);
+ xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0x08);
if (xfer == NULL)
return;
xfer->hand = sbp_orb_pointer_callback;
@@ -1250,18 +1268,11 @@
htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS )<< 16));
xfer->send.payload[1] = htonl((uint32_t)ocb->bus_addr);
- /*
- * sbp_xfer_free() will attempt to acquire
- * the SBP lock on entrance. Also, this removes
- * a LOR between the firewire layer and sbp
- */
- SBP_UNLOCK(sdev->target->sbp);
- if(fw_asyreq(xfer->fc, -1, xfer) != 0){
- sbp_xfer_free(xfer);
- ocb->ccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(ocb->ccb);
+ if (fw_asyreq(xfer->fc, -1, xfer) != 0) {
+ sbp_xfer_free(xfer);
+ ocb->ccb->ccb_h.status = CAM_REQ_INVALID;
+ xpt_done(ocb->ccb);
}
- SBP_LOCK(sdev->target->sbp);
}
static void
@@ -1279,15 +1290,14 @@
device_printf(sdev->target->sbp->fd.dev,
"%s: xfer->resp = %d\n", __func__, xfer->resp);
}
+ SBP_LOCK(sdev->target->sbp);
sbp_xfer_free(xfer);
sdev->flags &= ~ORB_DOORBELL_ACTIVE;
if ((sdev->flags & ORB_DOORBELL_NEED) != 0) {
sdev->flags &= ~ORB_DOORBELL_NEED;
- SBP_LOCK(sdev->target->sbp);
sbp_doorbell(sdev);
- SBP_UNLOCK(sdev->target->sbp);
}
- return;
+ SBP_UNLOCK(sdev->target->sbp);
}
static void
@@ -1305,7 +1315,7 @@
return;
}
sdev->flags |= ORB_DOORBELL_ACTIVE;
- xfer = sbp_write_cmd_locked(sdev, FWTCODE_WREQQ, 0x10);
+ xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x10);
if (xfer == NULL)
return;
xfer->hand = sbp_doorbell_callback;
@@ -1315,28 +1325,25 @@
}
static struct fw_xfer *
-sbp_write_cmd_locked(struct sbp_dev *sdev, int tcode, int offset)
+sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
{
struct fw_xfer *xfer;
struct fw_pkt *fp;
struct sbp_target *target;
- int s, new = 0;
+ int new = 0;
- mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
target = sdev->target;
- s = splfw();
xfer = STAILQ_FIRST(&target->xferlist);
if (xfer == NULL) {
if (target->n_xfer > 5 /* XXX */) {
printf("sbp: no more xfer for this target\n");
- splx(s);
return(NULL);
}
xfer = fw_xfer_alloc_buf(M_SBP, 8, 0);
if(xfer == NULL){
printf("sbp: fw_xfer_alloc_buf failed\n");
- splx(s);
return NULL;
}
target->n_xfer ++;
@@ -1346,7 +1353,6 @@
} else {
STAILQ_REMOVE_HEAD(&target->xferlist, link);
}
- splx(s);
if (new) {
xfer->recv.pay_len = 0;
@@ -1369,22 +1375,8 @@
fp->mode.wreqq.dst = FWLOCALBUS | sdev->target->fwdev->dst;
return xfer;
-
}
-static struct fw_xfer *
-sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
-{
- struct sbp_softc *sbp = sdev->target->sbp;
- struct fw_xfer *xfer;
-
- SBP_LOCK(sbp);
- xfer = sbp_write_cmd_locked(sdev, tcode, offset);
- SBP_UNLOCK(sbp);
-
- return (xfer);
-}
-
static void
sbp_mgm_orb(struct sbp_dev *sdev, int func, struct sbp_ocb *aocb)
{
@@ -1392,31 +1384,24 @@
struct fw_pkt *fp;
struct sbp_ocb *ocb;
struct sbp_target *target;
- int s, nid;
+ int nid;
target = sdev->target;
nid = target->sbp->fd.fc->nodeid | FWLOCALBUS;
- s = splfw();
- SBP_LOCK(target->sbp);
+ SBP_LOCK_ASSERT(target->sbp);
if (func == ORB_FUN_RUNQUEUE) {
ocb = STAILQ_FIRST(&target->mgm_ocb_queue);
if (target->mgm_ocb_cur != NULL || ocb == NULL) {
- SBP_UNLOCK(target->sbp);
- splx(s);
return;
}
STAILQ_REMOVE_HEAD(&target->mgm_ocb_queue, ocb);
- SBP_UNLOCK(target->sbp);
goto start;
}
if ((ocb = sbp_get_ocb(sdev)) == NULL) {
- SBP_UNLOCK(target->sbp);
- splx(s);
/* XXX */
return;
}
- SBP_UNLOCK(target->sbp);
ocb->flags = OCB_ACT_MGM;
ocb->sdev = sdev;
@@ -1456,17 +1441,13 @@
if (target->mgm_ocb_cur != NULL) {
/* there is a standing ORB */
- SBP_LOCK(target->sbp);
STAILQ_INSERT_TAIL(&sdev->target->mgm_ocb_queue, ocb, ocb);
- SBP_UNLOCK(target->sbp);
- splx(s);
return;
}
start:
target->mgm_ocb_cur = ocb;
- splx(s);
- callout_reset(&target->mgm_ocb_timeout, 5*hz,
+ callout_reset(&target->mgm_ocb_timeout, 5 * hz,
sbp_mgm_timeout, (caddr_t)ocb);
xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0);
if(xfer == NULL){
@@ -1674,6 +1655,7 @@
printf("sbp %08x %08x %08x %08x\n", ntohl(ld[8]), ntohl(ld[9]), ntohl(ld[10]), ntohl(ld[11]));
*/
sbp = (struct sbp_softc *)xfer->sc;
+ SBP_LOCK_ASSERT(sbp);
if (xfer->resp != 0){
printf("sbp_recv: xfer->resp = %d\n", xfer->resp);
goto done0;
@@ -1793,10 +1775,8 @@
/* we have to reset the fetch agent if it's dead */
if (sbp_status->dead) {
if (sdev->path) {
- SBP_LOCK(sbp);
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
- SBP_UNLOCK(sbp);
}
reset_agent = 1;
}
@@ -1901,9 +1881,7 @@
/* fix up inq data */
if (ccb->csio.cdb_io.cdb_bytes[0] == INQUIRY)
sbp_fix_inq_data(ocb);
- SBP_LOCK(sbp);
xpt_done(ccb);
- SBP_UNLOCK(sbp);
}
break;
default:
@@ -1942,22 +1920,19 @@
fw_asyreq(xfer->fc, -1, xfer);
#else
/* recycle */
- /* we don't need a lock here because bottom half is serialized */
STAILQ_INSERT_TAIL(&sbp->fwb.xferlist, xfer, link);
#endif
-
- return;
-
}
static void
sbp_recv(struct fw_xfer *xfer)
{
- int s;
+ struct sbp_softc *sbp;
- s = splcam();
+ sbp = (struct sbp_softc *)xfer->sc;
+ SBP_LOCK(sbp);
sbp_recv1(xfer);
- splx(s);
+ SBP_UNLOCK(sbp);
}
/*
* sbp_attach()
@@ -1968,7 +1943,7 @@
struct sbp_softc *sbp;
struct cam_devq *devq;
struct firewire_comm *fc;
- int i, s, error;
+ int i, error;
if (DFLTPHYS > SBP_MAXPHYS)
device_printf(dev, "Warning, DFLTPHYS(%dKB) is larger than "
@@ -1984,8 +1959,7 @@
if (cold)
sbp_cold ++;
- sbp = ((struct sbp_softc *)device_get_softc(dev));
- bzero(sbp, sizeof(struct sbp_softc));
+ sbp = device_get_softc(dev);
sbp->fd.dev = dev;
sbp->fd.fc = fc = device_get_ivars(dev);
mtx_init(&sbp->mtx, "sbp", NULL, MTX_DEF);
@@ -2039,7 +2013,7 @@
if (xpt_bus_register(sbp->sim, dev, /*bus*/0) != CAM_SUCCESS)
goto fail;
- if (xpt_create_path(&sbp->path, xpt_periph, cam_sim_path(sbp->sim),
+ if (xpt_create_path(&sbp->path, NULL, cam_sim_path(sbp->sim),
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
xpt_bus_deregister(cam_sim_path(sbp->sim));
goto fail;
@@ -2061,10 +2035,8 @@
sbp->fd.post_explore = sbp_post_explore;
if (fc->status != -1) {
- s = splfw();
- sbp_post_busreset((void *)sbp);
- sbp_post_explore((void *)sbp);
- splx(s);
+ sbp_post_busreset(sbp);
+ sbp_post_explore(sbp);
}
SBP_LOCK(sbp);
xpt_async(AC_BUS_RESET, sbp->path, /*arg*/ NULL);
@@ -2087,6 +2059,7 @@
SBP_DEBUG(0)
printf("sbp_logout_all\n");
END_DEBUG
+ SBP_LOCK_ASSERT(sbp);
for (i = 0 ; i < SBP_NUM_TARGETS ; i ++) {
target = &sbp->targets[i];
if (target->luns == NULL)
@@ -2110,7 +2083,9 @@
{
struct sbp_softc *sbp = ((struct sbp_softc *)device_get_softc(dev));
+ SBP_LOCK(sbp);
sbp_logout_all(sbp);
+ SBP_UNLOCK(sbp);
return (0);
}
@@ -2117,16 +2092,21 @@
static void
sbp_free_sdev(struct sbp_dev *sdev)
{
+ struct sbp_softc *sbp;
int i;
if (sdev == NULL)
return;
- for (i = 0; i < SBP_QUEUE_LEN; i++)
- bus_dmamap_destroy(sdev->target->sbp->dmat,
- sdev->ocb[i].dmamap);
- fwdma_free(sdev->target->sbp->fd.fc, &sdev->dma);
+ sbp = sdev->target->sbp;
+ SBP_UNLOCK(sbp);
+ callout_drain(&sdev->login_callout);
+ for (i = 0; i < SBP_QUEUE_LEN; i++) {
+ callout_drain(&sdev->ocb[i].timer);
+ bus_dmamap_destroy(sbp->dmat, sdev->ocb[i].dmamap);
+ }
+ fwdma_free(sbp->fd.fc, &sdev->dma);
free(sdev, M_SBP);
- sdev = NULL;
+ SBP_LOCK(sbp);
}
static void
@@ -2138,14 +2118,16 @@
if (target->luns == NULL)
return;
- callout_stop(&target->mgm_ocb_timeout);
sbp = target->sbp;
+ SBP_LOCK_ASSERT(sbp);
+ SBP_UNLOCK(sbp);
+ callout_drain(&target->mgm_ocb_timeout);
+ callout_drain(&target->scan_callout);
+ SBP_LOCK(sbp);
for (i = 0; i < target->num_lun; i++)
sbp_free_sdev(target->luns[i]);
- for (xfer = STAILQ_FIRST(&target->xferlist);
- xfer != NULL; xfer = next) {
- next = STAILQ_NEXT(xfer, link);
+ STAILQ_FOREACH_SAFE(xfer, &target->xferlist, link, next) {
fw_xfer_free_buf(xfer);
}
STAILQ_INIT(&target->xferlist);
@@ -2166,23 +2148,25 @@
printf("sbp_detach\n");
END_DEBUG
+ SBP_LOCK(sbp);
for (i = 0; i < SBP_NUM_TARGETS; i ++)
sbp_cam_detach_target(&sbp->targets[i]);
- SBP_LOCK(sbp);
xpt_async(AC_LOST_DEVICE, sbp->path, NULL);
xpt_free_path(sbp->path);
xpt_bus_deregister(cam_sim_path(sbp->sim));
cam_sim_free(sbp->sim, /*free_devq*/ TRUE);
- SBP_UNLOCK(sbp);
sbp_logout_all(sbp);
+ SBP_UNLOCK(sbp);
/* XXX wait for logout completion */
pause("sbpdtc", hz/2);
+ SBP_LOCK(sbp);
for (i = 0 ; i < SBP_NUM_TARGETS ; i ++)
sbp_free_target(&sbp->targets[i]);
+ SBP_UNLOCK(sbp);
fw_bindremove(fc, &sbp->fwb);
fw_xferlist_remove(&sbp->fwb.xferlist);
@@ -2202,9 +2186,9 @@
return;
if (sdev->status == SBP_DEV_RESET)
return;
+ SBP_LOCK_ASSERT(sdev->target->sbp);
sbp_abort_all_ocbs(sdev, CAM_DEV_NOT_THERE);
if (sdev->path) {
- SBP_LOCK(sdev->target->sbp);
xpt_release_devq(sdev->path,
sdev->freeze, TRUE);
sdev->freeze = 0;
@@ -2211,7 +2195,6 @@
xpt_async(AC_LOST_DEVICE, sdev->path, NULL);
xpt_free_path(sdev->path);
sdev->path = NULL;
- SBP_UNLOCK(sdev->target->sbp);
}
}
@@ -2220,6 +2203,7 @@
{
int i;
+ SBP_LOCK_ASSERT(target->sbp);
if (target->luns != NULL) {
SBP_DEBUG(0)
printf("sbp_detach_target %d\n", target->target_id);
@@ -2237,6 +2221,7 @@
struct sbp_target *target = sdev->target;
struct sbp_dev *tsdev;
+ SBP_LOCK_ASSERT(target->sbp);
for (i = 0; i < target->num_lun; i++) {
tsdev = target->luns[i];
if (tsdev == NULL)
@@ -2245,10 +2230,8 @@
continue;
if (tsdev->status == SBP_DEV_RESET)
continue;
- SBP_LOCK(target->sbp);
xpt_freeze_devq(tsdev->path, 1);
tsdev->freeze ++;
- SBP_UNLOCK(target->sbp);
sbp_abort_all_ocbs(tsdev, CAM_CMD_TIMEOUT);
if (method == 2)
tsdev->status = SBP_DEV_LOGIN;
@@ -2273,6 +2256,7 @@
struct sbp_dev *sdev = ocb->sdev;
struct sbp_target *target = sdev->target;
+ SBP_LOCK_ASSERT(target->sbp);
device_printf(sdev->target->sbp->fd.dev,
"%s:%s request timeout(mgm orb:0x%08x)\n",
__func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
@@ -2299,14 +2283,13 @@
"%s:%s request timeout(cmd orb:0x%08x) ... ",
__func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
sdev->timeout ++;
switch(sdev->timeout) {
case 1:
printf("agent reset\n");
- SBP_LOCK(sdev->target->sbp);
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
- SBP_UNLOCK(sdev->target->sbp);
sbp_abort_all_ocbs(sdev, CAM_CMD_TIMEOUT);
sbp_agent_reset(sdev);
break;
@@ -2328,7 +2311,7 @@
}
static void
-sbp_action1(struct cam_sim *sim, union ccb *ccb)
+sbp_action(struct cam_sim *sim, union ccb *ccb)
{
struct sbp_softc *sbp = (struct sbp_softc *)sim->softc;
@@ -2335,6 +2318,8 @@
struct sbp_target *target = NULL;
struct sbp_dev *sdev = NULL;
+ if (sbp != NULL)
+ SBP_LOCK_ASSERT(sbp);
/* target:lun -> sdev mapping */
if (sbp != NULL
&& ccb->ccb_h.target_id != CAM_TARGET_WILDCARD
@@ -2438,6 +2423,11 @@
xpt_done(ccb);
return;
}
+ if (csio->cdb_len > sizeof(ocb->orb) - 5 * sizeof(uint32_t)) {
+ ccb->ccb_h.status = CAM_REQ_INVALID;
+ xpt_done(ccb);
+ return;
+ }
#if 0
/* if we are in probe stage, pass only probe commands */
if (sdev->status == SBP_DEV_PROBE) {
@@ -2454,10 +2444,8 @@
if ((ocb = sbp_get_ocb(sdev)) == NULL) {
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
if (sdev->freeze == 0) {
- SBP_LOCK(sdev->target->sbp);
xpt_freeze_devq(sdev->path, 1);
sdev->freeze ++;
- SBP_UNLOCK(sdev->target->sbp);
}
xpt_done(ccb);
return;
@@ -2467,7 +2455,7 @@
ocb->sdev = sdev;
ocb->ccb = ccb;
ccb->ccb_h.ccb_sdev_ptr = sdev;
- ocb->orb[0] = htonl(1 << 31);
+ ocb->orb[0] = htonl(1U << 31);
ocb->orb[1] = 0;
ocb->orb[2] = htonl(((sbp->fd.fc->nodeid | FWLOCALBUS )<< 16) );
ocb->orb[3] = htonl(ocb->bus_addr + IND_PTR_OFFSET);
@@ -2478,11 +2466,6 @@
ocb->orb[4] |= htonl(ORB_CMD_IN);
}
- if (csio->ccb_h.flags & CAM_SCATTER_VALID)
- printf("sbp: CAM_SCATTER_VALID\n");
- if (csio->ccb_h.flags & CAM_DATA_PHYS)
- printf("sbp: CAM_DATA_PHYS\n");
-
if (csio->ccb_h.flags & CAM_CDB_POINTER)
cdb = (void *)csio->cdb_io.cdb_ptr;
else
@@ -2493,17 +2476,14 @@
printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntohl(ocb->orb[6]), ntohl(ocb->orb[7]));
*/
if (ccb->csio.dxfer_len > 0) {
- int s, error;
+ int error;
- s = splsoftvm();
- error = bus_dmamap_load(/*dma tag*/sbp->dmat,
+ error = bus_dmamap_load_ccb(/*dma tag*/sbp->dmat,
/*dma map*/ocb->dmamap,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
+ ccb,
sbp_execute_ocb,
ocb,
/*flags*/0);
- splx(s);
if (error)
printf("sbp: bus_dmamap_load error %d\n", error);
} else
@@ -2521,7 +2501,7 @@
ccg = &ccb->ccg;
if (ccg->block_size == 0) {
- printf("sbp_action1: block_size is 0.\n");
+ printf("sbp_action: block_size is 0.\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
xpt_done(ccb);
break;
@@ -2593,9 +2573,9 @@
cpi->initiator_id = SBP_INITIATOR;
cpi->bus_id = sim->bus_id;
cpi->base_transfer_speed = 400 * 1000 / 8;
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "SBP", HBA_IDLEN);
- strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
+ strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+ strlcpy(cpi->hba_vid, "SBP", HBA_IDLEN);
+ strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
cpi->unit_number = sim->unit_number;
cpi->transport = XPORT_SPI; /* XX should have a FireWire */
cpi->transport_version = 2;
@@ -2646,16 +2626,6 @@
}
static void
-sbp_action(struct cam_sim *sim, union ccb *ccb)
-{
- int s;
-
- s = splfw();
- sbp_action1(sim, ccb);
- splx(s);
-}
-
-static void
sbp_execute_ocb(void *arg, bus_dma_segment_t *segments, int seg, int error)
{
int i;
@@ -2750,8 +2720,7 @@
{
struct sbp_ocb *ocb;
struct sbp_ocb *next;
- int s = splfw(), order = 0;
- int flags;
+ int order = 0;
SBP_DEBUG(1)
device_printf(sdev->target->sbp->fd.dev,
@@ -2762,16 +2731,13 @@
#endif
__func__, sdev->bustgtlun, ntohl(sbp_status->orb_lo), sbp_status->src);
END_DEBUG
- SBP_LOCK(sdev->target->sbp);
- for (ocb = STAILQ_FIRST(&sdev->ocbs); ocb != NULL; ocb = next) {
- next = STAILQ_NEXT(ocb, ocb);
- flags = ocb->flags;
+ SBP_LOCK_ASSERT(sdev->target->sbp);
+ STAILQ_FOREACH_SAFE(ocb, &sdev->ocbs, ocb, next) {
if (OCB_MATCH(ocb, sbp_status)) {
/* found */
STAILQ_REMOVE(&sdev->ocbs, ocb, sbp_ocb, ocb);
if (ocb->ccb != NULL)
- untimeout(sbp_timeout, (caddr_t)ocb,
- ocb->ccb->ccb_h.timeout_ch);
+ callout_stop(&ocb->timer);
if (ntohl(ocb->orb[4]) & 0xffff) {
bus_dmamap_sync(sdev->target->sbp->dmat,
ocb->dmamap,
@@ -2800,9 +2766,7 @@
* execution.
*/
if (sdev->last_ocb != NULL) {
- SBP_UNLOCK(sdev->target->sbp);
sbp_free_ocb(sdev, sdev->last_ocb);
- SBP_LOCK(sdev->target->sbp);
}
sdev->last_ocb = ocb;
if (next != NULL &&
@@ -2813,8 +2777,6 @@
} else
order ++;
}
- SBP_UNLOCK(sdev->target->sbp);
- splx(s);
SBP_DEBUG(0)
if (ocb && order > 0) {
device_printf(sdev->target->sbp->fd.dev,
@@ -2828,10 +2790,9 @@
static struct sbp_ocb *
sbp_enqueue_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb)
{
- int s = splfw();
struct sbp_ocb *prev, *prev2;
- mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
SBP_DEBUG(1)
device_printf(sdev->target->sbp->fd.dev,
#if defined(__DragonFly__) || __FreeBSD_version < 500000
@@ -2843,9 +2804,11 @@
prev2 = prev = STAILQ_LAST(&sdev->ocbs, sbp_ocb, ocb);
STAILQ_INSERT_TAIL(&sdev->ocbs, ocb, ocb);
- if (ocb->ccb != NULL)
- ocb->ccb->ccb_h.timeout_ch = timeout(sbp_timeout, (caddr_t)ocb,
- (ocb->ccb->ccb_h.timeout * hz) / 1000);
+ if (ocb->ccb != NULL) {
+ callout_reset_sbt(&ocb->timer,
+ SBT_1MS * ocb->ccb->ccb_h.timeout, 0, sbp_timeout,
+ ocb, 0);
+ }
if (use_doorbell && prev == NULL)
prev2 = sdev->last_ocb;
@@ -2868,7 +2831,6 @@
*(volatile uint32_t *)&prev2->orb[1] = htonl(ocb->bus_addr);
*(volatile uint32_t *)&prev2->orb[0] = 0;
}
- splx(s);
return prev;
}
@@ -2877,18 +2839,15 @@
sbp_get_ocb(struct sbp_dev *sdev)
{
struct sbp_ocb *ocb;
- int s = splfw();
- mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
ocb = STAILQ_FIRST(&sdev->free_ocbs);
if (ocb == NULL) {
sdev->flags |= ORB_SHORTAGE;
printf("ocb shortage!!!\n");
- splx(s);
return NULL;
}
STAILQ_REMOVE_HEAD(&sdev->free_ocbs, ocb);
- splx(s);
ocb->ccb = NULL;
return (ocb);
}
@@ -2899,7 +2858,7 @@
ocb->flags = 0;
ocb->ccb = NULL;
- SBP_LOCK(sdev->target->sbp);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
STAILQ_INSERT_TAIL(&sdev->free_ocbs, ocb, ocb);
if ((sdev->flags & ORB_SHORTAGE) != 0) {
int count;
@@ -2909,7 +2868,6 @@
sdev->freeze = 0;
xpt_release_devq(sdev->path, count, TRUE);
}
- SBP_UNLOCK(sdev->target->sbp);
}
static void
@@ -2918,6 +2876,7 @@
struct sbp_dev *sdev;
sdev = ocb->sdev;
+ SBP_LOCK_ASSERT(sdev->target->sbp);
SBP_DEBUG(0)
device_printf(sdev->target->sbp->fd.dev,
#if defined(__DragonFly__) || __FreeBSD_version < 500000
@@ -2937,12 +2896,9 @@
bus_dmamap_unload(sdev->target->sbp->dmat, ocb->dmamap);
}
if (ocb->ccb != NULL) {
- untimeout(sbp_timeout, (caddr_t)ocb,
- ocb->ccb->ccb_h.timeout_ch);
+ callout_stop(&ocb->timer);
ocb->ccb->ccb_h.status = status;
- SBP_LOCK(sdev->target->sbp);
xpt_done(ocb->ccb);
- SBP_UNLOCK(sdev->target->sbp);
}
sbp_free_ocb(sdev, ocb);
}
@@ -2950,20 +2906,15 @@
static void
sbp_abort_all_ocbs(struct sbp_dev *sdev, int status)
{
- int s;
struct sbp_ocb *ocb, *next;
STAILQ_HEAD(, sbp_ocb) temp;
- s = splfw();
-
STAILQ_INIT(&temp);
- SBP_LOCK(sdev->target->sbp);
+ SBP_LOCK_ASSERT(sdev->target->sbp);
STAILQ_CONCAT(&temp, &sdev->ocbs);
STAILQ_INIT(&sdev->ocbs);
- SBP_UNLOCK(sdev->target->sbp);
- for (ocb = STAILQ_FIRST(&temp); ocb != NULL; ocb = next) {
- next = STAILQ_NEXT(ocb, ocb);
+ STAILQ_FOREACH_SAFE(ocb, &temp, ocb, next) {
sbp_abort_ocb(ocb, status);
}
if (sdev->last_ocb != NULL) {
@@ -2970,8 +2921,6 @@
sbp_free_ocb(sdev, sdev->last_ocb);
sdev->last_ocb = NULL;
}
-
- splx(s);
}
static devclass_t sbp_devclass;
Modified: trunk/sys/dev/firewire/sbp.h
===================================================================
--- trunk/sys/dev/firewire/sbp.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/sbp.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,11 +32,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/sbp.h 261455 2014-02-04 03:36:42Z eadler $
*
*/
-#define ORB_NOTIFY (1 << 31)
+#define ORB_NOTIFY (1U << 31)
#define ORB_FMT_STD (0 << 29)
#define ORB_FMT_VED (2 << 29)
#define ORB_FMT_NOP (3 << 29)
Modified: trunk/sys/dev/firewire/sbp_targ.c
===================================================================
--- trunk/sys/dev/firewire/sbp_targ.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/firewire/sbp_targ.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (C) 2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -31,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/firewire/sbp_targ.c 315813 2017-03-23 06:41:13Z mav $
*/
#include <sys/param.h>
@@ -62,6 +63,7 @@
#include <cam/cam_debug.h>
#include <cam/cam_periph.h>
#include <cam/scsi/scsi_all.h>
+#include <cam/scsi/scsi_message.h>
#define SBP_TARG_RECV_LEN 8
#define MAX_INITIATORS 8
@@ -186,6 +188,21 @@
#endif
};
+
+/*
+ * Urestricted page table format
+ * states that the segment length
+ * and high base addr are in the first
+ * 32 bits and the base low is in
+ * the second
+ */
+struct unrestricted_page_table_fmt {
+ uint16_t segment_len;
+ uint16_t segment_base_high;
+ uint32_t segment_base_low;
+};
+
+
struct orb_info {
struct sbp_targ_softc *sc;
struct fw_device *fwdev;
@@ -208,7 +225,10 @@
struct corb4 orb4;
STAILQ_ENTRY(orb_info) link;
uint32_t orb[8];
- uint32_t *page_table;
+ struct unrestricted_page_table_fmt *page_table;
+ struct unrestricted_page_table_fmt *cur_pte;
+ struct unrestricted_page_table_fmt *last_pte;
+ uint32_t last_block_read;
struct sbp_status status;
};
@@ -219,6 +239,7 @@
static void sbp_targ_recv(struct fw_xfer *);
static void sbp_targ_fetch_orb(struct sbp_targ_softc *, struct fw_device *,
uint16_t, uint32_t, struct sbp_targ_login *, int);
+static void sbp_targ_xfer_pt(struct orb_info *);
static void sbp_targ_abort(struct sbp_targ_softc *, struct orb_info *);
static void
@@ -252,13 +273,19 @@
}
for (orbi = STAILQ_FIRST(&login->orbs); orbi != NULL; orbi = next) {
next = STAILQ_NEXT(orbi, link);
+ if (debug)
+ printf("%s: free orbi %p\n", __func__, orbi);
free(orbi, M_SBP_TARG);
+ orbi = NULL;
}
callout_stop(&login->hold_callout);
STAILQ_REMOVE(&login->lstate->logins, login, sbp_targ_login, link);
login->lstate->sc->logins[login->id] = NULL;
+ if (debug)
+ printf("%s: free login %p\n", __func__, login);
free((void *)login, M_SBP_TARG);
+ login = NULL;
}
static void
@@ -361,12 +388,11 @@
if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD &&
ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) {
*lstate = sc->black_hole;
+ if (debug)
+ printf("setting black hole for this target id(%d)\n", ccb->ccb_h.target_id);
return (CAM_REQ_CMP);
}
- if (ccb->ccb_h.target_id != 0)
- return (CAM_TID_INVALID);
-
lun = ccb->ccb_h.target_lun;
if (lun >= MAX_LUN)
return (CAM_LUN_INVALID);
@@ -373,8 +399,15 @@
*lstate = sc->lstate[lun];
- if (notfound_failure != 0 && *lstate == NULL)
+ if (notfound_failure != 0 && *lstate == NULL) {
+ if (debug)
+ printf("%s: lstate for lun is invalid, target(%d), lun(%d)\n",
+ __func__, ccb->ccb_h.target_id, lun);
return (CAM_PATH_INVALID);
+ } else
+ if (debug)
+ printf("%s: setting lstate for tgt(%d) lun(%d)\n",
+ __func__,ccb->ccb_h.target_id, lun);
return (CAM_REQ_CMP);
}
@@ -411,11 +444,18 @@
printf("Couldn't allocate lstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
- }
- if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD)
+ } else {
+ if (debug)
+ printf("%s: malloc'd lstate %p\n",__func__, lstate);
+ }
+ if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD) {
sc->black_hole = lstate;
- else
+ if (debug)
+ printf("Blackhole set due to target id == %d\n",
+ ccb->ccb_h.target_id);
+ } else
sc->lstate[ccb->ccb_h.target_lun] = lstate;
+
memset(lstate, 0, sizeof(*lstate));
lstate->sc = sc;
status = xpt_create_path(&lstate->path, /*periph*/NULL,
@@ -424,6 +464,7 @@
xpt_path_lun_id(ccb->ccb_h.path));
if (status != CAM_REQ_CMP) {
free(lstate, M_SBP_TARG);
+ lstate = NULL;
xpt_print_path(ccb->ccb_h.path);
printf("Couldn't allocate path\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
@@ -443,6 +484,7 @@
if (lstate == NULL) {
ccb->ccb_h.status = CAM_LUN_INVALID;
+ printf("Invalid lstate for this target\n");
return;
}
ccb->ccb_h.status = CAM_REQ_CMP;
@@ -458,6 +500,7 @@
}
if (ccb->ccb_h.status != CAM_REQ_CMP) {
+ printf("status != CAM_REQ_CMP\n");
return;
}
@@ -475,7 +518,10 @@
sc->black_hole = NULL;
else
sc->lstate[ccb->ccb_h.target_lun] = NULL;
+ if (debug)
+ printf("%s: free lstate %p\n", __func__, lstate);
free(lstate, M_SBP_TARG);
+ lstate = NULL;
/* bus reset */
sc->fd.fc->ibr(sc->fd.fc);
@@ -538,7 +584,7 @@
if (orbi->orb_lo == tag_id)
goto found;
printf("%s: orb not found tag_id=0x%08x init_id=%d\n",
- __func__, tag_id, init_id);
+ __func__, tag_id, init_id);
return (NULL);
found:
return (orbi);
@@ -559,12 +605,13 @@
xpt_done(orbi->ccb);
orbi->ccb = NULL;
}
-#if 0
if (orbi->state <= ORBI_STATUS_ATIO) {
sbp_targ_remove_orb_info_locked(orbi->login, orbi);
+ if (debug)
+ printf("%s: free orbi %p\n", __func__, orbi);
free(orbi, M_SBP_TARG);
+ orbi = NULL;
} else
-#endif
orbi->state = ORBI_STATUS_ABORTED;
}
}
@@ -576,12 +623,21 @@
{
struct orb_info *orbi;
- orbi = (struct orb_info *)xfer->sc;
if (xfer->resp != 0) {
/* XXX */
printf("%s: xfer->resp = %d\n", __func__, xfer->resp);
}
+ orbi = (struct orb_info *)xfer->sc;
+ if ( orbi->page_table != NULL ) {
+ if (debug)
+ printf("%s: free orbi->page_table %p\n", __func__, orbi->page_table);
+ free(orbi->page_table, M_SBP_TARG);
+ orbi->page_table = NULL;
+ }
+ if (debug)
+ printf("%s: free orbi %p\n", __func__, orbi);
free(orbi, M_SBP_TARG);
+ orbi = NULL;
fw_xfer_free(xfer);
}
@@ -595,7 +651,7 @@
sbp_targ_remove_orb_info(orbi->login, orbi);
xfer = fwmem_write_block(orbi->fwdev, (void *)orbi,
- /*spd*/2, fifo_hi, fifo_lo,
+ /*spd*/FWSPD_S400, fifo_hi, fifo_lo,
sizeof(uint32_t) * (orbi->status.len + 1), (char *)&orbi->status,
sbp_targ_free_orbi);
@@ -605,6 +661,10 @@
}
}
+/*
+ * Generate the appropriate CAM status for the
+ * target.
+ */
static void
sbp_targ_send_status(struct orb_info *orbi, union ccb *ccb)
{
@@ -621,6 +681,8 @@
sbp_status->status = 0; /* XXX */
sbp_status->dead = 0; /* XXX */
+ ccb->ccb_h.status= CAM_REQ_CMP;
+
switch (ccb->csio.scsi_status) {
case SCSI_STATUS_OK:
if (debug)
@@ -628,8 +690,15 @@
sbp_status->len = 1;
break;
case SCSI_STATUS_CHECK_COND:
+ if (debug)
+ printf("%s: STATUS SCSI_STATUS_CHECK_COND\n", __func__);
+ goto process_scsi_status;
case SCSI_STATUS_BUSY:
+ if (debug)
+ printf("%s: STATUS SCSI_STATUS_BUSY\n", __func__);
+ goto process_scsi_status;
case SCSI_STATUS_CMD_TERMINATED:
+process_scsi_status:
{
struct sbp_cmd_status *sbp_cmd_status;
struct scsi_sense_data *sense;
@@ -640,9 +709,6 @@
int64_t sinfo;
int sense_len;
- if (debug)
- printf("%s: STATUS %d\n", __func__,
- ccb->csio.scsi_status);
sbp_cmd_status = (struct sbp_cmd_status *)&sbp_status->data[0];
sbp_cmd_status->status = ccb->csio.scsi_status;
sense = &ccb->csio.sense_data;
@@ -734,6 +800,7 @@
if (scsi_get_sks(sense, sense_len, sks) == 0) {
bcopy(sks, &sbp_cmd_status->s_keydep[0], sizeof(sks));
sbp_status->len = 5;
+ ccb->ccb_h.status |= CAM_SENT_SENSE;
}
break;
@@ -743,13 +810,20 @@
sbp_status->status);
}
- if (orbi->page_table != NULL)
- free(orbi->page_table, M_SBP_TARG);
sbp_targ_status_FIFO(orbi,
orbi->login->fifo_hi, orbi->login->fifo_lo, /*dequeue*/1);
}
+/*
+ * Invoked as a callback handler from fwmem_read/write_block
+ *
+ * Process read/write of initiator address space
+ * completion and pass status onto the backend target.
+ * If this is a partial read/write for a CCB then
+ * we decrement the orbi's refcount to indicate
+ * the status of the read/write is complete
+ */
static void
sbp_targ_cam_done(struct fw_xfer *xfer)
{
@@ -758,7 +832,7 @@
orbi = (struct orb_info *)xfer->sc;
- if (debug > 1)
+ if (debug)
printf("%s: resp=%d refcount=%d\n", __func__,
xfer->resp, orbi->refcount);
@@ -779,13 +853,26 @@
if (debug)
printf("%s: orbi aborted\n", __func__);
sbp_targ_remove_orb_info(orbi->login, orbi);
- if (orbi->page_table != NULL)
+ if (orbi->page_table != NULL) {
+ if (debug)
+ printf("%s: free orbi->page_table %p\n",
+ __func__, orbi->page_table);
free(orbi->page_table, M_SBP_TARG);
+ }
+ if (debug)
+ printf("%s: free orbi %p\n", __func__, orbi);
free(orbi, M_SBP_TARG);
- } else if (orbi->status.resp == 0) {
- if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0)
+ orbi = NULL;
+ } else if (orbi->status.resp == ORBI_STATUS_NONE) {
+ if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
+ if (debug)
+ printf("%s: CAM_SEND_STATUS set %0x\n", __func__, ccb->ccb_h.flags);
sbp_targ_send_status(orbi, ccb);
- ccb->ccb_h.status = CAM_REQ_CMP;
+ } else {
+ if (debug)
+ printf("%s: CAM_SEND_STATUS not set %0x\n", __func__, ccb->ccb_h.flags);
+ ccb->ccb_h.status = CAM_REQ_CMP;
+ }
SBP_LOCK(orbi->sc);
xpt_done(ccb);
SBP_UNLOCK(orbi->sc);
@@ -855,6 +942,13 @@
return (CAM_PATH_INVALID);
}
+/*
+ * directly execute a read or write to the initiator
+ * address space and set hand(sbp_targ_cam_done) to
+ * process the completion from the SIM to the target.
+ * set orbi->refcount to inidicate that a read/write
+ * is inflight to/from the initiator.
+ */
static void
sbp_targ_xfer_buf(struct orb_info *orbi, u_int offset,
uint16_t dst_hi, uint32_t dst_lo, u_int size,
@@ -874,16 +968,21 @@
len = MIN(size, 2048 /* XXX */);
size -= len;
orbi->refcount ++;
- if (ccb_dir == CAM_DIR_OUT)
+ if (ccb_dir == CAM_DIR_OUT) {
+ if (debug)
+ printf("%s: CAM_DIR_OUT --> read block in?\n",__func__);
xfer = fwmem_read_block(orbi->fwdev,
- (void *)orbi, /*spd*/2,
+ (void *)orbi, /*spd*/FWSPD_S400,
dst_hi, dst_lo + off, len,
ptr + off, hand);
- else
+ } else {
+ if (debug)
+ printf("%s: CAM_DIR_IN --> write block out?\n",__func__);
xfer = fwmem_write_block(orbi->fwdev,
- (void *)orbi, /*spd*/2,
+ (void *)orbi, /*spd*/FWSPD_S400,
dst_hi, dst_lo + off, len,
ptr + off, hand);
+ }
if (xfer == NULL) {
printf("%s: xfer == NULL", __func__);
/* XXX what should we do?? */
@@ -897,18 +996,22 @@
sbp_targ_pt_done(struct fw_xfer *xfer)
{
struct orb_info *orbi;
- union ccb *ccb;
- u_int i, offset, res, len;
- uint32_t t1, t2, *p;
+ struct unrestricted_page_table_fmt *pt;
+ uint32_t i;
orbi = (struct orb_info *)xfer->sc;
- ccb = orbi->ccb;
+
if (orbi->state == ORBI_STATUS_ABORTED) {
if (debug)
printf("%s: orbi aborted\n", __func__);
sbp_targ_remove_orb_info(orbi->login, orbi);
+ if (debug) {
+ printf("%s: free orbi->page_table %p\n", __func__, orbi->page_table);
+ printf("%s: free orbi %p\n", __func__, orbi);
+ }
free(orbi->page_table, M_SBP_TARG);
free(orbi, M_SBP_TARG);
+ orbi = NULL;
fw_xfer_free(xfer);
return;
}
@@ -920,60 +1023,158 @@
orbi->status.len = 1;
sbp_targ_abort(orbi->sc, STAILQ_NEXT(orbi, link));
+ if (debug)
+ printf("%s: free orbi->page_table %p\n", __func__, orbi->page_table);
+
sbp_targ_status_FIFO(orbi,
orbi->login->fifo_hi, orbi->login->fifo_lo, /*dequeue*/1);
free(orbi->page_table, M_SBP_TARG);
+ orbi->page_table = NULL;
fw_xfer_free(xfer);
return;
}
- res = ccb->csio.dxfer_len;
- offset = 0;
- if (debug)
- printf("%s: dxfer_len=%d\n", __func__, res);
- orbi->refcount ++;
- for (p = orbi->page_table, i = orbi->orb4.data_size; i > 0; i --) {
- t1 = ntohl(*p++);
- t2 = ntohl(*p++);
- if (debug > 1)
- printf("page_table: %04x:%08x %d\n",
- t1 & 0xffff, t2, t1>>16);
- len = MIN(t1 >> 16, res);
- res -= len;
- sbp_targ_xfer_buf(orbi, offset, t1 & 0xffff, t2, len,
- sbp_targ_cam_done);
- offset += len;
- if (res == 0)
- break;
+ orbi->refcount++;
+/*
+ * Set endianess here so we don't have
+ * to deal with is later
+ */
+ for (i = 0, pt = orbi->page_table; i < orbi->orb4.data_size; i++, pt++) {
+ pt->segment_len = ntohs(pt->segment_len);
+ if (debug)
+ printf("%s:segment_len = %u\n", __func__,pt->segment_len);
+ pt->segment_base_high = ntohs(pt->segment_base_high);
+ pt->segment_base_low = ntohl(pt->segment_base_low);
}
- orbi->refcount --;
+
+ sbp_targ_xfer_pt(orbi);
+
+ orbi->refcount--;
if (orbi->refcount == 0)
printf("%s: refcount == 0\n", __func__);
- if (res !=0)
- /* XXX handle res != 0 case */
- printf("%s: page table is too small(%d)\n", __func__, res);
fw_xfer_free(xfer);
return;
}
+static void sbp_targ_xfer_pt(struct orb_info *orbi)
+{
+ union ccb *ccb;
+ uint32_t res, offset, len;
+
+ ccb = orbi->ccb;
+ if (debug)
+ printf("%s: dxfer_len=%d\n", __func__, ccb->csio.dxfer_len);
+ res = ccb->csio.dxfer_len;
+ /*
+ * If the page table required multiple CTIO's to
+ * complete, then cur_pte is non NULL
+ * and we need to start from the last position
+ * If this is the first pass over a page table
+ * then we just start at the beginning of the page
+ * table.
+ *
+ * Parse the unrestricted page table and figure out where we need
+ * to shove the data from this read request.
+ */
+ for (offset = 0, len = 0; (res != 0) && (orbi->cur_pte < orbi->last_pte); offset += len) {
+ len = MIN(orbi->cur_pte->segment_len, res);
+ res -= len;
+ if (debug)
+ printf("%s:page_table: %04x:%08x segment_len(%u) res(%u) len(%u)\n",
+ __func__, orbi->cur_pte->segment_base_high,
+ orbi->cur_pte->segment_base_low,
+ orbi->cur_pte->segment_len,
+ res, len);
+ sbp_targ_xfer_buf(orbi, offset,
+ orbi->cur_pte->segment_base_high,
+ orbi->cur_pte->segment_base_low,
+ len, sbp_targ_cam_done);
+ /*
+ * If we have only written partially to
+ * this page table, then we need to save
+ * our position for the next CTIO. If we
+ * have completed the page table, then we
+ * are safe to move on to the next entry.
+ */
+ if (len == orbi->cur_pte->segment_len) {
+ orbi->cur_pte++;
+ } else {
+ uint32_t saved_base_low;
+
+ /* Handle transfers that cross a 4GB boundary. */
+ saved_base_low = orbi->cur_pte->segment_base_low;
+ orbi->cur_pte->segment_base_low += len;
+ if (orbi->cur_pte->segment_base_low < saved_base_low)
+ orbi->cur_pte->segment_base_high++;
+
+ orbi->cur_pte->segment_len -= len;
+ }
+ }
+ if (debug) {
+ printf("%s: base_low(%08x) page_table_off(%p) last_block(%u)\n",
+ __func__, orbi->cur_pte->segment_base_low,
+ orbi->cur_pte, orbi->last_block_read);
+ }
+ if (res != 0)
+ printf("Warning - short pt encountered. "
+ "Could not transfer all data.\n");
+ return;
+}
+
+/*
+ * Create page table in local memory
+ * and transfer it from the initiator
+ * in order to know where we are supposed
+ * to put the data.
+ */
+
static void
sbp_targ_fetch_pt(struct orb_info *orbi)
{
struct fw_xfer *xfer;
- if (debug)
- printf("%s: page_table_size=%d\n",
- __func__, orbi->orb4.data_size);
- orbi->page_table = malloc(orbi->orb4.data_size*8, M_SBP_TARG, M_NOWAIT);
- if (orbi->page_table == NULL)
- goto error;
- xfer = fwmem_read_block(orbi->fwdev, (void *)orbi, /*spd*/2,
- orbi->data_hi, orbi->data_lo, orbi->orb4.data_size*8,
- (void *)orbi->page_table, sbp_targ_pt_done);
- if (xfer != NULL)
+ /*
+ * Pull in page table from initiator
+ * and setup for data from our
+ * backend device.
+ */
+ if (orbi->page_table == NULL) {
+ orbi->page_table = malloc(orbi->orb4.data_size*
+ sizeof(struct unrestricted_page_table_fmt),
+ M_SBP_TARG, M_NOWAIT|M_ZERO);
+ if (orbi->page_table == NULL)
+ goto error;
+ orbi->cur_pte = orbi->page_table;
+ orbi->last_pte = orbi->page_table + orbi->orb4.data_size;
+ orbi->last_block_read = orbi->orb4.data_size;
+ if (debug && orbi->page_table != NULL)
+ printf("%s: malloc'd orbi->page_table(%p), orb4.data_size(%u)\n",
+ __func__, orbi->page_table, orbi->orb4.data_size);
+
+ xfer = fwmem_read_block(orbi->fwdev, (void *)orbi, /*spd*/FWSPD_S400,
+ orbi->data_hi, orbi->data_lo, orbi->orb4.data_size*
+ sizeof(struct unrestricted_page_table_fmt),
+ (void *)orbi->page_table, sbp_targ_pt_done);
+
+ if (xfer != NULL)
+ return;
+ } else {
+ /*
+ * This is a CTIO for a page table we have
+ * already malloc'd, so just directly invoke
+ * the xfer function on the orbi.
+ */
+ sbp_targ_xfer_pt(orbi);
return;
+ }
error:
orbi->ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+ if (debug)
+ printf("%s: free orbi->page_table %p due to xfer == NULL\n", __func__, orbi->page_table);
+ if (orbi->page_table != NULL) {
+ free(orbi->page_table, M_SBP_TARG);
+ orbi->page_table = NULL;
+ }
xpt_done(orbi->ccb);
return;
}
@@ -1016,6 +1217,8 @@
if (debug)
printf("%s: ctio aborted\n", __func__);
sbp_targ_remove_orb_info_locked(orbi->login, orbi);
+ if (debug)
+ printf("%s: free orbi %p\n", __func__, orbi);
free(orbi, M_SBP_TARG);
ccb->ccb_h.status = CAM_REQ_ABORTED;
xpt_done(ccb);
@@ -1051,17 +1254,16 @@
}
/* Sanity check */
- if (ccb_dir != CAM_DIR_NONE &&
- orbi->orb4.data_size != ccb->csio.dxfer_len)
- printf("%s: data_size(%d) != dxfer_len(%d)\n",
- __func__, orbi->orb4.data_size,
- ccb->csio.dxfer_len);
-
- if (ccb_dir != CAM_DIR_NONE)
+ if (ccb_dir != CAM_DIR_NONE) {
sbp_targ_xfer_buf(orbi, 0, orbi->data_hi,
orbi->data_lo,
MIN(orbi->orb4.data_size, ccb->csio.dxfer_len),
sbp_targ_cam_done);
+ if ( orbi->orb4.data_size > ccb->csio.dxfer_len ) {
+ orbi->data_lo += ccb->csio.dxfer_len;
+ orbi->orb4.data_size -= ccb->csio.dxfer_len;
+ }
+ }
if (ccb_dir == CAM_DIR_NONE) {
if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
@@ -1125,7 +1327,9 @@
cpi->target_sprt = PIT_PROCESSOR
| PIT_DISCONNECT
| PIT_TERM_IO;
- cpi->hba_misc = PIM_NOBUSRESET | PIM_NO_6_BYTE;
+ cpi->transport = XPORT_SPI; /* FIXME add XPORT_FW type to cam */
+ cpi->hba_misc = PIM_NOINITIATOR | PIM_NOBUSRESET |
+ PIM_NO_6_BYTE;
cpi->hba_eng_cnt = 0;
cpi->max_target = 7; /* XXX */
cpi->max_lun = MAX_LUN - 1;
@@ -1132,9 +1336,9 @@
cpi->initiator_id = 7; /* XXX */
cpi->bus_id = sim->bus_id;
cpi->base_transfer_speed = 400 * 1000 / 8;
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "SBP_TARG", HBA_IDLEN);
- strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
+ strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+ strlcpy(cpi->hba_vid, "SBP_TARG", HBA_IDLEN);
+ strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
cpi->unit_number = sim->unit_number;
cpi->ccb_h.status = CAM_REQ_CMP;
@@ -1163,10 +1367,42 @@
xpt_done(ccb);
break;
}
+#ifdef CAM_NEW_TRAN_CODE
+ case XPT_SET_TRAN_SETTINGS:
+ ccb->ccb_h.status = CAM_REQ_INVALID;
+ xpt_done(ccb);
+ break;
+ case XPT_GET_TRAN_SETTINGS:
+ {
+ struct ccb_trans_settings *cts = &ccb->cts;
+ struct ccb_trans_settings_scsi *scsi =
+ &cts->proto_specific.scsi;
+ struct ccb_trans_settings_spi *spi =
+ &cts->xport_specific.spi;
+
+ cts->protocol = PROTO_SCSI;
+ cts->protocol_version = SCSI_REV_2;
+ cts->transport = XPORT_FW; /* should have a FireWire */
+ cts->transport_version = 2;
+ spi->valid = CTS_SPI_VALID_DISC;
+ spi->flags = CTS_SPI_FLAGS_DISC_ENB;
+ scsi->valid = CTS_SCSI_VALID_TQ;
+ scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
+#if 0
+ printf("%s:%d:%d XPT_GET_TRAN_SETTINGS:\n",
+ device_get_nameunit(sc->fd.dev),
+ ccb->ccb_h.target_id, ccb->ccb_h.target_lun);
+#endif
+ cts->ccb_h.status = CAM_REQ_CMP;
+ xpt_done(ccb);
+ break;
+ }
+#endif
+
default:
- printf("%s: unknown function %d\n",
+ printf("%s: unknown function 0x%x\n",
__func__, ccb->ccb_h.func_code);
- ccb->ccb_h.status = CAM_REQ_INVALID;
+ ccb->ccb_h.status = CAM_PROVIDE_FAIL;
xpt_done(ccb);
break;
}
@@ -1245,11 +1481,11 @@
atio->ccb_h.target_id = 0; /* XXX */
atio->ccb_h.target_lun = orbi->login->lstate->lun;
atio->sense_len = 0;
- atio->tag_action = 1; /* XXX */
+ atio->tag_action = MSG_SIMPLE_TASK;
atio->tag_id = orbi->orb_lo;
atio->init_id = orbi->login->id;
- atio->ccb_h.flags = CAM_TAG_ACTION_VALID;
+ atio->ccb_h.flags |= CAM_TAG_ACTION_VALID;
bytes = (u_char *)&orb[5];
if (debug)
printf("%s: %p %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
@@ -1429,7 +1665,7 @@
login->loginres.recon_hold = htons(login->hold_sec);
STAILQ_INSERT_TAIL(&lstate->logins, login, link);
- fwmem_write_block(orbi->fwdev, NULL, /*spd*/2, orb[2], orb[3],
+ fwmem_write_block(orbi->fwdev, NULL, /*spd*/FWSPD_S400, orb[2], orb[3],
sizeof(struct sbp_login_res), (void *)&login->loginres,
fw_asy_callback_free);
/* XXX return status after loginres is successfully written */
@@ -1482,7 +1718,7 @@
orb0 = ntohl(orbi->orb[0]);
orb1 = ntohl(orbi->orb[1]);
- if ((orb0 & (1 << 31)) != 0) {
+ if ((orb0 & (1U << 31)) != 0) {
printf("%s: invalid pointer\n", __func__);
goto done;
}
@@ -1515,10 +1751,11 @@
orbi->orb_lo = orb_lo;
orbi->status.orb_hi = htons(orb_hi);
orbi->status.orb_lo = htonl(orb_lo);
+ orbi->page_table = NULL;
switch (mode) {
case FETCH_MGM:
- fwmem_read_block(fwdev, (void *)orbi, /*spd*/2, orb_hi, orb_lo,
+ fwmem_read_block(fwdev, (void *)orbi, /*spd*/FWSPD_S400, orb_hi, orb_lo,
sizeof(uint32_t) * 8, &orbi->orb[0],
sbp_targ_mgm_handler);
break;
@@ -1545,7 +1782,7 @@
SLIST_REMOVE_HEAD(&login->lstate->accept_tios, sim_links.sle);
STAILQ_INSERT_TAIL(&login->orbs, orbi, link);
SBP_UNLOCK(sc);
- fwmem_read_block(fwdev, (void *)orbi, /*spd*/2, orb_hi, orb_lo,
+ fwmem_read_block(fwdev, (void *)orbi, /*spd*/FWSPD_S400, orb_hi, orb_lo,
sizeof(uint32_t) * 8, &orbi->orb[0],
sbp_targ_cmd_handler);
break;
@@ -1552,7 +1789,7 @@
case FETCH_POINTER:
orbi->state = ORBI_STATUS_POINTER;
login->flags |= F_LINK_ACTIVE;
- fwmem_read_block(fwdev, (void *)orbi, /*spd*/2, orb_hi, orb_lo,
+ fwmem_read_block(fwdev, (void *)orbi, /*spd*/FWSPD_S400, orb_hi, orb_lo,
sizeof(uint32_t) * 2, &orbi->orb[0],
sbp_targ_pointer_handler);
break;
@@ -1709,7 +1946,7 @@
if (rtcode != 0)
printf("%s: rtcode = %d\n", __func__, rtcode);
sfp = &xfer->send.hdr;
- xfer->send.spd = 2; /* XXX */
+ xfer->send.spd = FWSPD_S400;
xfer->hand = sbp_targ_resp_callback;
sfp->mode.wres.dst = fp->mode.wreqb.src;
sfp->mode.wres.tlrt = fp->mode.wreqb.tlrt;
Modified: trunk/sys/dev/flash/at45d.c
===================================================================
--- trunk/sys/dev/flash/at45d.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/flash/at45d.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2006 M. Warner Losh
* Copyright (c) 2011-2012 Ian Lepore
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/flash/at45d.c 242625 2012-11-05 19:16:27Z dim $");
#include <sys/param.h>
#include <sys/systm.h>
Modified: trunk/sys/dev/flash/mx25l.c
===================================================================
--- trunk/sys/dev/flash/mx25l.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/flash/mx25l.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2006 M. Warner Losh. All rights reserved.
* Copyright (c) 2009 Oleksandr Tymoshenko. All rights reserved.
@@ -24,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/flash/mx25l.c 254991 2013-08-28 14:49:36Z loos $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -96,12 +97,26 @@
static void mx25l_task(void *arg);
struct mx25l_flash_ident flash_devices[] = {
- { "mx25ll32", 0xc2, 0x2016, 64 * 1024, 64, FL_NONE },
- { "m25p64", 0x20, 0x2017, 64 * 1024, 128, FL_NONE },
- { "mx25ll64", 0xc2, 0x2017, 64 * 1024, 128, FL_NONE },
- { "mx25ll128", 0xc2, 0x2018, 64 * 1024, 256, FL_ERASE_4K | FL_ERASE_32K },
- { "s25fl128", 0x01, 0x2018, 64 * 1024, 256, FL_NONE },
- { "s25sl064a", 0x01, 0x0216, 64 * 1024, 128, FL_NONE },
+ { "en25f32", 0x1c, 0x3116, 64 * 1024, 64, FL_NONE },
+ { "en25p32", 0x1c, 0x2016, 64 * 1024, 64, FL_NONE },
+ { "en25p64", 0x1c, 0x2017, 64 * 1024, 128, FL_NONE },
+ { "en25q64", 0x1c, 0x3017, 64 * 1024, 128, FL_ERASE_4K },
+ { "m25p64", 0x20, 0x2017, 64 * 1024, 128, FL_NONE },
+ { "mx25ll32", 0xc2, 0x2016, 64 * 1024, 64, FL_NONE },
+ { "mx25ll64", 0xc2, 0x2017, 64 * 1024, 128, FL_NONE },
+ { "mx25ll128", 0xc2, 0x2018, 64 * 1024, 256, FL_ERASE_4K | FL_ERASE_32K },
+ { "s25fl032", 0x01, 0x0215, 64 * 1024, 64, FL_NONE },
+ { "s25fl064", 0x01, 0x0216, 64 * 1024, 128, FL_NONE },
+ { "s25fl128", 0x01, 0x2018, 64 * 1024, 256, FL_NONE },
+ { "SST25VF032B", 0xbf, 0x254a, 64 * 1024, 64, FL_ERASE_4K | FL_ERASE_32K },
+
+ /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
+ { "w25x32", 0xef, 0x3016, 64 * 1024, 64, FL_ERASE_4K },
+ { "w25q32", 0xef, 0x4016, 64 * 1024, 64, FL_ERASE_4K },
+ { "w25q64", 0xef, 0x4017, 64 * 1024, 128, FL_ERASE_4K },
+ { "w25q64bv", 0xef, 0x4017, 64 * 1024, 128, FL_ERASE_4K },
+ { "w25q128", 0xef, 0x4018, 64 * 1024, 256, FL_ERASE_4K },
+ { "w25q256", 0xef, 0x4019, 64 * 1024, 512, FL_ERASE_4K },
};
static uint8_t
Modified: trunk/sys/dev/flash/mx25lreg.h
===================================================================
--- trunk/sys/dev/flash/mx25lreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/flash/mx25lreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2009, Oleksandr Tymoshenko <gonzo at FreeBSD.org>
* All rights reserved.
@@ -24,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/flash/mx25lreg.h 210238 2010-07-19 15:05:35Z adrian $
*/
#ifndef __MX25LREG_H__
Modified: trunk/sys/dev/fxp/if_fxp.c
===================================================================
--- trunk/sys/dev/fxp/if_fxp.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fxp/if_fxp.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1995, David Greenman
* Copyright (c) 2001 Jonathan Lemon <jlemon at freebsd.org>
@@ -28,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fxp/if_fxp.c 254263 2013-08-12 23:30:01Z scottl $");
/*
* Intel EtherExpress Pro/100B PCI Fast Ethernet driver
@@ -2593,7 +2594,7 @@
{
struct fxp_softc *sc = ifp->if_softc;
struct mii_data *mii;
- struct mii_softc *miisc;
+ struct mii_softc *miisc;
mii = device_get_softc(sc->miibus);
FXP_LOCK(sc);
Modified: trunk/sys/dev/fxp/if_fxpreg.h
===================================================================
--- trunk/sys/dev/fxp/if_fxpreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fxp/if_fxpreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1995, David Greenman
* Copyright (c) 2001 Jonathan Lemon <jlemon at freebsd.org>
@@ -25,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fxp/if_fxpreg.h 264442 2014-04-14 04:51:59Z yongari $
*/
#define FXP_VENDORID_INTEL 0x8086
@@ -250,7 +251,7 @@
/*
* Number of DMA segments in a TxCB.
*/
-#define FXP_NTXSEG 32
+#define FXP_NTXSEG 35
struct fxp_tbd {
uint32_t tb_addr;
Modified: trunk/sys/dev/fxp/if_fxpvar.h
===================================================================
--- trunk/sys/dev/fxp/if_fxpvar.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fxp/if_fxpvar.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1995, David Greenman
* All rights reserved.
@@ -24,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fxp/if_fxpvar.h 233586 2012-03-28 01:27:27Z yongari $
*/
/*
Modified: trunk/sys/dev/fxp/inphy.c
===================================================================
--- trunk/sys/dev/fxp/inphy.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fxp/inphy.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2001 Jonathan Lemon
* All rights reserved.
@@ -29,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/fxp/inphy.c 226154 2011-10-08 12:33:10Z marius $");
/*
* driver for Intel 82553 and 82555 PHYs
Modified: trunk/sys/dev/fxp/inphyreg.h
===================================================================
--- trunk/sys/dev/fxp/inphyreg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fxp/inphyreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2001 Jonathan Lemon
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fxp/inphyreg.h 226154 2011-10-08 12:33:10Z marius $
*/
#ifndef _INPHYREG_H
Modified: trunk/sys/dev/fxp/rcvbundl.h
===================================================================
--- trunk/sys/dev/fxp/rcvbundl.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/fxp/rcvbundl.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
Copyright (c) 1999-2001, Intel Corporation
@@ -29,7 +30,7 @@
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/fxp/rcvbundl.h 145368 2005-04-21 19:34:57Z mux $
*/
/*
rcvbundl.h
Added: trunk/sys/dev/gxemul/cons/gxemul_cons.c
===================================================================
--- trunk/sys/dev/gxemul/cons/gxemul_cons.c (rev 0)
+++ trunk/sys/dev/gxemul/cons/gxemul_cons.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,334 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2011-2012 Robert N. M. Watson
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/gxemul/cons/gxemul_cons.c 314667 2017-03-04 13:03:31Z avg $");
+
+#include <sys/param.h>
+#include <sys/cons.h>
+#include <sys/endian.h>
+#include <sys/kdb.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/reboot.h>
+#include <sys/tty.h>
+
+#include <ddb/ddb.h>
+
+#include <machine/cpuregs.h>
+
+#define GC_LOCK_INIT() mtx_init(&gc_lock, "gc_lock", NULL, MTX_SPIN)
+
+#define GC_LOCK() do { \
+ if (!kdb_active) \
+ mtx_lock_spin(&gc_lock); \
+} while (0)
+
+#define GC_LOCK_ASSERT() do { \
+ if (!kdb_active) \
+ mtx_assert(&gc_lock, MA_OWNED); \
+} while (0)
+
+#define GC_UNLOCK() do { \
+ if (!kdb_active) \
+ mtx_unlock_spin(&gc_lock); \
+} while (0)
+
+
+static struct mtx gc_lock;
+
+/*
+ * Low-level console driver functions.
+ */
+static cn_probe_t gxemul_cons_cnprobe;
+static cn_init_t gxemul_cons_cninit;
+static cn_term_t gxemul_cons_cnterm;
+static cn_getc_t gxemul_cons_cngetc;
+static cn_putc_t gxemul_cons_cnputc;
+static cn_grab_t gxemul_cons_cngrab;
+static cn_ungrab_t gxemul_cons_cnungrab;
+
+/*
+ * TTY-level fields.
+ */
+static tsw_outwakeup_t gxemul_cons_outwakeup;
+
+static struct ttydevsw gxemul_cons_ttydevsw = {
+ .tsw_flags = TF_NOPREFIX,
+ .tsw_outwakeup = gxemul_cons_outwakeup,
+};
+
+static struct callout gxemul_cons_callout;
+static u_int gxemul_cons_polltime = 10;
+#ifdef KDB
+static int gxemul_cons_alt_break_state;
+#endif
+
+static void gxemul_cons_timeout(void *);
+
+/*
+ * I/O routines lifted from Deimos.
+ *
+ * XXXRW: Should be using FreeBSD's bus routines here, but they are not
+ * available until later in the boot.
+ */
+
+static inline vm_offset_t
+mips_phys_to_uncached(vm_paddr_t phys)
+{
+
+ return (MIPS_PHYS_TO_DIRECT_UNCACHED(phys));
+}
+
+static inline uint8_t
+mips_ioread_uint8(vm_offset_t vaddr)
+{
+ uint8_t v;
+
+ __asm__ __volatile__ ("lbu %0, 0(%1)" : "=r" (v) : "r" (vaddr));
+ return (v);
+}
+
+static inline void
+mips_iowrite_uint8(vm_offset_t vaddr, uint8_t v)
+{
+
+ __asm__ __volatile__ ("sb %0, 0(%1)" : : "r" (v), "r" (vaddr));
+}
+
+/*
+ * gxemul-specific constants.
+ */
+#define GXEMUL_CONS_BASE 0x10000000 /* gxemul console device. */
+
+/*
+ * Routines for interacting with the gxemul test console. Programming details
+ * are a result of manually inspecting the source code for gxemul's
+ * dev_cons.cc and dev_cons.h.
+ *
+ * Offsets of I/O channels relative to the base.
+ */
+#define GXEMUL_PUTGETCHAR_OFF 0x00000000
+#define GXEMUL_CONS_HALT 0x00000010
+
+/*
+ * One-byte buffer as we can't check whether the console is readable without
+ * actually reading from it.
+ */
+static char buffer_data;
+static int buffer_valid;
+
+/*
+ * Low-level read and write routines.
+ */
+static inline uint8_t
+gxemul_cons_data_read(void)
+{
+
+ return (mips_ioread_uint8(mips_phys_to_uncached(GXEMUL_CONS_BASE +
+ GXEMUL_PUTGETCHAR_OFF)));
+}
+
+static inline void
+gxemul_cons_data_write(uint8_t v)
+{
+
+ mips_iowrite_uint8(mips_phys_to_uncached(GXEMUL_CONS_BASE +
+ GXEMUL_PUTGETCHAR_OFF), v);
+}
+
+static int
+gxemul_cons_writable(void)
+{
+
+ return (1);
+}
+
+static int
+gxemul_cons_readable(void)
+{
+ uint32_t v;
+
+ GC_LOCK_ASSERT();
+
+ if (buffer_valid)
+ return (1);
+ v = gxemul_cons_data_read();
+ if (v != 0) {
+ buffer_valid = 1;
+ buffer_data = v;
+ return (1);
+ }
+ return (0);
+}
+
+static void
+gxemul_cons_write(char ch)
+{
+
+ GC_LOCK_ASSERT();
+
+ while (!gxemul_cons_writable());
+ gxemul_cons_data_write(ch);
+}
+
+static char
+gxemul_cons_read(void)
+{
+
+ GC_LOCK_ASSERT();
+
+ while (!gxemul_cons_readable());
+ buffer_valid = 0;
+ return (buffer_data);
+}
+
+/*
+ * Implementation of a FreeBSD low-level, polled console driver.
+ */
+static void
+gxemul_cons_cnprobe(struct consdev *cp)
+{
+
+ sprintf(cp->cn_name, "ttyu0");
+ cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL;
+}
+
+static void
+gxemul_cons_cninit(struct consdev *cp)
+{
+
+ GC_LOCK_INIT();
+}
+
+static void
+gxemul_cons_cnterm(struct consdev *cp)
+{
+
+}
+
+static int
+gxemul_cons_cngetc(struct consdev *cp)
+{
+ int ret;
+
+ GC_LOCK();
+ ret = gxemul_cons_read();
+ GC_UNLOCK();
+ return (ret);
+}
+
+static void
+gxemul_cons_cnputc(struct consdev *cp, int c)
+{
+
+ GC_LOCK();
+ gxemul_cons_write(c);
+ GC_UNLOCK();
+}
+
+static void
+gxemul_cons_cngrab(struct consdev *cp)
+{
+
+}
+
+static void
+gxemul_cons_cnungrab(struct consdev *cp)
+{
+
+}
+
+CONSOLE_DRIVER(gxemul_cons);
+
+/*
+ * TTY-level functions for gxemul_cons.
+ */
+static void
+gxemul_cons_ttyinit(void *unused)
+{
+ struct tty *tp;
+
+ tp = tty_alloc(&gxemul_cons_ttydevsw, NULL);
+ tty_init_console(tp, 0);
+ tty_makedev(tp, NULL, "%s", "ttyu0");
+ callout_init(&gxemul_cons_callout, 1);
+ callout_reset(&gxemul_cons_callout, gxemul_cons_polltime,
+ gxemul_cons_timeout, tp);
+
+}
+SYSINIT(gxemul_cons_ttyinit, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE,
+ gxemul_cons_ttyinit, NULL);
+
+static void
+gxemul_cons_outwakeup(struct tty *tp)
+{
+ int len;
+ u_char ch;
+
+ /*
+ * XXXRW: Would be nice not to do blocking writes to the console here,
+ * rescheduling on our timer tick if work remains to be done..
+ */
+ for (;;) {
+ len = ttydisc_getc(tp, &ch, sizeof(ch));
+ if (len == 0)
+ break;
+ GC_LOCK();
+ gxemul_cons_write(ch);
+ GC_UNLOCK();
+ }
+}
+
+static void
+gxemul_cons_timeout(void *v)
+{
+ struct tty *tp;
+ int c;
+
+ tp = v;
+ tty_lock(tp);
+ GC_LOCK();
+ while (gxemul_cons_readable()) {
+ c = gxemul_cons_read();
+ GC_UNLOCK();
+#ifdef KDB
+ kdb_alt_break(c, &gxemul_cons_alt_break_state);
+#endif
+ ttydisc_rint(tp, c, 0);
+ GC_LOCK();
+ }
+ GC_UNLOCK();
+ ttydisc_rint_done(tp);
+ tty_unlock(tp);
+ callout_reset(&gxemul_cons_callout, gxemul_cons_polltime,
+ gxemul_cons_timeout, tp);
+}
Property changes on: trunk/sys/dev/gxemul/cons/gxemul_cons.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/gxemul/disk/gxemul_disk.c
===================================================================
--- trunk/sys/dev/gxemul/disk/gxemul_disk.c (rev 0)
+++ trunk/sys/dev/gxemul/disk/gxemul_disk.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,331 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2008-2012 Juli Mallett <jmallett at FreeBSD.org>
+ * 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: stable/10/sys/dev/gxemul/disk/gxemul_disk.c 265999 2014-05-14 01:35:43Z ian $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/gxemul/disk/gxemul_disk.c 265999 2014-05-14 01:35:43Z ian $");
+
+#include <sys/param.h>
+#include <sys/bio.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/rman.h>
+
+#include <geom/geom.h>
+
+#include <machine/cpuregs.h>
+
+#include <dev/gxemul/disk/gxemul_diskreg.h>
+
+struct gxemul_disk_softc {
+ device_t sc_dev;
+ uint64_t sc_size;
+ struct g_geom *sc_geom;
+ struct g_provider *sc_provider;
+};
+
+static struct mtx gxemul_disk_controller_mutex;
+
+static g_start_t gxemul_disk_start;
+static g_access_t gxemul_disk_access;
+
+struct g_class g_gxemul_disk_class = {
+ .name = "GXemul",
+ .version = G_VERSION,
+ .start = gxemul_disk_start,
+ .access = gxemul_disk_access,
+};
+
+DECLARE_GEOM_CLASS(g_gxemul_disk_class, g_gxemul_disk);
+
+static void gxemul_disk_identify(driver_t *, device_t);
+static int gxemul_disk_probe(device_t);
+static int gxemul_disk_attach(device_t);
+static void gxemul_disk_attach_geom(void *, int);
+
+static int gxemul_disk_read(unsigned, void *, off_t);
+static int gxemul_disk_size(unsigned, uint64_t *);
+static int gxemul_disk_write(unsigned, const void *, off_t);
+
+static void
+gxemul_disk_start(struct bio *bp)
+{
+ struct gxemul_disk_softc *sc;
+ unsigned diskid;
+ off_t offset;
+ uint8_t *buf;
+ int error;
+
+ sc = bp->bio_to->geom->softc;
+ diskid = device_get_unit(sc->sc_dev);
+
+ if ((bp->bio_length % GXEMUL_DISK_DEV_BLOCKSIZE) != 0) {
+ g_io_deliver(bp, EINVAL);
+ return;
+ }
+
+ buf = bp->bio_data;
+ offset = bp->bio_offset;
+ bp->bio_resid = bp->bio_length;
+ while (bp->bio_resid != 0) {
+ switch (bp->bio_cmd) {
+ case BIO_READ:
+ mtx_lock(&gxemul_disk_controller_mutex);
+ error = gxemul_disk_read(diskid, buf, offset);
+ mtx_unlock(&gxemul_disk_controller_mutex);
+ break;
+ case BIO_WRITE:
+ mtx_lock(&gxemul_disk_controller_mutex);
+ error = gxemul_disk_write(diskid, buf, offset);
+ mtx_unlock(&gxemul_disk_controller_mutex);
+ break;
+ default:
+ g_io_deliver(bp, EOPNOTSUPP);
+ return;
+ }
+ if (error != 0) {
+ g_io_deliver(bp, error);
+ return;
+ }
+
+ buf += GXEMUL_DISK_DEV_BLOCKSIZE;
+ offset += GXEMUL_DISK_DEV_BLOCKSIZE;
+ bp->bio_completed += GXEMUL_DISK_DEV_BLOCKSIZE;
+ bp->bio_resid -= GXEMUL_DISK_DEV_BLOCKSIZE;
+ }
+
+ g_io_deliver(bp, 0);
+}
+
+static int
+gxemul_disk_access(struct g_provider *pp, int r, int w, int e)
+{
+ return (0);
+}
+
+static void
+gxemul_disk_identify(driver_t *drv, device_t parent)
+{
+ unsigned diskid;
+
+ mtx_init(&gxemul_disk_controller_mutex, "GXemul disk controller", NULL, MTX_DEF);
+
+ mtx_lock(&gxemul_disk_controller_mutex);
+ for (diskid = 0; diskid < 0x100; diskid++) {
+ /*
+ * If we can read at offset 0, this disk id must be
+ * present enough. If we get an error, stop looking.
+ * Disks in GXemul are allocated linearly from 0.
+ */
+ if (gxemul_disk_read(diskid, NULL, 0) != 0)
+ break;
+ BUS_ADD_CHILD(parent, 0, "gxemul_disk", diskid);
+ }
+ mtx_unlock(&gxemul_disk_controller_mutex);
+}
+
+static int
+gxemul_disk_probe(device_t dev)
+{
+ device_set_desc(dev, "GXemul test disk");
+
+ return (BUS_PROBE_NOWILDCARD);
+}
+
+static void
+gxemul_disk_attach_geom(void *arg, int flag)
+{
+ struct gxemul_disk_softc *sc;
+
+ sc = arg;
+
+ sc->sc_geom = g_new_geomf(&g_gxemul_disk_class, "%s", device_get_nameunit(sc->sc_dev));
+ sc->sc_geom->softc = sc;
+
+ sc->sc_provider = g_new_providerf(sc->sc_geom, sc->sc_geom->name);
+ sc->sc_provider->sectorsize = GXEMUL_DISK_DEV_BLOCKSIZE;
+ sc->sc_provider->mediasize = sc->sc_size;
+ g_error_provider(sc->sc_provider, 0);
+}
+
+static int
+gxemul_disk_attach(device_t dev)
+{
+ struct gxemul_disk_softc *sc;
+ unsigned diskid;
+ int error;
+
+ diskid = device_get_unit(dev);
+
+ sc = device_get_softc(dev);
+ sc->sc_dev = dev;
+ sc->sc_geom = NULL;
+ sc->sc_provider = NULL;
+
+ mtx_lock(&gxemul_disk_controller_mutex);
+ error = gxemul_disk_size(diskid, &sc->sc_size);
+ if (error != 0) {
+ mtx_unlock(&gxemul_disk_controller_mutex);
+ return (error);
+ }
+ mtx_unlock(&gxemul_disk_controller_mutex);
+
+ g_post_event(gxemul_disk_attach_geom, sc, M_WAITOK, NULL);
+
+ return (0);
+}
+
+static int
+gxemul_disk_read(unsigned diskid, void *buf, off_t off)
+{
+ const volatile void *src;
+
+ mtx_assert(&gxemul_disk_controller_mutex, MA_OWNED);
+
+ if (off < 0 || off % GXEMUL_DISK_DEV_BLOCKSIZE != 0)
+ return (EINVAL);
+
+#ifdef _LP64
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET, (uint64_t)off);
+#else
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_LO,
+ (uint32_t)(off & 0xffffffff));
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_HI,
+ (uint32_t)((off >> 32) & 0xffffffff));
+#endif
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_DISKID, diskid);
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_START, GXEMUL_DISK_DEV_START_READ);
+ switch (GXEMUL_DISK_DEV_READ(GXEMUL_DISK_DEV_STATUS)) {
+ case GXEMUL_DISK_DEV_STATUS_FAILURE:
+ return (EIO);
+ default:
+ break;
+ }
+
+ if (buf != NULL) {
+ src = GXEMUL_DISK_DEV_FUNCTION(GXEMUL_DISK_DEV_BLOCK);
+ memcpy(buf, (const void *)(uintptr_t)src,
+ GXEMUL_DISK_DEV_BLOCKSIZE);
+ }
+
+ return (0);
+}
+
+static int
+gxemul_disk_size(unsigned diskid, uint64_t *sizep)
+{
+ uint64_t offset, ogood;
+ uint64_t m, s;
+ int error;
+
+ m = 1;
+ s = 3;
+ ogood = 0;
+
+ for (;;) {
+ offset = (ogood * s) + (m * GXEMUL_DISK_DEV_BLOCKSIZE);
+
+ error = gxemul_disk_read(diskid, NULL, offset);
+ if (error != 0) {
+ if (m == 1 && s == 1) {
+ *sizep = ogood + GXEMUL_DISK_DEV_BLOCKSIZE;
+ return (0);
+ }
+ if (m > 1)
+ m /= 2;
+ if (s > 1)
+ s--;
+ continue;
+ }
+ if (ogood == offset) {
+ m = 1;
+ continue;
+ }
+ ogood = offset;
+ m++;
+ }
+
+ return (EDOOFUS);
+}
+
+static int
+gxemul_disk_write(unsigned diskid, const void *buf, off_t off)
+{
+ volatile void *dst;
+
+ mtx_assert(&gxemul_disk_controller_mutex, MA_OWNED);
+
+ if (off < 0 || off % GXEMUL_DISK_DEV_BLOCKSIZE != 0)
+ return (EINVAL);
+
+#ifdef _LP64
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET, (uint64_t)off);
+#else
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_LO,
+ (uint32_t)(off & 0xffffffff));
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_HI,
+ (uint32_t)((off >> 32) & 0xffffffff));
+#endif
+
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_DISKID, diskid);
+
+ dst = GXEMUL_DISK_DEV_FUNCTION(GXEMUL_DISK_DEV_BLOCK);
+ memcpy((void *)(uintptr_t)dst, buf, GXEMUL_DISK_DEV_BLOCKSIZE);
+
+ GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_START, GXEMUL_DISK_DEV_START_WRITE);
+ switch (GXEMUL_DISK_DEV_READ(GXEMUL_DISK_DEV_STATUS)) {
+ case GXEMUL_DISK_DEV_STATUS_FAILURE:
+ return (EIO);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
+static device_method_t gxemul_disk_methods[] = {
+ DEVMETHOD(device_probe, gxemul_disk_probe),
+ DEVMETHOD(device_identify, gxemul_disk_identify),
+ DEVMETHOD(device_attach, gxemul_disk_attach),
+
+ { 0, 0 }
+};
+
+static driver_t gxemul_disk_driver = {
+ "gxemul_disk",
+ gxemul_disk_methods,
+ sizeof (struct gxemul_disk_softc)
+};
+
+static devclass_t gxemul_disk_devclass;
+DRIVER_MODULE(gxemul_disk, nexus, gxemul_disk_driver, gxemul_disk_devclass, 0, 0);
Property changes on: trunk/sys/dev/gxemul/disk/gxemul_disk.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/gxemul/disk/gxemul_diskreg.h
===================================================================
--- trunk/sys/dev/gxemul/disk/gxemul_diskreg.h (rev 0)
+++ trunk/sys/dev/gxemul/disk/gxemul_diskreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,70 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2008-2012 Juli Mallett <jmallett at FreeBSD.org>
+ * 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: stable/10/sys/dev/gxemul/disk/gxemul_diskreg.h 255212 2013-09-04 20:34:36Z gonzo $
+ */
+
+#ifndef _DEV_GXEMUL_DISK_GXEMUL_DISK_H_
+#define _DEV_GXEMUL_DISK_GXEMUL_DISK_H_
+
+#define GXEMUL_DISK_DEV_BASE (0x13000000)
+
+#define GXEMUL_DISK_DEV_BLOCKSIZE (0x0200)
+
+#define GXEMUL_DISK_DEV_ID_START (0x0000)
+#define GXEMUL_DISK_DEV_ID_END (0x0100)
+
+#ifdef _LP64
+#define GXEMUL_DISK_DEV_OFFSET (0x0000)
+#else
+#define GXEMUL_DISK_DEV_OFFSET_LO (0x0000)
+#define GXEMUL_DISK_DEV_OFFSET_HI (0x0008)
+#endif
+#define GXEMUL_DISK_DEV_DISKID (0x0010)
+#define GXEMUL_DISK_DEV_START (0x0020)
+#define GXEMUL_DISK_DEV_STATUS (0x0030)
+#define GXEMUL_DISK_DEV_BLOCK (0x4000)
+
+#ifdef _LP64
+#define GXEMUL_DISK_DEV_FUNCTION(f) \
+ (volatile uint64_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_DISK_DEV_BASE + (f))
+#define GXEMUL_DISK_DEV_READ(f) \
+ (volatile uint64_t)*GXEMUL_DISK_DEV_FUNCTION(f)
+#else
+#define GXEMUL_DISK_DEV_FUNCTION(f) \
+ (volatile uint32_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_DISK_DEV_BASE + (f))
+#define GXEMUL_DISK_DEV_READ(f) \
+ (volatile uint32_t)*GXEMUL_DISK_DEV_FUNCTION(f)
+#endif
+#define GXEMUL_DISK_DEV_WRITE(f, v) \
+ *GXEMUL_DISK_DEV_FUNCTION(f) = (v)
+
+#define GXEMUL_DISK_DEV_START_READ (0x00)
+#define GXEMUL_DISK_DEV_START_WRITE (0x01)
+
+#define GXEMUL_DISK_DEV_STATUS_FAILURE (0x00)
+
+#endif /* !_DEV_GXEMUL_DISK_GXEMUL_DISK_H_ */
Property changes on: trunk/sys/dev/gxemul/disk/gxemul_diskreg.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/gxemul/ether/gxreg.h
===================================================================
--- trunk/sys/dev/gxemul/ether/gxreg.h (rev 0)
+++ trunk/sys/dev/gxemul/ether/gxreg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,64 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2008-2012 Juli Mallett <jmallett at FreeBSD.org>
+ * 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: stable/10/sys/dev/gxemul/ether/gxreg.h 255212 2013-09-04 20:34:36Z gonzo $
+ */
+
+#ifndef _DEV_GXEMUL_ETHER_GXREG_H_
+#define _DEV_GXEMUL_ETHER_GXREG_H_
+
+#define GXEMUL_ETHER_DEV_BASE (0x14000000)
+#define GXEMUL_ETHER_DEV_IRQ (3)
+
+#define GXEMUL_ETHER_DEV_MTU (0x4000)
+
+#define GXEMUL_ETHER_DEV_BUFFER (0x0000)
+#define GXEMUL_ETHER_DEV_STATUS (0x4000)
+#define GXEMUL_ETHER_DEV_LENGTH (0x4010)
+#define GXEMUL_ETHER_DEV_COMMAND (0x4020)
+#define GXEMUL_ETHER_DEV_MAC (0x4040)
+
+#ifdef _LP64
+#define GXEMUL_ETHER_DEV_FUNCTION(f) \
+ (volatile uint64_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_ETHER_DEV_BASE + (f))
+#define GXEMUL_ETHER_DEV_READ(f) \
+ (volatile uint64_t)*GXEMUL_ETHER_DEV_FUNCTION(f)
+#else
+#define GXEMUL_ETHER_DEV_FUNCTION(f) \
+ (volatile uint32_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_ETHER_DEV_BASE + (f))
+#define GXEMUL_ETHER_DEV_READ(f) \
+ (volatile uint32_t)*GXEMUL_ETHER_DEV_FUNCTION(f)
+#endif
+#define GXEMUL_ETHER_DEV_WRITE(f, v) \
+ *GXEMUL_ETHER_DEV_FUNCTION(f) = (v)
+
+#define GXEMUL_ETHER_DEV_STATUS_RX_OK (0x01)
+#define GXEMUL_ETHER_DEV_STATUS_RX_MORE (0x02)
+
+#define GXEMUL_ETHER_DEV_COMMAND_RX (0x00)
+#define GXEMUL_ETHER_DEV_COMMAND_TX (0x01)
+
+#endif /* !_DEV_GXEMUL_ETHER_GXREG_H_ */
Property changes on: trunk/sys/dev/gxemul/ether/gxreg.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/dev/gxemul/ether/if_gx.c
===================================================================
--- trunk/sys/dev/gxemul/ether/if_gx.c (rev 0)
+++ trunk/sys/dev/gxemul/ether/if_gx.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -0,0 +1,399 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2008-2012 Juli Mallett <jmallett at FreeBSD.org>
+ * 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: stable/10/sys/dev/gxemul/ether/if_gx.c 265999 2014-05-14 01:35:43Z ian $
+ */
+
+#include "opt_inet.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/kernel.h>
+#include <sys/mbuf.h>
+#include <sys/lock.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/rman.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+
+#include <net/bpf.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+#include <net/if_var.h>
+#include <net/if_vlan_var.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#endif
+
+#include <machine/cpuregs.h>
+
+#include <dev/gxemul/ether/gxreg.h>
+
+struct gx_softc {
+ struct ifnet *sc_ifp;
+ device_t sc_dev;
+ unsigned sc_port;
+ int sc_flags;
+ struct ifmedia sc_ifmedia;
+ struct resource *sc_intr;
+ void *sc_intr_cookie;
+ struct mtx sc_mtx;
+};
+
+#define GXEMUL_ETHER_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
+#define GXEMUL_ETHER_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
+
+static void gx_identify(driver_t *, device_t);
+static int gx_probe(device_t);
+static int gx_attach(device_t);
+static int gx_detach(device_t);
+static int gx_shutdown(device_t);
+
+static void gx_init(void *);
+static int gx_transmit(struct ifnet *, struct mbuf *);
+
+static int gx_medchange(struct ifnet *);
+static void gx_medstat(struct ifnet *, struct ifmediareq *);
+
+static int gx_ioctl(struct ifnet *, u_long, caddr_t);
+
+static void gx_rx_intr(void *);
+
+static device_method_t gx_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_identify, gx_identify),
+ DEVMETHOD(device_probe, gx_probe),
+ DEVMETHOD(device_attach, gx_attach),
+ DEVMETHOD(device_detach, gx_detach),
+ DEVMETHOD(device_shutdown, gx_shutdown),
+
+ { 0, 0 }
+};
+
+static driver_t gx_driver = {
+ "gx",
+ gx_methods,
+ sizeof (struct gx_softc),
+};
+
+static devclass_t gx_devclass;
+
+DRIVER_MODULE(gx, nexus, gx_driver, gx_devclass, 0, 0);
+
+static void
+gx_identify(driver_t *drv, device_t parent)
+{
+ BUS_ADD_CHILD(parent, 0, "gx", 0);
+}
+
+static int
+gx_probe(device_t dev)
+{
+ if (device_get_unit(dev) != 0)
+ return (ENXIO);
+
+ device_set_desc(dev, "GXemul test Ethernet");
+
+ return (BUS_PROBE_NOWILDCARD);
+}
+
+static int
+gx_attach(device_t dev)
+{
+ struct ifnet *ifp;
+ struct gx_softc *sc;
+ uint8_t mac[6];
+ int error;
+ int rid;
+
+ sc = device_get_softc(dev);
+ sc->sc_dev = dev;
+ sc->sc_port = device_get_unit(dev);
+
+ /* Read MAC address. */
+ GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_MAC, (uintptr_t)mac);
+
+ /* Allocate and establish interrupt. */
+ rid = 0;
+ sc->sc_intr = bus_alloc_resource(sc->sc_dev, SYS_RES_IRQ, &rid,
+ GXEMUL_ETHER_DEV_IRQ - 2, GXEMUL_ETHER_DEV_IRQ - 2, 1, RF_ACTIVE);
+ if (sc->sc_intr == NULL) {
+ device_printf(dev, "unable to allocate IRQ.\n");
+ return (ENXIO);
+ }
+
+ error = bus_setup_intr(sc->sc_dev, sc->sc_intr, INTR_TYPE_NET, NULL,
+ gx_rx_intr, sc, &sc->sc_intr_cookie);
+ if (error != 0) {
+ device_printf(dev, "unable to setup interrupt.\n");
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_intr);
+ return (ENXIO);
+ }
+
+ bus_describe_intr(sc->sc_dev, sc->sc_intr, sc->sc_intr_cookie, "rx");
+
+ ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "cannot allocate ifnet.\n");
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_intr);
+ return (ENOMEM);
+ }
+
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
+ ifp->if_mtu = ETHERMTU;
+ ifp->if_init = gx_init;
+ ifp->if_softc = sc;
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | IFF_ALLMULTI;
+ ifp->if_ioctl = gx_ioctl;
+
+ sc->sc_ifp = ifp;
+ sc->sc_flags = ifp->if_flags;
+
+ ifmedia_init(&sc->sc_ifmedia, 0, gx_medchange, gx_medstat);
+
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL);
+ ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO);
+
+ mtx_init(&sc->sc_mtx, "GXemul Ethernet", NULL, MTX_DEF);
+
+ ether_ifattach(ifp, mac);
+
+ ifp->if_transmit = gx_transmit;
+
+ return (bus_generic_attach(dev));
+}
+
+static int
+gx_detach(device_t dev)
+{
+ struct gx_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_intr);
+ /* XXX Incomplete. */
+
+ return (0);
+}
+
+static int
+gx_shutdown(device_t dev)
+{
+ return (gx_detach(dev));
+}
+
+static void
+gx_init(void *arg)
+{
+ struct ifnet *ifp;
+ struct gx_softc *sc;
+
+ sc = arg;
+ ifp = sc->sc_ifp;
+
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+
+ ifp->if_drv_flags |= IFF_DRV_RUNNING;
+}
+
+static int
+gx_transmit(struct ifnet *ifp, struct mbuf *m)
+{
+ struct gx_softc *sc;
+
+ sc = ifp->if_softc;
+
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != IFF_DRV_RUNNING) {
+ m_freem(m);
+ return (0);
+ }
+
+ GXEMUL_ETHER_LOCK(sc);
+ GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_LENGTH, m->m_pkthdr.len);
+ m_copydata(m, 0, m->m_pkthdr.len, (void *)(uintptr_t)GXEMUL_ETHER_DEV_FUNCTION(GXEMUL_ETHER_DEV_BUFFER));
+ GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_COMMAND, GXEMUL_ETHER_DEV_COMMAND_TX);
+ GXEMUL_ETHER_UNLOCK(sc);
+
+ ETHER_BPF_MTAP(ifp, m);
+
+ ifp->if_opackets++;
+ ifp->if_obytes += m->m_pkthdr.len;
+
+ m_freem(m);
+
+ return (0);
+}
+
+static int
+gx_medchange(struct ifnet *ifp)
+{
+ return (ENOTSUP);
+}
+
+static void
+gx_medstat(struct ifnet *ifp, struct ifmediareq *ifm)
+{
+ struct gx_softc *sc;
+
+ sc = ifp->if_softc;
+
+ /* Lie amazingly. */
+ ifm->ifm_status = IFM_AVALID | IFM_ACTIVE;
+ ifm->ifm_active = IFT_ETHER | IFM_1000_T | IFM_FDX;
+}
+
+static int
+gx_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+{
+ struct gx_softc *sc;
+ struct ifreq *ifr;
+#ifdef INET
+ struct ifaddr *ifa;
+#endif
+ int error;
+
+ sc = ifp->if_softc;
+ ifr = (struct ifreq *)data;
+#ifdef INET
+ ifa = (struct ifaddr *)data;
+#endif
+
+ switch (cmd) {
+ case SIOCSIFADDR:
+#ifdef INET
+ /*
+ * Avoid reinitialization unless it's necessary.
+ */
+ if (ifa->ifa_addr->sa_family == AF_INET) {
+ ifp->if_flags |= IFF_UP;
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ gx_init(sc);
+ arp_ifinit(ifp, ifa);
+
+ return (0);
+ }
+#endif
+ error = ether_ioctl(ifp, cmd, data);
+ if (error != 0)
+ return (error);
+ return (0);
+
+ case SIOCSIFFLAGS:
+ if (ifp->if_flags == sc->sc_flags)
+ return (0);
+ if ((ifp->if_flags & IFF_UP) != 0) {
+ gx_init(sc);
+ } else {
+ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ }
+ }
+ sc->sc_flags = ifp->if_flags;
+ return (0);
+
+ case SIOCSIFMTU:
+ if (ifr->ifr_mtu + ifp->if_data.ifi_hdrlen > GXEMUL_ETHER_DEV_MTU)
+ return (ENOTSUP);
+ return (0);
+
+ case SIOCSIFMEDIA:
+ case SIOCGIFMEDIA:
+ error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, cmd);
+ if (error != 0)
+ return (error);
+ return (0);
+
+ default:
+ error = ether_ioctl(ifp, cmd, data);
+ if (error != 0)
+ return (error);
+ return (0);
+ }
+}
+
+static void
+gx_rx_intr(void *arg)
+{
+ struct gx_softc *sc = arg;
+
+ GXEMUL_ETHER_LOCK(sc);
+ for (;;) {
+ uint64_t status, length;
+ struct mbuf *m;
+
+ /*
+ * XXX
+ * Limit number of packets received at once?
+ */
+ status = GXEMUL_ETHER_DEV_READ(GXEMUL_ETHER_DEV_STATUS);
+ if (status == GXEMUL_ETHER_DEV_STATUS_RX_MORE) {
+ GXEMUL_ETHER_DEV_WRITE(GXEMUL_ETHER_DEV_COMMAND, GXEMUL_ETHER_DEV_COMMAND_RX);
+ continue;
+ }
+ if (status != GXEMUL_ETHER_DEV_STATUS_RX_OK)
+ break;
+ length = GXEMUL_ETHER_DEV_READ(GXEMUL_ETHER_DEV_LENGTH);
+ if (length > MCLBYTES - ETHER_ALIGN) {
+ sc->sc_ifp->if_ierrors++;
+ continue;
+ }
+
+ m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
+ if (m == NULL) {
+ device_printf(sc->sc_dev, "no memory for receive mbuf.\n");
+ sc->sc_ifp->if_iqdrops++;
+ GXEMUL_ETHER_UNLOCK(sc);
+ return;
+ }
+
+ /* Align incoming frame so IP headers are aligned. */
+ m->m_data += ETHER_ALIGN;
+
+ memcpy(m->m_data, (const void *)(uintptr_t)GXEMUL_ETHER_DEV_FUNCTION(GXEMUL_ETHER_DEV_BUFFER), length);
+
+ m->m_pkthdr.rcvif = sc->sc_ifp;
+ m->m_pkthdr.len = m->m_len = length;
+
+ sc->sc_ifp->if_ipackets++;
+
+ GXEMUL_ETHER_UNLOCK(sc);
+
+ (*sc->sc_ifp->if_input)(sc->sc_ifp, m);
+
+ GXEMUL_ETHER_LOCK(sc);
+ }
+ GXEMUL_ETHER_UNLOCK(sc);
+}
Property changes on: trunk/sys/dev/gxemul/ether/if_gx.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/dev/hifn/hifn7751.c
===================================================================
--- trunk/sys/dev/hifn/hifn7751.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/hifn/hifn7751.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $OpenBSD: hifn7751.c,v 1.120 2002/05/17 00:33:34 deraadt Exp $ */
/*-
@@ -41,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/hifn/hifn7751.c 314667 2017-03-04 13:03:31Z avg $");
/*
* Driver for various Hifn encryption processors.
@@ -258,7 +259,7 @@
static void
default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
{
- random_harvest(buf, count, count*NBBY, 0, RANDOM_PURE);
+ random_harvest(buf, count, count*NBBY/2, RANDOM_PURE_HIFN);
}
static u_int
@@ -590,7 +591,7 @@
if (sc->sc_flags & (HIFN_HAS_PUBLIC | HIFN_HAS_RNG))
hifn_init_pubrng(sc);
- callout_init(&sc->sc_tickto, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_tickto, 1);
callout_reset(&sc->sc_tickto, hz, hifn_tick, sc);
return (0);
@@ -768,7 +769,7 @@
sc->sc_rnghz = hz / 100;
else
sc->sc_rnghz = 1;
- callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_rngto, 1);
callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc);
}
Modified: trunk/sys/dev/hifn/hifn7751reg.h
===================================================================
--- trunk/sys/dev/hifn/hifn7751reg.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/hifn/hifn7751reg.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,4 +1,5 @@
/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/hifn/hifn7751reg.h 167755 2007-03-21 03:42:51Z sam $ */
/* $OpenBSD: hifn7751reg.h,v 1.35 2002/04/08 17:49:42 jason Exp $ */
/*-
Modified: trunk/sys/dev/hifn/hifn7751var.h
===================================================================
--- trunk/sys/dev/hifn/hifn7751var.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/hifn/hifn7751var.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,4 +1,5 @@
/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/hifn/hifn7751var.h 213091 2010-09-24 04:46:46Z gonzo $ */
/* $OpenBSD: hifn7751var.h,v 1.42 2002/04/08 17:49:42 jason Exp $ */
/*-
Modified: trunk/sys/dev/hptiop/hptiop.c
===================================================================
--- trunk/sys/dev/hptiop/hptiop.c 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/hptiop/hptiop.c 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* HighPoint RR3xxx/4xxx RAID Driver for FreeBSD
* Copyright (C) 2007-2012 HighPoint Technologies, Inc. All Rights Reserved.
@@ -25,17 +26,13 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/hptiop/hptiop.c 315813 2017-03-23 06:41:13Z mav $");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/cons.h>
-#if (__FreeBSD_version >= 500000)
#include <sys/time.h>
#include <sys/systm.h>
-#else
-#include <machine/clock.h>
-#endif
#include <sys/stat.h>
#include <sys/malloc.h>
@@ -43,11 +40,9 @@
#include <sys/libkern.h>
#include <sys/kernel.h>
-#if (__FreeBSD_version >= 500000)
#include <sys/kthread.h>
#include <sys/mutex.h>
#include <sys/module.h>
-#endif
#include <sys/eventhandler.h>
#include <sys/bus.h>
@@ -62,17 +57,9 @@
#include <vm/vm.h>
#include <vm/pmap.h>
-#if (__FreeBSD_version >= 500000)
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
-#else
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#endif
-#if (__FreeBSD_version <= 500043)
-#include <sys/devicestat.h>
-#endif
#include <cam/cam.h>
#include <cam/cam_ccb.h>
@@ -83,14 +70,11 @@
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
-#if (__FreeBSD_version < 500043)
-#include <sys/bus_private.h>
-#endif
#include <dev/hptiop/hptiop.h>
static const char driver_name[] = "hptiop";
-static const char driver_version[] = "v1.8";
+static const char driver_version[] = "v1.9";
static devclass_t hptiop_devclass;
@@ -177,27 +161,11 @@
.d_close = hptiop_close,
.d_ioctl = hptiop_ioctl,
.d_name = driver_name,
-#if __FreeBSD_version>=503000
.d_version = D_VERSION,
-#endif
-#if (__FreeBSD_version>=503000 && __FreeBSD_version<600034)
- .d_flags = D_NEEDGIANT,
-#endif
-#if __FreeBSD_version<600034
-#if __FreeBSD_version>=501000
- .d_maj = MAJOR_AUTO,
-#else
- .d_maj = HPT_DEV_MAJOR,
-#endif
-#endif
};
-#if __FreeBSD_version < 503000
-#define hba_from_dev(dev) ((struct hpt_iop_hba *)(dev)->si_drv1)
-#else
#define hba_from_dev(dev) \
((struct hpt_iop_hba *)devclass_get_softc(hptiop_devclass, dev2unit(dev)))
-#endif
#define BUS_SPACE_WRT4_ITL(offset, value) bus_space_write_4(hba->bar0t,\
hba->bar0h, offsetof(struct hpt_iopmu_itl, offset), (value))
@@ -245,9 +213,7 @@
int ret = EFAULT;
struct hpt_iop_hba *hba = hba_from_dev(dev);
-#if (__FreeBSD_version >= 500000)
mtx_lock(&Giant);
-#endif
switch (cmd) {
case HPT_DO_IOCONTROL:
@@ -259,9 +225,7 @@
break;
}
-#if (__FreeBSD_version >= 500000)
mtx_unlock(&Giant);
-#endif
return ret;
}
@@ -680,7 +644,7 @@
ccb = (union ccb *)srb->ccb;
- untimeout(hptiop_reset_adapter, hba, ccb->ccb_h.timeout_ch);
+ untimeout(hptiop_reset_adapter, hba, srb->timeout_ch);
if (ccb->ccb_h.flags & CAM_CDB_POINTER)
cdb = ccb->csio.cdb_io.cdb_ptr;
@@ -1437,7 +1401,7 @@
if ((ccb = xpt_alloc_ccb()) == NULL)
return(ENOMEM);
- if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, cam_sim_path(hba->sim),
+ if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(hba->sim),
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
xpt_free_ccb(ccb);
return(EIO);
@@ -1615,10 +1579,8 @@
1,
BUS_SPACE_MAXSIZE_32BIT,
BUS_DMA_ALLOCNOW,
-#if __FreeBSD_version > 502000
NULL,
NULL,
-#endif
&hba->ctlcfg_dmat)) {
device_printf(hba->pcidev, "alloc ctlcfg_dmat failed\n");
return -1;
@@ -1625,11 +1587,7 @@
}
if (bus_dmamem_alloc(hba->ctlcfg_dmat, (void **)&hba->ctlcfg_ptr,
-#if __FreeBSD_version>501000
BUS_DMA_WAITOK | BUS_DMA_COHERENT,
-#else
- BUS_DMA_WAITOK,
-#endif
&hba->ctlcfg_dmamap) != 0) {
device_printf(hba->pcidev,
"bus_dmamem_alloc failed!\n");
@@ -1642,10 +1600,11 @@
MVIOP_IOCTLCFG_SIZE,
hptiop_mv_map_ctlcfg, hba, 0)) {
device_printf(hba->pcidev, "bus_dmamap_load failed!\n");
- if (hba->ctlcfg_dmat)
+ if (hba->ctlcfg_dmat) {
bus_dmamem_free(hba->ctlcfg_dmat,
hba->ctlcfg_ptr, hba->ctlcfg_dmamap);
bus_dma_tag_destroy(hba->ctlcfg_dmat);
+ }
return -1;
}
@@ -1677,10 +1636,8 @@
1,
BUS_SPACE_MAXSIZE_32BIT,
BUS_DMA_ALLOCNOW,
-#if __FreeBSD_version > 502000
NULL,
NULL,
-#endif
&hba->ctlcfg_dmat)) {
device_printf(hba->pcidev, "alloc ctlcfg_dmat failed\n");
return -1;
@@ -1687,11 +1644,7 @@
}
if (bus_dmamem_alloc(hba->ctlcfg_dmat, (void **)&hba->ctlcfg_ptr,
-#if __FreeBSD_version>501000
BUS_DMA_WAITOK | BUS_DMA_COHERENT,
-#else
- BUS_DMA_WAITOK,
-#endif
&hba->ctlcfg_dmamap) != 0) {
device_printf(hba->pcidev,
"bus_dmamem_alloc failed!\n");
@@ -1869,8 +1822,12 @@
switch (id) {
case 0x4520:
+ case 0x4521:
case 0x4522:
sas = 1;
+ case 0x3620:
+ case 0x3622:
+ case 0x3640:
ops = &hptiop_mvfrey_ops;
break;
case 0x4210:
@@ -1936,9 +1893,7 @@
pci_get_bus(dev), pci_get_slot(dev),
pci_get_function(dev), hba->ops));
-#if __FreeBSD_version >=440000
pci_enable_busmaster(dev);
-#endif
hba->pcidev = dev;
hba->pciunit = unit;
@@ -1950,9 +1905,7 @@
goto release_pci_res;
}
-#if (__FreeBSD_version >= 500000)
mtx_init(&hba->lock, "hptioplock", NULL, MTX_DEF);
-#endif
if (bus_dma_tag_create(bus_get_dma_tag(dev),/* PCI parent */
1, /* alignment */
@@ -1964,10 +1917,8 @@
BUS_SPACE_UNRESTRICTED, /* nsegments */
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
0, /* flags */
-#if __FreeBSD_version>502000
NULL, /* lockfunc */
NULL, /* lockfuncarg */
-#endif
&hba->parent_dmat /* tag */))
{
device_printf(dev, "alloc parent_dmat failed\n");
@@ -2014,10 +1965,8 @@
hba->max_sg_count, /* nsegments */
0x20000, /* maxsegsize */
BUS_DMA_ALLOCNOW, /* flags */
-#if __FreeBSD_version>502000
busdma_lock_mutex, /* lockfunc */
&hba->lock, /* lockfuncarg */
-#endif
&hba->io_dmat /* tag */))
{
device_printf(dev, "alloc io_dmat failed\n");
@@ -2034,10 +1983,8 @@
1, /* nsegments */
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
0, /* flags */
-#if __FreeBSD_version>502000
NULL, /* lockfunc */
NULL, /* lockfuncarg */
-#endif
&hba->srb_dmat /* tag */))
{
device_printf(dev, "alloc srb_dmat failed\n");
@@ -2045,11 +1992,7 @@
}
if (bus_dmamem_alloc(hba->srb_dmat, (void **)&hba->uncached_ptr,
-#if __FreeBSD_version>501000
BUS_DMA_WAITOK | BUS_DMA_COHERENT,
-#else
- BUS_DMA_WAITOK,
-#endif
&hba->srb_dmamap) != 0)
{
device_printf(dev, "srb bus_dmamem_alloc failed!\n");
@@ -2070,23 +2013,14 @@
goto srb_dmamap_unload;
}
-#if __FreeBSD_version <700000
hba->sim = cam_sim_alloc(hptiop_action, hptiop_poll, driver_name,
- hba, unit, hba->max_requests - 1, 1, devq);
-#else
- hba->sim = cam_sim_alloc(hptiop_action, hptiop_poll, driver_name,
hba, unit, &Giant, hba->max_requests - 1, 1, devq);
-#endif
if (!hba->sim) {
device_printf(dev, "cam_sim_alloc failed\n");
cam_simq_free(devq);
goto srb_dmamap_unload;
}
-#if __FreeBSD_version <700000
- if (xpt_bus_register(hba->sim, 0) != CAM_SUCCESS)
-#else
if (xpt_bus_register(hba->sim, dev, 0) != CAM_SUCCESS)
-#endif
{
device_printf(dev, "xpt_bus_register failed\n");
goto free_cam_sim;
@@ -2123,13 +2057,8 @@
goto free_hba_path;
}
-#if __FreeBSD_version <700000
if (bus_setup_intr(hba->pcidev, hba->irq_res, INTR_TYPE_CAM,
- hptiop_pci_intr, hba, &hba->irq_handle))
-#else
- if (bus_setup_intr(hba->pcidev, hba->irq_res, INTR_TYPE_CAM,
NULL, hptiop_pci_intr, hba, &hba->irq_handle))
-#endif
{
device_printf(dev, "allocate intr function failed!\n");
goto free_irq_resource;
@@ -2148,9 +2077,6 @@
UID_ROOT, GID_WHEEL /*GID_OPERATOR*/,
S_IRUSR | S_IWUSR, "%s%d", driver_name, unit);
-#if __FreeBSD_version < 503000
- hba->ioctl_dev->si_drv1 = hba;
-#endif
return 0;
@@ -2359,6 +2285,7 @@
{
struct hpt_iop_hba * hba = (struct hpt_iop_hba *)cam_sim_softc(sim);
struct hpt_iop_srb * srb;
+ int error;
switch (ccb->ccb_h.func_code) {
@@ -2381,54 +2308,24 @@
}
srb->ccb = ccb;
+ error = bus_dmamap_load_ccb(hba->io_dmat,
+ srb->dma_map,
+ ccb,
+ hptiop_post_scsi_command,
+ srb,
+ 0);
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE)
- hptiop_post_scsi_command(srb, NULL, 0, 0);
- else if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int error;
-
- error = bus_dmamap_load(hba->io_dmat,
- srb->dma_map,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
- hptiop_post_scsi_command,
- srb, 0);
-
- if (error && error != EINPROGRESS) {
- device_printf(hba->pcidev,
- "%d bus_dmamap_load error %d",
- hba->pciunit, error);
- xpt_freeze_simq(hba->sim, 1);
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
-invalid:
- hptiop_free_srb(hba, srb);
- xpt_done(ccb);
- goto scsi_done;
- }
- }
- else {
- device_printf(hba->pcidev,
- "CAM_DATA_PHYS not supported");
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
- goto invalid;
- }
+ if (error && error != EINPROGRESS) {
+ device_printf(hba->pcidev,
+ "%d bus_dmamap_load error %d",
+ hba->pciunit, error);
+ xpt_freeze_simq(hba->sim, 1);
+ ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+ hptiop_free_srb(hba, srb);
+ xpt_done(ccb);
+ goto scsi_done;
}
- else {
- struct bus_dma_segment *segs;
- if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0 ||
- (ccb->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- device_printf(hba->pcidev, "SCSI cmd failed");
- ccb->ccb_h.status=CAM_PROVIDE_FAIL;
- goto invalid;
- }
-
- segs = (struct bus_dma_segment *)ccb->csio.data_ptr;
- hptiop_post_scsi_command(srb, segs,
- ccb->csio.sglist_cnt, 0);
- }
-
scsi_done:
hptiop_unlock_adapter(hba);
return;
@@ -2447,15 +2344,7 @@
break;
case XPT_CALC_GEOMETRY:
-#if __FreeBSD_version >= 500000
cam_calc_geometry(&ccb->ccg, 1);
-#else
- ccb->ccg.heads = 255;
- ccb->ccg.secs_per_track = 63;
- ccb->ccg.cylinders = ccb->ccg.volume_size /
- (ccb->ccg.heads * ccb->ccg.secs_per_track);
- ccb->ccb_h.status = CAM_REQ_CMP;
-#endif
break;
case XPT_PATH_INQ:
@@ -2474,9 +2363,9 @@
cpi->initiator_id = hba->max_devices;
cpi->base_transfer_speed = 3300;
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN);
- strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+ strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+ strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN);
+ strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
cpi->transport = XPORT_SPI;
cpi->transport_version = 2;
cpi->protocol = PROTO_SCSI;
@@ -2517,7 +2406,7 @@
iop_req32 = BUS_SPACE_RD4_ITL(inbound_queue);
if (iop_req32 == IOPMU_QUEUE_EMPTY) {
- device_printf(hba->pcidev, "invaild req offset\n");
+ device_printf(hba->pcidev, "invalid req offset\n");
ccb->ccb_h.status = CAM_BUSY;
bus_dmamap_unload(hba->io_dmat, srb->dma_map);
hptiop_free_srb(hba, srb);
@@ -2741,7 +2630,7 @@
BUS_SPACE_RD4_MVFREY2(inbound_write_ptr);
if (req->header.type == IOP_REQUEST_TYPE_SCSI_COMMAND) {
- ccb->ccb_h.timeout_ch = timeout(hptiop_reset_adapter, hba, 20*hz);
+ srb->timeout_ch = timeout(hptiop_reset_adapter, hba, 20*hz);
}
}
@@ -2853,6 +2742,7 @@
tmp_srb->phy_addr = phy_addr;
}
+ callout_handle_init(&tmp_srb->timeout_ch);
hptiop_free_srb(hba, tmp_srb);
hba->srb[i] = tmp_srb;
phy_addr += HPT_SRB_MAX_SIZE;
Modified: trunk/sys/dev/hptiop/hptiop.h
===================================================================
--- trunk/sys/dev/hptiop/hptiop.h 2018-05-27 23:50:14 UTC (rev 10106)
+++ trunk/sys/dev/hptiop/hptiop.h 2018-05-27 23:50:56 UTC (rev 10107)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* HighPoint RR3xxx/4xxx RAID Driver for FreeBSD
* Copyright (C) 2007-2012 HighPoint Technologies, Inc. All Rights Reserved.
@@ -27,7 +28,7 @@
#define _HPTIOP_H
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/hptiop/hptiop.h 255871 2013-09-25 17:16:21Z scottl $");
#define DBG 0
@@ -333,17 +334,9 @@
#define HPT_IOCTL_FLAG_OPEN 1
#define HPT_CTL_CODE_BSD_TO_IOP(x) ((x)-0xff00)
-#if __FreeBSD_version>503000
typedef struct cdev * ioctl_dev_t;
-#else
-typedef dev_t ioctl_dev_t;
-#endif
-#if __FreeBSD_version >= 500000
typedef struct thread * ioctl_thread_t;
-#else
-typedef struct proc * ioctl_thread_t;
-#endif
struct hpt_iop_hba {
struct hptiop_adapter_ops *ops;
@@ -425,11 +418,7 @@
struct cam_sim *sim;
struct cam_path *path;
void *req;
-#if (__FreeBSD_version >= 500000)
struct mtx lock;
-#else
- int hpt_splx;
-#endif
#define HPT_IOCTL_FLAG_OPEN 1
u_int32_t flag;
struct hpt_iop_srb* srb[HPT_SRB_MAX_QUEUE_SIZE];
@@ -472,21 +461,11 @@
u_int64_t phy_addr;
u_int32_t srb_flag;
int index;
+ struct callout_handle timeout_ch;
};
-#if __FreeBSD_version >= 500000
#define hptiop_lock_adapter(hba) mtx_lock(&(hba)->lock)
#define hptiop_unlock_adapter(hba) mtx_unlock(&(hba)->lock)
-#else
-static __inline void hptiop_lock_adapter(struct hpt_iop_hba *hba)
-{
- hba->hpt_splx = splcam();
-}
-static __inline void hptiop_unlock_adapter(struct hpt_iop_hba *hba)
-{
- splx(hba->hpt_splx);
-}
-#endif
#define HPT_OSM_TIMEOUT (20*hz) /* timeout value for OS commands */
@@ -499,24 +478,12 @@
int retval;
-#if __FreeBSD_version >= 500000
retval = msleep(ident, &hba->lock, priority, wmesg, timo);
-#else
- asleep(ident, priority, wmesg, timo);
- hptiop_unlock_adapter(hba);
- retval = await(priority, timo);
- hptiop_lock_adapter(hba);
-#endif
return retval;
}
-#if __FreeBSD_version < 501000
-#define READ_16 0x88
-#define WRITE_16 0x8a
-#define SERVICE_ACTION_IN 0x9e
-#endif
#define HPT_DEV_MAJOR 200
More information about the Midnightbsd-cvs
mailing list