}
// --- Management ---
-tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output, tPTY_ReqResize ReqResize, tPTY_ModeSet ModeSet)
+tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output, tPTY_ReqResize ReqResize, tPTY_ModeSet ModeSet, const struct ptydims *InitialDims, const struct ptymode *InitialMode)
{
tPTY **prev_np = NULL;
size_t namelen;
ret->OutputFcn = Output;
ret->ReqResize = ReqResize;
ret->ModeSet = ModeSet;
+ // - Initialise modes
+ if( InitialDims )
+ ret->Dims = *InitialDims;
+ if( InitialMode )
+ ret->Mode = *InitialMode;
// - Client node
ret->ClientNode.ImplPtr = ret;
ret->ClientNode.Type = &gPTY_NodeType_Client;
case PTY_IOCTL_SETID:
if( Data && !CheckString(Data) ) { errno = EINVAL; return -1; }
if( pty ) return EALREADY;
- pty = PTY_Create(Data, NULL, NULL,NULL, NULL);
+ pty = PTY_Create(Data, NULL, NULL,NULL, NULL, NULL,NULL);
if(pty == NULL)
return 1;
Node->ImplPtr = pty;
#include <fs_devfs.h>
#include <drv_serial.h>
#include <drv_pty.h>
+#include <debug_hooks.h>
// === TYPES ===
struct sSerialPort
{
tSerialPort *ret = malloc( sizeof(tSerialPort) );
// Automatically indexed
- ret->PTY = PTY_Create("serial#", ret, Serial_int_PTYOutput, Serial_int_PTYSetDims, Serial_int_PTYSetArrib);
- ret->OutputFcn = output;
- ret->OutHandle = handle;
- struct ptymode mode = {
- .OutputMode = PTYBUFFMT_TEXT,
- .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO
- };
struct ptydims dims = {
.W = 80, .H = 25,
.PW = 0, .PH = 0
};
- PTY_SetAttrib(ret->PTY, &dims, &mode, 0);
+ struct ptymode mode = {
+ .OutputMode = PTYBUFFMT_TEXT,
+ .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO
+ };
+ ret->PTY = PTY_Create("serial#", ret,
+ Serial_int_PTYOutput, Serial_int_PTYSetDims, Serial_int_PTYSetArrib,
+ &dims, &mode
+ );
+ ret->OutputFcn = output;
+ ret->OutHandle = handle;
return ret;
}
VT_int_Resize( &gVT_Terminals[i], giVT_RealWidth, giVT_RealHeight );
gVT_Terminals[i].Mode = PTYBUFFMT_TEXT;
char name[] = {'v','t','0'+i,'\0'};
- gVT_Terminals[i].PTY = PTY_Create(name, &gVT_Terminals[i],
- VT_PTYOutput, VT_PTYResize, VT_PTYModeset);
- struct ptymode mode = {
- .OutputMode = PTYBUFFMT_TEXT,
- .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO
- };
struct ptydims dims = {
.W = giVT_RealWidth / giVT_CharWidth,
.H = giVT_RealHeight / giVT_CharHeight,
.PW = giVT_RealWidth,
.PH = giVT_RealHeight
};
- PTY_SetAttrib(gVT_Terminals[i].PTY, &dims, &mode, 0);
+ struct ptymode mode = {
+ .OutputMode = PTYBUFFMT_TEXT,
+ .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO
+ };
+ gVT_Terminals[i].PTY = PTY_Create(name, &gVT_Terminals[i],
+ VT_PTYOutput, VT_PTYResize, VT_PTYModeset,
+ &dims, &mode);
}
// Add to DevFS
typedef int (*tPTY_ReqResize)(void *Handle, const struct ptydims *Dims);
typedef int (*tPTY_ModeSet)(void *Handle, const struct ptymode *Mode);
-extern tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn OutputFcn, tPTY_ReqResize ReqResize, tPTY_ModeSet ModeSet);
+extern tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn OutputFcn, tPTY_ReqResize ReqResize, tPTY_ModeSet ModeSet, const struct ptydims *InitialDims, const struct ptymode *InitialMode);
extern int PTY_SetAttrib(tPTY *PTY, const struct ptydims *Dims, const struct ptymode *Mode, int WasClient);
extern void PTY_Close(tPTY *PTY);
extern size_t PTY_SendInput(tPTY *PTY, const char *InputString, size_t InputLength);
return ;
}
- // bound, create PTY instance
- rdata->PTYInstance = PTY_Create("serial#", rdata, acessuart_pty_output, NULL, NULL);
- if( !rdata->PTYInstance ) {
- udi_channel_event_complete(channel_cb, UDI_STAT_RESOURCE_UNAVAIL);
- return ;
- }
-
- struct ptymode mode = {
- .OutputMode = PTYBUFFMT_TEXT,
- .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO
- };
+ // We're bound on the GIO channel, create a PTY for this UART
struct ptydims dims = {
.W = 80, .H = 25,
.PW = 0, .PH = 0
};
- PTY_SetAttrib(rdata->PTYInstance, &dims, &mode, 0);
+ struct ptymode mode = {
+ .OutputMode = PTYBUFFMT_TEXT,
+ .InputMode = PTYIMODE_CANON|PTYIMODE_ECHO
+ };
+ rdata->PTYInstance = PTY_Create("serial#", rdata, acessuart_pty_output,
+ NULL, NULL,
+ &dims, &mode
+ );
+ if( !rdata->PTYInstance ) {
+ udi_channel_event_complete(channel_cb, UDI_STAT_RESOURCE_UNAVAIL);
+ return ;
+ }
udi_channel_event_complete(channel_cb, UDI_OK);
}