[Kos-cvs] kos/modules/pmm _pmm_rmap.c,NONE,1.1

thomas at kos.enix.org thomas at kos.enix.org
Tue Dec 28 19:45:54 CET 2004


Update of /var/cvs/kos/kos/modules/pmm
In directory the-doors:/tmp/cvs-serv11338

Added Files:
	_pmm_rmap.c 
Log Message:
Forgot to add the _pmm_rmap.c fil

--- NEW FILE: _pmm_rmap.c ---

#include <kos/macros.h>
#include <debug/debug.h>

#include "_pmm.h"

/*
 * This function returns the list of rmapping corresponding to a
 * physical page, with the lock on the gpfm held, and returns the
 * flags needed to unlock the gpfm.
 *
 * @param paddr The physical address of the page
 *
 * @param list Where the head of the rmapping structures list will be
 * returned
 *
 * @param flags Where the flags needed to unlock the GPFM are returned
 *
 * @return Error code. If an error occurs, GPFM is left unlocked.
 */
result_t physmem_get_rmapping_list(paddr_t paddr, struct rmap **list,
				   spinlock_flags_t *flags)
{
  struct gpfme *gpfme;

  write_spin_lock (gpfm.lock, *flags);

  gpfme = _physmem_get_gpfme_at_phys_addr(paddr);
  if(gpfme == NULL)
    {
      DEBUG_PRINT3("[physmem_get_rmapping_list] Returning -EINVAL because no GPFME for phys addr 0x%x\n",
		   paddr);
      write_spin_unlock(gpfm.lock, *flags);
      return -EINVAL;
    }

  *list = gpfme->mapping_list;

  return ESUCCESS;
}

/*
 * This function updates the rmapping list head of a physical page,
 * increments the reference counter of this page (by an increment
 * which can be either positive or negative) and unlock the GPFM using
 * the given flags.
 *
 * @param paddr The physical address of the page*
 *
 * @param list The new head of the list
 *
 * @param flags The flags to unlock the GPFM
 *
 * @param count The increment (either negative or positive) to apply
 * to the reference counter of the page
 */
result_t physmem_commit_rmapping_list(paddr_t paddr, struct rmap *list,
				      spinlock_flags_t flags, int count)
{
  struct gpfme *gpfme;

  gpfme = _physmem_get_gpfme_at_phys_addr(paddr);
  if(gpfme == NULL)
    {
      DEBUG_PRINT3("[physmem_get_rmapping_list] Returning -EINVAL because no GPFME for phys addr 0x%x\n",
		   paddr);
      write_spin_unlock(gpfm.lock, flags);
      return -EINVAL;
    }

  gpfme->mapping_list = list;
  gpfme->ref_cnt      += count;

  write_spin_unlock(gpfm.lock, flags);

  return ESUCCESS;
}



More information about the Kos-cvs mailing list