Date: Mon, 14 Jun 2004 04:53:01 GMT From: Juli Mallett <jmallett@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 54901 for review Message-ID: <200406140453.i5E4r1Mo076800@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54901 Change 54901 by jmallett@jmallett_oingo on 2004/06/14 04:52:32 Open, Close, Seek. Fix return type botch for errors from Read/Write. Affected files ... .. //depot/projects/mips/sys/dev/arcs/arcs.c#4 edit .. //depot/projects/mips/sys/dev/arcs/arcs.h#3 edit Differences ... ==== //depot/projects/mips/sys/dev/arcs/arcs.c#4 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/dev/arcs/arcs.c#3 $ + * $P4: //depot/projects/mips/sys/dev/arcs/arcs.c#4 $ */ #include <sys/param.h> @@ -51,9 +51,12 @@ #define ARCS_FV_EnterInteractiveMode_Offset (7 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_GetChild_Offset (10 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_GetMemoryDescriptor_Offset (18 * sizeof (ARCS_Pointer_t)) +#define ARCS_FV_Open_Offset (23 * sizeof (ARCS_Pointer_t)) +#define ARCS_FV_Close_Offset (24 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_Read_Offset (25 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_GetReadStatus_Offset (26 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_Write_Offset (27 * sizeof (ARCS_Pointer_t)) +#define ARCS_FV_Seek_Offset (28 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_GetEnvironmentVariable_Offset (30 * sizeof (ARCS_Pointer_t)) int @@ -135,10 +138,46 @@ return (value); } +int +ARCS_Open(const char *name, int mode, int *fdp) +{ + uint32_t (*Open)(ARCS_Pointer_t, uint32_t, ARCS_Pointer_t); + int error; + uint32_t errord; + ARCS_Pointer_t named; + uint32_t moded; + uint32_t fdd; + ARCS_Pointer_t fdpd; + + Open = (uint32_t (*)(ARCS_Pointer_t, uint32_t, ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Open_Offset]; + named = (ARCS_Pointer_t)(intptr_t)name; + moded = (uint32_t)mode; + fdpd = (ARCS_Pointer_t)(intptr_t)&fdd; + errord = (*Open)(named, moded, fdpd); + error = (int)errord; + *fdp = (int)fdd; + return (error); +} + +int +ARCS_Close(int fd) +{ + uint32_t (*Close)(uint32_t); + int error; + uint32_t errord; + uint32_t fdd; + + Close = (uint32_t (*)(uint32_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Close_Offset]; + fdd = (uint32_t)fd; + errord = (*Close)(fdd); + error = (int)errord; + return (error); +} + size_t ARCS_Read(int fd, char *buf, size_t buflen) { - ARCS_Pointer_t (*Read)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t); + uint32_t (*Read)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t); size_t len; uint32_t fdd; ARCS_Pointer_t bufd; @@ -146,7 +185,7 @@ uint32_t lend; ARCS_Pointer_t lenpd; - Read = (ARCS_Pointer_t (*)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Read_Offset]; + Read = (uint32_t (*)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Read_Offset]; fdd = (uint32_t)fd; bufd = (ARCS_Pointer_t)(intptr_t)buf; buflend = (uint32_t)buflen; @@ -174,7 +213,7 @@ size_t ARCS_Write(int fd, const char *buf, size_t buflen) { - ARCS_Pointer_t (*Write)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t); + uint32_t (*Write)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t); size_t len; uint32_t fdd; ARCS_Pointer_t bufd; @@ -182,7 +221,7 @@ uint32_t lend; ARCS_Pointer_t lenpd; - Write = (ARCS_Pointer_t (*)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Write_Offset]; + Write = (uint32_t (*)(uint32_t, ARCS_Pointer_t, uint32_t, ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Write_Offset]; fdd = (uint32_t)fd; bufd = (ARCS_Pointer_t)(intptr_t)buf; buflend = (uint32_t)buflen; @@ -192,6 +231,28 @@ return (len); } +int +ARCS_Seek(int fd, off_t *offp, int whence) +{ + uint32_t (*Seek)(uint32_t, ARCS_Pointer_t, uint32_t); + int error; + uint32_t errord; + uint32_t fdd; + uint64_t offd; + ARCS_Pointer_t offpd; + uint32_t whenced; + + Seek = (uint32_t (*)(uint32_t, ARCS_Pointer_t, uint32_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_Seek_Offset]; + fdd = (uint32_t)fd; + offd = (uint64_t)*offp; + offpd = (ARCS_Pointer_t)(intptr_t)&offd; + whenced = (uint32_t)whence; + errord = (*Seek)(fdd, offpd, whenced); + error = (int)errord; + *offp = offd; + return (error); +} + struct ARCS_Component * ARCS_GetChild(const struct ARCS_Component *component) { ==== //depot/projects/mips/sys/dev/arcs/arcs.h#3 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/dev/arcs/arcs.h#2 $ + * $P4: //depot/projects/mips/sys/dev/arcs/arcs.h#3 $ */ #ifndef _DEV_ARCS_ARCS_H_ @@ -34,6 +34,8 @@ #if defined (IP22) typedef int32_t ARCS_Pointer_t; +#elif defined (IP30) +typedef int64_t ARCS_Pointer_t; #endif #else #error "ARCS not supported." @@ -107,9 +109,12 @@ void ARCS_Reboot(void); const char *ARCS_GetEnvironmentVariable(const char *); struct ARCS_Mem *ARCS_GetMemoryDescriptor(const struct ARCS_Mem *); +int ARCS_Open(const char *, int, int *); +int ARCS_Close(int); size_t ARCS_Read(int, char *, size_t); int ARCS_GetReadStatus(int); size_t ARCS_Write(int, const char *, size_t); +int ARCS_Seek(int, off_t *, int); struct ARCS_Component *ARCS_GetChild(const struct ARCS_Component *); #endif /* _DEV_ARCS_ARCS_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406140453.i5E4r1Mo076800>