From: John Hodge Date: Sun, 9 Feb 2014 06:02:25 +0000 (+0800) Subject: Kernel/PTYs - Add initial dims/mode to PTY_Create X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f7ec06bee2b80613d80c314bf864c69209d09829;p=tpg%2Facess2.git Kernel/PTYs - Add initial dims/mode to PTY_Create --- diff --git a/KernelLand/Kernel/drv/pty.c b/KernelLand/Kernel/drv/pty.c index ebce2085..69b1ce6e 100644 --- a/KernelLand/Kernel/drv/pty.c +++ b/KernelLand/Kernel/drv/pty.c @@ -121,7 +121,7 @@ int PTY_Install(char **Arguments) } // --- 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; @@ -229,6 +229,11 @@ tPTY *PTY_Create(const char *Name, void *Handle, tPTY_OutputFcn Output, tPTY_Req 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; @@ -825,7 +830,7 @@ int PTY_IOCtl(tVFS_Node *Node, int ID, void *Data) 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; diff --git a/KernelLand/Kernel/drv/serial.c b/KernelLand/Kernel/drv/serial.c index 08fb6786..2792df91 100644 --- a/KernelLand/Kernel/drv/serial.c +++ b/KernelLand/Kernel/drv/serial.c @@ -10,6 +10,7 @@ #include #include #include +#include // === TYPES === struct sSerialPort @@ -43,18 +44,20 @@ tSerialPort *Serial_CreatePort(tSerial_OutFcn output, void *handle) { 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; } diff --git a/KernelLand/Kernel/drv/vterm.c b/KernelLand/Kernel/drv/vterm.c index f37be220..1556aa81 100644 --- a/KernelLand/Kernel/drv/vterm.c +++ b/KernelLand/Kernel/drv/vterm.c @@ -176,19 +176,19 @@ int VT_Install(char **Arguments) 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 diff --git a/KernelLand/Kernel/include/drv_pty.h b/KernelLand/Kernel/include/drv_pty.h index bb316296..74e02bf3 100644 --- a/KernelLand/Kernel/include/drv_pty.h +++ b/KernelLand/Kernel/include/drv_pty.h @@ -16,7 +16,7 @@ typedef void (*tPTY_OutputFcn)(void *Handle, size_t Length, const void *Data); 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); diff --git a/KernelLand/Modules/Interfaces/UDI/trans/gio_uart.c b/KernelLand/Modules/Interfaces/UDI/trans/gio_uart.c index ec303678..e4206472 100644 --- a/KernelLand/Modules/Interfaces/UDI/trans/gio_uart.c +++ b/KernelLand/Modules/Interfaces/UDI/trans/gio_uart.c @@ -106,22 +106,23 @@ void acessuart_bind_ack(udi_gio_bind_cb_t *cb, udi_ubit32_t device_size_lo, udi_ 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); }