static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)

{

    if (s->RxBufAddr + size > s->RxBufferSize)

    {

        int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize);



        /* write packet data */

        if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s))

        {

            DEBUG_PRINT((">>> RTL8139: rx packet wrapped in buffer at %d\n", size-wrapped));



            if (size > wrapped)

            {

                cpu_physical_memory_write( s->RxBuf + s->RxBufAddr,

                                           buf, size-wrapped );

            }



            /* reset buffer pointer */

            s->RxBufAddr = 0;



            cpu_physical_memory_write( s->RxBuf + s->RxBufAddr,

                                       buf + (size-wrapped), wrapped );



            s->RxBufAddr = wrapped;



            return;

        }

    }



    /* non-wrapping path or overwrapping enabled */

    cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size );



    s->RxBufAddr += size;

}

static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)

{

    if (s->RxBufAddr + size > s->RxBufferSize)

    {

        int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize);



        

        if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s))

        {

            DEBUG_PRINT((">>> RTL8139: rx packet wrapped in buffer at %d\n", size-wrapped));



            if (size > wrapped)

            {

                cpu_physical_memory_write( s->RxBuf + s->RxBufAddr,

                                           buf, size-wrapped );

            }



            

            s->RxBufAddr = 0;



            cpu_physical_memory_write( s->RxBuf + s->RxBufAddr,

                                       buf + (size-wrapped), wrapped );



            s->RxBufAddr = wrapped;



            return;

        }

    }



    

    cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size );



    s->RxBufAddr += size;

}

static void FUNC_0(RTL8139State *VAR_0, const void *VAR_1, int VAR_2)

{

    if (VAR_0->RxBufAddr + VAR_2 > VAR_0->RxBufferSize)

    {

        int VAR_3 = MOD2(VAR_0->RxBufAddr + VAR_2, VAR_0->RxBufferSize);



        

        if (VAR_3 && VAR_0->RxBufferSize < 65536 && !rtl8139_RxWrap(VAR_0))

        {

            DEBUG_PRINT((">>> RTL8139: rx packet VAR_3 in buffer at %d\n", VAR_2-VAR_3));



            if (VAR_2 > VAR_3)

            {

                cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr,

                                           VAR_1, VAR_2-VAR_3 );

            }



            

            VAR_0->RxBufAddr = 0;



            cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr,

                                       VAR_1 + (VAR_2-VAR_3), VAR_3 );



            VAR_0->RxBufAddr = VAR_3;



            return;

        }

    }



    

    cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr, VAR_1, VAR_2 );



    VAR_0->RxBufAddr += VAR_2;

}

static void FUNC_0(RTL8139State *VAR_0, const void *VAR_1, int VAR_2)
{ if (VAR_0->RxBufAddr + VAR_2 > VAR_0->RxBufferSize)
{ int VAR_3 = MOD2(VAR_0->RxBufAddr + VAR_2, VAR_0->RxBufferSize); if (VAR_3 && VAR_0->RxBufferSize < 65536 && !rtl8139_RxWrap(VAR_0))
{ DEBUG_PRINT((">>> RTL8139: rx packet VAR_3 in buffer at %d\n", VAR_2-VAR_3)); if (VAR_2 > VAR_3)
{ cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr,
VAR_1, VAR_2-VAR_3 ); } VAR_0->RxBufAddr = 0; cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr,
VAR_1 + (VAR_2-VAR_3), VAR_3 ); VAR_0->RxBufAddr = VAR_3; return; } } cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr, VAR_1, VAR_2 ); VAR_0->RxBufAddr += VAR_2; }