summaryrefslogtreecommitdiffstats
path: root/v9fs.h
blob: 2588a8423cc592429c3a043c7b7c0693e593b372 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
/* -*- 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.
 *
 * ----------------------------------------------------------------------- */

#ifndef V9FS_H
#define V9FS_H

/* 9P protocol opcodes */
#define P9_TLERROR 6
#define P9_RLERROR 7
#define P9_TSTATFS 8
#define P9_RSTATFS 9
#define P9_TLOPEN 12
#define P9_RLOPEN 13
#define P9_TLCREATE 14
#define P9_RLCREATE 15
#define P9_TSYMLINK 16
#define P9_RSYMLINK 17
#define P9_TMKNOD 18
#define P9_RMKNOD 19
#define P9_TRENAME 20
#define P9_RRENAME 21
#define P9_TREADLINK 22
#define P9_RREADLINK 23
#define P9_TGETATTR 24
#define P9_RGETATTR 25
#define P9_TSETATTR 26
#define P9_RSETATTR 27
#define P9_TXATTRWALK 30
#define P9_RXATTRWALK 31
#define P9_TXATTRCREATE 32
#define P9_RXATTRCREATE 33
#define P9_TREADDIR 40
#define P9_RREADDIR 41
#define P9_TFSYNC 50
#define P9_RFSYNC 51
#define P9_TLOCK 52
#define P9_RLOCK 53
#define P9_TGETLOCK 54
#define P9_RGETLOCK 55
#define P9_TLINK 70
#define P9_RLINK 71
#define P9_TMKDIR 72
#define P9_RMKDIR 73
#define P9_TRENAMEAT 74
#define P9_RRENAMEAT 75
#define P9_TUNLINKAT 76
#define P9_RUNLINKAT 77
#define P9_TVERSION 100
#define P9_RVERSION 101
#define P9_TAUTH 102
#define P9_RAUTH 103
#define P9_TATTACH 104
#define P9_RATTACH 105
#define P9_TERROR 106
#define P9_RERROR 107
#define P9_TFLUSH 108
#define P9_RFLUSH 109
#define P9_TWALK 110
#define P9_RWALK 111
#define P9_TOPEN 112
#define P9_ROPEN 113
#define P9_TCREATE 114
#define P9_RCREATE 115
#define P9_TREAD 116
#define P9_RREAD 117
#define P9_TWRITE 118
#define P9_RWRITE 119
#define P9_TCLUNK 120
#define P9_RCLUNK 121
#define P9_TREMOVE 122
#define P9_RREMOVE 123
#define P9_TSTAT 124
#define P9_RSTAT 125
#define P9_TWSTAT 126
#define P9_RWSTAT 127

/* 9P QID types */
#define P9_QTDIR 0x80
#define P9_QTAPPEND 0x40
#define P9_QTEXCL 0x20
#define P9_QTMOUNT 0x10
#define P9_QTAUTH 0x08
#define P9_QTTMP 0x04
#define P9_QTSYMLINK 0x02
#define P9_QTLINK 0x01
#define P9_QTFILE 0x00

