Subversion Repositories SvarDOS

Rev

Rev 1954 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1954 Rev 2213
Line 21... Line 21...
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
22
 * DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
#include <i86.h>
25
#include <i86.h>
26
#include <string.h>
-
 
27
 
26
 
28
#include "env.h"
27
#include "env.h"
29
#include "helpers.h"
28
#include "helpers.h"
30
 
29
 
31
#include "rmodinit.h"
30
#include "rmodinit.h"
Line 164... Line 163...
164
  myptr[0x3A] = rmodseg & 0xff;
163
  myptr[0x3A] = rmodseg & 0xff;
165
  myptr[0x3B] = rmodseg >> 8;
164
  myptr[0x3B] = rmodseg >> 8;
166
 
165
 
167
  /* copy rmod to its destination (right past the PSP I prepared) */
166
  /* copy rmod to its destination (right past the PSP I prepared) */
168
  myptr = MK_FP(rmodseg, 0x100);
167
  myptr = MK_FP(rmodseg, 0x100);
169
  _fmemcpy(myptr, rmodcore, rmodcore_len);
168
  memcpy_ltr_far(myptr, rmodcore, rmodcore_len);
170
 
169
 
171
  /* mark rmod memory (MCB) as "self owned" */
170
  /* mark rmod memory (MCB) as "self owned" */
172
  mcb = MK_FP(rmodseg - 1, 0);
171
  mcb = MK_FP(rmodseg - 1, 0);
173
  owner = (void far *)(mcb + 1);
172
  owner = (void far *)(mcb + 1);
174
  *owner = rmodseg;
173
  *owner = rmodseg;
175
  _fmemcpy(mcb + 8, "SVARCOM", 8);
174
  memcpy_ltr_far(mcb + 8, "SVARCOM", 8);
176
 
175
 
177
  /* mark env memory (MCB) as "owned by rmod" */
176
  /* mark env memory (MCB) as "owned by rmod" */
178
  mcb = MK_FP(envseg - 1, 0);
177
  mcb = MK_FP(envseg - 1, 0);
179
  owner = (void far *)(mcb + 1);
178
  owner = (void far *)(mcb + 1);
180
  *owner = rmodseg;
179
  *owner = rmodseg;
181
  _fmemcpy(mcb + 8, "SVARENV", 8);
180
  memcpy_ltr_far(mcb + 8, "SVARENV", 8);
182
 
181
 
183
  /* if env block is newly allocated, then:
182
  /* if env block is newly allocated, then:
184
   *  if an original env is present then copy it
183
   *  if an original env is present then copy it
185
   *  otherwise fill the new env with a few NULs */
184
   *  otherwise fill the new env with a few NULs */
186
  if (envsize != 0) {
185
  if (envsize != 0) {
187
    owner = MK_FP(envseg, 0);
186
    owner = MK_FP(envseg, 0);
188
    owner[0] = 0;
187
    owner[0] = 0;
189
    owner[1] = 0;
188
    owner[1] = 0;
190
 
189
 
191
    /* do we have an original environment? if yes copy it (envsize is a number of paragraphs) */
190
    /* do we have an original environment? if yes copy it (envsize is a number of paragraphs) */
192
    if (origenvseg != 0) _fmemcpy(owner, MK_FP(origenvseg, 0), envsize * 16);
191
    if (origenvseg != 0) memcpy_ltr_far(owner, MK_FP(origenvseg, 0), envsize * 16);
193
  }
192
  }
194
 
193
 
195
  _asm {
194
  _asm {
196
    push ax
195
    push ax
197
    push bx
196
    push bx
Line 244... Line 243...
244
    pop ax
243
    pop ax
245
  }
244
  }
246
 
245
 
247
  /* prepare result (rmod props) */
246
  /* prepare result (rmod props) */
248
  res = MK_FP(rmodseg, 0x100 + rmodcore_len);
247
  res = MK_FP(rmodseg, 0x100 + rmodcore_len);
249
  _fmemset(res, 0, sizeof(*res));  /* zero out */
248
  sv_bzero(res, sizeof(*res));     /* zero out */
250
  res->rmodseg = rmodseg;          /* rmod segment */
249
  res->rmodseg = rmodseg;          /* rmod segment */
251
 
250
 
252
  /* save my original int22h handler and parent in rmod's memory */
251
  /* save my original int22h handler and parent in rmod's memory */
253
  res->origint22 = *((unsigned long *)0x0a); /* original int22h handler seg:off is at 0x0a of my PSP */
252
  res->origint22 = *((unsigned long *)0x0a); /* original int22h handler seg:off is at 0x0a of my PSP */
254
  res->origparent = *((unsigned short *)0x16); /* PSP segment of my parent is at 0x16 of my PSP */
253
  res->origparent = *((unsigned short *)0x16); /* PSP segment of my parent is at 0x16 of my PSP */
Line 363... Line 362...
363
 
362
 
364
  /* set the MCB description to ident, if provided */
363
  /* set the MCB description to ident, if provided */
365
  if (ident) {
364
  if (ident) {
366
    char far *mcbdesc = MK_FP(newseg - 1, 8);
365
    char far *mcbdesc = MK_FP(newseg - 1, 8);
367
    int i;
366
    int i;
368
    _fmemset(mcbdesc, 0, 8);
367
    sv_bzero(mcbdesc, 8);
369
    for (i = 0; (i < 8) && (ident[i] != 0); i++) { /* field's length is limited to 8 bytes max */
368
    for (i = 0; (i < 8) && (ident[i] != 0); i++) { /* field's length is limited to 8 bytes max */
370
      mcbdesc[i] = ident[i];
369
      mcbdesc[i] = ident[i];
371
    }
370
    }
372
  }
371
  }
373
 
372
 
374
  /* zero out the memory before handing it out */
373
  /* zero out the memory before handing it out */
375
  _fmemset(MK_FP(newseg, 0), 0, bytes);
374
  sv_bzero(MK_FP(newseg, 0), bytes);
376
 
375
 
377
  return(MK_FP(newseg, 0));
376
  return(MK_FP(newseg, 0));
378
}
377
}
379
 
378
 
380
 
379