From 82a326806fae091b50da827db58144daed567746 Mon Sep 17 00:00:00 2001 From: Brett Gordon Date: Thu, 23 Jun 2016 13:50:18 -0400 Subject: [PATCH] dwtime: fix signedness, change to truely static multiply. --- Kernel/include/drivewire.h | 4 ++++ Kernel/platform-coco3/config.h | 1 + Kernel/platform-coco3/devices.c | 1 + Kernel/platform-coco3/dwtime.c | 15 ++++++++------- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Kernel/include/drivewire.h b/Kernel/include/drivewire.h index dd3cdf9c..b2ee1913 100644 --- a/Kernel/include/drivewire.h +++ b/Kernel/include/drivewire.h @@ -1,6 +1,10 @@ #ifndef _DRIVEWIRE_H #define _DRIVEWIRE_H +/* Kernel definition */ +uint16_t dw_transaction( uint8_t *send, uint16_t scnt, + uint8_t *recv, uint16_t rcnt, uint8_t rawf ); + struct dw_trans{ uint8_t *sbuf; /* pointer to user-space send buffer */ uint16_t sbufz; /* size of send buffer */ diff --git a/Kernel/platform-coco3/config.h b/Kernel/platform-coco3/config.h index c3489a7b..2460370a 100644 --- a/Kernel/platform-coco3/config.h +++ b/Kernel/platform-coco3/config.h @@ -90,3 +90,4 @@ extern unsigned char vt_map( unsigned char c ); #define CONFIG_IDE /* enable if IDE interface present */ #define CONFIG_RTC /* enable RTC code */ +#define CONFIG_DWTIME_INTERVAL 10 /* time between dw timer polls in secs */ diff --git a/Kernel/platform-coco3/devices.c b/Kernel/platform-coco3/devices.c index 9def73fc..ea84f951 100644 --- a/Kernel/platform-coco3/devices.c +++ b/Kernel/platform-coco3/devices.c @@ -8,6 +8,7 @@ #include #include #include +#include struct devsw dev_tab[] = /* The device driver switch table */ diff --git a/Kernel/platform-coco3/dwtime.c b/Kernel/platform-coco3/dwtime.c index 1556e657..df138b28 100644 --- a/Kernel/platform-coco3/dwtime.c +++ b/Kernel/platform-coco3/dwtime.c @@ -4,6 +4,7 @@ #include #include #include +#include "config.h" #define DISC __attribute__((section(".discard"))) @@ -24,7 +25,7 @@ static int get_time( uint8_t *tbuf ) /* A Classic, as stolen from Gnu */ -DISC uint32_t __mulsi3( uint32_t a, uint32_t b) +DISC static uint32_t mul( uint32_t a, uint32_t b) { uint32_t r=0; while (a){ @@ -41,7 +42,7 @@ DISC uint32_t __mulsi3( uint32_t a, uint32_t b) DISC int dwtime_init( void ) { - char buffer[6]; + uint8_t buffer[6]; uint32_t ret; /* get time packet */ @@ -68,10 +69,11 @@ DISC int dwtime_init( void ) /* calculate days from years */ ret=365; - ret *= year - 70; + ret = mul( ret, year - 70 ); /* count leap days in preceding years */ ret += (year - 69) >> 2; + /* calculate days from months */ ret += mktime_moffset[month]; @@ -83,15 +85,15 @@ DISC int dwtime_init( void ) /* add in days in this month */ ret += day - 1; /* convert to hours */ - ret *= 24; + ret = mul( ret, 24 ); ret += hour; /* convert to minutes */ - ret *= 60; + ret = mul( ret, 60 ); ret += minute; /* convert to seconds */ - ret *= 60; + ret = mul( ret, 60 ); ret += second; tod.low=ret; @@ -101,7 +103,6 @@ DISC int dwtime_init( void ) } -#define CONFIG_DWTIME_INTERVAL 10 /* time between dw timer polls in secs */ /* Called every every decisec from timer.c */ uint8_t rtc_secs(void) -- 2.34.1