/* Linux errno */
#define L_EPERM            1      /* Operation not permitted */
#define L_ENOENT           2      /* No such file or directory */
#define L_ESRCH            3      /* No such process */
#define L_EINTR            4      /* Interrupted system call */
#define L_EIO              5      /* I/O error */
#define L_ENXIO            6      /* No such device or address */
#define L_E2BIG            7      /* Argument list too long */
#define L_ENOEXEC          8      /* Exec format error */
#define L_EBADF            9      /* Bad file number */
#define L_ECHILD          10      /* No child processes */
#define L_EAGAIN          11      /* Try again */
#define L_ENOMEM          12      /* Out of memory */
#define L_EACCES          13      /* Permission denied */
#define L_EFAULT          14      /* Bad address */
#define L_ENOTBLK         15      /* Block device required */
#define L_EBUSY           16      /* Device or resource busy */
#define L_EEXIST          17      /* File exists */
#define L_EXDEV           18      /* Cross-device link */
#define L_ENODEV          19      /* No such device */
#define L_ENOTDIR         20      /* Not a directory */
#define L_EISDIR          21      /* Is a directory */
#define L_EINVAL          22      /* Invalid argument */
#define L_ENFILE          23      /* File table overflow */
#define L_EMFILE          24      /* Too many open files */
#define L_ENOTTY          25      /* Not a typewriter */
#define L_ETXTBSY         26      /* Text file busy */
#define L_EFBIG           27      /* File too large */
#define L_ENOSPC          28      /* No space left on device */
#define L_ESPIPE          29      /* Illegal seek */
#define L_EROFS           30      /* Read-only file system */
#define L_EMLINK          31      /* Too many links */
#define L_EPIPE           32      /* Broken pipe */
#define L_EDOM            33      /* Math argument out of domain of func */
#define L_ERANGE          34      /* Math result not representable */
#define L_EDEADLK         35      /* Resource deadlock would occur */
#define L_ENAMETOOLONG    36      /* File name too long */
#define L_ENOLCK          37      /* No record locks available */
#define L_ENOSYS          38      /* Function not implemented */
#define L_ENOTEMPTY       39      /* Directory not empty */
#define L_ELOOP           40      /* Too many symbolic links encountered */
#define L_ENOMSG          42      /* No message of desired type */
#define L_EIDRM           43      /* Identifier removed */
#define L_ECHRNG          44      /* Channel number out of range */
#define L_EL2NSYNC        45      /* Level 2 not synchronized */
#define L_EL3HLT          46      /* Level 3 halted */
#define L_EL3RST          47      /* Level 3 reset */
#define L_ELNRNG          48      /* Link number out of range */
#define L_EUNATCH         49      /* Protocol driver not attached */
#define L_ENOCSI          50      /* No CSI structure available */
#define L_EL2HLT          51      /* Level 2 halted */
#define L_EBADE           52      /* Invalid exchange */
#define L_EBADR           53      /* Invalid request descriptor */
#define L_EXFULL          54      /* Exchange full */
#define L_ENOANO          55      /* No anode */
#define L_EBADRQC         56      /* Invalid request code */
#define L_EBADSLT         57      /* Invalid slot */
#define L_EBFONT          59      /* Bad font file format */
#define L_ENOSTR          60      /* Device not a stream */
#define L_ENODATA         61      /* No data available */
#define L_ETIME           62      /* Timer expired */
#define L_ENOSR           63      /* Out of streams resources */
#define L_ENONET          64      /* Machine is not on the network */
#define L_ENOPKG          65      /* Package not installed */
#define L_EREMOTE         66      /* Object is remote */
#define L_ENOLINK         67      /* Link has been severed */
#define L_EADV            68      /* Advertise error */
#define L_ESRMNT          69      /* Srmount error */
#define L_ECOMM           70      /* Communication error on send */
#define L_EPROTO          71      /* Protocol error */
#define L_EMULTIHOP       72      /* Multihop attempted */
#define L_EDOTDOT         73      /* RFS specific error */
#define L_EBADMSG         74      /* Not a data message */
#define L_EOVERFLOW       75      /* Value too large for defined data type */
#define L_ENOTUNIQ        76      /* Name not unique on network */
#define L_EBADFD          77      /* File descriptor in bad state */
#define L_EREMCHG         78      /* Remote address changed */
#define L_ELIBACC         79      /* Can not access a needed shared library */
#define L_ELIBBAD         80      /* Accessing a corrupted shared library */
#define L_ELIBSCN         81      /* .lib section in a.out corrupted */
#define L_ELIBMAX         82      /* Attempting to link in too many shared libraries */
#define L_ELIBEXEC        83      /* Cannot exec a shared library directly */
#define L_EILSEQ          84      /* Illegal byte sequence */
#define L_ERESTART        85      /* Interrupted system call should be restarted */
#define L_ESTRPIPE        86      /* Streams pipe error */
#define L_EUSERS          87      /* Too many users */
#define L_ENOTSOCK        88      /* Socket operation on non-socket */
#define L_EDESTADDRREQ    89      /* Destination address required */
#define L_EMSGSIZE        90      /* Message too long */
#define L_EPROTOTYPE      91      /* Protocol wrong type for socket */
#define L_ENOPROTOOPT     92      /* Protocol not available */
#define L_EPROTONOSUPPORT 93      /* Protocol not supported */
#define L_ESOCKTNOSUPPORT 94      /* Socket type not supported */
#define L_EOPNOTSUPP      95      /* Operation not supported on transport endpoint */
#define L_EPFNOSUPPORT    96      /* Protocol family not supported */
#define L_EAFNOSUPPORT    97      /* Address family not supported by protocol */
#define L_EADDRINUSE      98      /* Address already in use */
#define L_EADDRNOTAVAIL   99      /* Cannot assign requested address */
#define L_ENETDOWN        100     /* Network is down */
#define L_ENETUNREACH     101     /* Network is unreachable */
#define L_ENETRESET       102     /* Network dropped connection because of reset */
#define L_ECONNABORTED    103     /* Software caused connection abort */
#define L_ECONNRESET      104     /* Connection reset by peer */
#define L_ENOBUFS         105     /* No buffer space available */
#define L_EISCONN         106     /* Transport endpoint is already connected */
#define L_ENOTCONN        107     /* Transport endpoint is not connected */
#define L_ESHUTDOWN       108     /* Cannot send after transport endpoint shutdown */
#define L_ETOOMANYREFS    109     /* Too many references: cannot splice */
#define L_ETIMEDOUT       110     /* Connection timed out */
#define L_ECONNREFUSED    111     /* Connection refused */
#define L_EHOSTDOWN       112     /* Host is down */
#define L_EHOSTUNREACH    113     /* No route to host */
#define L_EALREADY        114     /* Operation already in progress */
#define L_EINPROGRESS     115     /* Operation now in progress */
#define L_ESTALE          116     /* Stale NFS file handle */
#define L_EUCLEAN         117     /* Structure needs cleaning */
#define L_ENOTNAM         118     /* Not a XENIX named type file */
#define L_ENAVAIL         119     /* No XENIX semaphores available */
#define L_EISNAM          120     /* Is a named type file */
#define L_EREMOTEIO       121     /* Remote I/O error */
#define L_EDQUOT          122     /* Quota exceeded */
#define L_ENOMEDIUM       123     /* No medium found */
#define L_EMEDIUMTYPE     124     /* Wrong medium type */
#define L_ECANCELED       125     /* Operation Canceled */
#define L_ENOKEY          126     /* Required key not available */
#define L_EKEYEXPIRED     127     /* Key has expired */
#define L_EKEYREVOKED     128     /* Key has been revoked */
#define L_EKEYREJECTED    129     /* Key was rejected by service */
#define L_EOWNERDEAD      130     /* Owner died */
#define L_ENOTRECOVERABLE 131     /* State not recoverable */
#define L_ERFKILL         132     /* Operation not possible due to RF-kill */
#define L_EHWPOISON       133     /* Memory page has hardware error */

