Watt-32 tcp/ip  2.2 dev-rel.10
netback.c
Go to the documentation of this file.
1 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 #include "wattcp.h"
8 #include "language.h"
9 #include "strings.h"
10 #include "pctcp.h"
11 #include "wdpmi.h"
12 #include "misc.h"
13 
14 #define TIMER_INTR 8
15 #define STK_SIZE 1024
16 
17 
18 #if (DOSX)
19  void backgroundon (void)
20  {
21  outsnl (_LANG("Use wintr_init() / wintr_enable() instead"));
22  exit (3);
23  }
24 
25 #elif !defined(NO_INLINE_ASM) /* MSC <=6 unsupported */
26 
27  static void (*user_routine)(void) = NULL;
28  static int inside = 0;
29 
30  static W32_IntrHandler oldinterrupt;
31 
32  static INTR_PROTOTYPE newinterrupt (void)
33  {
34  (*oldinterrupt)();
35  DISABLE();
36  if (inside)
37  {
38  static UINT tempstack [STK_SIZE];
39  #ifdef __WATCOMC__
40  STACK_SET (&tempstack[STK_SIZE-1]);
41  #else
42  static UINT old_SP;
43  static WORD old_SS;
44  asm mov ax, ss
45  asm mov old_SS, ax
46  asm mov ax, sp
47  asm mov old_SP, ax
48  asm mov ax, ds
49  asm mov ss, ax
50  asm lea sp, tempstack[STK_SIZE-1]
51 
52  #endif
53  ENABLE();
54 
55  if (user_routine)
56  (*user_routine)();
57  tcp_tick (NULL);
58 
59  DISABLE();
60 
61  #ifdef __WATCOMC__
62  STACK_RESTORE();
63  #else
64  asm mov ax, old_SS
65  asm mov ss, ax
66  asm mov ax, old_SP
67  asm mov sp, ax
68 
69  #endif
70  inside = 0;
71  }
72  ENABLE();
73  }
74 
75  void backgroundon (void)
76  {
77  oldinterrupt = getvect (TIMER_INTR);
78  setvect (TIMER_INTR, newinterrupt);
79  }
80 
81  void backgroundoff (void)
82  {
83  setvect (TIMER_INTR, oldinterrupt);
84  }
85 
86  void backgroundfn (void (*fn)(void))
87  {
88  user_routine = fn;
89  }
90 #endif /* DOSX */
Core definitions.
WORD W32_CALL tcp_tick(sock_type *s)
Must be called periodically by user application (or BSD socket API).
Definition: pctcp.c:1389