mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-26 07:15:03 +02:00
Add lock/unlock drive to SYS (from Lucho).
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@658 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
b0d2219a4c
commit
fa11f8e0c5
49
sys/sys.c
49
sys/sys.c
@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
/* These definitions deliberately put here instead of
|
/* These definitions deliberately put here instead of
|
||||||
* #including <stdio.h> to make executable MUCH smaller
|
* #including <stdio.h> to make executable MUCH smaller
|
||||||
|
* using [s]printf from prf.c!
|
||||||
*/
|
*/
|
||||||
extern WORD CDECL printf(CONST BYTE * fmt, ...);
|
extern WORD CDECL printf(CONST BYTE * fmt, ...);
|
||||||
extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...);
|
extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...);
|
||||||
@ -306,7 +307,7 @@ int main(int argc, char **argv)
|
|||||||
if (argc > drivearg + 1 && memicmp(argv[drivearg + 1], "BOOTONLY", 8) != 0)
|
if (argc > drivearg + 1 && memicmp(argv[drivearg + 1], "BOOTONLY", 8) != 0)
|
||||||
bsFile = argv[drivearg + 1]; /* don't write to file "BOOTONLY" */
|
bsFile = argv[drivearg + 1]; /* don't write to file "BOOTONLY" */
|
||||||
|
|
||||||
printf("\nWriting boot sector...\n");
|
printf("Processing boot sector...\n");
|
||||||
put_boot(drive, bsFile,
|
put_boot(drive, bsFile,
|
||||||
(argc > drivearg + 2)
|
(argc > drivearg + 2)
|
||||||
&& memicmp(argv[drivearg + 2], "BOTH", 4) == 0);
|
&& memicmp(argv[drivearg + 2], "BOTH", 4) == 0);
|
||||||
@ -413,6 +414,23 @@ void reset_drive(int DosDrive);
|
|||||||
parm [dx] \
|
parm [dx] \
|
||||||
modify [ax bx];
|
modify [ax bx];
|
||||||
|
|
||||||
|
void lock_drive(int DosDrive);
|
||||||
|
#pragma aux lock_drive = \
|
||||||
|
"mov ax,0x440d" \
|
||||||
|
"mov cx,0x84a" \
|
||||||
|
"xor dx,dx" \
|
||||||
|
"inc bx" \
|
||||||
|
"int 0x21" \
|
||||||
|
parm [bx];
|
||||||
|
|
||||||
|
void unlock_drive(int DosDrive);
|
||||||
|
#pragma aux unlock_drive = \
|
||||||
|
"mov ax,0x440d" \
|
||||||
|
"mov cx,0x86a" \
|
||||||
|
"inc bx" \
|
||||||
|
"int 0x21" \
|
||||||
|
parm [bx];
|
||||||
|
|
||||||
void truename(char far *dest, const char *src);
|
void truename(char far *dest, const char *src);
|
||||||
#pragma aux truename = \
|
#pragma aux truename = \
|
||||||
"mov ah,0x60" \
|
"mov ah,0x60" \
|
||||||
@ -435,10 +453,10 @@ int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno)
|
|||||||
return regs.x.cflag;
|
return regs.x.cflag;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define absread(int DosDrive, int foo, int cx, void *diskReadPacket) \
|
#define absread(DosDrive, foo, cx, diskReadPacket) \
|
||||||
int2526readwrite(DosDrive, diskReadPacket, 0x25)
|
int2526readwrite(DosDrive, diskReadPacket, 0x25)
|
||||||
|
|
||||||
#define abswrite(int DosDrive, int foo, int cx, void *diskReadPacket) \
|
#define abswrite(DosDrive, foo, cx, diskReadPacket) \
|
||||||
int2526readwrite(DosDrive, diskReadPacket, 0x26)
|
int2526readwrite(DosDrive, diskReadPacket, 0x26)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -468,6 +486,27 @@ void reset_drive(int DosDrive)
|
|||||||
intdos(®s, ®s);
|
intdos(®s, ®s);
|
||||||
} /* reset_drive */
|
} /* reset_drive */
|
||||||
|
|
||||||
|
void lock_drive(int DosDrive)
|
||||||
|
{
|
||||||
|
union REGS regs;
|
||||||
|
|
||||||
|
regs.x.ax = 0x440d;
|
||||||
|
regs.x.cx = 0x84a;
|
||||||
|
regs.x.dx = 0;
|
||||||
|
regs.h.bl = DosDrive + 1;
|
||||||
|
intdos(®s, ®s);
|
||||||
|
} /* lock_drive */
|
||||||
|
|
||||||
|
void unlock_drive(int DosDrive)
|
||||||
|
{
|
||||||
|
union REGS regs;
|
||||||
|
|
||||||
|
regs.x.ax = 0x440d;
|
||||||
|
regs.x.cx = 0x86a;
|
||||||
|
regs.h.bl = DosDrive + 1;
|
||||||
|
intdos(®s, ®s);
|
||||||
|
} /* unlock_drive */
|
||||||
|
|
||||||
void truename(char *dest, const char *src)
|
void truename(char *dest, const char *src)
|
||||||
{
|
{
|
||||||
union REGS regs;
|
union REGS regs;
|
||||||
@ -479,7 +518,7 @@ void truename(char *dest, const char *src)
|
|||||||
sregs.ds = FP_SEG(src);
|
sregs.ds = FP_SEG(src);
|
||||||
regs.x.si = FP_OFF(src);
|
regs.x.si = FP_OFF(src);
|
||||||
intdosx(®s, ®s, &sregs);
|
intdosx(®s, ®s, &sregs);
|
||||||
} /* reset_drive */
|
} /* truename */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -585,6 +624,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both)
|
|||||||
printf("Reading old bootsector from drive %c:\n", drive + 'A');
|
printf("Reading old bootsector from drive %c:\n", drive + 'A');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
lock_drive(drive);
|
||||||
reset_drive(drive);
|
reset_drive(drive);
|
||||||
/* suggestion: allow reading from a boot sector or image file here */
|
/* suggestion: allow reading from a boot sector or image file here */
|
||||||
if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0)
|
if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0)
|
||||||
@ -733,6 +773,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both)
|
|||||||
close(fd);
|
close(fd);
|
||||||
} /* if write boot sector file */
|
} /* if write boot sector file */
|
||||||
reset_drive(drive);
|
reset_drive(drive);
|
||||||
|
unlock_drive(drive);
|
||||||
} /* put_boot */
|
} /* put_boot */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user