ref: b0dd7c0479dffe59dbc08177df84ba7944c936c0
parent: c4cfe9a1f4ae8f3209a8484ab57db88f5633bfce
author: 9ferno <[email protected]>
date: Sat Aug 14 03:56:46 EDT 2021
setting default timezone to GMT
--- a/dis/init
+++ b/dis/init
@@ -9,9 +9,6 @@
mount -a { mntgen } /n
mount -a { mntgen } /mnt
-# usually better than 1970
-cat '#r/rtc' >/dev/time
-
#fn showlocaldev {
# echo $1' ' $2
# if(~ $#bootargs 0){
--- a/locale/timezone
+++ b/locale/timezone
@@ -1,24 +1,1 @@
-CST -21600 CDT -18000
- 9943200 25664400 41392800 57718800 73447200 89168400
- 104896800 120618000 126669600 152067600 162352800 183517200
- 199245600 215571600 230695200 247021200 262749600 278470800
- 294199200 309920400 325648800 341370000 357098400 372819600
- 388548000 404874000 419997600 436323600 452052000 467773200
- 483501600 499222800 514951200 530672400 544586400 562122000
- 576036000 594176400 607485600 625626000 638935200 657075600
- 670989600 688525200 702439200 719974800 733888800 752029200
- 765338400 783478800 796788000 814928400 828842400 846378000
- 860292000 877827600 891741600 909277200 923191200 941331600
- 954640800 972781200 986090400 1004230800 1018144800 1035680400
-1049594400 1067130000 1081044000 1099184400 1112493600 1130634000
-1143943200 1162083600 1173578400 1194141600 1205028000 1225591200
-1236477600 1257040800 1268532000 1289095200 1299981600 1320544800
-1331431200 1351994400 1362880800 1383444000 1394330400 1414893600
-1425780000 1446343200 1457834400 1478397600 1489284000 1509847200
-1520733600 1541296800 1552183200 1572746400 1583632800 1604196000
-1615687200 1636250400 1647136800 1667700000 1678586400 1699149600
-1710036000 1730599200 1741485600 1762048800 1772935200 1793498400
-1804989600 1825552800 1836439200 1857002400 1867888800 1888452000
-1899338400 1919901600 1930788000 1951351200 1962842400 1983405600
-1994292000 2014855200 2025741600 2046304800 2057191200 2077754400
-2088640800 2109204000 2120090400 2140653600
+GMT 0
--- a/os/init/disinit.b
+++ b/os/init/disinit.b
@@ -51,6 +51,12 @@
# sys->bind("#T","/dev",sys->MAFTER); # Touchscreen
# sys->bind("#W","/dev",sys->MAFTER); # Flash
+ # set clock
+ # does not handle bootp provided time source
+ now := getclock("#r/rtc");
+ now *= big 1000000;
+ setclock("#c/time", now);
+
# TODO '#c/sysenv' seems obsolete
#sys->print("srv()\n");
#srv();
@@ -123,4 +129,35 @@
return -1;
}
return 0;
+}
+
+getclock(timefile: string): big
+{
+ now := big 0;
+ if(timefile != nil){
+ fd := sys->open(timefile, Sys->OREAD);
+ if(fd != nil){
+ b := array[64] of byte;
+ n := sys->read(fd, b, len b-1);
+ if(n > 0){
+ now = big string b[0:n];
+ if(now <= big 16r20000000)
+ now = big 0; # remote itself is not initialised
+ }
+ }
+ }
+ return now;
+}
+
+setclock(timefile: string, now: big)
+{
+ fd := sys->open(timefile, sys->OWRITE);
+ if (fd == nil) {
+ sys->print("init: can't open %s: %r", timefile);
+ return;
+ }
+
+ b := sys->aprint("%ubd", now);
+ if (sys->write(fd, b, len b) != len b)
+ sys->print("init: can't write to %s: %r", timefile);
}