Author: wmb Date: 2008-08-29 01:14:16 +0200 (Fri, 29 Aug 2008) New Revision: 900
Modified: clients/lib/lib.c clients/lib/wrappers.c clients/lib/wrappers64.c ofw/core/filecmds.fth Log: Added "firmworks,create" to the client interface so client programs can ask OFW to create new files.
Modified: clients/lib/lib.c =================================================================== --- clients/lib/lib.c 2008-08-28 22:42:50 UTC (rev 899) +++ clients/lib/lib.c 2008-08-28 23:14:16 UTC (rev 900) @@ -103,9 +103,14 @@ if (fp == (FILE *)NULL) return ((FILE *)NULL);
- if ((fp->id = OFOpen(name)) == 0) + if ((fp->id = OFOpen(name)) == 0) { + if (mode[0] == 'w' && ((fp->id = OFCreate(name)) != 0)) + goto good; + return ((FILE *)NULL); + }
+ good: fp->bufc = 0; return(fp); }
Modified: clients/lib/wrappers.c =================================================================== --- clients/lib/wrappers.c 2008-08-28 22:42:50 UTC (rev 899) +++ clients/lib/wrappers.c 2008-08-28 23:14:16 UTC (rev 900) @@ -243,6 +243,24 @@ return ((ihandle) argarray[CIF_HANDLER_IN+LOW(1)]); }
+/* FirmWorks extension */ +ihandle +OFCreate( char *devicename) +{ +#ifdef CIF64 + ULONG argarray[] = { 0,(ULONG)"firmworks,create", 0,1, 0,1, 0,0, 0,0}; +#else + cell_t argarray[] = { (cell_t)"firmworks,create", 1,1,0,0}; +#endif + + argarray[CIF_HANDLER_IN+LOW(0)] = (long)devicename; + if (call_firmware(argarray) != 0) + { + return (ihandle)0; + } + return ((ihandle) argarray[CIF_HANDLER_IN+LOW(1)]); +} + void OFClose(ihandle id) {
Modified: clients/lib/wrappers64.c =================================================================== --- clients/lib/wrappers64.c 2008-08-28 22:42:50 UTC (rev 899) +++ clients/lib/wrappers64.c 2008-08-28 23:14:16 UTC (rev 900) @@ -176,6 +176,19 @@ }
ihandle +OFCreate( char *devicename) +{ + ULONG argarray[] = { (ULONG)"firmworks,create",1,1,0,0}; + + argarray[CIF_HANDLER_IN+0] = (long)devicename; + if (call_firmware(argarray) != 0) + { + return (ihandle)0; + } + return ((ihandle) argarray[CIF_HANDLER_IN+1]); +} + +ihandle OFOpen( char *devicename) { ULONG argarray[] = { (ULONG)"open",1,1,0,0};
Modified: ofw/core/filecmds.fth =================================================================== --- ofw/core/filecmds.fth 2008-08-28 22:42:50 UTC (rev 899) +++ ofw/core/filecmds.fth 2008-08-28 23:14:16 UTC (rev 900) @@ -525,6 +525,12 @@ ; ' $create-file to _ofcreate
+dev /client-services +: firmworks,create ( cstr -- ihandle ) + cscount ['] $create-file catch if 2drop 0 then +; +device-end + internal
: ?delete-file ( path$ -- continue? )
openfirmware@openfirmware.info