Ignore:
Timestamp:
Sep 2, 2000, 11:08:23 PM (25 years ago)
Author:
bird
Message:

Merged in the Grace branch. New Win32k!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev16/d16init.c

    r2898 r4164  
    1 /* $Id: d16init.c,v 1.6 2000-02-25 18:15:02 bird Exp $
     1/* $Id: d16init.c,v 1.7 2000-09-02 21:07:55 bird Exp $
    22 *
    33 * d16init - init routines for both drivers.
     
    66 *            compleated. CodeEnd and DataEnd should not be set here.?
    77 *
    8  * Copyright (c) 1999 knut st. osmundsen
     8 * Copyright (c) 1999-2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    99 *
    1010 * Project Odin Software License can be found in LICENSE.TXT
     
    3636#include <memory.h>
    3737
     38#include "devSegDf.h"
     39#undef  DATA16_INIT
     40#define DATA16_INIT
     41#undef  CODE16_INIT
     42#define CODE16_INIT
    3843#include "probkrnl.h"
    3944#include "dev1632.h"
    4045#include "dev16.h"
     46#include "vprntf16.h"
     47#include "log.h"
     48#include "options.h"
     49
     50
    4151
    4252/**
     
    5161USHORT NEAR dev0Init(PRPINITIN pRpIn, PRPINITOUT pRpOut)
    5262{
     63    APIRET  rc;
    5364    Device_Help = pRpIn->DevHlpEP;
    5465
     66    /*
     67     * Does this work at Ring-3 (inittime)?
     68     * If this work we could be saved from throuble!
     69     */
     70    rc = initGetDosTableData();
     71    if (rc != NO_ERROR)
     72        printf16("win32k - elf$: initGetDosTableData failed with rc=%d\n", rc);
     73
    5574    pRpOut->BPBArray = NULL;
    56     pRpOut->CodeEnd  = (USHORT)&CODE16END;
    57     pRpOut->DataEnd  = (USHORT)&DATA16END;
     75    pRpOut->CodeEnd = (USHORT)&CODE16_INITSTART;
     76    pRpOut->DataEnd = (USHORT)&DATA16_INITSTART;
    5877    pRpOut->Unit     = 0;
    5978    pRpOut->rph.Status = STATUS_DONE;
     
    8099    NPSZ            npszErrMsg = NULL;
    81100
     101    /*
     102     * Probe kernel data.
     103     */
    82104    rc = ProbeKernel(pRpIn);
    83105    if (rc == NO_ERROR)
    84106    {
     107        /*
     108         * Open and send a Ring-0 init packet to elf$.
     109         * If this succeeds win32k$ init succeeds.
     110         */
    85111        rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
    86112                     OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
     
    93119            if (rc == NO_ERROR)
    94120            {
    95                 if (data.Status != STATUS_DONE)
    96                     npszErrMsg = "Ring-0 initiation failed\n\r";
     121                if ((rc = data.Status) == STATUS_DONE)
     122                {
     123                    if (!options.fQuiet)
     124                        printf16("Win32k.sys succesfully initiated!\n");
     125                    pRpOut->Status = pRpOut->rph.Status = data.Status;
     126                }
    97127                else
    98                 {
    99                     /* FIXME quiet test! */
    100                     register NPSZ npsz = "Win32k.sys succesfully initiated!\n\r";
    101                     DosPutMessage(1, strlen(npsz)+1, npsz);
    102                     pRpOut->Status = data.Status;
    103                 }
     128                    npszErrMsg = "Ring-0 initiation failed. rc=%d\n";
    104129            }
    105130            else
    106             {
    107                 APIRET rc2 = rc;
    108                 NPSZ   npsz;
    109                             /*0123456789012345678901234567890 1*/
    110                 npszErrMsg = "DosDevIOCtl failed. rc=       \n\r";
    111 
    112                 npsz  = &npszErrMsg[29];
    113                 do
    114                 {
    115                     *npsz-- = (char)((rc2 % 10) + '0');
    116                     rc2 = rc2/10;
    117                 } while (rc2 > 0);
    118             }
    119 
     131                npszErrMsg = "Ring-0 init: DosDevIOCtl failed. rc=%d\n";
    120132            DosClose(hDev0);
    121133        }
    122134        else
    123             npszErrMsg = "DosOpen failed.\n\r";
     135            npszErrMsg = "Ring-0 init: DosOpen failed. rc=%d\n";
    124136    }
    125137    else
    126         npszErrMsg = "ProbeKernel failed.\n\r";
    127     pRpOut->BPBArray = NULL;
    128     pRpOut->CodeEnd = (USHORT)&CODE16END;
    129     pRpOut->DataEnd = (USHORT)&DATA16END;
     138        npszErrMsg = ""; /* ProbeKrnl do its own complaining, but we need something here to indicate failure. */
     139
     140    /*
     141     * Fill return data.
     142     */
     143    pRpOut->CodeEnd = (USHORT)&CODE16_INITSTART;
     144    pRpOut->DataEnd = (USHORT)&DATA16_INITSTART;
     145    pRpOut->BPBArray= NULL;
    130146    pRpOut->Unit    = 0;
    131147
     148    /*
     149     * Any errors?, if so complain!
     150     */
    132151    if (npszErrMsg)
    133152    {
    134         DosPutMessage(1, strlen(npszErrMsg) + 1, npszErrMsg);
    135         return pRpOut->rph.Status = STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL;
    136     }
    137 
     153        printf16(npszErrMsg, rc);
     154        pRpOut->Status = pRpOut->rph.Status = STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL;
     155    }
     156
     157    /* Init is completed. */
     158    fInitTime = FALSE;
     159
     160    /* successful return */
    138161    return pRpOut->rph.Status;
    139162}
     
    142165
    143166/**
    144  * R0 16-bit initiation function.
     167 * R0 16-bit initiation.
    145168 * This gets TKSSBase, thunks parameters and calls R0 32-bit initiation function.
    146169 * @returns   Status word.
    147170 * @param     pRp  Generic IO Control request packet.
    148171 */
    149 USHORT NEAR R0Init16(PRP_GENIOCTL pRp)
     172USHORT NEAR  R0Init16(PRP_GENIOCTL pRp)
    150173{
    151174    USHORT usRc = STATUS_DONE;
     
    162185        ULONG ulLinData;
    163186
     187        /*
     188         * Thunk the request packet and lock userdata.
     189         */
    164190        if (!DevHelp_VirtToLin(SELECTOROF(pRp->ParmPacket), OFFSETOF(pRp->ParmPacket), &ulLinParm)
    165191            &&
     
    175201                                (LIN)~0UL, SSToDS_16(&hLockData[0]), &cPages)
    176202                )
    177             {   /* data and param is locked (do we need to lock the request packet too ?). */
    178                 /* create new 32-bit packet */
     203            {
     204                /*
     205                 * -data and param is locked (do we need to lock the request packet too ?).-
     206                 * Create new 32-bit init packet - Parameter pointer is thunked.
     207                 */
    179208                RP32INIT rp32init;
    180209
     
    191220                ((PD16R0INITDATA)pRp->DataPacket)->Status = usRc;
    192221
    193                 /* finished - unlock data and parm */
     222                /*
     223                 * finished - unlock data and parm
     224                 */
    194225                DevHelp_VMUnLock((LIN)SSToDS_16(&hLockParm[0]));
    195226                DevHelp_VMUnLock((LIN)SSToDS_16(&hLockData[0]));
     
    204235        usRc |= ERROR_I24_GEN_FAILURE;
    205236
    206 
    207     #if 0
    208     rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE | VMDHL_VERIFY,
    209                         &DATA32START,
    210                         (ULONG)(&end) - (ULONG)&DATA32START),
    211                         (void*)-1,
    212                         &lock[0],
    213                         &cPages);
    214 
    215     rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_VERIFY,
    216                         &CODE32START,
    217                         (ULONG)(&CODE32END) - (ULONG)&CODE32START),
    218                         (void*)-1,
    219                         &lock[0],
    220                         &cPages);
    221     #endif
    222 
    223237    return usRc;
    224238}
     
    235249 *            After R0Init16 is called TKSSBase16 _is_ set.
    236250 *            IMPORTANT! This function must _not_ be called after the initiation of the second device driver!!!
    237  */
    238 USHORT NEAR initGetDosTableData(void)
     251 *                       (Since this is init code not present after init...)
     252 */
     253USHORT NEAR  initGetDosTableData(void)
    239254{
    240255    APIRET     rc;
     
    244259    if (TKSSBase16 != 0)
    245260        return NO_ERROR;
     261    /*
     262    _asm {
     263        int 3;
     264    }
     265    */
    246266
    247267    /* First we're to get the DosTable2 stuff. */
Note: See TracChangeset for help on using the changeset viewer.