OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [cpu/] [common/] [parse.c] - Diff between revs 1486 and 1487

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1486 Rev 1487
Line 92... Line 92...
   translations then translate() performs translation otherwise phy address is
   translations then translate() performs translation otherwise phy address is
   equal to logical. */
   equal to logical. */
static oraddr_t translate(oraddr_t laddr,int* breakpoint)
static oraddr_t translate(oraddr_t laddr,int* breakpoint)
{
{
  int i;
  int i;
  int brkp;
 
 
 
  /* No translation (i.e. when loading kernel into simulator) */
  /* No translation (i.e. when loading kernel into simulator) */
/*  PRINTF("transl_table=%x  laddr=%x\n", transl_table, laddr);
/*  PRINTF("transl_table=%x  laddr=%x\n", transl_table, laddr);
  PRINTF("laddr=%x\n", laddr);*/
  PRINTF("laddr=%x\n", laddr);*/
  if (transl_table == 0)
  if (transl_table == 0)
    return laddr;
    return laddr;
 
 
  /* Try to find our translation in the table. */
  /* Try to find our translation in the table. */
  for(i = 0; i < (MEMORY_LEN / PAGE_SIZE) * 16; i += 16)
  for(i = 0; i < (MEMORY_LEN / PAGE_SIZE) * 16; i += 16)
    if ((laddr & ~(PAGE_SIZE - 1)) == eval_direct32(transl_table + i,
    if ((laddr & ~(PAGE_SIZE - 1)) == eval_direct32(transl_table + i, 0, 0)) {
                                                    &brkp, 0, 0)) {
 
      /* Page modified */
      /* Page modified */
      set_direct32(transl_table + i + 8, -2, &brkp, 0, 0);
      set_direct32(transl_table + i + 8, -2, 0, 0);
      PRINTF("found paddr=%"PRIx32"\n",
      PRINTF("found paddr=%"PRIx32"\n",
             eval_direct32(transl_table + i + 4, &brkp, 0, 0) |
             eval_direct32(transl_table + i + 4, 0, 0) |
                                                     (laddr & (PAGE_SIZE - 1)));
                                                     (laddr & (PAGE_SIZE - 1)));
      return (oraddr_t)eval_direct32(transl_table + i + 4, &brkp, 0, 0) |
      return (oraddr_t)eval_direct32(transl_table + i + 4, 0, 0) |
                                            (laddr & (oraddr_t)(PAGE_SIZE - 1));
                                            (laddr & (oraddr_t)(PAGE_SIZE - 1));
    }
    }
 
 
  /* Allocate new phy page for us. */
  /* Allocate new phy page for us. */
  for(i = 0; i < (MEMORY_LEN / PAGE_SIZE) * 16; i += 16)
  for(i = 0; i < (MEMORY_LEN / PAGE_SIZE) * 16; i += 16)
    if (eval_direct32(transl_table + i + 8, &brkp, 0, 0) == 0) {
    if (eval_direct32(transl_table + i + 8, 0, 0) == 0) {
      /* VPN */
      /* VPN */
      set_direct32(transl_table + i, laddr & ~(PAGE_SIZE - 1), &brkp, 0, 0);
      set_direct32(transl_table + i, laddr & ~(PAGE_SIZE - 1), 0, 0);
      /* PPN */
      /* PPN */
      set_direct32(transl_table + i + 4, (i/16) * PAGE_SIZE, &brkp, 0, 0);
      set_direct32(transl_table + i + 4, (i/16) * PAGE_SIZE, 0, 0);
      /* Page modified */
      /* Page modified */
      set_direct32(transl_table + i + 8, -2, &brkp, 0, 0);
      set_direct32(transl_table + i + 8, -2, 0, 0);
      PRINTF("newly allocated ppn=%"PRIx32"\n",
      PRINTF("newly allocated ppn=%"PRIx32"\n",
             eval_direct32(transl_table + i + 4, &brkp, 0, 0));
             eval_direct32(transl_table + i + 4, 0, 0));
      PRINTF("newly allocated .ppn=%"PRIxADDR"\n", transl_table + i + 4);
      PRINTF("newly allocated .ppn=%"PRIxADDR"\n", transl_table + i + 4);
      PRINTF("newly allocated ofs=%"PRIxADDR"\n", (laddr & (PAGE_SIZE - 1)));
      PRINTF("newly allocated ofs=%"PRIxADDR"\n", (laddr & (PAGE_SIZE - 1)));
      PRINTF("newly allocated paddr=%"PRIx32"\n",
      PRINTF("newly allocated paddr=%"PRIx32"\n",
             eval_direct32(transl_table + i + 4, &brkp, 0, 0) |
             eval_direct32(transl_table + i + 4, 0, 0) |
                                                     (laddr & (PAGE_SIZE - 1)));
                                                     (laddr & (PAGE_SIZE - 1)));
      return (oraddr_t)eval_direct32(transl_table + i + 4, &brkp, 0, 0) |
      return (oraddr_t)eval_direct32(transl_table + i + 4, 0, 0) |
                                            (laddr & (oraddr_t)(PAGE_SIZE - 1));
                                            (laddr & (oraddr_t)(PAGE_SIZE - 1));
    }
    }
  /* If we come this far then all phy memory is used and we can't find our page
  /* If we come this far then all phy memory is used and we can't find our page
     nor allocate new page. */
     nor allocate new page. */
  transl_error = 1;
  transl_error = 1;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.