Subversion Repositories HelenOS-historic

Rev

Rev 1757 | Rev 1766 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1757 Rev 1760
Line 926... Line 926...
926
 * @param order  Allocate exactly 2^order frames.
926
 * @param order  Allocate exactly 2^order frames.
927
 * @param flags  Flags for host zone selection and address processing.
927
 * @param flags  Flags for host zone selection and address processing.
928
 * @param status Allocation status (FRAME_OK on success), unused if NULL.
928
 * @param status Allocation status (FRAME_OK on success), unused if NULL.
929
 * @param pzone  Preferred zone
929
 * @param pzone  Preferred zone
930
 *
930
 *
931
 * @return Allocated frame.
931
 * @return Physical address of the allocated frame.
932
 *
932
 *
933
 */
933
 */
934
pfn_t frame_alloc_generic(__u8 order, int flags, int *status, int *pzone)
934
void * frame_alloc_generic(__u8 order, int flags, int *status, int *pzone)
935
{
935
{
936
    ipl_t ipl;
936
    ipl_t ipl;
937
    int freed;
937
    int freed;
938
    pfn_t v;
938
    pfn_t v;
939
    zone_t *zone;
939
    zone_t *zone;
Line 969... Line 969...
969
 
969
 
970
        if (flags & FRAME_ATOMIC) {
970
        if (flags & FRAME_ATOMIC) {
971
            ASSERT(status != NULL);
971
            ASSERT(status != NULL);
972
            if (status)
972
            if (status)
973
                *status = FRAME_NO_MEMORY;
973
                *status = FRAME_NO_MEMORY;
974
            return NULL;
974
            return 0;
975
        }
975
        }
976
       
976
       
977
        panic("Sleep not implemented.\n");
977
        panic("Sleep not implemented.\n");
978
        goto loop;
978
        goto loop;
979
    }
979
    }
Line 984... Line 984...
984
    spinlock_unlock(&zone->lock);
984
    spinlock_unlock(&zone->lock);
985
    interrupts_restore(ipl);
985
    interrupts_restore(ipl);
986
 
986
 
987
    if (status)
987
    if (status)
988
        *status = FRAME_OK;
988
        *status = FRAME_OK;
-
 
989
 
-
 
990
    if (flags & FRAME_KA)
-
 
991
        return (void *)PA2KA(PFN2ADDR(v));
989
    return v;
992
    return (void *)PFN2ADDR(v);
990
}
993
}
991
 
994
 
992
/** Free a frame.
995
/** Free a frame.
993
 *
996
 *
994
 * Find respective frame structure for supplied PFN.
997
 * Find respective frame structure for supplied PFN.
995
 * Decrement frame reference count.
998
 * Decrement frame reference count.
996
 * If it drops to zero, move the frame structure to free list.
999
 * If it drops to zero, move the frame structure to free list.
997
 *
1000
 *
998
 * @param pfn Frame number of the frame to be freed.
1001
 * @param Frame Physical Address of of the frame to be freed.
999
 */
1002
 */
1000
void frame_free(pfn_t pfn)
1003
void frame_free(__address frame)
1001
{
1004
{
1002
    ipl_t ipl;
1005
    ipl_t ipl;
1003
    zone_t *zone;
1006
    zone_t *zone;
-
 
1007
    pfn_t pfn = ADDR2PFN(frame);
1004
 
1008
 
1005
    ipl = interrupts_disable();
1009
    ipl = interrupts_disable();
1006
   
1010
   
1007
    /*
1011
    /*
1008
     * First, find host frame zone for addr.
1012
     * First, find host frame zone for addr.