LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Openrisc > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: =?unknown-8bit?Q?Gy=F6rgy?= 'nog' Jeney<nog@s...>
    Date: Tue Jul 5 17:52:53 CEST 2005
    Subject: [openrisc] [or1ksim #139] move sched_next_insn
    Top
    Hi,

    ChangeLog:
    * move sched_next_insn from sim-cmd.c to sched.c. It is also usefull for the
    pic and the tick timer.

    nog.
    -------------- next part --------------
    diff -upr --unidirectional-new-file ./support/sched.h /home/nog/or1ksim-ac/support/sched.h
    --- ./support/sched.h 2005-07-05 15:31:47.000000000 +0200
    +++ /home/nog/or1ksim-ac/support/sched.h 2005-07-05 15:28:11.000000000 +0200
    @@ -49,6 +49,7 @@ struct scheduler_struct {

    void sched_init(void);
    void sched_reset(void);
    +void sched_next_insn(void (*func)(void *), void *dat);

    extern struct scheduler_struct scheduler;

    diff -upr --unidirectional-new-file ./support/sched.c /home/nog/or1ksim-ac/support/sched.c
    --- ./support/sched.c 2005-07-05 06:18:33.000000000 +0200
    +++ /home/nog/or1ksim-ac/support/sched.c 2005-05-13 18:07:03.000000000 +0200
    @@ -90,4 +90,22 @@ void sched_init(void)
    scheduler.job_queue = NULL;
    sched_guard(NULL);
    }
    +
    +/* Schedules the next job so that it will run after the next instruction */
    +void sched_next_insn(void (*func)(void *), void *dat)
    +{
    + int32_t cycles = 1;
    + struct sched_entry *cur = scheduler.job_queue;
    +
    + /* The cycles count of the jobs may go into negatives. If this happens, func
    + * will get called before the next instruction has executed. */
    + while(cur && (cur->time < 0)) {
    + cycles -= cur->time;
    + cur = cur->next;
    + }
    +
    + SCHED_ADD(func, dat, cycles);
    +}
    +
    +
    #warning Scheduler should continue from previous cycles not current ones
    diff -upr --unidirectional-new-file ./sim-cmd.c /home/nog/or1ksim-ac/sim-cmd.c
    --- ./sim-cmd.c 2005-07-05 06:18:33.000000000 +0200
    +++ /home/nog/or1ksim-ac/sim-cmd.c 2005-06-30 10:06:00.000000000 +0200
    @@ -109,22 +109,6 @@ static void debugmem( oraddr_t from, ora
    }
    }

    -/* Schedules the next job so that it will run after the next instruction */
    -static void sched_next_insn(void (*func)(void *))
    -{
    - int32_t cycles = 1;
    - struct sched_entry *cur = scheduler.job_queue;
    -
    - /* The cycles count of the jobs may go into negatives. If this happens, func
    - * will get called before the next instruction has executed. */
    - while(cur && (cur->time < 0)) {
    - cycles -= cur->time;
    - cur = cur->next;
    - }
    -
    - SCHED_ADD(func, NULL, cycles);
    -}
    -
    /* Scheduler job that drops us back into interactive mode after the next
    * instruction has executed */
    void reenter_int(void *dat)
    @@ -175,7 +159,7 @@ static int sim_cmd_help(int argc, char *
    static int sim_cmd_trace(int argc, char **argv) /* trace */
    {
    runtime.sim.hush = 0;
    - sched_next_insn(reenter_int);
    + sched_next_insn(reenter_int, NULL);
    return 1;
    }

    @@ -417,7 +401,7 @@ void print_insn_exec(void *dat)
    dumpreg();
    if(runtime.cpu.instructions < to_insn_num) {
    /* Instruction count has not yet been reached, reschedule */
    - sched_next_insn(print_insn_exec);
    + sched_next_insn(print_insn_exec, NULL);
    return;
    }
    handle_sim_command();
    @@ -442,12 +426,12 @@ static int sim_cmd_run(int argc, char **
    } else {
    /* The user wants to see the execution dumps. Schedule a task to show
    * it to him after each cycle */
    - sched_next_insn(print_insn_exec);
    + sched_next_insn(print_insn_exec, NULL);
    }
    to_insn_num += runtime.cpu.instructions;
    } else {
    if(!runtime.sim.hush)
    - sched_next_insn(print_insn_exec);
    + sched_next_insn(print_insn_exec, NULL);
    }
    } else /* Run 0 instructions */ diff -upr --unidirectional-new-file ./pic/pic.c /home/nog/or1ksim-ac/pic/pic.c --- ./pic/pic.c 2005-06-30 11:30:17.000000000 +0200 +++ /home/nog/or1ksim-ac/pic/pic.c 2005-07-05 15:43:18.000000000 +0200 @@ -64,7 +64,7 @@ void pic_clock(void *dat) except_handle(EXCEPT_INT, cpu_state.sprs[SPR_EEAR_BASE]); } else if(cpu_state.sprs[SPR_PICSR] & (1 << (int)dat)) /* Reschedule only if the interrupt hasn't been cleared */ - SCHED_ADD(pic_clock, dat, 1); + sched_next_insn(pic_clock, dat); } /* WARNING: Don't eaven try and call this function *during* a simulated @@ -89,6 +89,6 @@ void report_interrupt(int line) except_handle(EXCEPT_INT, cpu_state.sprs[SPR_EEAR_BASE]); } else /* Interrupts not currently enabled, retry next clock cycle */ - SCHED_ADD(pic_clock, (void *)line, 1); + sched_next_insn(pic_clock, (void *)line); } } diff -upr --unidirectional-new-file ./tick/tick.c /home/nog/or1ksim-ac/tick/tick.c --- ./tick/tick.c 2005-07-05 09:44:56.000000000 +0200 +++ /home/nog/or1ksim-ac/tick/tick.c 2005-07-05 15:43:52.000000000 +0200 @@ -75,7 +75,7 @@ void tick_raise_except(void *dat) /* Reschedule unconditionally, since we have to raise the exception until * TTMR_IP has been cleared */ - SCHED_ADD(tick_raise_except, NULL, 1); + sched_next_insn(tick_raise_except, NULL); } /* Restarts the tick timer */

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.