summaryrefslogtreecommitdiffstats
path: root/open.asm
diff options
context:
space:
mode:
Diffstat (limited to 'open.asm')
-rw-r--r--open.asm63
1 files changed, 58 insertions, 5 deletions
diff --git a/open.asm b/open.asm
index db5e7c2..b14add7 100644
--- a/open.asm
+++ b/open.asm
@@ -25,6 +25,10 @@
*
* ----------------------------------------------------------------------- */
+#include "v9fs.h"
+ .code16
+ .section ".rtext","ax"
+
/* ------------------------------------------------------------------------- *
* fxn_create
* ------------------------------------------------------------------------- */
@@ -57,9 +61,9 @@ END(fxn_open)
* ------------------------------------------------------------------------- */
GPROC(fxn_spopenfile)
- lfsw dos_sdafcb,%si
- movw %fs:SPN_SPCACTION(%si),%ax /* Open action */
- movw %fs:SPN_SPCMODE(%si),%dx /* Open mode */
+ lfsw dos_sdafcb,%bx
+ movw %fs:SDF_SPCACTION(%bx),%ax /* Open action */
+ movw %fs:SDF_SPCMODE(%bx),%dx /* Open mode */
call do_open
andw %ax,%ax
jnz 1f
@@ -72,7 +76,7 @@ END(fxn_spopenfile)
* do_open
*
* Common interface to all the open variants. Take the extended open
- * action code in %ax and the open mode in %dx. SDN_FN1 contains the
+ * action code in %al and the open mode in %dx. SDN_FN1 contains the
* fully qualified filename.
*
* On return, the status code is in %(e)ax and on success an extended
@@ -80,6 +84,55 @@ END(fxn_spopenfile)
* ------------------------------------------------------------------------- */
LPROC(do_open)
- movw $0x08030002,%eax
+ lfsw dos_sdafn,%si
+
+ pushw %ax /* 8(%bp) Action code */
+ pushw %dx /* 6(%bp) Open mode */
+ pushw F_ES /* 2(%bp) SFT pointer - also used as FID */
+ pushw F_DI
+ pushw %bp /* (%bp) */
+ movw %sp,%bp
+
+ addw $2,%si /* Skip leading drive : */
+
+ testb $0x03,%al
+ jz 101f
+
+ /* Open or "replace" */
+ movl 2(%bp),%eax
+ call path_walk_asciiz
+ jc 101f /* Not found */
+ andb %al,%al /* P9_QTFILE = 0x00 */
+ jne 102f /* Not a file */
+
+ movw msgbuf7,%si
+ movl 2(%bp),%eax
+ stosl
+ movzwl 6(%bp),%eax
+ andb $3,%al /* O_RDONLY, O_WRONLY, O_RDWR */
+ movb 8(%bp),%cl
+ andb $0x2,%cl
+ orb %cl,%ah /* 0x200 = O_TRUNC */
+ stosl
+ movb $P9_TLOPEN,%al
+ call simple_message
+ jc 102f
+
+ /* XXX: Set %cx return status */
+
+ xorw %ax,%ax /* Success! */
+ jmp 100f
+
+103:
+ /* Error, but need to clunk */
+ movl 2(%bp),%eax
+ call clunk
+101: /* XXX: should handle create!!! */
+102:
+ /* Error: XXX: handle error code */
+ movl $0x08030002,%eax
+100:
+ popw %bp
+ addw $8,%sp
retw
END(do_open)