/*
 * Fields in the DOS Swappable Data Area (SDA)
 *
 * The SDA is different in DOS 3 and DOS 4+, but the areas we care about
 * are either at the common head of the SDA (SDA_), they are at a
 * fixed address relative to the filename buffers (SDN_), or they are
 * at a fixed address with the FCB fields (SDF_)
 */
#define SDA_ERRLOCUS	0x003	/* Extended error locus */
#define SDA_ERREXT	0x004	/* Extended error code */
#define SDA_ERRACTION	0x006	/* Extended error suggested action */
#define SDA_ERRCLASS	0x007	/* Extended error class */
#define SDA_ERRPTR	0x008	/* Extended error pointer */
#define SDA_DTAPTR	0x00C	/* Pointer to current DTA */

#define SDN_FN1		0x000	/* First filename */
#define SDN_FN2		0x080	/* Second filename */
#define SDN_SEARCHDATA	0x100	/* Find first/find next data block */
#define SDN_DIRENT	0x115	/* FAT-style directory entry for found file */
#define SDN_CDS		0x135	/* Copy of CDS for current file */

#define SDF_DEVNAME	0x000	/* Formatted filename for device comparison */
#define SDF_WILDREN	0x00c	/* Wildcard pattern for rename */
#define SDF_ATTRIB	0x020	/* Search attributes */
#define SDF_FCBTYPE	0x021	/* Extended FCB? */
#define SDF_DIRSRCH	0x022	/* Directory search attributes */
#define SDF_OPENMODE	0x023	/* File open mode */

/* These are DOS 4+ specific; base them on SDF for consistency */
#define SDF_SPCACTION	(0x2dd-0x22b)	/* Special open action */
#define SDF_SPCATTRIB	(0x2df-0x22b)	/* Special open file attributes */
#define SDF_SPCMODE	(0x2e1-0x22b)	/* Special open mode */

/*
 * Fields in the DOS Current Directory Structure (CDS)
 *
 * Each drive letter has one CDS, but that includes SUBST, JOIN etc.
 */
#define CDS_PATH	0x00	/* Path to current directory */
#define CDS_FLAGS	0x43	/* Drive attribute flags */
#define CDS_DPBPTR	0x45	/* Drive Parameter Block pointer */
#define CDS_REDIRPTR	0x49	/* Pointer to redirector */
#define CDS_USERVAL	0x4d	/* Network redirector "userval" */
#define CDS_ROOTOFFSET	0x4f	/* Characters to skip in path */

