1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-23 09:09:26 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Nick Briggs
3a4a94344a Merge branch 'master' into nhb-pcap-ethernet 2026-03-19 17:06:05 -07:00
Nick Briggs
5432d73819 Adds generation of SIGIO on X11 connection if O_ASYNC defined 2025-12-11 09:18:40 -08:00
Nick Briggs
a074c4a3c0 Adds required include of <string.h> for strncpy in non-BYTESWAP compilations. 2025-12-07 21:11:39 -08:00
Nick Briggs
cdaa7b6889 Cleans up the interrupt state structure to match Lisp naming
Adds names for individual interrupt-in-progress bits in the
struct interrupt_state to match the structure defined in Lisp.

Adjusts the base datatype to DLword to make clear the size and
alignment of interrupt bits in the structure.
2025-12-07 18:39:59 -08:00
Nick Briggs
eedc8a504a Uses endian independent structure layouts to access returned ethernet packet length field 2025-10-31 15:38:54 -07:00
5 changed files with 53 additions and 30 deletions

View File

@@ -65,21 +65,28 @@ typedef struct closure_type {
#endif /* BIGVM */
typedef struct interrupt_state { /* Interrupt-request mask to communicate with INTERRUPTED */
unsigned LogFileIO : 1; /* console msg arrived to print */
unsigned ETHERInterrupt : 1; /* 10MB activity happened */
unsigned IOInterrupt : 1; /* I/O happened (not used yet) */
unsigned gcdisabled : 1;
unsigned vmemfull : 1;
unsigned stackoverflow : 1;
unsigned storagefull : 1;
unsigned waitinginterrupt : 1;
unsigned nil : 8; /* mask of ints being processed */
DLword LogFileIO : 1; /* console msg arrived to print */
DLword ETHERInterrupt : 1; /* 10MB activity happened */
DLword IOInterrupt : 1; /* I/O happened (not used yet) */
DLword gcdisabled : 1;
DLword vmemfull : 1;
DLword stackoverflow : 1;
DLword storagefull : 1;
DLword waitinginterrupt : 1;
DLword P_LogFileIO : 1; /* interrupts awaiting processing, cleared by Lisp */
DLword P_ETHERInterrupt : 1;
DLword P_IOInterrupt : 1;
DLword P_gcdisabled : 1;
DLword P_vmemfull : 1;
DLword P_stackoverflow : 1;
DLword P_storagefull : 1;
DLword P_waitinginterrupt : 1;
DLword intcharcode;
} INTSTAT;
typedef struct interrupt_state_2 { /* alternate view of the interrupt state */
unsigned pendingmask : 8;
unsigned handledmask : 8;
DLword pendingmask : 8;
DLword handledmask : 8;
DLword nil;
} INTSTAT2;
@@ -204,21 +211,28 @@ typedef struct closure_type {
typedef struct interrupt_state { /* Interrupt-request mask to communicate with INTERRUPTED */
DLword intcharcode;
unsigned nil : 8;
unsigned waitinginterrupt : 1;
unsigned storagefull : 1;
unsigned stackoverflow : 1;
unsigned vmemfull : 1;
unsigned gcdisabled : 1;
unsigned IOInterrupt : 1; /* I/O happened (not used yet) */
unsigned ETHERInterrupt : 1; /* 10MB activity happened */
unsigned LogFileIO : 1; /* console msg arrived to print */
DLword P_waitinginterrupt : 1; /* interrupts awaiting processing, cleared by Lisp */
DLword P_storagefull : 1;
DLword P_stackoverflow : 1;
DLword P_vmemfull : 1;
DLword P_gcdisabled : 1;
DLword P_IOInterrupt : 1;
DLword P_ETHERInterrupt : 1;
DLword P_LogFileIO : 1;
DLword waitinginterrupt : 1;
DLword storagefull : 1;
DLword stackoverflow : 1;
DLword vmemfull : 1;
DLword gcdisabled : 1;
DLword IOInterrupt : 1; /* I/O happened (not used yet) */
DLword ETHERInterrupt : 1; /* 10MB activity happened */
DLword LogFileIO : 1; /* console msg arrived to print */
} INTSTAT;
typedef struct interrupt_state_2 { /* alternate view of the interrupt state */
DLword nil;
unsigned handledmask : 8;
unsigned pendingmask : 8;
DLword handledmask : 8;
DLword pendingmask : 8;
} INTSTAT2;
struct state {

View File

@@ -11,6 +11,7 @@
#include <errno.h>
#include <limits.h> /* for NAME_MAX */
#include <dirent.h> /* for MAXNAMLEN */
#include <string.h> /* for strncpy in non-BYTESWAP case */
#include "lispemul.h" /* for DLword */
#include "commondefs.h" /* for error */

View File

@@ -297,12 +297,10 @@ static int recvPacket(void) {
#if defined(BYTESWAP)
log_debug((" recvPacket() :: byte-swapping %d bytes at %p\n", bLen, (void *)ether_buf));
dblwordsSwap(ether_buf, bLen);
IOPage->dlethernet[2] = bLen;
#else
log_debug((" recvPacket() :: %d bytes at %p\n", bLen, (void *)ether_buf));
IOPage->dlethernet[3] = bLen;
#endif
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = blen;
ether_bsize = 0;

View File

@@ -477,7 +477,7 @@ int *ether_debug(void) {
estat[0] = 0;
if (ether_fd < 0) return (NIL);
printf("fd %d bsize %d buf %p icb %X in %d out %d\n ", ether_fd, ether_bsize, (void *)ether_buf,
IOPage->dlethernet[3], ether_in, ether_out);
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB, ether_in, ether_out);
#endif /* MAIKO_ENABLE_ETHERNET */
return (estat);
@@ -542,7 +542,7 @@ LispPTR check_ether(void) {
memcpy(&ether_buf[0], &nit_buf[nitpos], fromlen);
ether_bsize = 0; /* deactivate receiver */
ether_in++;
IOPage->dlethernet[3] = fromlen;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = fromlen;
DBPRINT(
("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen));
nitpos += fromlen;
@@ -586,7 +586,7 @@ LispPTR check_ether(void) {
memcpy(&ether_buf[0], nit_buf, data.len);
ether_bsize = 0;
ether_in++;
IOPage->dlethernet[3] = data.len;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = data.len;
((INTSTAT *)NativeAligned4FromLAddr(*INTERRUPTSTATE_word))->ETHERInterrupt = 1;
ETHEREventCount++;
Irq_Stk_Check = Irq_Stk_End = 0;
@@ -649,7 +649,7 @@ LispPTR get_packet(void) {
memcpy(&ether_buf[0], &nit_buf[nitpos], fromlen);
ether_bsize = 0; /* deactivate receiver */
ether_in++;
IOPage->dlethernet[3] = fromlen;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = fromlen;
DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen));
nitpos += fromlen;
return (ATOM_T);
@@ -683,7 +683,7 @@ LispPTR get_packet(void) {
memcpy(&ether_buf[0], nit_buf, data.len);
ether_bsize = 0;
ether_in++;
IOPage->dlethernet[3] = data.len;
((DLETHERCSB *)IOPage->dlethernet)->DLFIRSTICB = data.len;
return (ATOM_T);
}
} else if (errno != EWOULDBLOCK)

View File

@@ -17,6 +17,8 @@
#include <stdbool.h> // for false, bool, true
#include <stdio.h> // for NULL
#include <stdlib.h> // for exit
#include <fcntl.h> // for fcntl, O_ASYNC, ...
#include <unistd.h> // for getpid
#include "adr68k.h" // for NativeAligned4FromLAddr
#include "dbprint.h" // for TPRINT
#include "devif.h" // for (anonymous), MRegion, DspInterface, OUTER_S...
@@ -248,6 +250,7 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, u
unsigned depth_hint)
{
Screen *Xscreen;
int xfd;
dsp->identifier = Display_Name; /* This is a hack. The display name */
/* has to dealt with in a more */
@@ -360,5 +363,12 @@ DspInterface X_init(DspInterface dsp, LispPTR lispbitmap, unsigned width_hint, u
break;
}
XInitImage(&dsp->ScreenBitmap);
#if defined(O_ASYNC)
xfd = ConnectionNumber(dsp->display_id);
if (fcntl(xfd, F_SETOWN, getpid()) == -1) perror("X_init: fcntl F_SETOWN error");
if (fcntl(xfd, F_SETFL, fcntl(xfd, F_GETFL, 0) | O_ASYNC) == -1) perror("X_init: fcntl F_SETFL O_ASYNC error");
#endif
return (dsp);
}