Subversion Repositories SvarDOS

Rev

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

Rev 1944 Rev 1946
Line 75... Line 75...
75
  unsigned short keybid;
75
  unsigned short keybid;
76
  unsigned short countryid; /* 1=USA, 33=FR, 48=PL, etc */
76
  unsigned short countryid; /* 1=USA, 33=FR, 48=PL, etc */
77
};
77
};
78
 
78
 
79
 
79
 
80
/* returns the DOS boot drive letter ('A', 'B', 'C', etc) */
-
 
81
static unsigned char GETDOSBOOTDRIVE(void);
-
 
82
#pragma aux GETDOSBOOTDRIVE = \
-
 
83
"mov ax, 0x3305" /* int 0x21,AX=3305 - get boot drive (MS-DOS 4.0+) */ \
-
 
84
"int 0x21" \
-
 
85
"jnc GOOD" \
-
 
86
"mov dl, 3"      /* fall back to "C" on error (DOS 3.x...) */ \
-
 
87
"GOOD:" \
-
 
88
"add dl, '@'"    /* convert the drive id (A=1, B=2...) into a drive letter */ \
-
 
89
modify [ax] \
-
 
90
value [dl]
-
 
91
 
-
 
92
 
-
 
93
/* install a dummy int24h handler that always fails. this is to avoid the
80
/* install a dummy int24h handler that always fails. this is to avoid the
94
 * annoying "abort, retry, fail... DOS messages. */
81
 * annoying "abort, retry, fail... DOS messages. */
95
static void install_int24(void) {
82
static void install_int24(void) {
96
  static unsigned char handler[] = { /* contains machine code instructions */
83
  static unsigned char handler[] = { /* contains machine code instructions */
97
    0xB0, 0x03,  /* mov al, 3   ; tell DOS the action has to FAIL   */
84
    0xB0, 0x03,  /* mov al, 3   ; tell DOS the action has to FAIL   */
Line 300... Line 287...
300
      video_putstring(1, 0, COLOR_BODY, buf, -1);
287
      video_putstring(1, 0, COLOR_BODY, buf, -1);
301
    }*/
288
    }*/
302
  }
289
  }
303
}
290
}
304
 
291
 
-
 
292
 
305
static void newscreen(unsigned char statusbartype) {
293
static void newscreen(unsigned char statusbartype) {
306
  const char *msg;
294
  const char *msg;
307
  mdr_cout_cls(COLOR_BODY);
295
  mdr_cout_cls(COLOR_BODY);
308
  msg = svarlang_strid(0x00); /* "SVARDOS INSTALLATION" */
296
  msg = svarlang_strid(0x00); /* "SVARDOS INSTALLATION" */
309
  mdr_cout_char_rep(0, 0, ' ', COLOR_TITLEBAR, 80);
297
  mdr_cout_char_rep(0, 0, ' ', COLOR_TITLEBAR, 80);
Line 472... Line 460...
472
  if (c == 0) return(MENUNEXT);
460
  if (c == 0) return(MENUNEXT);
473
  return(MENUQUIT);
461
  return(MENUQUIT);
474
}
462
}
475
 
463
 
476
 
464
 
477
/* returns 0 if drive is removable, 1 if fixed, -1 on error */
-
 
478
static int isdriveremovable(unsigned char drv);
-
 
479
#pragma aux isdriveremovable = \
-
 
480
"mov ax, 0x4408" \
-
 
481
"int 0x21" \
-
 
482
"jnc DONE" \
-
 
483
"xor ax,ax" \
-
 
484
"dec ax" \
-
 
485
"DONE:" \
-
 
486
parm [bl] \
-
 
487
value [ax]
-
 
488
 
-
 
489
 
-
 
490
/* returns total disk space of drive drv (in MiB, max 2048, A=1 B=2 etc), or -1 if drive invalid */
465
/* returns total disk space of drive drv (in MiB, max 2048, A=1 B=2 etc), or -1 if drive invalid */
491
static int disksize(unsigned char drv) {
466
static int disksize(unsigned char drv) {
492
  unsigned short sec_per_cluster = 0;
467
  unsigned short sec_per_cluster = 0;
493
  unsigned short tot_clusters = 0;
468
  unsigned short tot_clusters = 0;
494
  unsigned short bytes_per_sec = 0;
469
  unsigned short bytes_per_sec = 0;
Line 967... Line 942...
967
    fprintf(fd, "\r\n");
942
    fprintf(fd, "\r\n");
968
  }
943
  }