/*
 * Fields in the DOS System File Table (SFT) entries
 */
#define SFT_HANDLES	0x00	/* Count of file handles */
#define SFT_MODE	0x02	/* File open mode per INT 21h, AH=3Dh */
#define SFT_ATTRIB	0x04	/* File attribute */
#define SFT_DEVINFO	0x05	/* Device info word (includes drive #) */
#define SFT_DPBPTR	0x07	/* Drive Parameter Block pointer */
#define SFT_CLUSTER	0x0b	/* Starting cluster */
#define SFT_DATETIME	0x0d	/* date:time */
#define SFT_SIZE	0x11	/* Size of file in bytes */
#define SFT_OFFSET	0x15	/* File pointer */
#define SFT_OWNER	0x31	/* PSP of process owning file */
	
/* FID numbers we use */
#define FID_ROOT	2
#define FID_DISKSPACE	3
#define FID_CHDIR	4

/* Invocation frame assuming prev_stack is loaded into gs:bp */
#define F_GS	%gs:(%bp)
#define F_FS	%gs:2(%bp)
#define F_ES	%gs:4(%bp)
#define F_DS	%gs:6(%bp)
#define F_EDI	%gs:8(%bp)
#define F_DI	%gs:8(%bp)
#define F_ESI	%gs:12(%bp)
#define F_SI	%gs:12(%bp)
#define F_EBP	%gs:16(%bp)
#define F_BP	%gs:16(%bp)
#define F_ESP	%gs:20(%bp)
#define F_SP	%gs:20(%bp)
#define F_EBX	%gs:24(%bp)
#define F_BX	%gs:24(%bp)
#define F_BL	%gs:24(%bp)
#define F_BH	%gs:25(%bp)
#define F_EDX	%gs:28(%bp)
#define F_DX	%gs:28(%bp)
#define F_DL	%gs:28(%bp)
#define F_DH	%gs:29(%bp)
#define F_ECX	%gs:32(%bp)
#define F_CX	%gs:32(%bp)
#define F_CL	%gs:32(%bp)
#define F_CH	%gs:33(%bp)
#define F_EAX	%gs:36(%bp)
#define F_AX	%gs:36(%bp)
#define F_AL	%gs:36(%bp)
#define F_AH	%gs:37(%bp)
#define F_IP	%gs:40(%bp)
#define F_CS	%gs:42(%bp)
#define F_FLAGS	%gs:44(%bp)
#define F_TOS	%gs:46(%bp)	/* Word on stack before INT 2F */
#define F_TOSH	%gs:47(%bp)	/* Word on stack before INT 2F - high byte */

/* Magic number we store in the CDS */
#define CDS_MAGIC	0xe882

/* Procedure wrappers */
#define GLOBAL(x)	.globl x ; x ## :
#define GPROC(x)	.globl x ; .type x,@function ; x ## :
#define LPROC(x)	.type x,@function ; x ## :
#define END(x)		.size x,.-x

/*
 * Macros to print out a message and an error
 */
	.macro printmsg msg
	.pushsection ".rodata.str","a",@progbits
101:	.asciz "\msg"
	.popsection
	pushw $101b
	call puts
	.endm

	.macro printerr msg
	.pushsection ".rodata.str","a",@progbits
101:	.asciz "\msg"
	.popsection
	pushw $101b
	call puterr
	.endm

#ifdef DEBUG
	.macro debugmsg msg
	.pushsection ".rrodata.str","a",@progbits
101:	.asciz "\msg"
	.popsection
	pushw $101b
	call debug_puts
	.endm
#else
	.macro debugmsg msg
	.endm
#endif

/*
 * Macros to define data objects
 *
 * Prefix is:
 * <g>lobal or <l>ocal,
 * <r>esident or <i>nit,
 * <r>odata <d>ata or <b>ss
 */
	.macro lrrbyte name val
	.pushsection ".rrodata.byte","a",@progbits
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro lrdbyte name val
	.pushsection ".rdata.byte","aw",@progbits
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro lrbbyte name
	.pushsection ".rbss.byte","aw",@nobits
	.balign 1
\name:
	.space 1
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro lirbyte name val
	.pushsection ".rodata.byte","a",@progbits
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro lidbyte name val
	.pushsection ".data.byte","aw",@progbits
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro libbyte name
	.pushsection ".bss.byte","aw",@nobits
	.balign 1
