summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-22 15:19:51 -0700
committerH. Peter Anvin <hpa@zytor.com>2013-03-22 15:21:24 -0700
commite209e69718f52c5387604a554eedce18b03fd7a9 (patch)
tree09ddae5fa86b3a2a5821597b06e95c130f6cae1e
parente151e0aa23f83ead8c24f80695fec07f85496afe (diff)
downloadvirtio9p-master.tar.gz
virtio9p-master.tar.xz
virtio9p-master.zip
Add a (barely) working open function (no create yet)HEADmaster
Add a minimally functional open implementation
-rw-r--r--int2f.asm1
-rw-r--r--open.asm63
-rw-r--r--pathname.asm2
3 files changed, 60 insertions, 6 deletions
diff --git a/int2f.asm b/int2f.asm
index 063d075..f3ba189 100644
--- a/int2f.asm
+++ b/int2f.asm
@@ -57,6 +57,7 @@ LPROC(int2f_11) /* it is a redirector call */
pushw %fs
pushw %gs
+ cld
movw %cs,%cx
movw %cx,%ds
movw %ss,prev_stack+2
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)
diff --git a/pathname.asm b/pathname.asm
index 469e607..ff05aa2 100644
--- a/pathname.asm
+++ b/pathname.asm
@@ -37,7 +37,7 @@
* ------------------------------------------------------------------------- */
GPROC(get_end_path)
pushw %ax
- xchg %si,%bx
+ movw %si,%bx
1:
fs lodsb
andb %al,%al