Subversion Repositories SvarDOS

Rev

Rev 1908 | Rev 1918 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1908 Rev 1911
Line 452... Line 452...
452
parm [bl] \
452
parm [bl] \
453
value [ax]
453
value [ax]
454
 
454
 
455
 
455
 
456
/* returns total disk space of drive drv (in MiB, max 2048, A=1 B=2 etc), or -1 if drive invalid */
456
/* returns total disk space of drive drv (in MiB, max 2048, A=1 B=2 etc), or -1 if drive invalid */
457
static int disksize(int drv);
457
static int disksize(unsigned char drv) {
-
 
458
  unsigned short sec_per_cluster = 0;
-
 
459
  unsigned short tot_clusters = 0;
458
#pragma aux disksize = \
460
  unsigned short bytes_per_sec = 0;
459
"mov ah, 0x36" \
461
  long res;
460
"int 0x21" \
462
  _asm {
461
"cmp ax, 0xffff" /* AX=FFFFh on error */ \
463
    push ax
462
"je FAIL" \
464
    push bx
463
/* AX=sec_per_cluster DX=tot_clusters BX=free_clusters CX=bytes_per_sec */ \
465
    push cx
464
"mul dx"        /* (DX AX) = AX * DX */ \
466
    push dx
-
 
467
 
465
"mov si,ax" \
468
    mov ah, 0x36
466
"mov di,dx" \
469
    mov dl, drv
467
"mul cx"      /* hi * lo */ \
470
    int 0x21
468
"xchg ax, di" /* First mul saved, grab orig DX */ \
471
    /* AX=sec_per_cluster DX=tot_clusters BX=free_clusters CX=bytes_per_sec */
469
"mul bx"      /* lo * hi */ \
472
    mov sec_per_cluster, ax
470
"add di, ax"  /* top word of result */ \
473
    mov bytes_per_sec, cx
471
"mov ax, si"  /* retrieve original AX */ \
474
    mov tot_clusters, dx
-
 
475
 
472
"mul bx"      /* lo * lo */ \
476
    pop dx
473
"add dx, di"  /* DX:AX has the low 32 bits of the multiplication result */ \
477
    pop cx
474
"mov cl, 4" \
478
    pop bx
-
 
479
    pop ax
-
 
480
  }
-
 
481
 
475
"shr dx, cl"  /* (DX AX) >> 20 (convert bytes to MiB) */ \
482
  if (sec_per_cluster == 0xffff) return(-1);
476
"FAIL:" \
483
  res = sec_per_cluster;
477
parm [dl] \
484
  res *= tot_clusters;
478
modify [ax bx cx dx si di] \
485
  res *= bytes_per_sec;
479
value [dx]
486
  res >>= 20;
-
 
487
  return((int)res);
-
 
488
}
480
 
489
 
481
 
490
 
482
/* returns 0 if disk is empty, non-zero otherwise */
491
/* returns 0 if disk is empty, non-zero otherwise */
483
static int diskempty(int drv) {
492
static int diskempty(int drv) {
484
  unsigned int rc;
493
  unsigned int rc;
Line 1007... Line 1016...
1007
  struct slocales *locales = &locales_data;
1016
  struct slocales *locales = &locales_data;
1008
  int targetdrv;
1017
  int targetdrv;
1009
  int sourcedrv;
1018
  int sourcedrv;
1010
  int action;
1019
  int action;
1011
 
1020
 
1012
  /* setup the internal int 24h handler ("always fail") */
1021
  /* setup an internal int 24h handler ("always fail") so DOS does not output
-
 
1022
   * the ugly "abort, retry, fail" messages */
1013
  int24hdl();
1023
  int24hdl();
1014
 
1024
 
1015
  /* read the svardos build revision (from floppy label) */
1025
  /* read the svardos build revision (from floppy label) */
1016
  {
1026
  {
1017
    const char *fspec = "*.*";
1027
    const char *fspec = "*.*";