\name:
	.space 1
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro lrrword name val
	.pushsection ".rrodata.word","a",@progbits
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro lrdword name val
	.pushsection ".rdata.word","aw",@progbits
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro lrbword name
	.pushsection ".rbss.word","aw",@nobits
	.balign 2
\name:
	.space 2
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro lirword name val
	.pushsection ".rodata.word","a",@progbits
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro lidword name val
	.pushsection ".data.word","aw",@progbits
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro libword name
	.pushsection ".bss.word","aw",@nobits
	.balign 2
\name:
	.space 2
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro lrrlong name val
	.pushsection ".rrodata.long","a",@progbits
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro lrdlong name val
	.pushsection ".rdata.long","aw",@progbits
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro lrblong name
	.pushsection ".rbss.long","aw",@nobits
	.balign 4
\name:
	.space 4
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro lirlong name val
	.pushsection ".rodata.long","a",@progbits
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro lidlong name val
	.pushsection ".data.long","aw",@progbits
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro liblong name
	.pushsection ".bss.long","aw",@nobits
	.balign 4
\name:
	.space 4
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro grrbyte name val
	.pushsection ".rrodata.byte","a",@progbits
	.globl \name
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro grdbyte name val
	.pushsection ".rdata.byte","aw",@progbits
	.globl \name
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro grbbyte name
	.pushsection ".rbss.byte","aw",@nobits
	.globl \name
	.balign 1
\name:
	.space 1
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro girbyte name val
	.pushsection ".rodata.byte","a",@progbits
	.globl \name
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro gidbyte name val
	.pushsection ".data.byte","aw",@progbits
	.globl \name
	.balign 1
\name:
	.byte \val
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro gibbyte name
	.pushsection ".bss.byte","aw",@nobits
	.globl \name
	.balign 1
\name:
	.space 1
	.size \name,1
	.type \name,@object
	.popsection
	.endm

	.macro grrword name val
	.pushsection ".rrodata.word","a",@progbits
	.globl \name
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro grdword name val
	.pushsection ".rdata.word","aw",@progbits
	.globl \name
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro grbword name
	.pushsection ".rbss.word","aw",@nobits
	.globl \name
	.balign 2
\name:
	.space 2
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro girword name val
	.pushsection ".rodata.word","a",@progbits
	.globl \name
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro gidword name val
	.pushsection ".data.word","aw",@progbits
	.globl \name
	.balign 2
\name:
	.word \val
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro gibword name
	.pushsection ".bss.word","aw",@nobits
	.globl \name
	.balign 2
\name:
	.space 2
	.size \name,2
	.type \name,@object
	.popsection
	.endm

	.macro grrlong name val
	.pushsection ".rrodata.long","a",@progbits
	.globl \name
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro grdlong name val
	.pushsection ".rdata.long","aw",@progbits
	.globl \name
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro grblong name
	.pushsection ".rbss.long","aw",@nobits
	.globl \name
	.balign 4
\name:
	.space 4
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro girlong name val
	.pushsection ".rodata.long","a",@progbits
	.globl \name
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro gidlong name val
	.pushsection ".data.long","aw",@progbits
	.globl \name
	.balign 4
\name:
	.long \val
	.size \name,4
	.type \name,@object
	.popsection
	.endm

	.macro giblong name
	.pushsection ".bss.long","aw",@nobits
	.globl \name
	.balign 4
\name:
	.space 4
	.size \name,4
	.type \name,@object
	.popsection
	.endm

/*
 * Macros to define bss buffers
 *
 * Prefix is:
 * <g>lobal or <l>ocal,
 * <r>esident or <i>nit
 */
	.macro lrbuf name len align=1
	.pushsection ".rbss","aw",@nobits
	.balign \align
\name:
	.space \len
	.size \name, .-\name
	.type \name,@object
	.popsection
	.endm

	.macro libuf name len align=1
	.pushsection ".bss","aw",@nobits
	.balign \align
\name:
	.space \len
	.size \name, .-\name
	.type \name,@object
	.popsection
	.endm

	.macro grbuf name len align=1
	.pushsection ".rbss","aw",@nobits
	.globl \name
	.balign \align
\name:
	.space \len
	.size \name, .-\name
	.type \name,@object
	.popsection
	.endm

	.macro gibuf name len align=1
	.pushsection ".bss","aw",@nobits
	.globl \name
	.balign \align
\name:
	.space \len
	.size \name, .-\name
	.type \name,@object
	.popsection
	.endm


#endif /* V9FS_H */