home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / at / at_setup.inf < prev    next >
Internet Message Format  |  1994-03-04  |  5KB

  1. From: mcvax!hp4nl!botter!klipper.cs.vu.nl!ogilvie@uunet.uu.net (Ogilvie)
  2. Newsgroups: comp.sys.ibm.pc
  3. Subject: Re: Setup RAM information: here  is the info + program
  4. Date: 17 Sep 88 16:21:54 GMT
  5.  
  6. Here follows some code to deal with the AT-setup,  but first the theory:
  7.  
  8. Setup information is kept in the Motorola MC146818 CMOS RTC RAM, which
  9. is a battery-powered chip with a real-time  clock (so the PC knows
  10. time and date at startup) and 64 bytes of RAM (also battery powered so
  11. the information is secured over power-downs).
  12.  
  13. I have a quiestion too: Does anyone knows if the number of hard disk
  14. definitions in the BIOS is recorded somewhere?
  15.  
  16. Here follows what I kow about the SETUP.
  17.  
  18. I/O addresses:        to chip:    70h
  19.             from chip:    71h
  20.  
  21. Internal RAM usage:
  22. address        meaning
  23. -----------    ------------------
  24. 0        seconds (real time)
  25. 1        seconds (alarm)
  26. 2        minutes (real time)
  27. 3        minutes (alarm)
  28. 4        hours (real time)
  29. 5        hours (alarm)
  30. 6        day of the week
  31. 7        day-number
  32. 8        month-number
  33. 9        year
  34. 10        status reg. A
  35. 11        status reg. B
  36. 12        status reg. C
  37. 13        status reg. D
  38. 14        chip diagnostics status
  39. 15        shutdown reason
  40. 16        diskette types for A and B (see below)
  41. 17        reserved
  42. 18        hard disk types C and D (see below
  43. 19        reserved
  44. 20        equipment byte
  45. 21        low byte amount of standard memory
  46. 22        high byte amount of standard memory
  47. 23        low byte expansion memory
  48. 24        high byte " "
  49. 25        hard disk type C if byte 18, bits 7-4 == 15
  50. 26        hard disk type D if byte 18, bits 3-0 == 15
  51. -45        reserved
  52. 46-47        RTC checksum
  53. 48        as byte 16, actual
  54. 49        as byte 18, actual
  55. 50        eon
  56. 51        flags
  57. 52-63        reserved
  58.  
  59.  
  60. Diskette types (byte 16)
  61. ------------------------
  62. bits 7-4: A-drive
  63.       0: not present
  64.       1: 320/360Kb
  65.       2: 1.2Mb
  66. bits 3-0: B-drive (same)
  67.  
  68.  
  69. Hard disk types (byte 18)
  70. -------------------------
  71. bits 7-4: first hard disk
  72.       0: not installed
  73.       1-14: index into BIOS table with definitions (see below)
  74.       15: installed, see byte 25 for actual type
  75. bits 3-0: second hard disk (same)
  76.  
  77. Now follows some code. The first is in assembler. The routines can read
  78. any byte from the RTC-RAM. The second copies the ROM-BIOS stored HD
  79. definitons to user memory.
  80. Next follows a C-program that displays the definitons found in the BIOS.
  81.  
  82. -------------------------------------- cut ----------------------------
  83. ; Assembler to be linked with MS-C (4.0)
  84.  
  85.     PUBLIC _getrtc, _gettab
  86.  
  87. rtc_port0 equ 70h
  88. rtc_port1 equ 71h
  89. CMOSDIAG  equ 10h
  90.  
  91. _TEXT    SEGMENT    PUBLIC BYTE 'CODE'    ; start the code segment
  92.     ASSUME CS:_TEXT,DS:nothing
  93.  
  94. _getrtc    PROC NEAR
  95. ;
  96. ;   ret= getrtc (regnum)
  97. ;
  98.     push    bp
  99.     mov    bp,sp
  100.  
  101.     mov    ax,CMOSDIAG
  102.     out    rtc_port0,al
  103.     jmp    $+2        ; delay a little for chip
  104.     jmp    $+2        ; before reading it's answer
  105.     in    al,rtc_port1    ; Get the answer
  106.     test    al,0C0h        ; battery and checksum ok?
  107.     jz    ok
  108.     mov    ax, -1
  109.     jmp    eind        ; (dutch for end, but end is reserved)
  110.  
  111.      ok:mov    al,[bp+4]
  112.     out    rtc_port0,al
  113.     jmp    $+2
  114.     jmp    $+2
  115.     in    al, rtc_port1
  116.     xor    ah,ah
  117.    eind:pop    bp
  118.     ret
  119. _getrtc    ENDP
  120.  
  121.  
  122. _gettab    PROC NEAR    ; get the disk definition tabel in the BIOS
  123. ;
  124. ; gettab (table, curr_ptr)
  125. ;
  126. ; The disk table in the BIOS is copied into a user-structure (see below).
  127. ; In order to know where it starts, the caller got the current definition
  128. ; which is just an index into this table, and transformed this into a
  129. ; negative offset to be used by this routine. The current pointer of
  130. ; the interrupt 41h vector points to this definition in the ROM-BIOS.
  131. ;
  132.     push    bp
  133.     mov    bp,sp
  134.     push    ds
  135.     push    ds
  136.  
  137.     mov    di,[bp+4]    ; destination
  138.     mov    cx,[bp+6]    ; length
  139.     shr    cx,1        ; move words
  140.  
  141.     xor    ax,ax
  142.     mov    es,ax
  143.     mov    ax,es:[104h+2]    ; FDBtab segment at int 41h location
  144.     mov    ds,ax        ; source segment at int 41h location
  145.  
  146.     mov    ax,es:[104h]    ; FDBtab offset + index
  147.     sub    ax,[bp+8]    ; base of table
  148.     mov    si,ax        ; source offset
  149.  
  150.     pop    es        ; es=ds (destination segment)
  151.     cld
  152.     rep    movsw        ; copy it.
  153.  
  154.     pop    ds
  155.     pop    bp
  156.     ret
  157. _gettab    ENDP
  158.  
  159. ENDS
  160.     end
  161. -------------------------------- cut ----------------------
  162.  
  163. /* File to read out the disk types defined in your BIOS and display
  164.  * them on the screen. Uses the previous assembler
  165.  */
  166.  
  167. #include <stdio.h>
  168.  
  169. int i, disktype;
  170.  
  171. typedef unsigned int word;
  172. typedef unsigned char byte;
  173.  
  174. struct FDBTAB {        /* fixed disk base table */
  175.     word    ncyls;
  176.     byte    nheads;
  177.     word    dummy1;
  178.     word    wr_pre;
  179.     byte    eccburst;
  180.     byte    control;
  181.     byte    dummy2;
  182.     byte    dummy3;
  183.     byte    dummy4;
  184.     word    landing;
  185.     byte    sects;
  186.     byte    reserved;
  187. } FDBtab [60];
  188.  
  189. char header[]="\
  190. nr.  cyls.  heads  wr-pre  ecc  control  landing  sects\n\
  191. ---  -----  -----  ------  ---  -------  -------  -----\n";
  192.  
  193. main(argc,argv)
  194. int argc;
  195. char *argv[];
  196. {
  197.     if (argc>1)
  198.     if (stricmp(argv[1],"-i")==0)
  199.         ignore= 1;            /* don't stop after null definiton */
  200.     if ((disktype=getrtc(0x12)) == -1) {
  201.         puts ("RTC-diagnose bad or not an AT");
  202.         exit(1);
  203.     }
  204.     disktype = (disktype & 0xF0) >> 4;
  205.     if (disktype==15)
  206.     disktype= getrtc(0x19);
  207.     printf ("current type HD1: %d\n\n",disktype);
  208.     gettab (FDBtab, 60*sizeof(struct FDBTAB), (disktype-1)*sizeof(struct FDBTAB));
  209.  
  210.     i=0; printf (header);
  211.     while (FDBtab[i].ncyls || FDBtab[i+1].ncyls || ignore) {
  212.     printf ("%2d%8u%7d%8d%5d%9x%9d%7d\n",i+1,
  213.             FDBtab[i].ncyls,
  214.             FDBtab[i].nheads,
  215.             FDBtab[i].wr_pre,
  216.             FDBtab[i].eccburst,
  217.             FDBtab[i].control,
  218.             FDBtab[i].landing,
  219.             FDBtab[i].sects );
  220.     i++;
  221.     }
  222. }
  223. ------------------------ cut ------------------
  224.  
  225. Kind regards, Paul Ogilvie
  226.