Skip to content

Commit

Permalink
08 Nov 2006 Fix (hopefully) hang after resume - Greg Smith
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/jj/hercules.svn/trunk@4035 956126f8-22a0-4046-8f4a-272fa8102e63
  • Loading branch information
Greg Smith committed Nov 9, 2006
1 parent d737548 commit eccb994
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
08 Nov 2006 Fix (hopefully) hang after resume - Greg Smith
08 Nov 2006 Fix Diag 204 RMF structure size - Ivan Warren
Detected by "aleeuw2000"
06 Nov 2006 Update to instfetch processing - Greg Smith
Expand Down
114 changes: 114 additions & 0 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "inline.h"

#include "sr.h"

#if !defined(_CLOCK_C_)
#define _CLOCK_C_

Expand Down Expand Up @@ -386,6 +388,118 @@ U64 new_clock;
return new_clock;
}

#define SR_SYS_CLOCK_CURRENT_CSR ( SR_SYS_CLOCK | 0x001 )
#define SR_SYS_CLOCK_UNIVERSAL_TOD ( SR_SYS_CLOCK | 0x002 )
#define SR_SYS_CLOCK_HW_STEERING ( SR_SYS_CLOCK | 0x004 )
#define SR_SYS_CLOCK_HW_EPISODE ( SR_SYS_CLOCK | 0x005 )
#define SR_SYS_CLOCK_HW_OFFSET ( SR_SYS_CLOCK | 0x006 )

#define SR_SYS_CLOCK_OLD_CSR ( SR_SYS_CLOCK | 0x100 )
#define SR_SYS_CLOCK_OLD_CSR_START_TIME ( SR_SYS_CLOCK | 0x101 )
#define SR_SYS_CLOCK_OLD_CSR_BASE_OFFSET ( SR_SYS_CLOCK | 0x102 )
#define SR_SYS_CLOCK_OLD_CSR_FINE_S_RATE ( SR_SYS_CLOCK | 0x103 )
#define SR_SYS_CLOCK_OLD_CSR_GROSS_S_RATE ( SR_SYS_CLOCK | 0x104 )

#define SR_SYS_CLOCK_NEW_CSR ( SR_SYS_CLOCK | 0x200 )
#define SR_SYS_CLOCK_NEW_CSR_START_TIME ( SR_SYS_CLOCK | 0x201 )
#define SR_SYS_CLOCK_NEW_CSR_BASE_OFFSET ( SR_SYS_CLOCK | 0x202 )
#define SR_SYS_CLOCK_NEW_CSR_FINE_S_RATE ( SR_SYS_CLOCK | 0x203 )
#define SR_SYS_CLOCK_NEW_CSR_GROSS_S_RATE ( SR_SYS_CLOCK | 0x204 )

int clock_hsuspend(void *file)
{
int i;
char buf[SR_MAX_STRING_LENGTH];

i = (current == &new);
SR_WRITE_VALUE(file, SR_SYS_CLOCK_CURRENT_CSR, i, sizeof(i));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_UNIVERSAL_TOD, universal_tod, sizeof(universal_tod));
snprintf(buf, sizeof(buf), "%f", hw_steering);
SR_WRITE_STRING(file, SR_SYS_CLOCK_HW_STEERING, buf);
SR_WRITE_VALUE(file, SR_SYS_CLOCK_HW_EPISODE, hw_episode, sizeof(hw_episode));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_HW_OFFSET, hw_offset, sizeof(hw_offset));

SR_WRITE_VALUE(file, SR_SYS_CLOCK_OLD_CSR_START_TIME, old.start_time, sizeof(old.start_time));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_OLD_CSR_BASE_OFFSET, old.base_offset, sizeof(old.base_offset));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_OLD_CSR_FINE_S_RATE, old.fine_s_rate, sizeof(old.fine_s_rate));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_OLD_CSR_GROSS_S_RATE, old.gross_s_rate, sizeof(old.gross_s_rate));

SR_WRITE_VALUE(file, SR_SYS_CLOCK_NEW_CSR_START_TIME, new.start_time, sizeof(new.start_time));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_NEW_CSR_BASE_OFFSET, new.base_offset, sizeof(new.base_offset));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_NEW_CSR_FINE_S_RATE, new.fine_s_rate, sizeof(new.fine_s_rate));
SR_WRITE_VALUE(file, SR_SYS_CLOCK_NEW_CSR_GROSS_S_RATE, new.gross_s_rate, sizeof(new.gross_s_rate));

return 0;
}

