xref: /freebsd/share/man/man9/fetch.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
15406291aSMike Pritchard.\"	$NetBSD: fetch.9,v 1.2 1996/01/09 21:59:24 perry Exp $
25406291aSMike Pritchard.\"
35406291aSMike Pritchard.\" Copyright (c) 1996 Jason R. Thorpe.
45406291aSMike Pritchard.\" All rights reserved.
55406291aSMike Pritchard.\"
65406291aSMike Pritchard.\" This code is derived from software contributed by Kenneth Stailey.
75406291aSMike Pritchard.\"
85406291aSMike Pritchard.\" Redistribution and use in source and binary forms, with or without
95406291aSMike Pritchard.\" modification, are permitted provided that the following conditions
105406291aSMike Pritchard.\" are met:
115406291aSMike Pritchard.\" 1. Redistributions of source code must retain the above copyright
125406291aSMike Pritchard.\"    notice, this list of conditions and the following disclaimer.
135406291aSMike Pritchard.\" 2. Redistributions in binary form must reproduce the above copyright
145406291aSMike Pritchard.\"    notice, this list of conditions and the following disclaimer in the
155406291aSMike Pritchard.\"    documentation and/or other materials provided with the distribution.
165406291aSMike Pritchard.\" 3. All advertising materials mentioning features or use of this software
175406291aSMike Pritchard.\"    must display the following acknowledgement:
185406291aSMike Pritchard.\"	This product includes software developed for the NetBSD Project
195406291aSMike Pritchard.\"	by Jason R. Thorpe.
205406291aSMike Pritchard.\" 4. The name of the author may not be used to endorse or promote products
215406291aSMike Pritchard.\"    derived from this software without specific prior written permission.
225406291aSMike Pritchard.\"
235406291aSMike Pritchard.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
245406291aSMike Pritchard.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
255406291aSMike Pritchard.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
265406291aSMike Pritchard.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
275406291aSMike Pritchard.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
285406291aSMike Pritchard.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
295406291aSMike Pritchard.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
305406291aSMike Pritchard.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
315406291aSMike Pritchard.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
325406291aSMike Pritchard.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
335406291aSMike Pritchard.\" SUCH DAMAGE.
345406291aSMike Pritchard.\"
35*fd5827b1SMark Johnston.Dd July 22, 2021
365406291aSMike Pritchard.Dt FETCH 9
373d45e180SRuslan Ermilov.Os
385406291aSMike Pritchard.Sh NAME
395406291aSMike Pritchard.Nm fetch ,
405406291aSMike Pritchard.Nm fubyte ,
4155b95b33SEdward Tomasz Napierala.Nm fuword ,
4255b95b33SEdward Tomasz Napierala.Nm fuword16 ,
4355b95b33SEdward Tomasz Napierala.Nm fuword32 ,
444f3dc900SKonstantin Belousov.Nm fuword64 ,
454f3dc900SKonstantin Belousov.Nm fueword ,
464f3dc900SKonstantin Belousov.Nm fueword32 ,
474f3dc900SKonstantin Belousov.Nm fueword64
485406291aSMike Pritchard.Nd fetch data from user-space
495406291aSMike Pritchard.Sh SYNOPSIS
5032eef9aeSRuslan Ermilov.In sys/types.h
5132eef9aeSRuslan Ermilov.In sys/systm.h
525406291aSMike Pritchard.Ft int
532361c6d1SKonstantin Belousov.Fn fubyte "volatile const void *base"
5495fd910eSBruce Evans.Ft long
552361c6d1SKonstantin Belousov.Fn fuword "volatile const void *base"
5655b95b33SEdward Tomasz Napierala.Ft int
572361c6d1SKonstantin Belousov.Fn fuword16 "volatile const void *base"
5855b95b33SEdward Tomasz Napierala.Ft int32_t
592361c6d1SKonstantin Belousov.Fn fuword32 "volatile const void *base"
6055b95b33SEdward Tomasz Napierala.Ft int64_t
612361c6d1SKonstantin Belousov.Fn fuword64 "volatile const void *base"
6203fd4409SJohn Baldwin.Ft int
632361c6d1SKonstantin Belousov.Fn fueword "volatile const void *base" "long *val"
6403fd4409SJohn Baldwin.Ft int
652361c6d1SKonstantin Belousov.Fn fueword32 "volatile const void *base" "int32_t *val"
6603fd4409SJohn Baldwin.Ft int
672361c6d1SKonstantin Belousov.Fn fueword64 "volatile const void *base" "int64_t *val"
685406291aSMike Pritchard.Sh DESCRIPTION
695406291aSMike PritchardThe
705406291aSMike Pritchard.Nm
714f3dc900SKonstantin Belousovfunctions are designed to copy small amounts of data from user-space
724f3dc900SKonstantin Belousovof the current process.
73*fd5827b1SMark JohnstonIf the user address is naturally aligned, then the operation will be
74*fd5827b1SMark Johnstonperformed atomically.
75*fd5827b1SMark JohnstonOtherwise it may fail or be performed non-atomically, depending on
76*fd5827b1SMark Johnstonthe platform.
775406291aSMike Pritchard.Pp
785406291aSMike PritchardThe
795406291aSMike Pritchard.Nm
805406291aSMike Pritchardroutines provide the following functionality:
814f3dc900SKonstantin Belousov.Bl -tag -width "fueword32()"
825406291aSMike Pritchard.It Fn fubyte
835406291aSMike PritchardFetches a byte of data from the user-space address
845406291aSMike Pritchard.Pa base .
854f3dc900SKonstantin BelousovThe byte read is zero-extended into the results variable.
8655b95b33SEdward Tomasz Napierala.It Fn fuword
874f3dc900SKonstantin BelousovFetches a word of data (long) from the user-space address
8855b95b33SEdward Tomasz Napierala.Pa base .
8955b95b33SEdward Tomasz Napierala.It Fn fuword16
9055b95b33SEdward Tomasz NapieralaFetches 16 bits of data from the user-space address
9155b95b33SEdward Tomasz Napierala.Pa base .
924f3dc900SKonstantin BelousovThe half-word read is zero-extended into the results variable.
9355b95b33SEdward Tomasz Napierala.It Fn fuword32
9455b95b33SEdward Tomasz NapieralaFetches 32 bits of data from the user-space address
9555b95b33SEdward Tomasz Napierala.Pa base .
9655b95b33SEdward Tomasz Napierala.It Fn fuword64
9755b95b33SEdward Tomasz NapieralaFetches 64 bits of data from the user-space address
985406291aSMike Pritchard.Pa base .
994f3dc900SKonstantin Belousov.It Fn fueword
1004f3dc900SKonstantin BelousovFetches a word of data (long) from the user-space address
1014f3dc900SKonstantin Belousov.Pa base
1024f3dc900SKonstantin Belousovand stores the result in the variable pointed by
1034f3dc900SKonstantin Belousov.Pa val .
1044f3dc900SKonstantin Belousov.It Fn fueword32
1054f3dc900SKonstantin BelousovFetches 32 bits of data from the user-space address
1064f3dc900SKonstantin Belousov.Pa base
1074f3dc900SKonstantin Belousovand stores the result in the variable pointed by
1084f3dc900SKonstantin Belousov.Pa val .
1094f3dc900SKonstantin Belousov.It Fn fueword64
1104f3dc900SKonstantin BelousovFetches 64 bits of data from the user-space address
1114f3dc900SKonstantin Belousov.Pa base
1124f3dc900SKonstantin Belousovand stores the result in the variable pointed by
1134f3dc900SKonstantin Belousov.Pa val .
1145406291aSMike Pritchard.El
1154f3dc900SKonstantin Belousov.Pp
1164f3dc900SKonstantin BelousovThe callers of
1174f3dc900SKonstantin Belousov.Fn fuword ,
1184f3dc900SKonstantin Belousov.Fn fuword32
1194f3dc900SKonstantin Belousovand
1204f3dc900SKonstantin Belousov.Fn fuword64
1214f3dc900SKonstantin Belousovfunctions cannot distinguish between -1 read from
1224f3dc900SKonstantin Belousovuserspace and function failure.
1235406291aSMike Pritchard.Sh RETURN VALUES
1245406291aSMike PritchardThe
1254f3dc900SKonstantin Belousov.Fn fubyte ,
1264f3dc900SKonstantin Belousov.Fn fuword ,
1274f3dc900SKonstantin Belousov.Fn fuword16 ,
1284f3dc900SKonstantin Belousov.Fn fuword32 ,
1294f3dc900SKonstantin Belousovand
1309c11d8d4SBrooks Davis.Fn fuword64
1315406291aSMike Pritchardfunctions return the data fetched or -1 on failure.
1324f3dc900SKonstantin BelousovThe
1334f3dc900SKonstantin Belousov.Fn fueword ,
1344f3dc900SKonstantin Belousov.Fn fueword32
1354f3dc900SKonstantin Belousovand
1364f3dc900SKonstantin Belousov.Fn fueword64
1374f3dc900SKonstantin Belousovfunctions return 0 on success and -1 on failure.
1385406291aSMike Pritchard.Sh SEE ALSO
1395406291aSMike Pritchard.Xr copy 9 ,
1406fe89339SBen Smithurst.Xr store 9
141