Verified Commit 435843ce authored by Allie Sargente's avatar Allie Sargente 😑

Made a few updates

Signed-off-by: Allie Sargente's avatarAllison Sargente <[email protected]>
parent e3950bd3
No preview for this file type
No preview for this file type
#!/bin/sh
# (c) 2019 Apollo Developers
# For terms, see LICENSE
# Script for updating floppy.img
# Should work on linux
# Must be run as root for mount
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo '> Mounting Floppy Image'
mkdir -p /var/tmp-image
losetup /dev/loop0 floppy.img
mount /dev/loop0 /var/tmp-image
echo '> Cleaning kernel folder'
rm /var/tmp-image/Apollo/*.mod
echo '> Copying kernel modules'
cp *.mod /var/tmp-image/Apollo/
echo '> Unmounting Floppy Image'
umount /dev/loop0
losetup -d /dev/loop0
rm -rf /var/tmp-image
No preview for this file type
......@@ -15,22 +15,29 @@ static const uint32_t PIT_config[] = { 36157, 99, 2, 27, 3, 2 };
static int timekeeping(struct regs *regs, void *p)
{
// Grab current timestamp so we can update it
uint64_t ts = get_timestamp();
timekeeping_state_t *state = (timekeeping_state_t*)p;
state->ticks += 1;
timekeeping_state_t *state = (timekeeping_state_t*)p;
state->ticks += 1;
state->correction_count += 1;
// PIT is definately gonna be set to less than 1 uS
ts += state->us_per_tick; // Add microseconds the clock.
state->us_correction_count++;
if(state->us_correction_count >= state->us_correction_rate) {
ts += state->us_correction_factor;
state->us_correction_count = 0;
}
if (state->correction_count >= state->correction_rate) {
state->ticks = state->ticks + state->correction_factor;
// Add ticks that we missed from the rounding error
state->ticks += state->correction_factor;
// Factor into the system clock
ts += (state->us_per_tick * state->correction_factor);
state->correction_count = 0;
}
// The PIT is set to around 27 microseconds
ts += state->us_per_tick;
set_timestamp(ts);
return 0;
}
......@@ -77,7 +84,7 @@ static int PIT_init()
static prereq_t prereqs[] = {{"interrupts", NULL}, {NULL, NULL}};
MODULE = {
.name = "PIT",
.name = "timekeeping",
.required = prereqs,
.load_after = NULL,
.init = &PIT_init,
......
......@@ -3,12 +3,25 @@
* timekeeping.h - Functionality for time
*/
typedef struct callback_state
{
// Data given by register_callback()
uint64_t miliseconds;
int periodic;
void (*cb)(void *);
void *data;
// Internal bookkeeping
uint64_t time_elapsed;
int active;
} callback_state_t;
typedef struct timekeeping_state
{
uint32_t frequency; // Frequency of clock
int32_t ticks; // Simple number of ticks
uint32_t rollover; // Rollover for ticks
uint64_t ticks; // Simple number of ticks
uint32_t tick_per_us; // Set to 0 if tick > 1 microsecond
uint32_t us_per_tick; // Set to 0 if tick < 1 microsecond
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment