Subversion Repositories SvarDOS

Rev

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

Rev 453 Rev 454
Line 37... Line 37...
37
struct rmod_props far *rmod_install(unsigned short envsize) {
37
struct rmod_props far *rmod_install(unsigned short envsize) {
38
  char far *myptr, far *mcb;
38
  char far *myptr, far *mcb;
39
  unsigned short far *owner;
39
  unsigned short far *owner;
40
  const unsigned short sizeof_rmodandprops_paras = rmod_len + sizeof(struct rmod_props) + 15 / 16;
40
  const unsigned short sizeof_rmodandprops_paras = rmod_len + sizeof(struct rmod_props) + 15 / 16;
41
  unsigned short rmodseg = 0xffff;
41
  unsigned short rmodseg = 0xffff;
42
  unsigned short envseg = 0, origenvseg = 0;
42
  unsigned short envseg, origenvseg;
43
  struct rmod_props far *res = NULL;
43
  struct rmod_props far *res = NULL;
44
 
44
 
45
  /* read my current env segment from PSP and save it */
45
  /* read my current env segment from PSP and save it */
46
  _asm {
-
 
47
    push ax
-
 
48
    push bx
-
 
49
    mov bx, 0x2c
46
  envseg = *((unsigned short *)0x2c);
50
    mov ax, [bx]
-
 
51
    mov envseg, ax
-
 
52
    mov origenvseg, ax
47
  origenvseg = envseg;
53
    pop bx
-
 
54
    pop ax
-
 
55
  }
-
 
56
 
48
 
57
  /* printf("original (PSP) env buffer at %04X\r\n", envseg); */
49
  /* printf("original (PSP) env buffer at %04X\r\n", envseg); */
58
 
50
 
59
  /* if envseg is zero, then enforce our own one (MSDOS 5 does not provide a default env) */
51
  /* if envseg is zero, then enforce our own one (MSDOS 5 does not provide a default env) */
60
  if ((envseg == 0) && (envsize == 0)) envsize = 256;
52
  if ((envseg == 0) && (envsize == 0)) envsize = 256;
Line 63... Line 55...
63
  if (envsize != 0) {
55
  if (envsize != 0) {
64
    envsize += 15;
56
    envsize += 15;
65
    envsize /= 16;
57
    envsize /= 16;
66
  }
58
  }
67
 
59
 
68
 
-
 
69
  _asm {
60
  _asm {
70
    /* link in the UMB memory chain for enabling high-memory allocation (and save initial status on stack) */
61
    /* link in the UMB memory chain for enabling high-memory allocation (and save initial status on stack) */
71
    mov ax, 0x5802  /* GET UMB LINK STATE */
62
    mov ax, 0x5802  /* GET UMB LINK STATE */
72
    int 0x21
63
    int 0x21
73
    xor ah, ah
64
    xor ah, ah
Line 174... Line 165...
174
  /* save my original parent in rmod's memory */
165
  /* save my original parent in rmod's memory */
175
  res->origparent = *((unsigned long *)0x0a); /* original parent seg:off is at 0x0a of my PSP */
166
  res->origparent = *((unsigned long *)0x0a); /* original parent seg:off is at 0x0a of my PSP */
176
 
167
 
177
  /* set the int22 handler in my PSP to rmod so DOS jumps to rmod after I
168
  /* set the int22 handler in my PSP to rmod so DOS jumps to rmod after I
178
   * terminate and save the original handler in rmod's memory */
169
   * terminate and save the original handler in rmod's memory */
179
  _asm {
170
  {
180
    push ax
-
 
181
    push bx
-
 
182
    push si
-
 
183
    push di
-
 
184
    push es
-
 
185
 
-
 
186
    mov bx, 0x0a                   /* int22 handler is at 0x0A of the PSP */
171
    unsigned short *ptr = (void *)0x0a; /* int22 handler is at 0x0A of the PSP */
187
    mov ax, RMOD_OFFSET_ROUTINE
172
    ptr[0] = RMOD_OFFSET_ROUTINE;
188
    mov [bx], ax                   /* int handler offset */
-
 
189
    mov ax, rmodseg
173
    ptr[1] = rmodseg;
190
    mov [bx+2], ax                 /* int handler segment */
-
 
191
 
-
 
192
    pop es
-
 
193
    pop di
-
 
194
    pop si
-
 
195
    pop bx
-
 
196
    pop ax
-
 
197
  }
174
  }
198
 
175
 
199
  return(res);
176
  return(res);
200
}
177
}
201
 
178