969
}
944
}
970
 
945
 
971
 
946
 
-
 
947
/* get the DOS "current drive" (0=A:, 1=B:, etc) */
-
 
948
static unsigned char get_cur_drive(void);
-
 
949
#pragma aux get_cur_drive = \
-
 
950
"mov ah, 0x19" /* DOS 1+ GET CURRENT DEFAULT DRIVE */ \
-
 
951
"int 0x21" \
-
 
952
modify [ah] \
-
 
953
value [al]
-
 
954
 
-
 
955
 
972
/* generates configuration files on the dest drive, this is run once system booted successfully */
956
/* generates configuration files on the dest drive, this is run once system
-
 
957
 * booted successfully on the dst drive (postinst stage) */
973
static void bootfilesgen(const struct slocales *locales) {
958
static void bootfilesgen(const struct slocales *locales) {
974
  char buff[128];
959
  char buff[128];
975
  FILE *fd;
960
  FILE *fd;
976
  unsigned char bootdrv = GETDOSBOOTDRIVE();
961
  unsigned char bootdrv = get_cur_drive() + 'A';
977
 
962
 
978
  /****************
963
  /****************
979
   * CONFIG.SYS ***
964
   * CONFIG.SYS ***
980
   ****************/
965
   ****************/
981
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\CONFIG.SYS", bootdrv);
966
  snprintf(buff, sizeof(buff), "%c:\\CONFIG.SYS", bootdrv);
982
  fd = fopen(buff, "wb");
967
  fd = fopen(buff, "wb");
983
  if (fd == NULL) return;
968
  if (fd == NULL) return;
984
  fprintf(fd, "; SvarDOS kernel configuration\r\n"
969
  fprintf(fd, "; SvarDOS kernel configuration\r\n"
985
              "\r\n"
970
              "\r\n"
986
              "; highest allowed drive letter\r\n"
971
              "; highest allowed drive letter\r\n"
Line 1021... Line 1006...
1021
      "@ECHO OFF\r\n"
1006
      "@ECHO OFF\r\n"
1022
      "SET TEMP=#:\\TEMP\r\n"
1007
      "SET TEMP=#:\\TEMP\r\n"
1023
      "SET DOSDIR=#:\\SVARDOS\r\n"
1008
      "SET DOSDIR=#:\\SVARDOS\r\n"
1024
      "SET NLSPATH=%DOSDIR%\\NLS\r\n"
1009
      "SET NLSPATH=%DOSDIR%\\NLS\r\n"
1025
      "SET DIRCMD=/O/P\r\n"
1010
      "SET DIRCMD=/O/P\r\n"
1026
      "SET WATTCP.CFG=%DOSDIR%\\CFG\r\n"
1011
      "SET WATTCP.CFG=%DOSDIR%\r\n"
1027
      "PATH %DOSDIR%\r\n"
1012
      "PATH %DOSDIR%\r\n"
1028
      "PROMPT $P$G\r\n"
1013
      "PROMPT $P$G\r\n"
1029
      "\r\n"
1014
      "\r\n"
1030
      "REM enable CPU power saving\r\n"
1015
      "REM enable CPU power saving\r\n"
1031
      "FDAPM ADV:REG\r\n"
1016
      "FDAPM ADV:REG\r\n"
Line 1087... Line 1072...
1087
    /* write to file */
1072
    /* write to file */
1088
    fputs(pkg_cfg, fd);
1073
    fputs(pkg_cfg, fd);
1089
    fclose(fd);
1074
    fclose(fd);
1090
  }
1075
  }
1091
 
1076
 
-
 
1077
  /****************
1092
  /*** PICOTCP ***/
1078
   * PICOTCP      *
-
 
1079
   ****************/
1093
  /* TODO (or not? maybe not that useful) */
1080
  /* TODO (or not? maybe not that useful) */
1094
 
1081
 
-
 
1082
  /****************
1095
  /*** WATTCP ***/
1083
   * WATTCP.CFG   *
-
 
1084
   ****************/
1096
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\WATTCP.CFG", bootdrv);
1085
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\WATTCP.CFG", bootdrv);
1097
  fd = fopen(buff, "wb");
1086
  fd = fopen(buff, "wb");
1098
  if (fd == NULL) return;
1087
  if (fd == NULL) return;
1099
  fprintf(fd, "my_ip = dhcp\r\n"
1088
  fprintf(fd, "my_ip = dhcp\r\n"
1100
              "#my_ip = 192.168.0.7\r\n"
1089
              "#my_ip = 192.168.0.7\r\n"
1101
              "#netmask = 255.255.255.0\r\n"
1090
              "#netmask = 255.255.255.0\r\n"
1102
              "#nameserver = 192.168.0.1\r\n"
1091
              "#nameserver = 192.168.0.1\r\n"
1103
              "#nameserver = 192.168.0.2\r\n"
1092
              "#nameserver = 192.168.0.2\r\n"
1104
              "#gateway = 192.168.0.1\r\n");
1093
              "#gateway = 192.168.0.1\r\n");
1105
  fclose(fd);
1094
  fclose(fd);
-
 
1095
 
-
 
1096
  /****************
-
 
1097
   * POSTINST.BAT *
-
 
1098
   ****************/
-
 
1099
  /* create the postinst.bat file for actual installation of packages */
-
 
1100
  snprintf(buff, sizeof(buff), "POSTINST.BAT");
-
 
1101
  fd = fopen(buff, "wb");
-
 
1102
  if (fd == NULL) {
-
 
1103
    return;
-
 
1104
  }
-
 
1105
  fprintf(fd,
-
 
1106
    "@ECHO OFF\r\n"
-
 
1107
    "SET DOSDIR=%c:\\SVARDOS\r\n"
-
 
1108
    "PATH %%DOSDIR%%\r\n"
-
 
1109
    "ECHO INSTALLING PACKAGES\r\n"
-
 
1110
    "COPY \\COMMAND.COM \\CMD.COM\r\n" /* move COMMAND.COM so it does not clashes with the installation of the SVARCOM package */
-
 
1111
    "SET COMSPEC=%c:\\CMD.COM\r\n"
-
 
1112
    "DEL \\AUTOEXEC.BAT\r\n"
-
 
1113
    "COPY AUTOEXEC.BAT \\\r\n"
-
 
1114
    "DEL \\COMMAND.COM\r\n"
-
 
1115
    "DEL \\KERNEL.SYS\r\n" /* KERNEL.SYS will be installed from the package in a moment */
-
 
1116
    "FOR %%%%P IN (*.SVP) DO PKG INSTALL %%%%P\r\n" /* install packages */
-
 
1117
    "DEL *.SVP\r\n", bootdrv, bootdrv);
-
 
1118
 
-
 
1119
  /* restore COMSPEC and do some cleanup */
-
 
1120
  fprintf(fd, "DEL pkg.exe\r\n"
-
 
1121
              "DEL install.com\r\n"
-
 
1122
              "DEL install.lng\r\n"
-
 
1123
              "SET COMSPEC=\\COMMAND.COM\r\n"
-
 
1124
              "DEL \\CMD.COM\r\n");
-
 
1125
  /* print out the "installation over" message (load codepage first, now that MODE is installed) */
-
 
1126
  genlocalesconf(fd, locales);
-
 
1127
  fprintf(fd, "ECHO.\r\n"
-
 
1128
              "ECHO ");
-
 
1129
  fprintf(fd, svarlang_strid(0x0502)); /* "SvarDOS installation is over. Please restart your computer now" */
-
 
1130
  fprintf(fd, "\r\n"
-
 
1131
              "ECHO.\r\n");
-
 
1132
  fclose(fd);
-
 
1133
 
1106
}
1134
}
1107
 
