int page_check_range(target_ulong start, target_ulong len, int flags)

{

    PageDesc *p;

    target_ulong end;

    target_ulong addr;



    if (start + len < start)

        /* we've wrapped around */

        return -1;



    end = TARGET_PAGE_ALIGN(start+len); /* must do before we loose bits in the next step */

    start = start & TARGET_PAGE_MASK;



    for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {

        p = page_find(addr >> TARGET_PAGE_BITS);

        if( !p )

            return -1;

        if( !(p->flags & PAGE_VALID) )

            return -1;



        if ((flags & PAGE_READ) && !(p->flags & PAGE_READ))

            return -1;

        if (flags & PAGE_WRITE) {

            if (!(p->flags & PAGE_WRITE_ORG))

                return -1;

            /* unprotect the page if it was put read-only because it

               contains translated code */

            if (!(p->flags & PAGE_WRITE)) {

                if (!page_unprotect(addr, 0, NULL))

                    return -1;

            }

            return 0;

        }

    }

    return 0;

}

int page_check_range(target_ulong start, target_ulong len, int flags)

{

    PageDesc *p;

    target_ulong end;

    target_ulong addr;



    if (start + len < start)

        

        return -1;



    end = TARGET_PAGE_ALIGN(start+len); 

    start = start & TARGET_PAGE_MASK;



    for(addr = start; addr < end; addr += TARGET_PAGE_SIZE) {

        p = page_find(addr >> TARGET_PAGE_BITS);

        if( !p )

            return -1;

        if( !(p->flags & PAGE_VALID) )

            return -1;



        if ((flags & PAGE_READ) && !(p->flags & PAGE_READ))

            return -1;

        if (flags & PAGE_WRITE) {

            if (!(p->flags & PAGE_WRITE_ORG))

                return -1;

            



            if (!(p->flags & PAGE_WRITE)) {

                if (!page_unprotect(addr, 0, NULL))

                    return -1;

            }

            return 0;

        }

    }

    return 0;

}

int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)

{

    PageDesc *p;

    target_ulong end;

    target_ulong addr;



    if (VAR_0 + VAR_1 < VAR_0)

        

        return -1;



    end = TARGET_PAGE_ALIGN(VAR_0+VAR_1); 

    VAR_0 = VAR_0 & TARGET_PAGE_MASK;



    for(addr = VAR_0; addr < end; addr += TARGET_PAGE_SIZE) {

        p = page_find(addr >> TARGET_PAGE_BITS);

        if( !p )

            return -1;

        if( !(p->VAR_2 & PAGE_VALID) )

            return -1;



        if ((VAR_2 & PAGE_READ) && !(p->VAR_2 & PAGE_READ))

            return -1;

        if (VAR_2 & PAGE_WRITE) {

            if (!(p->VAR_2 & PAGE_WRITE_ORG))

                return -1;

            



            if (!(p->VAR_2 & PAGE_WRITE)) {

                if (!page_unprotect(addr, 0, NULL))

                    return -1;

            }

            return 0;

        }

    }

    return 0;

}

int FUNC_0(target_ulong VAR_0, target_ulong VAR_1, int VAR_2)
{ PageDesc *p; target_ulong end; target_ulong addr; if (VAR_0 + VAR_1 < VAR_0)
return -1; end = TARGET_PAGE_ALIGN(VAR_0+VAR_1); VAR_0 = VAR_0 & TARGET_PAGE_MASK; for(addr = VAR_0; addr < end; addr += TARGET_PAGE_SIZE) { p = page_find(addr >> TARGET_PAGE_BITS); if( !p )
return -1; if( !(p->VAR_2 & PAGE_VALID) )
return -1; if ((VAR_2 & PAGE_READ) && !(p->VAR_2 & PAGE_READ))
return -1; if (VAR_2 & PAGE_WRITE) { if (!(p->VAR_2 & PAGE_WRITE_ORG))
return -1; if (!(p->VAR_2 & PAGE_WRITE)) { if (!page_unprotect(addr, 0, NULL))
return -1; } return 0; } } return 0; }