提交 1e161063 编写于 作者: W wenjun

add OpenHarmony 1.0 baseline

上级 914385f5
### 该问题是怎么引起的?
### 重现步骤
### 报错信息
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
# $FreeBSD: releng/11.4/COPYRIGHT 356232 2019-12-31 16:04:16Z gjb $
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
The compilation of software known as FreeBSD is distributed under the
following terms:
Copyright (c) 1992-2020 The FreeBSD Project.
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.
The 4.4BSD and 4.4BSD-Lite software is distributed under the following
terms:
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
Releases is copyrighted by The Regents of the University of California.
Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. 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.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the University of
California, Berkeley and its contributors.
4. 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.
THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
The Institute of Electrical and Electronics Engineers and the American
National Standards Committee X3, on Information Processing Systems have
given us permission to reprint portions of their documentation.
In the following statement, the phrase ``this text'' refers to portions
of the system documentation.
Portions of this text are reprinted and reproduced in electronic form in
the second BSD Networking Software Release, from IEEE Std 1003.1-1988, IEEE
Standard Portable Operating System Interface for Computer Environments
(POSIX), copyright C 1988 by the Institute of Electrical and Electronics
Engineers, Inc. In the event of any discrepancy between these versions
and the original IEEE Standard, the original IEEE Standard is the referee
document.
In the following statement, the phrase ``This material'' refers to portions
of the system documentation.
This material is reproduced with permission from American National
Standards Committee X3, on Information Processing Systems. Computer and
Business Equipment Manufacturers Association (CBEMA), 311 First St., NW,
Suite 500, Washington, DC 20001-2178. The developmental work of
Programming Language C was completed by the X3J11 Technical Committee.
The views and conclusions contained in the software and documentation are
those of the authors and should not be interpreted as representing official
policies, either expressed or implied, of the Regents of the University
of California.
NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ("BSD")
source has been updated. The copyright addendum may be found at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change and is
included below.
July 22, 1999
To All Licensees, Distributors of Any Version of BSD:
As you know, certain of the Berkeley Software Distribution ("BSD") source
code files require that further distributions of products containing all or
portions of the software, acknowledge within their advertising materials
that such products contain software developed by UC Berkeley and its
contributors.
Specifically, the provision reads:
" * 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors."
Effective immediately, licensees and distributors are no longer required to
include the acknowledgement within advertising materials. Accordingly, the
foregoing paragraph of those BSD Unix files containing it is hereby deleted
in its entirety.
William Hoskins
Director, Office of Technology Licensing
University of California, Berkeley
$FreeBSD: releng/11.4/LOCKS 255635 2013-09-17 14:19:05Z trasz $
This file documents formal review/approval requirements that have been
approved by core.
subsystem login expires notes
--------------------------------------
Special cases:
releng/4.* Requires Security Officer approval.
releng/5.* Requires Security Officer approval.
releng/6.* Requires Security Officer approval.
releng/7.* Requires Security Officer approval.
releng/8.* Requires Security Officer approval.
head/sys/dev/random Requires Security Officer approval.
head/sys/libkern/arc4random.c Requires Security Officer approval.
stable/*/sys/dev/random Requires Security Officer approval.
stable/*/sys/libkern/arc4random.c Requires Security Officer approval.
$FreeBSD: releng/11.4/MAINTAINERS 360660 2020-05-05 17:10:49Z dim $
Please note that the content of this file is strictly advisory.
No locks listed here are valid. The only strict review requirements
are granted by core. These are documented in head/LOCKS and enforced
by svnadmin/conf/approvers.
The source tree is a community effort. However, some folks go to the
trouble of looking after particular areas of the tree. In return for
their active caretaking of the code it is polite to coordinate changes
with them. This is a list of people who have expressed an interest in
part of the code or listed their active caretaking role so that other
committers can easily find somebody who is familiar with it. The notes
should specify if there is a 3rd party source tree involved or other
things that should be kept in mind.
However, this is not a 'big stick', it is an offer to help and a source
of guidance. It does not override the communal nature of the tree.
It is not a registry of 'turf' or private property.
***
This list is prone to becoming stale quickly. The best way to find the recent
maintainer of a sub-system is to check recent logs for that directory or
sub-system.
***
***
Maintainers are encouraged to visit:
https://reviews.freebsd.org/herald
and configure notifications for parts of the tree which they maintain.
Notifications can automatically be sent when someone proposes a revision or
makes a commit to the specified subtree.
***
subsystem login notes
-----------------------------
atf freebsd-testing,jmmv,ngie Pre-commit review requested.
ath(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
contrib/libcxxrt dim,emaste Pre-commit review preferred.
contrib/llvm-project/compiler-rt dim Pre-commit review preferred.
contrib/llvm-project/libcxx dim Pre-commit review preferred.
contrib/llvm-project/libunwind dim,emaste,jhb Pre-commit review preferred.
contrib/llvm-project/lldb dim,emaste Pre-commit review preferred.
contrib/llvm-project/llvm dim Pre-commit review preferred.
contrib/llvm-project/openmp dim,emaste Pre-commit review preferred.
contrib/netbsd-tests freebsd-testing,ngie Pre-commit review requested.
contrib/pjdfstest freebsd-testing,ngie,pjd Pre-commit review requested.
dev/usb/wlan adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
*env(3) secteam Due to the problematic security history of this
code, please have patches reviewed by secteam.
etc/mail gshapiro Pre-commit review requested. Keep in sync with -STABLE.
etc/sendmail gshapiro Pre-commit review requested. Keep in sync with -STABLE.
fetch des Pre-commit review requested, email only.
geli pjd Pre-commit review requested (both sys/geom/eli/ and sbin/geom/class/eli/).
isci(4) jimharris Pre-commit review requested.
iwm(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
iwn(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
kqueue jmg Pre-commit review requested. Documentation Required.
libdpv dteske Pre-commit review requested. Keep in sync with dpv(1).
libfetch des Pre-commit review requested, email only.
libfigpar dteske Pre-commit review requested.
libpam des Pre-commit review requested, email only.
linprocfs des Pre-commit review requested, email only.
lpr gad Pre-commit review requested, particularly for
lpd/recvjob.c and lpd/printjob.c.
nanobsd imp Pre-commit phabricator review requested.
net80211 adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
nfs freebsd-fs@FreeBSD.org, rmacklem is best for reviews.
nis(8), yp(8) araujo Pre-commit review requested.
nvd(4) jimharris Pre-commit review requested.
nvme(4) jimharris Pre-commit review requested.
nvmecontrol(8) jimharris Pre-commit review requested.
opencrypto jmg Pre-commit review requested. Documentation Required.
openssh des Pre-commit review requested, email only.
openssl benl,jkim Pre-commit review requested.
otus(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
pci bus imp,jhb Pre-commit review requested.
pmcstudy(8) rrs Pre-commit review requested.
procfs des Pre-commit review requested, email only.
pseudofs des Pre-commit review requested, email only.
release/release.sh gjb,re Pre-commit review and regression tests
requested.
sctp rrs,tuexen Pre-commit review requested (changes need to be backported to github).
sendmail gshapiro Pre-commit review requested.
sh(1) jilles Pre-commit review requested. This also applies
to kill(1), printf(1) and test(1) which are
compiled in as builtins.
share/mk imp, bapt, bdrewery, emaste, sjg Make is hard.
share/mk/*.test.mk freebsd-testing,ngie (same list as share/mk too) Pre-commit review requested.
stand/forth dteske Pre-commit review requested.
sys/compat/linuxkpi hselasky If in doubt, ask.
sys/dev/e1000 erj Pre-commit phabricator review requested.
sys/dev/ixgbe erj Pre-commit phabricator review requested.
sys/dev/ixl erj Pre-commit phabricator review requested.
sys/dev/sound/usb hselasky If in doubt, ask.
sys/dev/usb hselasky If in doubt, ask.
sys/netinet/ip_carp.c glebius Pre-commit review recommended.
sys/netpfil/pf kp,glebius Pre-commit review recommended.
tests freebsd-testing,ngie Pre-commit review requested.
usr.sbin/bsdconfig dteske Pre-commit phabricator review requested.
usr.sbin/dpv dteske Pre-commit review requested. Keep in sync with libdpv.
usr.sbin/pkg pkg@ Please coordinate behavior or flag changes with pkg team.
usr.sbin/sysrc dteske Pre-commit phabricator review requested. Keep in sync with bsdconfig(8) sysrc.subr.
vmm(4) neel,grehan Pre-commit review requested.
autofs(5) trasz Pre-commit review recommended.
iscsi(4) trasz Pre-commit review recommended.
rctl(8) trasz Pre-commit review recommended.
This is the top level of the FreeBSD source directory. This file
was last revised on:
$FreeBSD: releng/11.4/README 329145 2018-02-12 01:08:44Z kevans $
For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).
The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree. See build(7)
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.
The `buildkernel` and `installkernel` targets build and install
the kernel and the modules (see below). Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.
Building a kernel is a somewhat more involved process. See build(7), config(8),
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information.
Note: If you want to build and install the kernel with the
`buildkernel` and `installkernel` targets, you might need to build
world before. More information is available in the handbook.
The kernel configuration files reside in the sys/<arch>/conf
sub-directory. GENERIC is the default configuration used in release builds.
NOTES contains entries and documentation for all possible
devices, not just those commonly used.
Source Roadmap:
---------------
bin System/user commands.
cddl Various commands and libraries under the Common Development
and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Various commands and libraries under the GNU Public License.
Please see gnu/COPYING* for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources.
tests Regression tests which can be run by Kyua. See tests/README
for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.
For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html
此差异已折叠。
/* $NetBSD: memcpy_arm.S,v 1.1 2003/10/14 07:51:45 scw Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Neil A. Carson and Mark Brinicombe
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 "asm.h"
// We do not need to check whether the addresses are in the
// kernel or virtual address spaces, since we only access them
// using user privileges.
.syntax unified
.arm
// size_t _arm_user_copy(void *dst, const void *src, size_t len)
FUNCTION(_arm_user_copy)
/* save leaf functions having to store this away */
stmdb sp!, {r0, r1, r2, lr} /* _arm_user_copy() returns dest addr */
subs r2, r2, #4
blt .Lmemcpy_l4 /* less than 4 bytes */
ands r12, r0, #3
bne .Lmemcpy_destul /* oh unaligned destination addr */
ands r12, r1, #3
bne .Lmemcpy_srcul /* oh unaligned source addr */
.Lmemcpy_t8:
/* We have aligned source and destination */
subs r2, r2, #8
blt .Lmemcpy_l12 /* less than 12 bytes (4 from above) */
subs r2, r2, #0x14
blt .Lmemcpy_l32 /* less than 32 bytes (12 from above) */
stmdb sp!, {r4} /* borrow r4 */
/* blat 32 bytes at a time */
/* XXX for really big copies perhaps we should use more registers */
.Lmemcpy_loop32:
0: ldmia r1!, {r3, r4, r12, lr}
1: stmia r0!, {r3, r4, r12, lr}
2: ldmia r1!, {r3, r4, r12, lr}
3: stmia r0!, {r3, r4, r12, lr}
subs r2, r2, #0x20
bge .Lmemcpy_loop32
cmn r2, #0x10
4: ldmiage r1!, {r3, r4, r12, lr} /* blat a remaining 16 bytes */
5: stmiage r0!, {r3, r4, r12, lr}
subge r2, r2, #0x10
ldmia sp!, {r4} /* return r4 */
.Lmemcpy_l32:
adds r2, r2, #0x14
/* blat 12 bytes at a time */
.Lmemcpy_loop12:
6: ldmiage r1!, {r3, r12, lr}
7: stmiage r0!, {r3, r12, lr}
subsge r2, r2, #0x0c
bge .Lmemcpy_loop12
.Lmemcpy_l12:
adds r2, r2, #8
blt .Lmemcpy_l4
subs r2, r2, #4
8: ldrlt r3, [r1], #4
9: strlt r3, [r0], #4
10: ldmiage r1!, {r3, r12}
11: stmiage r0!, {r3, r12}
subge r2, r2, #4
.Lmemcpy_l4:
/* less than 4 bytes to go */
adds r2, r2, #4
beq .Lmemcpy_return
/* copy the crud byte at a time */
cmp r2, #2
12: ldrb r3, [r1], #1
13: strb r3, [r0], #1
14: ldrbge r3, [r1], #1
15: strbge r3, [r0], #1
16: ldrbgt r3, [r1], #1
17: strbgt r3, [r0], #1
.Lmemcpy_return:
ldmia sp!, {r0, r1, r2, lr}
mov r0, 0
bx lr
/* erg - unaligned destination */
.Lmemcpy_destul:
rsb r12, r12, #4
cmp r12, #2
/* align destination with byte copies */
18: ldrb r3, [r1], #1
19: strb r3, [r0], #1
20: ldrbge r3, [r1], #1
21: strbge r3, [r0], #1
22: ldrbgt r3, [r1], #1
23: strbgt r3, [r0], #1
subs r2, r2, r12
blt .Lmemcpy_l4 /* less the 4 bytes */
ands r12, r1, #3
beq .Lmemcpy_t8 /* we have an aligned source */
/* erg - unaligned source */
/* This is where it gets nasty ... */
.Lmemcpy_srcul:
bic r1, r1, #3
24: ldr lr, [r1], #4
cmp r12, #2
bgt .Lmemcpy_srcul3
beq .Lmemcpy_srcul2
cmp r2, #0x0c
blt .Lmemcpy_srcul1loop4
sub r2, r2, #0x0c
stmdb sp!, {r4, r5}
.Lmemcpy_srcul1loop16:
mov r3, lr, lsr #8
25: ldmia r1!, {r4, r5, r12, lr}
orr r3, r3, r4, lsl #24
mov r4, r4, lsr #8
orr r4, r4, r5, lsl #24
mov r5, r5, lsr #8
orr r5, r5, r12, lsl #24
mov r12, r12, lsr #8
orr r12, r12, lr, lsl #24
26: stmia r0!, {r3-r5, r12}
subs r2, r2, #0x10
bge .Lmemcpy_srcul1loop16
ldmia sp!, {r4, r5}
adds r2, r2, #0x0c
blt .Lmemcpy_srcul1l4
.Lmemcpy_srcul1loop4:
mov r12, lr, lsr #8
27: ldr lr, [r1], #4
orr r12, r12, lr, lsl #24
28: str r12, [r0], #4
subs r2, r2, #4
bge .Lmemcpy_srcul1loop4
.Lmemcpy_srcul1l4:
sub r1, r1, #3
b .Lmemcpy_l4
.Lmemcpy_srcul2:
cmp r2, #0x0c
blt .Lmemcpy_srcul2loop4
sub r2, r2, #0x0c
stmdb sp!, {r4, r5}
.Lmemcpy_srcul2loop16:
mov r3, lr, lsr #16
29: ldmia r1!, {r4, r5, r12, lr}
orr r3, r3, r4, lsl #16
mov r4, r4, lsr #16
orr r4, r4, r5, lsl #16
mov r5, r5, lsr #16
orr r5, r5, r12, lsl #16
mov r12, r12, lsr #16
orr r12, r12, lr, lsl #16
30: stmia r0!, {r3-r5, r12}
subs r2, r2, #0x10
bge .Lmemcpy_srcul2loop16
ldmia sp!, {r4, r5}
adds r2, r2, #0x0c
blt .Lmemcpy_srcul2l4
.Lmemcpy_srcul2loop4:
mov r12, lr, lsr #16
31: ldr lr, [r1], #4
orr r12, r12, lr, lsl #16
32: str r12, [r0], #4
subs r2, r2, #4
bge .Lmemcpy_srcul2loop4
.Lmemcpy_srcul2l4:
sub r1, r1, #2
b .Lmemcpy_l4
.Lmemcpy_srcul3:
cmp r2, #0x0c
blt .Lmemcpy_srcul3loop4
sub r2, r2, #0x0c
stmdb sp!, {r4, r5}
.Lmemcpy_srcul3loop16:
mov r3, lr, lsr #24
33: ldmia r1!, {r4, r5, r12, lr}
orr r3, r3, r4, lsl #8
mov r4, r4, lsr #24
orr r4, r4, r5, lsl #8
mov r5, r5, lsr #24
orr r5, r5, r12, lsl #8
mov r12, r12, lsr #24
orr r12, r12, lr, lsl #8
34: stmia r0!, {r3-r5, r12}
subs r2, r2, #0x10
bge .Lmemcpy_srcul3loop16
ldmia sp!, {r4, r5}
adds r2, r2, #0x0c
blt .Lmemcpy_srcul3l4
.Lmemcpy_srcul3loop4:
mov r12, lr, lsr #24
35: ldr lr, [r1], #4
orr r12, r12, lr, lsl #8
36: str r12, [r0], #4
subs r2, r2, #4
bge .Lmemcpy_srcul3loop4
.Lmemcpy_srcul3l4:
sub r1, r1, #1
b .Lmemcpy_l4
.Lfix_return1:
ldmia sp!, {r4}
.Lfix_return2:
ldmia sp!, {r0, r1}
cmp r0, r1
bhs .Lfix_return
sub r0, r2, r0
b .Lfix_return_done
.Lfix_return:
sub r0, r2, r1
.Lfix_return_done:
ldmia sp!, {r2, lr}
sub r0, r2, r0
bx lr
.Lfix_return3:
ldmia sp!, {r4, r5}
b .Lfix_return2
.pushsection __exc_table, "a"
.long 0b, .Lfix_return1
.long 1b, .Lfix_return1
.long 2b, .Lfix_return1
.long 3b, .Lfix_return1
.long 4b, .Lfix_return1
.long 5b, .Lfix_return1
.long 6b, .Lfix_return2
.long 7b, .Lfix_return2
.long 8b, .Lfix_return2
.long 9b, .Lfix_return2
.long 10b, .Lfix_return2
.long 11b, .Lfix_return2
.long 12b, .Lfix_return2
.long 13b, .Lfix_return2
.long 14b, .Lfix_return2
.long 15b, .Lfix_return2
.long 16b, .Lfix_return2
.long 17b, .Lfix_return2
.long 18b, .Lfix_return2
.long 19b, .Lfix_return2
.long 20b, .Lfix_return2
.long 21b, .Lfix_return2
.long 22b, .Lfix_return2
.long 23b, .Lfix_return2
.long 24b, .Lfix_return2
.long 25b, .Lfix_return3
.long 26b, .Lfix_return3
.long 27b, .Lfix_return2
.long 28b, .Lfix_return2
.long 29b, .Lfix_return3
.long 30b, .Lfix_return3
.long 31b, .Lfix_return2
.long 32b, .Lfix_return2
.long 33b, .Lfix_return3
.long 34b, .Lfix_return3
.long 35b, .Lfix_return2
.long 36b, .Lfix_return2
.popsection
/* $FreeBSD: releng/11.4/stand/kshim/bsd_busspace.c 291400 2015-11-27 18:14:45Z zbb $ */
/*-
* Copyright (c) 2013 Hans Petter Selasky. 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 "implementation/freebsd_sys.h"
struct burst {
uint32_t dw0;
uint32_t dw1;
uint32_t dw2;
uint32_t dw3;
uint32_t dw4;
uint32_t dw5;
uint32_t dw6;
uint32_t dw7;
};
void bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t data);
void bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t data);
void bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t data);
uint8_t bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
uint16_t bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
uint32_t bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
void bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint16_t *datap, bus_size_t count);
void bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint16_t *datap, bus_size_t count);
void bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void bus_space_read_region_1(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_write_region_1(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_read_region_4(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void bus_space_write_region_4(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void
bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint8_t *datap, bus_size_t count)
{
while (count--) {
*datap++ = bus_space_read_1(t, h, offset);
}
}
void
bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint16_t *datap, bus_size_t count)
{
while (count--) {
*datap++ = bus_space_read_2(t, h, offset);
}
}
void
bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint32_t *datap, bus_size_t count)
{
h += offset;
while (count--) {
*datap++ = *((volatile uint32_t *)h);
}
}
void
bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint8_t *datap, bus_size_t count)
{
while (count--) {
uint8_t temp = *datap++;
bus_space_write_1(t, h, offset, temp);
}
}
void
bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint16_t *datap, bus_size_t count)
{
while (count--) {
uint16_t temp = *datap++;
bus_space_write_2(t, h, offset, temp);
}
}
void
bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint32_t *datap, bus_size_t count)
{
h += offset;
while (count--) {
*((volatile uint32_t *)h) = *datap++;
}
}
void
bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint8_t data)
{
*((volatile uint8_t *)(h + offset)) = data;
}
void
bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint16_t data)
{
*((volatile uint16_t *)(h + offset)) = data;
}
void
bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint32_t data)
{
*((volatile uint32_t *)(h + offset)) = data;
}
uint8_t
bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset)
{
return (*((volatile uint8_t *)(h + offset)));
}
uint16_t
bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset)
{
return (*((volatile uint16_t *)(h + offset)));
}
uint32_t
bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset)
{
return (*((volatile uint32_t *)(h + offset)));
}
void
bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint8_t *datap, bus_size_t count)
{
h += offset;
while (count--) {
*datap++ = *((volatile uint8_t *)h);
h += 1;
}
}
void
bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint8_t *datap, bus_size_t count)
{
h += offset;
while (count--) {
*((volatile uint8_t *)h) = *datap++;
h += 1;
}
}
void
bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint32_t *datap, bus_size_t count)
{
enum { BURST = sizeof(struct burst) / 4 };
h += offset;
while (count >= BURST) {
*(struct burst *)datap = *((/* volatile */ struct burst *)h);
h += BURST * 4;
datap += BURST;
count -= BURST;
}
while (count--) {
*datap++ = *((volatile uint32_t *)h);
h += 4;
}
}
void
bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h,
bus_size_t offset, uint32_t *datap, bus_size_t count)
{
enum { BURST = sizeof(struct burst) / 4 };
h += offset;
while (count >= BURST) {
*((/* volatile */ struct burst *)h) = *(struct burst *)datap;
h += BURST * 4;
datap += BURST;
count -= BURST;
}
while (count--) {
*((volatile uint32_t *)h) = *datap++;
h += 4;
}
}
/* $FreeBSD: releng/11.4/stand/kshim/bsd_kernel.c 315221 2017-03-14 02:06:03Z pfg $ */
/*-
* Copyright (c) 2013 Hans Petter Selasky. 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 "implementation/global_implementation.h"
#ifdef LOSCFG_DRIVERS_USB_HOST_DRIVER
extern volatile uint8_t g_device_is_ready;
#endif
#undef USB_DEBUG_VAR
#define USB_DEBUG_VAR usb_debug
/*------------------------------------------------------------------------*
* Implementation of mutex API
*------------------------------------------------------------------------*/
struct mtx Giant = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
struct mtx Gcall = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
/*------------------------------------------------------------------------*
* Implementation of device API
*------------------------------------------------------------------------*/
#ifdef LOSCFG_USB_DEBUG
static uint8_t
devclass_equal(const char *a, const char *b)
{
char ta, tb;
if (a == b)
return (1);
if(!a || !b)
return (0);
while (1) {
ta = *a;
tb = *b;
if (ta != tb)
return (0);
if (ta == 0)
break;
a++;
b++;
}
return (1);
}
static TAILQ_HEAD(, debug_module_data) debug_module_head =
TAILQ_HEAD_INITIALIZER(debug_module_head);
void
debug_module_register(void *data)
{
struct debug_module_data *mdata = data;
TAILQ_INSERT_TAIL(&debug_module_head, mdata, entry);
}
void
debug_module_unregister(void *data)
{
struct debug_module_data *mdata = data;
TAILQ_REMOVE(&debug_module_head, mdata, entry);
}
struct debug_module_data *
get_debug_module(const char *modname)
{
static struct debug_module_data *mod;
TAILQ_FOREACH(mod, &debug_module_head, entry) {
if (devclass_equal(mod->mod_name, modname)) {
return (mod);
}
}
return (NULL);
}
void
debug_module_dump(void)
{
const struct debug_module_data *mod;
TAILQ_FOREACH(mod, &debug_module_head, entry) {
PRINTK("%s\n", mod->mod_name);
}
}
#endif
#undef USB_DEBUG_VAR
/* $FreeBSD: releng/11.4/stand/kshim/bsd_kernel.h 329183 2018-02-12 20:51:28Z kevans $ */
/*-
* Copyright (c) 2011 Hans Petter Selasky. 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.
*/
#ifndef _BSD_KERNEL_H_
#define _BSD_KERNEL_H_
#include <los_typedef.h>
#include <stdint.h>
#define _KERNEL
#include "sys/module.h"
#include "sys/bus.h"
#define __FreeBSD_version 1000000
#define rebooting 0
#define M_USB 0
#define M_USBDEV 0
#define USB_PROC_MAX 3
#define M_DEVBUF 1
#define SYSCTL_DECL(...)
#define SYSCTL_INT(...)
#define TUNABLE_INT(...)
#define EVENTHANDLER_DECLARE(...)
#define EVENTHANDLER_INVOKE(...)
#define SCHEDULER_STOPPED(x) (0)
#define PI_SWI(...) (0)
#define UNIQ_NAME(x) x
#define UNIQ_NAME_STR(x) #x
#define hz LOSCFG_BASE_CORE_TICK_PER_SECOND
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
typedef unsigned long bus_addr_t;
typedef unsigned long bus_size_t;
typedef void *bus_dmamap_t;
typedef void *bus_dma_tag_t;
typedef unsigned long bus_space_handle_t;
typedef struct bus_dma_segment {
bus_addr_t ds_addr; /* DMA address */
bus_size_t ds_len; /* length of transfer */
} bus_dma_segment_t;
typedef enum {
BUS_DMA_LOCK = 0x01,
BUS_DMA_UNLOCK = 0x02,
} bus_dma_lock_op_t;
extern struct mtx Giant;
#define CUR_TICKS (LOS_TickCountGet() & 0xFFFFFFFF)
#ifdef LOSCFG_USB_DEBUG
#define DEBUG_MODULE(name, func) \
/* static */struct debug_module_data debug_##name##_mod = { \
func, #name, { 0, 0 } };
struct debug_module_data {
void (*callback) (int arg);
const char *mod_name;
TAILQ_ENTRY(debug_module_data) entry;
};
void debug_module_register(void *data);
void debug_module_unregister(void *data);
struct debug_module_data *get_debug_module(const char *modname);
void debug_module_dump(void);
#define usb_debug(fmt, ...) \
dprintf("[USB_DEBUG]: In %s %d, " fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define usb_debug(fmt, ...)
#endif
#define usb_err(fmt, ...) \
dprintf("[USB_ERR]: In %s %d, " fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__);
#define device_printf(dev, fmt,...) \
dprintf("%s (%s): " fmt, __FUNCTION__, device_get_nameunit(dev), ##__VA_ARGS__)
#define bus_get_dma_tag(...) (NULL)
/* BUS SPACE API */
void module_register(void *);
void module_unregister(void *);
/* USB */
typedef int usb_handle_request_t (device_t dev, const void *req, void **pptr, uint16_t *plen,
uint16_t offset, uint8_t *pstate);
typedef int usb_take_controller_t (device_t dev);
/* set some defaults */
#ifndef USB_POOL_SIZE
#define USB_POOL_SIZE (1024*1024) /* 1 MByte */
#endif
#ifndef __DECONST
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
#endif
/* BUS SPACE API */
void bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint8_t data);
void bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint16_t data);
void bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, uint32_t data);
uint8_t bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
uint16_t bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
uint32_t bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset);
void bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint16_t *datap, bus_size_t count);
void bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint16_t *datap, bus_size_t count);
void bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void bus_space_read_region_1(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_write_region_1(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint8_t *datap, bus_size_t count);
void bus_space_read_region_4(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint32_t *datap, bus_size_t count);
void bus_space_write_region_4(bus_space_tag_t space, bus_space_handle_t handle, bus_size_t offset,
uint32_t *datap, bus_size_t count);
extern void devclass_module_dump(void);
#endif /* _BSD_KERNEL_H_ */
/* $FreeBSD: releng/11.4/stand/usb/usb_busdma_loader.c 291399 2015-11-27 18:13:28Z zbb $ */
/*-
* Copyright (c) 2013 Hans Petter Selasky. 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 <los_memory.h>
#include "los_vm_iomap.h"
#include "los_vm_map.h"
#include <asm/dma.h>
#include <user_copy.h>
#include "implementation/global_implementation.h"
#if USB_HAVE_BUSDMA
static void usb_pc_common_mem_cb(struct usb_page_cache *pc,
void *vaddr, uint32_t length);
#endif
void
usb_dma_cache_invalid(void *addr, unsigned int size)
{
UINTPTR start = (UINTPTR)addr & ~(USB_CACHE_ALIGN_SIZE - 1);
UINTPTR end = (UINTPTR)addr + size;
end = ALIGN(end, USB_CACHE_ALIGN_SIZE);
DCacheInvRange(start, end);
}
void
usb_dma_cache_flush(void *addr, unsigned int size)
{
UINTPTR start = (UINTPTR)addr & ~(USB_CACHE_ALIGN_SIZE - 1);
UINTPTR end = (UINTPTR)addr + size;
end = ALIGN(end, USB_CACHE_ALIGN_SIZE);
DCacheFlushRange(start, end);
}
/*------------------------------------------------------------------------*
* usbd_get_page - lookup DMA-able memory for the given offset
*
* NOTE: Only call this function when the "page_cache" structure has
* been properly initialized !
*------------------------------------------------------------------------*/
void
usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset,
struct usb_page_search *res)
{
#if USB_HAVE_BUSDMA
struct usb_page *page;
if (pc->page_start) {
/* Case 1 - something has been loaded into DMA */
if (pc->buffer) {
/* Case 1a - Kernel Virtual Address */
res->buffer = USB_ADD_BYTES(pc->buffer, offset);
}
offset += pc->page_offset_buf;
/* compute destination page */
page = pc->page_start;
if (pc->ismultiseg) {
page += (offset / USB_PAGE_SIZE);
offset %= USB_PAGE_SIZE;
res->length = USB_PAGE_SIZE - offset;
res->physaddr = page->physaddr + offset;
} else {
res->length = (usb_size_t)-1;
res->physaddr = page->physaddr + offset;
}
if (!pc->buffer) {
/* Case 1b - Non Kernel Virtual Address */
res->buffer = USB_ADD_BYTES(page->buffer, offset);
}
return;
}
#endif
/* Case 2 - Plain PIO */
res->buffer = USB_ADD_BYTES(pc->buffer, offset);
res->length = (usb_size_t)-1;
#if USB_HAVE_BUSDMA
res->physaddr = 0;
#endif
}
/*------------------------------------------------------------------------*
* usbd_copy_in - copy directly to DMA-able memory
*------------------------------------------------------------------------*/
void
usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset,
const void *ptr, usb_frlength_t len)
{
struct usb_page_search buf_res;
int ret;
while (len != 0) {
usbd_get_page(cache, offset, &buf_res);
if (buf_res.length > len) {
buf_res.length = len;
}
ret = memcpy_s(buf_res.buffer, buf_res.length, ptr, buf_res.length);
if (ret != EOK) {
return;
}
offset += buf_res.length;
len -= buf_res.length;
ptr = USB_ADD_BYTES(ptr, buf_res.length);
}
}
/*------------------------------------------------------------------------*
* usbd_copy_out - copy directly from DMA-able memory
*------------------------------------------------------------------------*/
void
usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset,
void *ptr, usb_frlength_t len)
{
struct usb_page_search res;
while (len != 0) {
usbd_get_page(cache, offset, &res);
if (res.length > len) {
res.length = len;
}
(void)memcpy_s(ptr, len, res.buffer, res.length);
offset += res.length;
len -= res.length;
ptr = USB_ADD_BYTES(ptr, res.length);
}
}
int
copyin(const void *uaddr, void *kaddr, size_t len)
{
size_t ret = LOS_ArchCopyFromUser(kaddr, uaddr, len);
return ret ? EFAULT : 0;
}
int
copyout(const void *kaddr, void *uaddr, size_t len)
{
size_t ret = LOS_ArchCopyToUser(uaddr, kaddr, len);
return ret ? EFAULT : 0;
}
/* In user mode, the src buffer is from user */
int
usbd_copy_from_user(void *dest, uint32_t dest_len, const void *src, uint32_t src_len)
{
int ret;
if (!LOS_IsUserAddressRange((vaddr_t)(UINTPTR)src, src_len)) {
ret = memcpy_s(dest, dest_len, src, src_len);
} else {
ret = ((dest_len >= src_len) ? LOS_ArchCopyFromUser(dest, src, src_len) : ERANGE_AND_RESET);
}
return ret ? EFAULT : 0;
}
/* In user mode, the dest buffer is from user */
int
usbd_copy_to_user(void *dest, uint32_t dest_len, const void *src, uint32_t src_len)
{
int ret;
if (!LOS_IsUserAddressRange((vaddr_t)(UINTPTR)dest, dest_len)) {
ret = memcpy_s(dest, dest_len, src, src_len);
} else {
ret = ((dest_len >= src_len) ? LOS_ArchCopyToUser(dest, src, src_len) : ERANGE_AND_RESET);
}
return ret ? EFAULT : 0;
}
/*------------------------------------------------------------------------*
* usbd_frame_zero - zero DMA-able memory
*------------------------------------------------------------------------*/
void
usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset,
usb_frlength_t len)
{
struct usb_page_search res;
while (len != 0) {
usbd_get_page(cache, offset, &res);
if (res.length > len) {
res.length = len;
}
(void)memset_s(res.buffer, res.length, 0, res.length);
offset += res.length;
len -= res.length;
}
}
#if USB_HAVE_BUSDMA
/*------------------------------------------------------------------------*
* usb_pc_common_mem_cb - BUS-DMA callback function
*------------------------------------------------------------------------*/
static void
usb_pc_common_mem_cb(struct usb_page_cache *pc, void *dma_handle, uint32_t length)
{
struct usb_page *pg;
usb_size_t rem;
bus_size_t off;
bus_addr_t phys = (bus_addr_t)(UINTPTR)dma_handle;
pg = pc->page_start;
pg->physaddr = phys & ~(USB_PAGE_SIZE - 1);
rem = phys & (USB_PAGE_SIZE - 1);
pc->page_offset_buf = rem;
pc->page_offset_end += rem;
length += rem;
for (off = USB_PAGE_SIZE; off < length; off += USB_PAGE_SIZE) {
pg++;
pg->physaddr = (phys + off) & ~(USB_PAGE_SIZE - 1);
}
}
/*------------------------------------------------------------------------*
* usb_pc_alloc_mem - allocate DMA'able memory
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
uint8_t
usb_pc_alloc_mem(struct usb_page_cache *pc, struct usb_page *pg,
usb_size_t size, usb_size_t align)
{
void *ptr;
DMA_ADDR_T dma_handle;
/* allocate zeroed memory */
if (align < USB_CACHE_ALIGN_SIZE) {
ptr = LOS_DmaMemAlloc(&dma_handle, size, USB_CACHE_ALIGN_SIZE, DMA_NOCACHE);
} else {
ptr = LOS_DmaMemAlloc(&dma_handle, size, align, DMA_NOCACHE);
}
if (ptr == NULL)
goto error;
(void)memset_s(ptr, size, 0, size);
/* setup page cache */
pc->buffer = (uint8_t *)ptr;
pc->page_start = pg;
pc->page_offset_buf = 0;
pc->page_offset_end = size;
pc->map = NULL;
pc->tag = (bus_dma_tag_t)ptr;
pc->ismultiseg = (align == 1);
/* compute physical address */
usb_pc_common_mem_cb(pc, (void *)(UINTPTR)dma_handle, size);
usb_pc_cpu_flush(pc);
return (0);
error:
/* reset most of the page cache */
pc->buffer = NULL;
pc->page_start = NULL;
pc->page_offset_buf = 0;
pc->page_offset_end = 0;
pc->map = NULL;
pc->tag = NULL;
return (1);
}
/*------------------------------------------------------------------------*
* usb_pc_free_mem - free DMA memory
*
* This function is NULL safe.
*------------------------------------------------------------------------*/
void
usb_pc_free_mem(struct usb_page_cache *pc)
{
if ((pc != NULL) && (pc->buffer != NULL)) {
LOS_DmaMemFree(pc->tag);
pc->buffer = NULL;
}
}
/*------------------------------------------------------------------------*
* usb_pc_load_mem - load virtual memory into DMA
*
* Return values:
* 0: Success
* Else: Error
*------------------------------------------------------------------------*/
uint8_t
usb_pc_load_mem(struct usb_page_cache *pc, usb_size_t size, uint8_t data_sync)
{
/* setup page cache */
pc->page_offset_buf = 0;
pc->page_offset_end = size;
pc->ismultiseg = 1;
mtx_assert(pc->tag_parent->mtx, MA_OWNED);
if (size > 0) {
/* compute physical address */
usb_pc_common_mem_cb(pc, (void *)(UINTPTR)LOS_DmaVaddrToPaddr(pc->buffer), size);
}
if (data_sync == 0) {
/*
* Call callback so that refcount is decremented
* properly:
*/
pc->tag_parent->dma_error = 0;
(pc->tag_parent->func) (pc->tag_parent);
}
return (0);
}
/*------------------------------------------------------------------------*
* usb_pc_cpu_invalidate - invalidate CPU cache
*------------------------------------------------------------------------*/
void
usb_pc_cpu_invalidate(struct usb_page_cache *pc)
{
if (pc->page_offset_end == pc->page_offset_buf) {
/* nothing has been loaded into this page cache! */
return;
}
usb_dma_cache_invalid(pc->buffer, pc->page_offset_end - pc->page_offset_buf);
}
/*------------------------------------------------------------------------*
* usb_pc_cpu_flush - flush CPU cache
*------------------------------------------------------------------------*/
void
usb_pc_cpu_flush(struct usb_page_cache *pc)
{
if (pc->page_offset_end == pc->page_offset_buf) {
/* nothing has been loaded into this page cache! */
return;
}
usb_dma_cache_flush(pc->buffer, pc->page_offset_end - pc->page_offset_buf);
}
/*------------------------------------------------------------------------*
* usb_pc_dmamap_create - create a DMA map
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
uint8_t
usb_pc_dmamap_create(struct usb_page_cache *pc, usb_size_t size)
{
return (0); /* NOP, success */
}
/*------------------------------------------------------------------------*
* usb_pc_dmamap_destroy
*
* This function is NULL safe.
*------------------------------------------------------------------------*/
void
usb_pc_dmamap_destroy(struct usb_page_cache *pc)
{
/* NOP */
}
/*------------------------------------------------------------------------*
* usb_dma_tag_setup - initialise USB DMA tags
*------------------------------------------------------------------------*/
void
usb_dma_tag_setup(struct usb_dma_parent_tag *udpt,
struct usb_dma_tag *udt, bus_dma_tag_t dmat,
struct mtx *mtx, usb_dma_callback_t *func,
uint8_t ndmabits, uint8_t nudt)
{
(void)memset_s(udpt, sizeof(*udpt), 0, sizeof(*udpt));
/* sanity checking */
if ((nudt == 0) ||
(ndmabits == 0) ||
(mtx == NULL)) {
/* something is corrupt */
return;
}
/* initialise condition variable */
cv_init(udpt->cv, "USB DMA CV");
/* store some information */
udpt->mtx = mtx;
udpt->func = func;
udpt->tag = dmat;
udpt->utag_first = udt;
udpt->utag_max = nudt;
udpt->dma_bits = ndmabits;
while (nudt--) {
(void)memset_s(udt, sizeof(*udt), 0, sizeof(*udt));
udt->tag_parent = udpt;
udt++;
}
}
/*------------------------------------------------------------------------*
* usb_bus_tag_unsetup - factored out code
*------------------------------------------------------------------------*/
void
usb_dma_tag_unsetup(struct usb_dma_parent_tag *udpt)
{
struct usb_dma_tag *udt;
uint8_t nudt;
udt = udpt->utag_first;
nudt = udpt->utag_max;
while (nudt--) {
udt->align = 0;
udt++;
}
if (udpt->utag_max) {
/* destroy the condition variable */
cv_destroy(udpt->cv);
}
}
/*------------------------------------------------------------------------*
* usb_bdma_work_loop
*
* This function handles loading of virtual buffers into DMA and is
* only called when "dma_refcount" is zero.
*------------------------------------------------------------------------*/
void
usb_bdma_work_loop(struct usb_xfer_queue *pq)
{
struct usb_xfer_root *info;
struct usb_xfer *xfer;
usb_frcount_t nframes;
xfer = pq->curr;
info = xfer->xroot;
mtx_assert(info->xfer_mtx, MA_OWNED);
if (xfer->error) {
/* some error happened */
USB_BUS_LOCK(info->bus);
usbd_transfer_done(xfer, USB_ERR_NORMAL_COMPLETION);
USB_BUS_UNLOCK(info->bus);
return;
}
if (!xfer->flags_int.bdma_setup) {
struct usb_page *pg;
usb_frlength_t frlength_0;
uint8_t isread;
xfer->flags_int.bdma_setup = 1;
/* reset BUS-DMA load state */
info->dma_error = 0;
if (xfer->flags_int.isochronous_xfr) {
/* only one frame buffer */
nframes = 1;
frlength_0 = xfer->sumlen;
} else {
/* can be multiple frame buffers */
nframes = xfer->nframes;
frlength_0 = xfer->frlengths[0];
}
/*
* Set DMA direction first. This is needed to
* select the correct cache invalidate and cache
* flush operations.
*/
isread = USB_GET_DATA_ISREAD(xfer);
pg = xfer->dma_page_ptr;
if (xfer->flags_int.control_xfr &&
xfer->flags_int.control_hdr) {
/* special case */
if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) {
/* The device controller writes to memory */
xfer->frbuffers[0].isread = 1;
} else {
/* The host controller reads from memory */
xfer->frbuffers[0].isread = 0;
}
} else {
/* default case */
xfer->frbuffers[0].isread = isread;
}
/*
* Setup the "page_start" pointer which points to an array of
* USB pages where information about the physical address of a
* page will be stored. Also initialise the "isread" field of
* the USB page caches.
*/
xfer->frbuffers[0].page_start = pg;
info->dma_nframes = nframes;
info->dma_currframe = 0;
info->dma_frlength_0 = frlength_0;
pg += (frlength_0 / USB_PAGE_SIZE);
pg += 2;
while (--nframes > 0) {
xfer->frbuffers[nframes].isread = isread;
xfer->frbuffers[nframes].page_start = pg;
pg += (xfer->frlengths[nframes] / USB_PAGE_SIZE);
pg += 2;
}
}
if (info->dma_error) {
USB_BUS_LOCK(info->bus);
usbd_transfer_done(xfer, USB_ERR_DMA_LOAD_FAILED);
USB_BUS_UNLOCK(info->bus);
return;
}
if (info->dma_currframe != info->dma_nframes) {
if (info->dma_currframe == 0) {
/* special case */
(void)usb_pc_load_mem(xfer->frbuffers,
info->dma_frlength_0, 0);
} else {
/* default case */
nframes = info->dma_currframe;
(void)usb_pc_load_mem(xfer->frbuffers + nframes,
xfer->frlengths[nframes], 0);
}
/* advance frame index */
info->dma_currframe++;
return;
}
/* go ahead */
usb_bdma_pre_sync(xfer);
/* start loading next USB transfer, if any */
usb_command_wrapper(pq, NULL);
/* finally start the hardware */
usbd_pipe_enter(xfer);
}
/*------------------------------------------------------------------------*
* usb_bdma_done_event
*
* This function is called when the BUS-DMA has loaded virtual memory
* into DMA, if any.
*------------------------------------------------------------------------*/
void
usb_bdma_done_event(struct usb_dma_parent_tag *udpt)
{
struct usb_xfer_root *info;
info = USB_DMATAG_TO_XROOT(udpt);
mtx_assert(info->xfer_mtx, MA_OWNED);
/* copy error */
info->dma_error = udpt->dma_error;
/* enter workloop again */
usb_command_wrapper(&info->dma_q,
info->dma_q.curr);
}
static usb_frcount_t
usb_bdma_frame_num(struct usb_xfer *xfer)
{
if (xfer->flags_int.isochronous_xfr) {
/* only one frame buffer */
return (1);
} else {
/* can be multiple frame buffers */
return (xfer->nframes);
}
}
/*------------------------------------------------------------------------*
* usb_bdma_pre_sync
*
* This function handles DMA synchronisation that must be done before
* an USB transfer is started.
*------------------------------------------------------------------------*/
void
usb_bdma_pre_sync(struct usb_xfer *xfer)
{
struct usb_page_cache *pc;
usb_frcount_t nframes;
nframes = usb_bdma_frame_num(xfer);
pc = xfer->frbuffers;
while (nframes--) {
if (pc->isread) {
usb_pc_cpu_invalidate(pc);
} else {
usb_pc_cpu_flush(pc);
}
pc++;
}
}
/*------------------------------------------------------------------------*
* usb_bdma_post_sync
*
* This function handles DMA synchronisation that must be done after
* an USB transfer is complete.
*------------------------------------------------------------------------*/
void
usb_bdma_post_sync(struct usb_xfer *xfer)
{
struct usb_page_cache *pc;
usb_frcount_t nframes;
nframes = usb_bdma_frame_num(xfer);
pc = xfer->frbuffers;
while (nframes--) {
if (pc->isread) {
usb_pc_cpu_invalidate(pc);
}
pc++;
}
}
#endif
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* from: FreeBSD: src/sys/i386/i386/autoconf.c,v 1.156
*/
/*
* Setup the system to run on the current machine.
*
* Configure() is called at boot time and initializes the vba
* device tables and the memory controller monitoring. Available
* devices are determined (from possibilities mentioned in ioconf.c),
* and the drivers are initialized.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.4/sys/arm/arm/autoconf.c 331722 2018-03-29 02:50:57Z eadler $");
#include <sys/bus.h>
extern int nexus_init(void);
device_t nexus;
void
configure(void)
{
kobj_init_mutex(NULL);
root_bus_configure();
nexus = device_add_child(root_bus, "nexus", 0);
nexus_init();
}
/* $NetBSD: in_cksum.c,v 1.7 1997/09/02 13:18:15 thorpej Exp $ */
/*-
* Copyright (c) 1988, 1992, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1996
* Matt Thomas <matt@3am-software.com>
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)in_cksum.c 8.1 (Berkeley) 6/10/93
*/
#include "los_base.h"
#include "sys/types.h"
#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x)
#define REDUCE32 \
{ \
q_util.q = sum; \
sum = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \
}
#define REDUCE16 \
{ \
q_util.q = sum; \
l_util.l = q_util.s[0] + q_util.s[1] + q_util.s[2] + q_util.s[3]; \
sum = l_util.s[0] + l_util.s[1]; \
ADDCARRY(sum); \
}
union un_l_util {
u_int16_t s[2];
u_int32_t l;
};
union un_q_util {
u_int16_t s[4];
u_int32_t l[2];
u_int64_t q;
};
/*do_cksum is implemented in in_cksum_arm.S*/
extern unsigned int do_cksum(const void * buf, int len);
static u_int64_t _do_cksum(const void *buf, int len)
{
u_int64_t sum;
union un_q_util q_util;
sum = do_cksum(buf, len);
REDUCE32;
return (sum);
}
/* This function is for LWIP_CHKSUM */
unsigned short in_cksum(const void *buf, int len)
{
u_int64_t sum = 0;
union un_q_util q_util;
union un_l_util l_util;
if (((int)buf) & 1) {
sum = _do_cksum(buf, len) << 8;
} else {
sum = _do_cksum(buf, len);
}
REDUCE16;
return (unsigned short)(~sum & 0xffff);
}
/* This function is for LWIP_CHKSUM_COPY */
unsigned short in_cksum_copy(const void *src, void *dst, int len)
{
u_int64_t sum = 0;
union un_q_util q_util;
union un_l_util l_util;
int src_len = strlen(src);
if (src_len >= len) {
src_len = len;
}
if (memcpy_s(dst, len, src, src_len) != EOK) {
return (unsigned short)(sum);
}
if (((long)dst) & 1) {
sum = _do_cksum(dst, len) << 8;
}else {
sum = _do_cksum(dst, len);
}
REDUCE16;
return (unsigned short)(~sum & 0xffff);
}
/*As usb_rtl8188eus used csum_partial, so wrapper this interface for usb_rtl8188*/
unsigned int csum_partial(const void *buf, int len, unsigned int wsum)
{
u_int64_t sum = 0;
union un_q_util q_util;
if (((int)buf) & 1) {
sum = _do_cksum(buf, len) << 8;
} else {
sum = _do_cksum(buf, len);
}
if(wsum > 0) {
sum += (unsigned int)wsum;
REDUCE32;
}
return (unsigned int)(sum);
}
/* Keep this function for compatible */
unsigned int csum_partial_copy_nocheck(const void *src, void *dst, int len, unsigned int wsum)
{
u_int64_t sum = 0;
union un_q_util q_util;
int src_len = strlen(src);
if (src_len >= len) {
src_len = len;
}
if (memcpy_s(dst, len, src, src_len) != EOK) {
return (unsigned int)(sum);
}
if (((int)dst) & 1) {
sum = _do_cksum(dst, len) << 8;
}else {
sum = _do_cksum(dst, len);
}
if(wsum > 0) {
sum += (unsigned int)wsum;
REDUCE32;
}
return (unsigned int)(sum);
}
/* $NetBSD: in_cksum_arm.S,v 1.2 2003/09/23 10:01:36 scw Exp $ */
/*-
* Copyright 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Steve C. Woodford for Wasabi Systems, Inc.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*
*/
/*
* Hand-optimised in_cksum() and in4_cksum() implementations for ARM/armv5e
*/
#define _ASM_TYPE_FUNCTION #function
#define _ASM_TYPE_OBJECT #object
#define _C_LABEL(x) x
#define _ASM_LABEL(x) x
#ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 2
#endif
#ifdef GPROF
#define _PROF_PROLOGUE \
mov ip, lr; \
bl __mcount
#else
#define _PROF_PROLOGUE
#endif
#define GLOBAL(x) .global x
#ifdef __thumb__
#define _FUNC_MODE .code 16; .thumb_func
#else
#define _FUNC_MODE .code 32
#endif
#ifndef _STANDALONE
#define STOP_UNWINDING .cantunwind
#define _FNSTART .fnstart
#define _FNEND .fnend
#define _SAVE(...) .save __VA_ARGS__
#else
#define STOP_UNWINDING
#define _FNSTART
#define _FNEND
#define _SAVE(...)
#endif
#define _LEENTRY(x) .type x,_ASM_TYPE_FUNCTION; _FUNC_MODE; x:
#define _LEEND(x) /* nothing */
#define _EENTRY(x) GLOBAL(x); _LEENTRY(x)
#define _EEND(x) _LEEND(x)
#define _LENTRY(x) .text; _ALIGN_TEXT; _LEENTRY(x); _FNSTART
#define _LEND(x) .size x, . - x; _FNEND
#define _ENTRY(x) .text; _ALIGN_TEXT; _EENTRY(x); _FNSTART
#define _END(x) _LEND(x)
#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
#define EENTRY(y) _EENTRY(_C_LABEL(y));
#define ENTRY_NP(y) _ENTRY(_C_LABEL(y))
#define EENTRY_NP(y) _EENTRY(_C_LABEL(y))
#define END(y) _END(_C_LABEL(y))
#define EEND(y) _EEND(_C_LABEL(y))
#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y))
#if defined (_HAVE_ARMv4T_INSTRUCTIONS)
#define RET bx lr
#define RETeq bxeq lr
#define RETne bxne lr
#define RETc(c) bx##c lr
#else
#define RET mov pc, lr
#define RETeq moveq pc, lr
#define RETne movne pc, lr
#define RETc(c) mov##c pc, lr
#endif
.syntax unified
ENTRY(do_cksum)
stmfd sp!, {r4-r7, lr}
bl L_cksumdata
mov r0, r2
ldmfd sp!, {r4-r7, pc}
END(do_cksum)
/*
* The main in*_cksum() workhorse...
*
* Entry parameters:
* r0 Pointer to buffer
* r1 Buffer length
* lr Return address
*
* Returns:
* r2 Accumulated 32-bit sum
*
* Clobbers:
* r0-r7
*/
/* LINTSTUB: Ignore */
ASENTRY_NP(L_cksumdata)
#ifdef _ARM_ARCH_5E
pld [r0] /* Pre-fetch the start of the buffer */
#endif
mov r2, #0
/* We first have to word-align the buffer. */
ands r7, r0, #0x03
beq .Lcksumdata_wordaligned
rsb r7, r7, #0x04
cmp r1, r7 /* Enough bytes left to make it? */
blt .Lcksumdata_endgame
cmp r7, #0x02
ldrb r4, [r0], #0x01 /* Fetch 1st byte */
ldrbge r5, [r0], #0x01 /* Fetch 2nd byte */
movlt r5, #0x00
ldrbgt r6, [r0], #0x01 /* Fetch 3rd byte */
movle r6, #0x00
/* Combine the three bytes depending on endianness and alignment */
#ifdef __ARMEB__
orreq r2, r5, r4, lsl #8
orreq r2, r2, r6, lsl #24
orrne r2, r4, r5, lsl #8
orrne r2, r2, r6, lsl #16
#else
orreq r2, r4, r5, lsl #8
orreq r2, r2, r6, lsl #16
orrne r2, r5, r4, lsl #8
orrne r2, r2, r6, lsl #24
#endif
subs r1, r1, r7 /* Update length */
RETeq /* All done? */
/* Buffer is now word aligned */
.Lcksumdata_wordaligned:
#ifdef _ARM_ARCH_5E
cmp r1, #0x04 /* Less than 4 bytes left? */
blt .Lcksumdata_endgame /* Yup */
/* Now quad-align, if necessary */
ands r7, r0, #0x04
ldrne r7, [r0], #0x04
subne r1, r1, #0x04
subs r1, r1, #0x40
blt .Lcksumdata_bigloop_end /* Note: C flag clear if branch taken */
/*
* Buffer is now quad aligned. Sum 64 bytes at a time.
* Note: First ldrd is hoisted above the loop, together with
* setting r6 to zero to avoid stalling for results in the
* loop. (r7 is live, from above).
*/
ldrd r4, [r0], #0x08
mov r6, #0x00
.Lcksumdata_bigloop:
pld [r0, #0x18]
adds r2, r2, r6
adcs r2, r2, r7
ldrd r6, [r0], #0x08
adcs r2, r2, r4
adcs r2, r2, r5
ldrd r4, [r0], #0x08
adcs r2, r2, r6
adcs r2, r2, r7
ldrd r6, [r0], #0x08
adcs r2, r2, r4
adcs r2, r2, r5
ldrd r4, [r0], #0x08
adcs r2, r2, r6
adcs r2, r2, r7
pld [r0, #0x18]
ldrd r6, [r0], #0x08
adcs r2, r2, r4
adcs r2, r2, r5
ldrd r4, [r0], #0x08
adcs r2, r2, r6
adcs r2, r2, r7
ldrd r6, [r0], #0x08
adcs r2, r2, r4
adcs r2, r2, r5
adc r2, r2, #0x00
subs r1, r1, #0x40
ldrdge r4, [r0], #0x08
bge .Lcksumdata_bigloop
adds r2, r2, r6 /* r6/r7 still need summing */
.Lcksumdata_bigloop_end:
adcs r2, r2, r7
adc r2, r2, #0x00
#else /* !_ARM_ARCH_5E */
subs r1, r1, #0x40
blt .Lcksumdata_bigloop_end
.Lcksumdata_bigloop:
ldmia r0!, {r3, r4, r5, r6}
adds r2, r2, r3
adcs r2, r2, r4
adcs r2, r2, r5
ldmia r0!, {r3, r4, r5, r7}
adcs r2, r2, r6
adcs r2, r2, r3
adcs r2, r2, r4
adcs r2, r2, r5
ldmia r0!, {r3, r4, r5, r6}
adcs r2, r2, r7
adcs r2, r2, r3
adcs r2, r2, r4
adcs r2, r2, r5
ldmia r0!, {r3, r4, r5, r7}
adcs r2, r2, r6
adcs r2, r2, r3
adcs r2, r2, r4
adcs r2, r2, r5
adcs r2, r2, r7
adc r2, r2, #0x00
subs r1, r1, #0x40
bge .Lcksumdata_bigloop
.Lcksumdata_bigloop_end:
#endif
adds r1, r1, #0x40
RETeq
cmp r1, #0x20
#ifdef _ARM_ARCH_5E
ldrdge r4, [r0], #0x08 /* Avoid stalling pld and result */
blt .Lcksumdata_less_than_32
pld [r0, #0x18]
ldrd r6, [r0], #0x08
adds r2, r2, r4
adcs r2, r2, r5
ldrd r4, [r0], #0x08
adcs r2, r2, r6
adcs r2, r2, r7
ldrd r6, [r0], #0x08
adcs r2, r2, r4
adcs r2, r2, r5
adcs r2, r2, r6 /* XXX: Unavoidable result stall */
adcs r2, r2, r7
#else
blt .Lcksumdata_less_than_32
ldmia r0!, {r3, r4, r5, r6}
adds r2, r2, r3
adcs r2, r2, r4
adcs r2, r2, r5
ldmia r0!, {r3, r4, r5, r7}
adcs r2, r2, r6
adcs r2, r2, r3
adcs r2, r2, r4
adcs r2, r2, r5
adcs r2, r2, r7
#endif
adc r2, r2, #0x00
subs r1, r1, #0x20
RETeq
.Lcksumdata_less_than_32:
/* There are less than 32 bytes left */
and r3, r1, #0x18
rsb r4, r3, #0x18
sub r1, r1, r3
adds r4, r4, r4, lsr #1 /* Side effect: Clear carry flag */
addne pc, pc, r4
nop
/*
* Note: We use ldm here, even on armv5e, since the combined issue/result
* latencies for ldm and ldrd are the same. Using ldm avoids needless #ifdefs.
*/
/* At least 24 bytes remaining... */
ldmia r0!, {r4, r5}
adcs r2, r2, r4
adcs r2, r2, r5
/* At least 16 bytes remaining... */
ldmia r0!, {r4, r5}
adcs r2, r2, r4
adcs r2, r2, r5
/* At least 8 bytes remaining... */
ldmia r0!, {r4, r5}
adcs r2, r2, r4
adcs r2, r2, r5
/* Less than 8 bytes remaining... */
adc r2, r2, #0x00
subs r1, r1, #0x04
blt .Lcksumdata_lessthan4
ldr r4, [r0], #0x04
sub r1, r1, #0x04
adds r2, r2, r4
adc r2, r2, #0x00
/* Deal with < 4 bytes remaining */
.Lcksumdata_lessthan4:
adds r1, r1, #0x04
RETeq
/* Deal with 1 to 3 remaining bytes, possibly misaligned */
.Lcksumdata_endgame:
ldrb r3, [r0] /* Fetch first byte */
cmp r1, #0x02
ldrbge r4, [r0, #0x01] /* Fetch 2nd and 3rd as necessary */
movlt r4, #0x00
ldrbgt r5, [r0, #0x02]
movle r5, #0x00
/* Combine the three bytes depending on endianness and alignment */
tst r0, #0x01
#ifdef __ARMEB__
orreq r3, r4, r3, lsl #8
orreq r3, r3, r5, lsl #24
orrne r3, r3, r4, lsl #8
orrne r3, r3, r5, lsl #16
#else
orreq r3, r3, r4, lsl #8
orreq r3, r3, r5, lsl #16
orrne r3, r4, r3, lsl #8
orrne r3, r3, r5, lsl #24
#endif
adds r2, r2, r3
adc r2, r2, #0x00
RET
END(L_cksumdata)
/*-
* Copyright 1998 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
* granted, provided that both the above copyright notice and this
* permission notice appear in all copies, that both the above
* copyright notice and this permission notice appear in all
* supporting documentation, and that the name of M.I.T. not be used
* in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. M.I.T. makes
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
* SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*
* This code implements a `root nexus' for Arm Architecture
* machines. The function of the root nexus is to serve as an
* attachment point for both processors and buses, and to manage
* resources which are common to all of them. In particular,
* this code implements the core resource managers for interrupt
* requests, DMA requests (which rightfully should be a part of the
* ISA code but it's easier to do it here for now), I/O port addresses,
* and I/O memory address space.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: releng/11.4/sys/arm/arm/nexus.c 308382 2016-11-06 18:40:12Z gonzo $");
#include <sys/kobj.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include "device_if.h"
#include "bus_if.h"
#include <sys/malloc.h>
#include <sys/module.h>
#ifdef LOSCFG_DRIVERS_HDF_USB
#include "hdf_usb.h"
#endif
struct devclass_res {
TAILQ_ENTRY(devclass_res) link;
struct resource_list nx_resources;
char* devclass_name;
};
TAILQ_HEAD(devclass_res_list, devclass_res);
static struct devclass_res_list devclass_resources;
static int nexus_probe(device_t);
static int nexus_attach(device_t);
static int nexus_print_child(device_t, device_t);
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int);
static device_method_t nexus_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, nexus_probe),
DEVMETHOD(device_attach, nexus_attach),
/* Bus interface */
DEVMETHOD(bus_print_child, nexus_print_child),
DEVMETHOD(bus_add_child, bus_generic_add_child),
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
{ 0, 0 }
};
static devclass_t nexus_devclass;
static driver_t nexus_driver = {
"nexus",
nexus_methods,
1 /* no softc */
};
EARLY_DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0,
BUS_PASS_BUS + BUS_PASS_ORDER_EARLY);
static struct resource_list *get_resource_list(const char *devclass_name)
{
struct devclass_res *dr = NULL;
if (devclass_name == NULL) {
return (NULL);
}
TAILQ_FOREACH(dr, &devclass_resources, link) {
if (!strcmp(dr->devclass_name, devclass_name)) {
break;
}
}
if (dr == NULL) {
dr = malloc(sizeof(struct devclass_res) + strlen(devclass_name) + 1);
if (dr == NULL) {
return (NULL);
}
dr->devclass_name = (char *)(dr + 1);
(void)strcpy_s(dr->devclass_name, strlen(devclass_name) + 1, devclass_name);
resource_list_init(&dr->nx_resources);
TAILQ_INSERT_TAIL(&devclass_resources, dr, link);
}
return (&dr->nx_resources);
}
static void add_resource(const char *devclass_name, int type, int unit, rman_res_t start, rman_res_t end,
rman_res_t count)
{
struct resource_list *res_list = get_resource_list(devclass_name);
if (res_list == NULL) {
return;
}
resource_list_add(res_list, type, unit, start, end, count);
}
int
nexus_init(void)
{
TAILQ_INIT(&devclass_resources);
#ifdef LOSCFG_DRIVERS_HDF_USB
UsbResourceInit(nexus, add_resource);
#endif
machine_resource_init(add_resource);
return driver_module_handler(NULL, MOD_LOAD, &nexus_root_driver_mod);
}
static int
nexus_probe(device_t dev)
{
device_quiet(dev); /* suppress attach message for neatness */
return (BUS_PROBE_DEFAULT);
}
static int
nexus_attach(device_t dev)
{
/*
* First, deal with the children we know about already
*/
bus_generic_probe(dev);
bus_generic_attach(dev);
return (0);
}
static int
nexus_print_child(device_t bus, device_t child)
{
int retval = 0;
retval += bus_print_child_header(bus, child);
retval += printf("\n");
return (retval);
}
/*
* Allocate a resource on behalf of child. NB: child is usually going to be a
* child of one of our descendants, not a direct child of nexus0.
* (Exceptions include footbridge.)
*/
static struct resource *
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
devclass_t dc = device_get_devclass(child);
struct resource_list *res_list = NULL;
if (dc == NULL || rid == NULL) {
return (NULL);
}
res_list = get_resource_list(devclass_get_name(dc));
if (res_list == NULL) {
return (NULL);
}
struct resource_list_entry *rle = resource_list_find(res_list, type, *rid);
if (rle == NULL) {
return(NULL);
}
return (rle->res);
}
/*-
* Copyright (c) 2005 M. Warner Losh.
* 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,
* without modification, immediately at the beginning of the file.
* 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: releng/11.4/sys/arm/include/_bus.h 331722 2018-03-29 02:50:57Z eadler $
*/
#ifndef ARM_INCLUDE__BUS_H
#define ARM_INCLUDE__BUS_H
/*
* Addresses (in bus space).
*/
typedef u_long bus_addr_t;
typedef u_long bus_size_t;
/*
* Access methods for bus space.
*/
typedef struct bus_space *bus_space_tag_t;
typedef u_long bus_space_handle_t;
#endif /* ARM_INCLUDE__BUS_H */
/*-
* Largely written by Julian Elischer (julian@tfs.com)
* for TRW Financial Systems.
*
* TRW Financial Systems, in accordance with their agreement with Carnegie
* Mellon University, makes this software available to CMU to distribute
* or use in any manner that they see fit as long as this message is kept with
* the software. For this reason TFS also grants any other persons or
* organisations permission to use or modify this software.
*
* TFS supplies this software to be publicly redistributed
* on the understanding that TFS is not responsible for the correct
* functioning of this software in any circumstances.
*
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
*
* $FreeBSD: releng/11.4/sys/cam/scsi/scsi_all.h 351582 2019-08-28 20:23:08Z mav $
*/
#ifndef __INCLUDE_SCSI_ALL_H
#define __INCLUDE_SCSI_ALL_H
#define SC_SCSI_1 0x01
#define SC_SCSI_2 0x03
#define SCSI_REV_2 0x02
/*
* Opcodes
*/
#define TEST_UNIT_READY 0x00
#define REQUEST_SENSE 0x03
#define READ_6 0x08
#define WRITE_6 0x0A
#define INQUIRY 0x12
#define MODE_SELECT_6 0x15
#define MODE_SENSE_6 0x1A
#define START_STOP_UNIT 0x1B
#define START_STOP 0x1B
#define RESERVE 0x16
#define RELEASE 0x17
#define RECEIVE_DIAGNOSTIC 0x1C
#define SEND_DIAGNOSTIC 0x1D
#define PREVENT_ALLOW 0x1E
#define READ_CAPACITY 0x25
#define READ_10 0x28
#define WRITE_10 0x2A
#define POSITION_TO_ELEMENT 0x2B
#define WRITE_VERIFY_10 0x2E
#define VERIFY_10 0x2F
#define SYNCHRONIZE_CACHE 0x35
#define READ_DEFECT_DATA_10 0x37
#define WRITE_BUFFER 0x3B
#define READ_BUFFER 0x3C
#define CHANGE_DEFINITION 0x40
#define WRITE_SAME_10 0x41
#define UNMAP 0x42
#define LOG_SELECT 0x4C
#define LOG_SENSE 0x4D
#define MODE_SELECT_10 0x55
#define RESERVE_10 0x56
#define RELEASE_10 0x57
#define MODE_SENSE_10 0x5A
#define PERSISTENT_RES_IN 0x5E
#define PERSISTENT_RES_OUT 0x5F
#define EXTENDED_COPY 0x83
#define RECEIVE_COPY_STATUS 0x84
#define ATA_PASS_16 0x85
#define READ_16 0x88
#define COMPARE_AND_WRITE 0x89
#define WRITE_16 0x8A
#define WRITE_VERIFY_16 0x8E
#define VERIFY_16 0x8F
#define SYNCHRONIZE_CACHE_16 0x91
#define WRITE_SAME_16 0x93
#define SERVICE_ACTION_IN 0x9E
#define REPORT_LUNS 0xA0
#define ATA_PASS_12 0xA1
#define MAINTENANCE_IN 0xA3
#define MAINTENANCE_OUT 0xA4
#define MOVE_MEDIUM 0xA5
#define READ_12 0xA8
#define WRITE_12 0xAA
#define WRITE_VERIFY_12 0xAE
#define VERIFY_12 0xAF
#define READ_ELEMENT_STATUS 0xB8
#define READ_CD 0xBE
/* Maintenance In Service Action Codes */
#define REPORT_IDENTIFYING_INFRMATION 0x05
#define REPORT_TARGET_PORT_GROUPS 0x0A
#define REPORT_ALIASES 0x0B
#define REPORT_SUPPORTED_OPERATION_CODES 0x0C
#define REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0D
#define REPORT_PRIORITY 0x0E
#define REPORT_TIMESTAMP 0x0F
#define MANAGEMENT_PROTOCOL_IN 0x10
/* Maintenance Out Service Action Codes */
#define SET_IDENTIFY_INFORMATION 0x06
#define SET_TARGET_PORT_GROUPS 0x0A
#define CHANGE_ALIASES 0x0B
#define SET_PRIORITY 0x0E
#define SET_TIMESTAMP 0x0F
#define MANGAEMENT_PROTOCOL_OUT 0x10
/*
* Device Types
*/
#define T_DIRECT 0x00
#define T_SEQUENTIAL 0x01
#define T_PRINTER 0x02
#define T_PROCESSOR 0x03
#define T_WORM 0x04
#define T_CDROM 0x05
#define T_SCANNER 0x06
#define T_OPTICAL 0x07
#define T_CHANGER 0x08
#define T_COMM 0x09
#define T_ASC0 0x0a
#define T_ASC1 0x0b
#define T_STORARRAY 0x0c
#define T_ENCLOSURE 0x0d
#define T_RBC 0x0e
#define T_OCRW 0x0f
#define T_OSD 0x11
#define T_ADC 0x12
#define T_NODEVICE 0x1f
#define T_ANY 0xff /* Used in Quirk table matches */
#define T_REMOV 1
#define T_FIXED 0
/*
* This length is the initial inquiry length used by the probe code, as
* well as the length necessary for scsi_print_inquiry() to function
* correctly. If either use requires a different length in the future,
* the two values should be de-coupled.
*/
#define SHORT_INQUIRY_LENGTH 36
struct scsi_test_unit_ready
{
uint8_t opcode;
uint8_t byte2;
uint8_t unused[3];
uint8_t control;
};
struct scsi_sense
{
uint8_t opcode;
uint8_t byte2;
uint8_t unused[2];
uint8_t length;
uint8_t control;
};
struct scsi_inquiry
{
uint8_t opcode;
uint8_t byte2;
#define SI_EVPD 0x01
#define SI_CMDDT 0x02
uint8_t page_code;
uint8_t length[2];
uint8_t control;
};
struct scsi_sense_data
{
uint8_t error_code;
/*
* SPC-4 says that the maximum length of sense data is 252 bytes.
* So this structure is exactly 252 bytes log.
*/
#define SSD_FULL_SIZE 252
uint8_t sense_buf[SSD_FULL_SIZE - 1];
/*
* XXX KDM is this still a reasonable minimum size?
*/
#define SSD_MIN_SIZE 18
/*
* Maximum value for the extra_len field in the sense data.
*/
#define SSD_EXTRA_MAX 244
};
struct scsi_start_stop_unit
{
uint8_t opcode;
uint8_t byte2;
#define SSS_IMMED 0x01
uint8_t reserved[2];
uint8_t how;
#define SSS_START 0x01
#define SSS_LOEJ 0x02
#define SSS_PC_MASK 0xf0
#define SSS_PC_START_VALID 0x00
#define SSS_PC_ACTIVE 0x10
#define SSS_PC_IDLE 0x20
#define SSS_PC_STANDBY 0x30
#define SSS_PC_LU_CONTROL 0x70
#define SSS_PC_FORCE_IDLE_0 0xa0
#define SSS_PC_FORCE_STANDBY_0 0xb0
uint8_t control;
};
/*
* Opcodes
*/
#define VERIFIED 0x2f
#define REZERO_UNIT 0x01
#define FORMAT_UNIT 0x04
#define REASSIGN_BLOCKS 0x07
#define MODE_SELECT 0x15
#define MODE_SENSE 0x1a
#define READ_FORMAT_CAPACITIES 0x23
#define WRITE_AND_VERIFY 0x2e
#define READ_DEFECT_DATA_10 0x37
#define SANITIZE 0x48
#define READ_DEFECT_DATA_12 0xb7
#endif
/*-
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
* Copyright (c) 2013-2018 Mellanox Technologies, Ltd.
* 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 unmodified, 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: releng/11.4/sys/compat/linuxkpi/common/include/asm/atomic.h 337898 2018-08-16 08:12:36Z hselasky $
*/
#ifndef _ASM_ATOMIC_H_
#define _ASM_ATOMIC_H_
#include "los_atomic.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
typedef Atomic atomic_t;
typedef Atomic64 atomic64_t;
#define ATOMIC_INIT(x) (x)
#define atomic_read(v) LOS_AtomicRead(v)
#define atomic_set(v, i) LOS_AtomicSet(v, i)
#define atomic_inc(v) LOS_AtomicInc(v)
#define atomic_dec(v) LOS_AtomicDec(v)
#define atomic_add(i, v) LOS_AtomicAdd(v, i)
#define atomic_sub(i, v) LOS_AtomicSub(v, i)
#define atomic_add_return(i, v) LOS_AtomicAdd(v, i)
#define atomic_inc_return(v) LOS_AtomicIncRet(v)
#define atomic_dec_return(v) LOS_AtomicDecRet(v)
#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
#define ATOMIC64_INIT(x) (x)
#define atomic64_read(v) LOS_Atomic64Read(v)
#define atomic64_set(v, i) LOS_Atomic64Set(v, i)
#define atomic64_inc(v) LOS_Atomic64Inc(v)
#define atomic64_dec(v) LOS_Atomic64Dec(v)
#define atomic64_add(i, v) LOS_Atomic64Add(v, i)
#define atomic64_sub(i, v) LOS_Atomic64Sub(v, i)
#define atomic64_add_return(i, v) LOS_Atomic64Add(v, i)
#define atomic64_inc_return(v) LOS_Atomic64IncRet(v)
#define atomic64_dec_return(v) LOS_Atomic64DecRet(v)
#define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0)
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _ASM_ATOMIC_H_ */
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. 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.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _ASM_BARRIER_H_
#define _ASM_BARRIER_H_
#include "los_hw.h"
#endif /* _ASM_BARRIER_H_ */
/*-
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
* Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
* 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 unmodified, 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: releng/11.4/sys/compat/linuxkpi/common/include/asm/io.h 290135 2015-10-29 08:28:39Z hselasky $
*/
#ifndef _ASM_IO_H_
#define _ASM_IO_H_
#include <linux/io.h>
#endif /* _ASM_IO_H_ */
此差异已折叠。
/*-
* Copyright (c) 2017 Mark Johnston <markj@FreeBSD.org>
*
* 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: releng/11.4/sys/compat/linuxkpi/common/include/linux/atomic.h 328653 2018-02-01 13:01:44Z hselasky $
*/
#ifndef _LINUX_ATOMIC_H_
#define _LINUX_ATOMIC_H_
#include "asm/atomic.h"
#endif /* _LINUX_ATOMIC_H_ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册