Ignore:
Timestamp:
Feb 25, 2000, 7:19:24 PM (26 years ago)
Author:
bird
Message:

Symbol Database is implemented.
No scanning of the os2krnl file, the loaded image is now scaned to determin
which build, debug/retail and smp/uni.
And yet some more enhanchments like 16-bit logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev32/d32init.c

    r2878 r2898  
    1 /* $Id: d32init.c,v 1.15 2000-02-23 23:01:00 bird Exp $
     1/* $Id: d32init.c,v 1.16 2000-02-25 18:15:03 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    1515                                        /* the one used in calltab.asm.       */
    1616#define static                          /* just to make all symbols visible in the kernel debugger.  */
     17#if  0                                  /* Enable this to have extra debug logging. */
     18    #define kprintf2(a) kprintf
     19#else
     20    #define kprintf2(a) (void)0
     21#endif
    1722
    1823
     
    4954static char * apszInfoLevel[] = {"INFOLEVEL_QUIET", "INFOLEVEL_ERROR", "INFOLEVEL_WARNING", "INFOLEVEL_INFO", "INFOLEVEL_INFOALL", "!invalid!"};
    5055#endif
     56static PMTE    pKrnlMTE = NULL;
     57static PSMTE   pKrnlSMTE = NULL;
     58static POTE    pKrnlOTE = NULL;
     59
    5160
    5261/*******************************************************************************
     
    7079/* extern(s) located in mytkExecPgm.asm  */
    7180extern char     mytkExecPgm;
    72 extern char     CODE32START;
    73 extern char     CODE32END;
    74 extern char     CONST32_ROEND;
    75 extern char     DATA16START;
    76 extern char     DATA16_CONSTEND;
    7781
    7882
     
    9498USHORT _loadds _Far32 _Pascal R0Init32(RP32INIT *pRpInit)
    9599{
    96     char   *pszTmp2;
    97     char   *pszTmp;
    98     ULONG   ul;
    99     APIRET  rc;
    100     LOCKHANDLE lhData16={0,0,0,0, 0,0,0,0, 0,0,0,0};
    101     LOCKHANDLE lhData = {0,0,0,0, 0,0,0,0, 0,0,0,0};
    102     LOCKHANDLE lhCode = {0,0,0,0, 0,0,0,0, 0,0,0,0};
     100    char *      pszTmp2;
     101    char *      pszTmp;
     102    ULONG       ul;
     103    APIRET      rc;
     104    LOCKHANDLE  lockhandle;
    103105
    104106    pulTKSSBase32 = (PULONG)_TKSSBase16;
    105 
    106     SET_OPTIONS_TO_DEFAULT(options);
    107107
    108108    /*---------------------*/
     
    273273
    274274    /* Transfer version and build number from 16-bit probkrnl.c */
    275     options.ulBuild    = _ulBuild;
     275    options.ulBuild    = _usBuild;
    276276    options.usVerMajor = _usVerMajor;
    277277    options.usVerMinor = _usVerMinor;
    278278
    279     /* log option summary - FIXME */
     279    /* Log option summary */
     280    #ifdef DEBUG
    280281    kprintf(("Options - Summary - Start\n"));
    281282    if (options.fQuiet)
     
    306307             options.cbSwpHeapInit, options.cbSwpHeapMax));
    307308    kprintf(("Options - Summary - End\n"));
     309    #endif /* debug */
    308310    /* end option summary */
    309311
     
    331333     */
    332334    /* 32-bit code segment */
     335    memset(SSToDS(&lockhandle), 0, sizeof(lockhandle));
    333336    rc = D32Hlp_VMLock2(&CODE32START,
    334337                        ((unsigned)&CODE32END & ~0xFFF) - (unsigned)&CODE32START, /* Round down so we don't overlap with the next request. */
    335338                        VMDHL_LONG,
    336                         SSToDS(&lhCode));
     339                        SSToDS(&lockhandle));
    337340    if (rc != NO_ERROR)
    338341        kprintf(("code segment lock failed with with rc=%d\n", rc));
    339342
    340343    /* 32-bit data segment */
     344    memset(SSToDS(&lockhandle), 0, sizeof(lockhandle));
    341345    rc = D32Hlp_VMLock2(callTab,
    342346                        &CONST32_ROEND - (char*)callTab,
    343347                        VMDHL_LONG | VMDHL_WRITE,
    344                         SSToDS(&lhData));
     348                        SSToDS(&lockhandle));
    345349    if (rc != NO_ERROR)
    346350        kprintf(("data segment lock failed with with rc=%d\n", rc));
    347351
    348     /* 16-bit data segment */
     352    /* 16-bit data segment - is this necessary? */
     353    memset(SSToDS(&lockhandle), 0, sizeof(lockhandle));
    349354    rc = D32Hlp_VMLock2(&DATA16START,
    350                         &DATA16_CONSTEND - &DATA16START,
     355                        &DATA16END - &DATA16START,
    351356                        VMDHL_LONG | VMDHL_WRITE,
    352                         SSToDS(&lhData16));
     357                        SSToDS(&lockhandle));
    353358    if (rc != NO_ERROR)
    354         kprintf(("data segment lock failed with with rc=%d\n", rc));
     359        kprintf(("16-bit data segment lock failed with with rc=%d\n", rc));
    355360
    356361    return STATUS_DONE;
     
    371376    int   i = 0;
    372377
     378    /* determin ulBase */
    373379    if (*pszNum == '0')
    374380        if (pszNum[1] == 'x' || pszNum[1] == 'X')
     
    403409/**
    404410 * Get kernel OTEs
     411 * This function set pKrnlMTE, pKrnlSMTE and pKrnlOTE.
    405412 * @returns   Strategy return code:
    406413 *            STATUS_DONE on success.
    407414 *            STATUS_DONE | STERR | errorcode on failure.
    408  * @param     pOTEBuf  Pointer to output buffer.
     415 * @param     pKrnlInfo  Pointer to output buffer.
     416 *                       If NULL only the three global variables are set.
    409417 * @status    completely implemented and tested.
    410418 * @author    knut st. osmundsen
    411419 * @remark    Called from IOCtl.
     420 *            WARNING! This function is called before the initroutine (R0INIT)!
    412421 */
    413 USHORT _loadds _Far32 _Pascal GetOTEs32(PKRNLOBJTABLE pOTEBuf)
     422USHORT _loadds _Far32 _Pascal GetKernelInfo32(PKRNLINFO pKrnlInfo)
    414423{
    415     PMTE    pMTE;
    416     PSMTE   pSMTE;
    417     POTE    pOTE;
    418424    int     i;
    419425    USHORT  usRc;
    420426
    421     pMTE = GetOS2KrnlMTE();
    422     if (pMTE != NULL)
     427    /* VerifyImporTab32 is called before the initroutine! */
     428    pulTKSSBase32 = (PULONG)_TKSSBase16;
     429
     430    /* Find the kernel OTE table */
     431    pKrnlMTE = GetOS2KrnlMTE();
     432    if (pKrnlMTE != NULL)
    423433    {
    424         pSMTE = pMTE->mte_swapmte;
    425         if (pSMTE != NULL)
     434        pKrnlSMTE = pKrnlMTE->mte_swapmte;
     435        if (pKrnlSMTE != NULL)
    426436        {
    427             pOTEBuf->cObjects = (unsigned char)pSMTE->smte_objcnt;
    428             if (pSMTE->smte_objcnt <= MAXKRNLOBJECTS)
     437            if (pKrnlSMTE->smte_objcnt <= MAXKRNLOBJECTS)
    429438            {
    430                 pOTE = pSMTE->smte_objtab;
    431                 if (pOTE != NULL)
     439                pKrnlOTE = pKrnlSMTE->smte_objtab;
     440                if (pKrnlOTE != NULL)
    432441                {
    433                     /* Copy OTEs */
    434                     for (i = 0; i < pOTEBuf->cObjects; i++)
    435                         memcpy((void*)&pOTEBuf->aObjects[i], &pOTE[i], sizeof(OTE));
     442                    /*
     443                     * Thats all?
     444                     */
     445                    if (pKrnlInfo == NULL)
     446                        return NO_ERROR;
     447
     448                    pKrnlInfo->cObjects = (unsigned char)pKrnlSMTE->smte_objcnt;
     449
     450                    /*
     451                     * Copy OTEs
     452                     */
     453                    for (i = 0; i < pKrnlInfo->cObjects; i++)
     454                    {
     455                        memcpy((void*)&pKrnlInfo->aObjects[i], &pKrnlOTE[i], sizeof(OTE));
     456                        kprintf2(("GetKernelInfo32: %d base=0x%08x size=0x%08x flags=0x%08x\n",
     457                                  i, pKrnlOTE[i].ote_base, pKrnlOTE[i].ote_size, pKrnlOTE[i].ote_flags));
     458                    }
    436459                    usRc = 0;
    437460
     
    439462                     * Search for internal revision stuff in the two first objects.
    440463                     */
    441                     #if 0
    442                     for (i = 0; i < 2; i++)
     464                    pKrnlInfo->usBuild = 0;
     465                    for (i = 0; i < 2 && pKrnlInfo->usBuild == 0; i++)
    443466                    {
    444                         const char *psz = (const char*)pOTE[i].ote_base;
    445                         const char *pszEnd = psz + pOTE[i].ote_size;
     467                        const char *psz = (const char*)pKrnlOTE[i].ote_base;
     468                        const char *pszEnd = psz + pKrnlOTE[i].ote_size;
    446469
    447470                        while (psz + 100 < pszEnd)
    448471                        {
    449                             strncmp(psz, "Internal revision");
     472                            if (strncmp(psz, "Internal revision ", 18) == 0 && (psz[18] >= '0' && psz[18] <= '9'))
     473                            {
     474                                int j;
     475                                kprintf2(("GetOTEs32: found internal revision: '%s'\n", psz));
     476
     477                                /* skip to end of "Internal revision " string. */
     478                                psz += 18;
     479
     480                                /* Read number*/
     481                                while ((*psz >= '0' && *psz <= '9') || *psz == '.')
     482                                {
     483                                    if (*psz != '.')
     484                                        pKrnlInfo->usBuild = (unsigned short)(pKrnlInfo->usBuild * 10 + (*psz - '0'));
     485                                    psz++;
     486                                }
     487
     488                                /* Check if build number seems valid. */
     489                                if (   !(pKrnlInfo->usBuild >=  8254 && pKrnlInfo->usBuild <  8383) /* Warp 3 fp 32 -> fp 60 */
     490                                    && !(pKrnlInfo->usBuild >=  9023 && pKrnlInfo->usBuild <  9063) /* Warp 4 GA -> fp 40 */
     491                                    && !(pKrnlInfo->usBuild >= 14039 && pKrnlInfo->usBuild < 14080) /* Warp 4.5 GA -> fp 40 */
     492                                      )
     493                                {
     494                                    kprintf(("GetOTEs32: info summary: Build %d is invalid - invalid fixpack?\n", pKrnlInfo->usBuild));
     495                                    usRc = 6;
     496                                    break;
     497                                }
     498
     499                                /* If this is an Aurora or Warp 3 kernel there is more info! */
     500                                pKrnlInfo->fSMP = (char)(*psz != ','
     501                                    && (   (psz[1] == '_' && (psz[2] == 'S' || psz[2] == 's'))  /* F_SMP */
     502                                        || (psz[2] == '_' && (psz[1] == 'S' || psz[1] == 's'))));/* _SMP  */
     503
     504                                /* Check if its a debug kernel (look for DEBUG at start of object 3-5) */
     505                                j = 3;
     506                                pKrnlInfo->fDebug = FALSE;
     507                                while (j < 5)
     508                                {
     509
     510                                    /* There should be no iopl object preceding the debugger data object. */
     511                                    if ((pKrnlOTE[j].ote_flags & OBJIOPL) != 0)
     512                                        break;
     513                                    /* Is this is? */
     514                                    if ((pKrnlOTE[j].ote_flags & OBJINVALID) == 0
     515                                        && (pKrnlOTE[j].ote_flags & (OBJREAD | OBJWRITE)) == (OBJREAD | OBJWRITE)
     516                                        && strncmp((char*)pKrnlOTE[j].ote_base, "DEBUG", 5) == 0)
     517                                    {
     518                                        pKrnlInfo->fDebug = TRUE;
     519                                        break;
     520                                    }
     521                                    j++;
     522                                }
     523
     524                                /* Display info */
     525                                kprintf(("GetOTEs32: info summary: Build %d, fSMP=%d, fDebug=%d\n",
     526                                         pKrnlInfo->usBuild, pKrnlInfo->fSMP, pKrnlInfo->fDebug));
     527
     528                                /* Break out */
     529                                break;
     530                            }
    450531
    451532                            /* next */
    452533                            psz++;
    453                         }
     534                        } /* while loop searching for "Internal revision " */
     535                    } /* for loop on objects 0-1. */
     536
     537                    /* Set error code if not found */
     538                    if (pKrnlInfo->usBuild == 0)
     539                    {
     540                        usRc = 5;
     541                        kprintf(("GetOTEs32: Internal revision was not found!\n"));
    454542                    }
    455                     #endif
    456543                }
    457544                else
     
    466553    else
    467554        usRc = 1;
     555
    468556
    469557    if (usRc != 0)
     
    515603    int cb = -3;
    516604
    517     kprintf(("interpretFunctionProlog32(0x%08x, %d):\n"
    518              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
    519              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
    520              pach, fOverload,
    521              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
    522              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
     605    kprintf2(("interpretFunctionProlog32(0x%08x, %d):\n"
     606              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
     607              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
     608              pach, fOverload,
     609              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
     610              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
    523611
    524612    /*
     
    699787    int cb = -7;
    700788
    701     kprintf(("interpretFunctionProlog16(0x%08x, %d):\n"
    702              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
    703              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
    704              pach, fOverload,
    705              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
    706              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
     789    kprintf2(("interpretFunctionProlog16(0x%08x, %d):\n"
     790              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n"
     791              "\t%02x %02x %02x %02x - %02x %02x %02x %02x\n",
     792              pach, fOverload,
     793              pach[0], pach[1], pach[2], pach[3], pach[4], pach[5], pach[6], pach[7],
     794              pach[8], pach[9], pach[10],pach[11],pach[12],pach[13],pach[14],pach[15]));
    707795    /*
    708796     * Check for the well known prolog (the only that is supported now)
     
    817905 * @returns   0 if ok. !0 if not ok.
    818906 * @remark    Called from IOCtl.
    819  *            WARNING! VerifyImporTab32 is called before the initroutine!
     907 *            WARNING! This function is called before the initroutine (R0INIT)!
    820908 */
    821909USHORT _loadds _Far32 _Pascal VerifyImportTab32(void)
     
    828916    pulTKSSBase32 = (PULONG)_TKSSBase16;
    829917
    830     /* verify */
     918    /* Check that pKrnlOTE is set */
     919    if (GetKernelInfo32(NULL) != NO_ERROR)
     920        return STATUS_DONE | STERR | 1;
     921
     922    /*
     923     * Verify aImportTab.
     924     */
    831925    for (i = 0; i < NBR_OF_KRNLIMPORTS; i++)
    832926    {
    833         /* verify that it is found */
     927        /*
     928         * Debug info
     929         */
     930        kprintf2(("VerifyImportTab32: procedure no.%d is being checked: %s addr=0x%08x iObj=%d offObj=%d\n",
     931                  i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress,
     932                  _aImportTab[i].iObject, _aImportTab[i].offObject));
     933
     934        /* Verify that it is found */
    834935        if (!_aImportTab[i].fFound)
    835936        {
    836             kprintf(("VerifyImportTab32: procedure no.%d was not found!\n", i));
    837             return STATUS_DONE | STERR | 1;
     937            kprintf(("VerifyImportTab32: procedure no.%d was not fFound!\n", i));
     938            return STATUS_DONE | STERR | 2;
    838939        }
    839940
    840         /* verify read/writeable. - FIXME */
     941        /* Verify read/writeable. */
     942        if (_aImportTab[i].iObject >= pKrnlSMTE->smte_objcnt                                /* object index valid? */
     943            || _aImportTab[i].ulAddress < pKrnlOTE[_aImportTab[i].iObject].ote_base         /* address valid? */
     944            || _aImportTab[i].ulAddress + 16 > (pKrnlOTE[_aImportTab[i].iObject].ote_base +
     945                                                pKrnlOTE[_aImportTab[i].iObject].ote_size)  /* address valid? */
     946            || _aImportTab[i].ulAddress - _aImportTab[i].offObject
     947               != pKrnlOTE[_aImportTab[i].iObject].ote_base                                 /* offObject ok?  */
     948            )
     949        {
     950            kprintf(("VerifyImportTab32: procedure no.%d has an invalid address or object number.!\n"
     951                     "                   %s  addr=0x%08x iObj=%d offObj=%d\n",
     952                     i, &_aImportTab[i].achName[0], _aImportTab[i].ulAddress,
     953                     _aImportTab[i].iObject, _aImportTab[i].offObject));
     954            return STATUS_DONE | STERR | 3;
     955        }
     956
     957
     958
    841959        if (_aImportTab[i].ulAddress < 0xffe00000UL)
    842960        {
    843             kprintf(("VerifyImportTab32: procedure no.%d has an invlalid address, %#08x!\n",
     961            kprintf(("VerifyImportTab32: procedure no.%d has an invalid address, %#08x!\n",
    844962                     i, _aImportTab[i].ulAddress));
    845             return STATUS_DONE | STERR | 2;
     963            return STATUS_DONE | STERR | 4;
    846964        }
    847965
     
    855973                if (EPT32BitEntry(_aImportTab[i]))
    856974                {
    857                     cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC32);
     975                    cb = interpretFunctionProlog32((char*)_aImportTab[i].ulAddress,
     976                                                   _aImportTab[i].fType == EPT_PROC32);
    858977                    cbmin = 5; /* Size of the jump instruction */
    859978                }
    860979                else
    861980                {
    862                     cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress, _aImportTab[i].fType == EPT_PROC16);
     981                    cb = interpretFunctionProlog16((char*)_aImportTab[i].ulAddress,
     982                                                   _aImportTab[i].fType == EPT_PROC16);
    863983                    cbmin = 7; /* Size of the far jump instruction */
    864984                }
     
    870990                {   /* failed, too small or too large. */
    871991                    kprintf(("VerifyImportTab32: verify failed for procedure no.%d (cd=%d)\n", i, cb));
    872                     return STATUS_DONE | STERR | 3;
     992                    return STATUS_DONE | STERR | 5;
    873993                }
    874994                break;
     
    8811001                kprintf(("VerifyImportTab32: only EPT_PROC is implemented\n",i));
    8821002                Int3(); /* temporary fix! */
    883                 return STATUS_DONE | STERR | 4;
     1003                return STATUS_DONE | STERR | 6;
    8841004        }
    8851005    }
Note: See TracChangeset for help on using the changeset viewer.