⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 biosial.c

📁 此为marvell 6081在bios芯片中运行的代码
💻 C
📖 第 1 页 / 共 5 页
字号:
             * stack pointer, bp and stack segment must be returned to it's
             * previous value.
             */

            if(sp.val < 0x200)
            {
                incrementSP = MV_TRUE;
                _asm{
                    push si
                    add sp, 0x200
                    add bp, 0x200
                    mov si, ss
                    sub si, 0x20
                    mov ss, si
                    pop si
                }
#ifdef DEBUG_IAL
                printHexSingle ("Stack WO",sp.val);
#endif



            }

            ax.parts.hval= requestIO (channelIndex, PMPort,
                                      lowLBAAddress, 0, 
                                      sectorCount,
                                      (ax.parts.hval == 0x42) ? MV_UDMA_TYPE_READ : MV_UDMA_TYPE_WRITE,
                                      segment, offset);
            /* Revert sp, bp and ss to it's previous value */
            if(incrementSP == MV_TRUE)
            {
                _asm{
                    push si
                    sub sp, 0x200
                    sub bp, 0x200
                    mov si, ss
                    add si, 0x20
                    mov ss, si
                    pop si
                }
#ifdef DEBUG_IAL
                printHexSingle ("StackB",sp.val);
#endif			
            }

            if(ax.parts.hval != 0x0)
            {
#ifdef DEBUG_IAL
                printHexSingle ("UDMA comp Err",ax.parts.hval);
                printAll = MV_TRUE;
#endif
                if(mvStorageDevATASoftResetDevice(&sataAdapter.mvSataAdapter,
                                                  channelIndex, PMPort, 0) ==
                   MV_FALSE)
                {
#ifdef DEBUG_IAL
                    printHexSingle ("Softrst Err",ax.parts.hval);
#endif



                }
                flags |= 0x1;
            }
            /* 
             * Revert the Request Queue hi base address to it's value that is
             * set in initializeDriver 
             */
            if((channelIndex == 0) && (useIoBar == MV_FALSE))
            {
                mvSataWriteReg(&sataAdapter.mvSataAdapter, 0x22010, mvSataBarOffset);
            }
            break;
        }
    case 0x45:          /* Lock / unlock media */
    case 0x46:          /* Eject removable media */
        {
            /* Return media is not removable */
            flags |= 0x1;
            ax.parts.hval = 0xb2;
            break;
        }
    case 0x48:  /* Get drive parameters extended */
        {
            unsigned short temp;
            unsigned long size_of_disk;
            if(readSegmentOffset16bit(ds, si.val) < 26)
            {
                flags |= 0x1;
                ax.parts.hval = 1;
                break;
            }
            ax.parts.hval = 0;
            if(readSegmentOffset16bit(ds, si.val) > 30)
            {
                writeSegmentOffset16bit(ds, si.val, 30);
            }
            if((readSegmentOffset16bit(ds, si.val) > 26) &&
               (readSegmentOffset16bit(ds, si.val) < 30))
            {
                writeSegmentOffset16bit(ds, si.val, 26);
            }
            /* WORD 2 - geometry in fields 4..15 is invalid */
            writeSegmentOffset16bit(ds, si.val + 2, 0);
            /* Reset fields 4..15 */
            for(temp = 4 ; temp < 16 ; temp += 2)
            {
                writeSegmentOffset16bit(ds, si.val + temp, 0);
            }

            size_of_disk = sataAdapter.channelsInfo[channelIndex].diskSize[PMPort];
            writeSegmentOffset16bit(ds, si.val+16, (unsigned short)(size_of_disk & 0xffff));
            writeSegmentOffset16bit(ds, si.val+18, (unsigned short)((size_of_disk >> 16) & 0xffff));
            writeSegmentOffset16bit(ds, si.val+20, 0);
            writeSegmentOffset16bit(ds, si.val+22, 0);
            writeSegmentOffset16bit(ds, si.val+24, 512);    /* 512 byte per sector */

            break;
        }
    case 0x06:          /* Format Bad Track */
    case 0x07:          /* Format Drive */
    case 0x0a:          /* Read Long Sectors */
    case 0x0b:          /* Write Long Sectors */
    case 0x0e:          /* Diagnostics 1: Read Test Buffer */
    case 0x0f:          /* Diagnostics 2: Write Test Buffer */
    default:
        {
            /* function not supported */
#ifdef DEBUG_IAL
            printAll = MV_TRUE;
            printHexSingle("UNSP",ax.parts.hval);
            printHexSingle ("Press any key" ,0);
#endif
            ax.parts.hval = 0x01;
            flags |= 1;
            break;
        }
    }

#ifdef DEBUG_IAL
    if(printAll == MV_TRUE)
    {
        printHexSingle ("----",0);
        printHexSingle ("- AX",ax);
        printHexSingle ("- BX",bx);
        printHexSingle ("- CX",cx);
        printHexSingle ("- DX",dx);
        printHexSingle ("- ES",es);
        printHexSingle ("- DI",di);
        printHexSingle ("- flags",flags);
        printHexSingle ("----",0);
    }
