Subversion Repositories SvarDOS

Rev

Rev 1865 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1865 Rev 1877
Line 124... Line 124...
124
/* DR-DOS specific boot processing: check for F5/F8 boot key presses and reset
124
/* DR-DOS specific boot processing: check for F5/F8 boot key presses and reset
125
 * the wild pointer to DR-DOS kernel (CONFIG.SYS) environment because it is not
125
 * the wild pointer to DR-DOS kernel (CONFIG.SYS) environment because it is not
126
 * allocated memory hence will be overwritten soon.
126
 * allocated memory hence will be overwritten soon.
127
 * details: https://github.com/SvarDOS/edrdos/issues/83
127
 * details: https://github.com/SvarDOS/edrdos/issues/83
128
 * this function returns 0, FLAG_SKIP_AUTOEXEC or FLAG_STEPBYSTEP */
128
 * this function returns 0, FLAG_SKIP_AUTOEXEC or FLAG_STEPBYSTEP */
129
static unsigned char drdos_init(void) {
129
static void drdos_init(struct config *cfg) {
130
  unsigned short kernenvseg = 0;
130
  unsigned short kernenvseg = 0;
131
  unsigned char far *e;
131
  unsigned char far *e;
132
  unsigned short far *scancode;
132
  unsigned short far *scancode;
133
 
133
 
134
  /* If I am init then query kernel's private data via INT 21,4458 (DR-DOS).
134
  /* If I am init then query kernel's private data via INT 21,4458 (DR-DOS).
Line 152... Line 152...
152
 
152
 
153
    /* if DR-DOS env is at seg 0x60 then overwrite my own env in PSP with this.
153
    /* if DR-DOS env is at seg 0x60 then overwrite my own env in PSP with this.
154
     * Seg 0x60 is used since https://github.com/SvarDOS/edrdos/issues/88 and
154
     * Seg 0x60 is used since https://github.com/SvarDOS/edrdos/issues/88 and
155
     * it is safe to be used as it won't be overwritten */
155
     * it is safe to be used as it won't be overwritten */
156
    cmp ax, 0x60
156
    cmp ax, 0x60
157
    ja FAIL
157
    jne FAIL
158
    mov bx, 0x2C         /* environment segment field in my PSP */
158
    mov bx, 0x2C         /* environment segment field in my PSP */
159
    mov [bx], ax
159
    mov [bx], ax
160
 
160
 
161
    FAIL:
161
    FAIL:
162
    pop es
162
    pop es
163
    pop bx
163
    pop bx
164
    pop ax
164
    pop ax
165
  }
165
  }
166
 
166
 
167
  if (kernenvseg == 0) return(0); /* either not DR-DOS, or kern env was read already or something failed */
167
  if (kernenvseg == 0) return; /* either not DR-DOS, or kern env was read already or something failed */
-
 
168
 
-
 
169
  /* now I know that 1) I am running under (E)DR-DOS and 2) I am init, so /P implied */
-
 
170
  cfg->flags |= FLAG_PERMANENT;
-
 
171
 
-
 
172
  /* DR-DOS kernel environment present: make sure to ask SvarCOM to alloc its
-
 
173
   * own environment, because the kernel's environment might vanish eventually */
-
 
174
  if (cfg->envsiz < 256) cfg->envsiz = 256;
168
 
175
 
169
  e = MK_FP(kernenvseg, 0);
176
  e = MK_FP(kernenvseg, 0);
170
 
177
 
171
  /* move forward until the DRDOS' environment 1Ah terminator is found */
178
  /* move forward until the DRDOS' environment 1Ah terminator is found */
172
  while (*e != 0x1A) e++;
179
  while (*e != 0x1A) e++;
173
  e++;
180
  e++;
174
 
181
 
175
  /* next I have the boot key press scancode: either 0x0000, 0x3F00 or 0x4200
182
  /* next I have the boot key press scancode: either 0x0000, 0x3F00 or 0x4200
176
   * 0x3F00 means "F5 was pressed" while 0x4200 is for F8 */
183
   * 0x3F00 means "F5 was pressed" while 0x4200 is for F8 */
177
  scancode = (void far *)e;
184
  scancode = (void far *)e;
-
 