int clock_hresume(void *file)
{
size_t key, len;
int i;
float f;
char buf[SR_MAX_STRING_LENGTH];

memset(&old, 0, sizeof(CSR));
memset(&new, 0, sizeof(CSR));
current = &new;
universal_tod = 0;
hw_steering = 0.0;
hw_episode = 0;
hw_offset = 0;

do {
SR_READ_HDR(file, key, len);
switch (key) {
case SR_SYS_CLOCK_CURRENT_CSR:
SR_READ_VALUE(file, len, &i, sizeof(i));
current = i ? &new : &old;
break;
case SR_SYS_CLOCK_UNIVERSAL_TOD:
SR_READ_VALUE(file, len, &universal_tod, sizeof(universal_tod));
break;
case SR_SYS_CLOCK_HW_STEERING:
SR_READ_STRING(file, buf, len);
sscanf(buf, "%f",&f);
hw_steering = f;
break;
case SR_SYS_CLOCK_HW_EPISODE:
SR_READ_VALUE(file, len, &hw_episode, sizeof(hw_episode));
break;
case SR_SYS_CLOCK_HW_OFFSET:
SR_READ_VALUE(file, len, &hw_offset, sizeof(hw_offset));
break;
case SR_SYS_CLOCK_OLD_CSR_START_TIME:
SR_READ_VALUE(file, len, &old.start_time, sizeof(old.start_time));
break;
case SR_SYS_CLOCK_OLD_CSR_BASE_OFFSET:
SR_READ_VALUE(file, len, &old.base_offset, sizeof(old.base_offset));
break;
case SR_SYS_CLOCK_OLD_CSR_FINE_S_RATE:
SR_READ_VALUE(file, len, &old.fine_s_rate, sizeof(old.fine_s_rate));
break;
case SR_SYS_CLOCK_OLD_CSR_GROSS_S_RATE:
SR_READ_VALUE(file, len, &old.gross_s_rate, sizeof(old.gross_s_rate));
break;
case SR_SYS_CLOCK_NEW_CSR_START_TIME:
SR_READ_VALUE(file, len, &new.start_time, sizeof(new.start_time));
break;
case SR_SYS_CLOCK_NEW_CSR_BASE_OFFSET:
SR_READ_VALUE(file, len, &new.base_offset, sizeof(new.base_offset));
break;
case SR_SYS_CLOCK_NEW_CSR_FINE_S_RATE:
SR_READ_VALUE(file, len, &new.fine_s_rate, sizeof(new.fine_s_rate));
break;
case SR_SYS_CLOCK_NEW_CSR_GROSS_S_RATE:
SR_READ_VALUE(file, len, &new.gross_s_rate, sizeof(new.gross_s_rate));
break;
default:
SR_READ_SKIP(file, len);
break;
}
} while ((key & SR_SYS_MASK) == SR_SYS_CLOCK);
return 0;
}


#endif

Expand Down
2 changes: 2 additions & 0 deletions clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void set_int_timer(REGS *, S32); /* Set interval timer */
U64 tod_clock(REGS *); /* Get TOD clock */
void set_tod_clock(U64); /* Set TOD clock */
int chk_int_timer(REGS *); /* Check int_timer pending */
int clock_hsuspend(void *file); /* Hercules suspend */
int clock_hresume(void *file); /* Hercules resume */

#endif

Expand Down
10 changes: 10 additions & 0 deletions sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ BYTE psw[16];
servc_hsuspend(file);
SR_WRITE_HDR(file, SR_DELIMITER, 0);

/* Save clock state */
SR_WRITE_HDR(file, SR_SYS_CLOCK, 0);
clock_hsuspend(file);
SR_WRITE_HDR(file, SR_DELIMITER, 0);

/* Write CPU data */
for (i = 0; i < MAX_CPU_ENGINES; i++)
{
Expand Down Expand Up @@ -616,6 +621,11 @@ S64 dreg;
if (rc < 0) goto sr_error_exit;
break;

case SR_SYS_CLOCK:
rc = clock_hresume(file);
if (rc < 0) goto sr_error_exit;
break;

case SR_CPU:
SR_READ_VALUE(file, len, &i, sizeof(i));
if (i >= MAX_CPU_ENGINES)
Expand Down
2 changes: 2 additions & 0 deletions sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@

#define SR_SYS_SERVC 0xace11000

#define SR_SYS_CLOCK 0xace12000

#define SR_CPU 0xace20000
#define SR_CPU_ARCHMODE 0xace20001
#define SR_CPU_PX 0xace20002
Expand Down

0 comments on commit eccb994

Please sign in to comment.