Ignore:
Timestamp:
Jul 17, 2000, 12:43:41 AM (25 years ago)
Author:
bird
Message:

Checkin of current code in the Grace brance for backup purpose.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GRACE/src/win32k/dev16/d16init.c

    r2898 r3834  
    1 /* $Id: d16init.c,v 1.6 2000-02-25 18:15:02 bird Exp $
     1/* $Id: d16init.c,v 1.6.4.1 2000-07-16 22:43:21 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
     
    3939#include "dev1632.h"
    4040#include "dev16.h"
     41#include "vprntf16.h"
     42#include "log.h"
     43#include "options.h"
    4144
    4245/**
     
    5154USHORT NEAR dev0Init(PRPINITIN pRpIn, PRPINITOUT pRpOut)
    5255{
     56    APIRET  rc;
    5357    Device_Help = pRpIn->DevHlpEP;
     58
     59    /*
     60     * Does this work at Ring-3 (inittime)?
     61     * If this work we could be saved from throuble!
     62     */
     63    rc = initGetDosTableData();
     64    if (rc != NO_ERROR)
     65        printf16("win32k - elf$: initGetDosTableData failed with rc=%d\n", rc);
    5466
    5567    pRpOut->BPBArray = NULL;
     
    8092    NPSZ            npszErrMsg = NULL;
    8193
     94    /*
     95     * Probe kernel data.
     96     */
    8297    rc = ProbeKernel(pRpIn);
    8398    if (rc == NO_ERROR)
    8499    {
     100        /*
     101         * Open and send a Ring-0 init packet to elf$.
     102         * If this succeeds win32k$ init succeeds.
     103         */
    85104        rc = DosOpen("\\dev\\elf$", &hDev0, &usAction, 0UL, FILE_NORMAL,
    86105                     OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
     
    93112            if (rc == NO_ERROR)
    94113            {
    95                 if (data.Status != STATUS_DONE)
    96                     npszErrMsg = "Ring-0 initiation failed\n\r";
     114                if ((rc = data.Status) == STATUS_DONE)
     115                {
     116                    if (!options.fQuiet)
     117                        printf16("Win32k.sys succesfully initiated!\n");
     118                    pRpOut->Status = pRpOut->rph.Status = data.Status;
     119                }
    97120                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                 }
     121                    npszErrMsg = "Ring-0 initiation failed. rc=%d\n";
    104122            }
    105123            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 
     124                npszErrMsg = "Ring-0 init: DosDevIOCtl failed. rc=%d\n";
    120125            DosClose(hDev0);
    121126        }
    122127        else
    123             npszErrMsg = "DosOpen failed.\n\r";
     128            npszErrMsg = "Ring-0 init: DosOpen failed. rc=%d\n";
    124129    }
    125130    else
    126         npszErrMsg = "ProbeKernel failed.\n\r";
    127     pRpOut->BPBArray = NULL;
     131        npszErrMsg = ""; /* ProbeKrnl do its own complaining, but we need something here to indicate failure. */
     132
     133    /*
     134     * Fill return data.
     135     */
    128136    pRpOut->CodeEnd = (USHORT)&CODE16END;
    129137    pRpOut->DataEnd = (USHORT)&DATA16END;
     138    pRpOut->BPBArray= NULL;
    130139    pRpOut->Unit    = 0;
    131140
     141    /*
     142     * Any errors?, if so complain!
     143     */
    132144    if (npszErrMsg)
    133145    {
    134         DosPutMessage(1, strlen(npszErrMsg) + 1, npszErrMsg);
    135         return pRpOut->rph.Status = STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL;
    136     }
    137 
     146        printf16(npszErrMsg, rc);
     147        return pRpOut->Status = pRpOut->rph.Status = STATUS_DONE | STERR | ERROR_I24_QUIET_INIT_FAIL;
     148    }
     149
     150    /* successful return */
    138151    return pRpOut->rph.Status;
    139152}
     
    142155
    143156/**
    144  * R0 16-bit initiation function.
     157 * R0 16-bit initiation.
    145158 * This gets TKSSBase, thunks parameters and calls R0 32-bit initiation function.
    146159 * @returns   Status word.
     
    162175        ULONG ulLinData;
    163176
     177        /*
     178         * Thunk the request packet and lock userdata.
     179         */
    164180        if (!DevHelp_VirtToLin(SELECTOROF(pRp->ParmPacket), OFFSETOF(pRp->ParmPacket), &ulLinParm)
    165181            &&
     
    175191                                (LIN)~0UL, SSToDS_16(&hLockData[0]), &cPages)
    176192                )
    177             {   /* data and param is locked (do we need to lock the request packet too ?). */
    178                 /* create new 32-bit packet */
     193            {
     194                /*
     195                 * -data and param is locked (do we need to lock the request packet too ?).-
     196                 * Create new 32-bit init packet - Parameter pointer is thunked.
     197                 */
    179198                RP32INIT rp32init;
    180199
     
    191210                ((PD16R0INITDATA)pRp->DataPacket)->Status = usRc;
    192211
    193                 /* finished - unlock data and parm */
     212                /*
     213                 * finished - unlock data and parm
     214                 */
    194215                DevHelp_VMUnLock((LIN)SSToDS_16(&hLockParm[0]));
    195216                DevHelp_VMUnLock((LIN)SSToDS_16(&hLockData[0]));
     
    204225        usRc |= ERROR_I24_GEN_FAILURE;
    205226
    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 
    223227    return usRc;
    224228}
     
    235239 *            After R0Init16 is called TKSSBase16 _is_ set.
    236240 *            IMPORTANT! This function must _not_ be called after the initiation of the second device driver!!!
     241 *                       (Since this is init code not present after init...)
    237242 */
    238243USHORT NEAR initGetDosTableData(void)
Note: See TracChangeset for help on using the changeset viewer.