185
  if (*scancode == 0x3F00) {
178
  if (*scancode == 0x3F00) return(FLAG_SKIP_AUTOEXEC);
186
    cfg->flags |= FLAG_SKIP_AUTOEXEC;
-
 
187
  } else if (*scancode == 0x4200) {
179
  if (*scancode == 0x4200) return(FLAG_STEPBYSTEP);
188
    cfg->flags |= FLAG_STEPBYSTEP;
-
 
189
  }
180
 
190
 
181
/*
191
/*
182
  printf("kernel env seg is at %04X and starts with bytes 0x%02X 0x%02X 0x%02X 0x%02X\r\n", kernenvseg, e[0], e[1], e[2], e[3]);
192
  printf("kernel env seg is at %04X and starts with bytes 0x%02X 0x%02X 0x%02X 0x%02X\r\n", kernenvseg, e[0], e[1], e[2], e[3]);
183
  {
193
  {
184
    int i;
194
    int i;
Line 192... Line 202...
192
      printf("%02X ", e[i]);
202
      printf("%02X ", e[i]);
193
    }
203
    }
194
    printf("\r\n=== DUMP ENDS ===\r\n");
204
    printf("\r\n=== DUMP ENDS ===\r\n");
195
  }
205
  }
196
*/
206
*/
197
  return(0);
-
 
198
}
207
}
199
 
208
 
200
 
209
 
201
/* parses command line the hard way (directly from PSP) */
210
/* parses command line the hard way (directly from PSP) */
202
static void parse_argv(struct config *cfg) {
211
static void parse_argv(struct config *cfg) {
Line 1040... Line 1049...
1040
 
1049
 
1041
    /* DR-DOS specific: if I am the init shell (zeroed env seg) then detect F5/F8 now
1050
    /* DR-DOS specific: if I am the init shell (zeroed env seg) then detect F5/F8 now
1042
     * This must be done BEFORE rmod_install() because DR-DOS's boot environment
1051
     * This must be done BEFORE rmod_install() because DR-DOS's boot environment
1043
     * is located at an unallocated memory location that is likely to be overwritten
1052
     * is located at an unallocated memory location that is likely to be overwritten
1044
     * by rmod_install(). */
1053
     * by rmod_install(). */
1045
    cfg.flags |= drdos_init();
1054
    drdos_init(&cfg);
1046
 
1055
 
1047
    rmod = rmod_install(cfg.envsiz, BUFFER, BUFFER_len);
1056
    rmod = rmod_install(cfg.envsiz, BUFFER, BUFFER_len, &(cfg.flags));
1048
    if (rmod == NULL) {
1057
    if (rmod == NULL) {
1049
      nls_outputnl_err(2,1); /* "FATAL ERROR: rmod_install() failed" */
1058
      nls_outputnl_err(2,1); /* "FATAL ERROR: rmod_install() failed" */
1050
      return(1);
1059
      return(1);
1051
    }
1060
    }
1052
    /* copy flags to rmod's storage (and enable ECHO) */
1061
    /* copy flags to rmod's storage (and enable ECHO) */
1053
    rmod->flags = cfg.flags | FLAG_ECHOFLAG;
1062
    rmod->flags = cfg.flags | FLAG_ECHOFLAG;
1054
    /* printf("rmod installed at %Fp\r\n", rmod); */
1063
    /* printf("rmod installed at %Fp\r\n", rmod); */
1055
    rmod->version = BYTE_VERSION;
1064
    rmod->version = BYTE_VERSION;
1056
 
1065
 
1057
    /* if my environment seg was zeroed, then I am the init process (under DR-DOS and MS-DOS 5 at least) */
-
 
1058
    if (rmod->origenvseg == 0) {
-
 
1059
      cfg.flags |= FLAG_PERMANENT; /* imply /P so AUTOEXEC.BAT is executed */
-
 
1060
    }
-
 
1061
  } else {
1066
  } else {
1062
    /* printf("rmod found at %Fp\r\n", rmod); */
1067
    /* printf("rmod found at %Fp\r\n", rmod); */
1063
    /* if I was spawned by rmod and FLAG_EXEC_AND_QUIT is set, then I should
1068
    /* if I was spawned by rmod and FLAG_EXEC_AND_QUIT is set, then I should
1064
     * die asap, because the command has been executed already, so I no longer
1069
     * die asap, because the command has been executed already, so I no longer
1065
     * have a purpose in life, UNLESS I still have a batch file to run or
1070
     * have a purpose in life, UNLESS I still have a batch file to run or