1135
 
1108
 
1136
 
1109
static int copypackages(char drvletter, const struct slocales *locales) {
1137
static int copypackages(char drvletter, const struct slocales *locales) {
1110
  char pkglist[512];
1138
  char pkglist[512];
Line 1195... Line 1223...
1195
      *pkgptr = 0;
1223
      *pkgptr = 0;
1196
      pkgptr++;
1224
      pkgptr++;
1197
    }
1225
    }
1198
  }
1226
  }
1199
 
1227
 
1200
  /* open the post-install autoexec.bat and prepare initial instructions */
1228
  /* create an empty postinst.bat file so installer knows it is 2nd stage */
1201
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\POSTINST.BAT", drvletter);
1229
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\POSTINST.BAT", drvletter);
1202
  fd = fopen(buff, "wb");
1230
  fd = fopen(buff, "wb");
1203
  if (fd == NULL) return(-1);
1231
  if (fd == NULL) return(-1);
1204
  fputs(
-
 
1205
    "@ECHO OFF\r\n"
-
 
1206
    "INSTALL\r\n"  /* installer will run in 2nd stage (generating pkg.cfg and stuff) */
-
 
1207
    "ECHO INSTALLING SVARDOS\r\n"
-
 
1208
    "COPY \\COMMAND.COM \\CMD.COM\r\n" /* move COMMAND.COM so it does not clashes with the installation of the SVARCOM package */
-
 
1209
    "SET COMSPEC=\\CMD.COM\r\n" /* no drive letter because I do not know it */
-
 
1210
    "DEL \\COMMAND.COM\r\n"
-
 
1211
    "DEL \\KERNEL.SYS\r\n" /* KERNEL.SYS will be installed from the package in a moment */
-
 
1212
    "FOR %%P IN (*.SVP) DO PKG INSTALL %%P\r\n" /* install packages */
-
 
1213
    "DEL *.SVP\r\n", fd);