#endif




}


/*******************************************************************************
* int13EntryPoint - Interrupt 13h entry point
*
*
* DESCRIPTION:
*   Checks if the requested interrupt 13h is for the adapter (by checking DL).
*   If so, it calls int13ExecuteRequest ; otherwise it calls the next
*   interrupt 13h handler in the chain.
*
* INPUT:
*   All CPU registers
*
* RETURN:
*   None
*
*******************************************************************************/

void int13EntryPoint (void)
{
    _asm{
        nop
        nop
        nop
        pushf
        cmp byte dl, cs:drivesNumbers + 0
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 1
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 2
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 3
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 4
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 5
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 6
        je  int13ExectueRequestWrapper
        cmp byte dl, cs:drivesNumbers + 7
        je  int13ExectueRequestWrapper

        popf
        jmp oldInt13VectorCode

        int13ExectueRequestWrapper :        
        popf
        jmp     int13ExecuteRequest






    }





}

/*******************************************************************************
* oldInt13VectorCode - Old Interrupt 13h entry point
*
*
* DESCRIPTION:
*   This function is modified in runtime (self modifying code) and has a far
*   call to the previous interrupt 13h handler before this driver hooks in
*   the interrupt 13h for the SATA channels.
*
* INPUT:
*   None
*
* RETURN:
*   None
*
*******************************************************************************/
void oldInt13VectorCode(void)
{
    printf("NULL\n");
    return;
}


/*******************************************************************************
* printf - Prints to the monitor a formatted string
*
*
* DESCRIPTION:
*   Gets a formatted string, while utilizing sprintf it prints to the monitor.
*
* INPUT:
*   None
*
* RETURN:
*   None
*
*******************************************************************************/
void printf(const char *fmt, ...)
{
    va_list args;
    int i;
    char prntBuff[100];
    va_start(args, fmt);
    i = vsprintf (prntBuff,fmt,args);
    va_end(args);
    printString(prntBuff);
    return;
}

unsigned char intToChr (unsigned char value)
{
    if((value <= 9))
    {
        return(value + '0');
    }
    if((value >= 10) && (value <= 15))
    {
        return(value + 'a'-10);
    }
    return 0;
}
#ifdef PRNTHEXTSINGLE
void printHexSingle(char *fmt, unsigned short value_)
{
    int i = 0;
    char prntBuff[20];
    unsigned short value = value_;
    for(i = 0 ; fmt[i] ; i++)
    {
        prntBuff[i] = fmt[i];
    }
    prntBuff[i] = ' ';
    prntBuff[i+1] = 0;

#ifdef DEBUG_IAL
    printStringSerial (prntBuff);
#else
    printString (prntBuff);
#endif
    for(i = 0 ; i < 4 ; i ++)
    {
        prntBuff[3-i] = intToChr(value & 0xf);
        value = value >> 4;
    }
    prntBuff[4] = '\n';
    prntBuff[5] = 0;
#ifdef DEBUG_IAL
    printStringSerial (prntBuff);
#else
    printString (prntBuff);
#endif





}
#endif

/*******************************************************************************
* mvLogMsg - Log messages printing function
*
*
* DESCRIPTION:
*   This function is part of the CORE driver OS dependent function. It gets
*   a level of the log message and accordingly decides wether to print it out
*   or not.
*
* INPUT:
*   level   -   Level of the requested message to be logged
*   fmt     -   Pointer to formatted string
*   ...     -   Parameters the are used to properly printing the log message
*
* RETURN:
*   None
*
*******************************************************************************/
#ifdef MV_DEBUG_LOG
int mvLogMsg(MV_U8 level, MV_CHAR_PTR fmt, ...)
{
    va_list args;
    int i;
    char prntBuff[150];
    if(level & 0x40)
    {
        va_start(args, fmt);
        i = vsprintf (prntBuff,fmt,args);
        va_end(args);
        printString (prntBuff);
    }
    return 0;
}
#endif



void resizeToZero(void)
{

    printf("Resizing ROM image to 0\n");
    /* Resize ROM image size to 0 - no need to recalculate checksum */
    * (unsigned char *) 0x2 = 0;
}

/*******************************************************************************
* initializeDriver - Initializes BIOS Driver parameters
*
*
* DESCRIPTION:
*   This function modifed the GDT table (global descriptor table) to be suitable
*   for accessing 88SX50xx internal registers. It then initlizes 88SX50xx part
*   and initializes all storage devices connected to it.
*
* INPUT:
*   Nonte
*
* RETURN:
*   None
*
*******************************************************************************/
void initializeDriver(void)
{
    unsigned long temp, *temp1;
    unsigned int dataSegment;
    unsigned short buff[3];

    if(alreadyInitializedChannelsFlag)
    {
        return;
    }

    mvSataDeviceId = mvSataReadConfigWord(0x2);
    mvSataRevisi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -