summaryrefslogtreecommitdiffstats
path: root/readdir.asm
blob: 4bd411824e02f19f0edf41751e5999572bb249d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* -*- asm -*- ----------------------------------------------------------- *
 *   
 *   Copyright 2013 H. Peter Anvin - All Rights Reserved
 *
 *   Permission is hereby granted, free of charge, to any person
 *   obtaining a copy of this software and associated documentation
 *   files (the "Software"), to deal in the Software without
 *   restriction, including without limitation the rights to use,
 *   copy, modify, merge, publish, distribute, sublicense, and/or
 *   sell copies of the Software, and to permit persons to whom
 *   the Software is furnished to do so, subject to the following
 *   conditions:
 *   
 *   The above copyright notice and this permission notice shall
 *   be included in all copies or substantial portions of the Software.
 *   
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *   OTHER DEALINGS IN THE SOFTWARE.
 *
 * ----------------------------------------------------------------------- */

#include "v9fs.h"

	.code16
	.section ".rtext","ax"

/* ------------------------------------------------------------------------- *
 *  fxn_findfirst
 * ------------------------------------------------------------------------- */

GPROC(fxn_findfirst)
	lfsw dos_sdafcb,%si
	movw dos_sdafn,%bx
	addw $SDN_SEARCHDATA,%bx
	movb drive_letter,%ah
	orb $0xc0,%ah
	movb %fs:SDF_ATTRIB(%si),%al		/* File search attributes */
	/* Save drive letter and search attributes */
	movw %ax,%fs:(%bx)
#ifdef DEBUG
	debugmsg "findfirst attrib = "
	pushw %ax
	call debug_printhex2
#endif
	testb $0x08,%al
	jnz label
#ifdef DEBUG
	debugmsg " fn1 = "
	pushw %ax
	pushw %fs
	leaw %fs:(SDN_FN1-SDN_SEARCHDATA)(%bx),%ax
	pushw %ax
	call debug_puts_far
	popw %ax
	call debug_crlf
#endif
	
	movl $0x08030002,%eax		/* File not found */
	clc
	retw
label:
	/* Should check that we are in the root directory here */
	leaw (SDN_DIRENT-SDN_SEARCHDATA)(%bx),%di
	pushw %es
	pushw %fs
	popw %es
	movw $11,%cx
	movw $volume_label,%si
	rep movsb
	stosb				/* Attribute: directory entry */
	xorw %ax,%ax
	movw $((32-12)/2),%cx
	rep stosb
	movb $21,(16-32)(%di)		/* 1980-01-01 */
	popw %es
	xorw %ax,%ax
	retw
END(fxn_findfirst)

/* ------------------------------------------------------------------------- *
 *  fxn_findnext
 * ------------------------------------------------------------------------- */

GPROC(fxn_findnext)
	movl $0x08060012,%eax		/* No more files */
	clc
	retw
END(fxn_findnext)