-
 
1214
 
-
 
1215
  /* replace autoexec.bat and config.sys now and write some nice message on screen */
-
 
1216
  fprintf(fd, "DEL pkg.exe\r\n"
-
 
1217
              "DEL install.com\r\n"
-
 
1218
              "DEL install.lng\r\n"
-
 
1219
              "COPY CONFIG.SYS \\\r\n"
-
 
1220
              "DEL CONFIG.SYS\r\n"
-
 
1221
              "DEL \\AUTOEXEC.BAT\r\n"
-
 
1222
              "COPY AUTOEXEC.BAT \\\r\n"
-
 
1223
              "DEL AUTOEXEC.BAT\r\n"
-
 
1224
              "SET COMSPEC=\\COMMAND.COM\r\n"
-
 
1225
              "DEL \\CMD.COM\r\n");
-
 
1226
  /* print out the "installation over" message */
-
 
1227
  fprintf(fd, "ECHO.\r\n"
-
 
1228
              "ECHO ");
-
 
1229
  fprintf(fd, svarlang_strid(0x0502), BUILDSTRING); /* "SvarDOS installation is over. Please restart your computer now" */
-
 
1230
  fprintf(fd, "\r\n"
-
 
1231
              "ECHO.\r\n");
-
 
1232
  fclose(fd);
1232
  fclose(fd);
1233
 
1233
 
1234
  /* prepare a dummy autoexec.bat that will call temp\postinst.bat */
1234
  /* prepare a dummy autoexec.bat that will exec install and call temp\postinst.bat */
1235
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", drvletter);
1235
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", drvletter);
1236
  fd = fopen(buff, "wb");
1236
  fd = fopen(buff, "wb");
1237
  if (fd == NULL) return(-1);
1237
  if (fd == NULL) return(-1);
1238
  fprintf(fd, "@ECHO OFF\r\n"
1238
  fprintf(fd, "@ECHO OFF\r\n"
1239
              "SET DOSDIR=\\SVARDOS\r\n"
-
 
1240
              "PATH %%DOSDIR%%\r\n");
1239
              "PATH %%DOSDIR%%\r\n");
1241
  genlocalesconf(fd, locales);
-
 
1242
  fprintf(fd, "CD TEMP\r\n"
1240
  fprintf(fd, "CD TEMP\r\n"
-
 
1241
              "install\r\n"   /* installer will run in 2nd stage (generating autoexec.bat, pkg.cfg and stuff) */
1243
              "postinst.bat\r\n");
1242
              "postinst.bat\r\n");
1244
  fclose(fd);
1243
  fclose(fd);
1245
 
1244
 
1246
  return(0);
1245
  return(0);
1247
}
1246
}