msx2: make tickspersec runtime configurable
authorgeijoenr <enric.geijo@gmail.com>
Sun, 1 Feb 2015 19:07:22 +0000 (19:07 +0000)
committergeijoenr <enric.geijo@gmail.com>
Sun, 1 Feb 2015 19:25:36 +0000 (19:25 +0000)
Kernel/include/kdata.h
Kernel/kdata.c
Kernel/platform-msx2/config.h
Kernel/platform-msx2/devices.c
Kernel/process.c
Kernel/start.c
Kernel/syscall_fs2.c

index 3336754..9a67abc 100644 (file)
@@ -35,6 +35,7 @@ extern ptptr init_process;  /* The process table address of the first process. *
 extern bool inint;     /* flag is set whenever interrupts are being serviced */
 
 extern uint8_t ticks_this_dsecond;       /* Tick counter for counting off one decisecond */
+extern uint8_t ticks_per_dsecond;       /* Ticks per decisecond at machine interrupt rate rate */
 extern uint16_t runticks;  /* Number of ticks current process has been swapped in */
 
 extern time_t tod;      /* Time of day */
index 565b76e..6e3a2cb 100644 (file)
@@ -10,11 +10,11 @@ uint16_t runticks;
 bool inint;
 uint16_t root_dev;
 uint8_t ticks_this_dsecond;
+uint8_t ticks_per_dsecond;
 inoptr root;
 uint16_t waitno;
 time_t tod;                    // time of day
 ticks_t ticks;
-
 int16_t acct_fh = -1;          /* Accounting file handle */
 
 struct runload loadavg[3] = {
index d62e44b..3098133 100644 (file)
@@ -23,7 +23,7 @@
 #define VT_RIGHT       79
 #define VT_BOTTOM      23
 
-#define TICKSPERSEC 50   /* Ticks per second (actually should be dynamic FIXME) */
+#define TICKSPERSEC 60     /* default value, it will be upated on device_init */
 #define PROGBASE    0x0000  /* also data base */
 #define PROGLOAD    0x0100
 #define PROGTOP     0xF000  /* Top of program, base of U_DATA */
index fd038df..5ec5d79 100644 (file)
@@ -67,8 +67,10 @@ void device_init(void)
     }
     if ((infobits & INTFREQ_MASK) == INTFREQ_60Hz) {
        kprintf("60Hz\n");
+       ticks_per_dsecond = 6;
     } else {
        kprintf("50Hz\n");
+       ticks_per_dsecond = 5;
     }
 
     if (megasd_probe()) {
index 97ad52f..1a70547 100644 (file)
@@ -331,7 +331,7 @@ void timer_interrupt(void)
 
        /* Do once-per-decisecond things - this doesn't work out well on
           boxes with 64 ticks/second.. need a better approach */
-       if (++ticks_this_dsecond == TICKSPERSEC / 10) {
+       if (++ticks_this_dsecond == ticks_per_dsecond) {
                static ptptr p;
 
                /* Update global time counters */
index 0f56d18..c1ecd34 100644 (file)
@@ -152,6 +152,10 @@ void fuzix_main(void)
 
        create_init();
        kputs("Enabling interrupts ... ");
+
+       /* runtime configurable, defaults to build time setting */
+       ticks_per_dsecond = TICKSPERSEC / 10;
+
         ei();
        kputs("ok.\n");
 
index 5357fa6..b96656f 100644 (file)
@@ -670,6 +670,7 @@ arg_t _uname(void)
        sysinfo.memk = procmem;
        sysinfo.usedk = pagemap_mem_used();
        sysinfo.nproc = PTABSIZE;
+       sysinfo.ticks = ticks_per_dsecond * 10;
        sysinfo.loadavg[0] = loadavg[0].average;
        sysinfo.loadavg[1] = loadavg[1].average;
        sysinfo.loadavg[2] = loadavg[2].average;