?? task.c
字號:
/*
* Task related routines.
*
* Copyright(?) 1999 R.J.M. Close, distribute under GPL
*/
#include "task.h"
// Initiates the relavent type of task with the supplied args.
void x_send_mail (unsigned int arg1, unsigned int arg2, unsigned char* arg3, unsigned int arg4)
{
switch (arg2) {
case 1:
dp_task (arg1, arg3, arg4);
return;
case 2:
at_task (arg1, arg3, arg4);
return;
case 3:
io_task (arg1, arg3, arg4);
return;
default:
printf("x_send_mail: error task type %d not valid!\n", arg2);
return;
}
}
void dp_task(unsigned int arg1, unsigned char* arg2, unsigned int arg3)
{
// Major function, needs filling in!
//printf("dp_task: (%x, %p, %x);\n", arg1, arg2, arg3);
if (arg1 > 0x1b) goto loc_290B3;
if (arg1 >= 0x1a) goto loc_2906D;
if (arg1 > 0x13) return;
switch(arg1) {
//loc_28D38
case 0:
// This is how it is called in UART_init().
dp_init_variables();
if (arg2 == NULL) {
printf("dp_task: error: arg2 is NULL.\n");
break;
}
if (dp_init_modem() != 1) {
*arg2 = 0;
x_modem_state = 1;
break;
}
else {
*arg2 = 1;
x_init_modem_options();
// ll_load_modem_options(); Loads options from registry in NT.
x_output(0);
dp_update_modem_options();
x_modem_state = 1;
break;
}
case 1:
if(dp_sleep == 0)
dp_onhook_cmd();
dp_deinit_modem();
x_modem_mode = 0;
x_fax_state = 0;
dp_state = 20;
break;
case 2:
dp_periodic_task();
break;
case 3:
*arg2 = 0;
break;
case 0x78:
dp_hdlc_mode();
break;
default:
printf("dp_task: error: case %d not implemented.\n", arg1);
break;
}
return;
loc_2906D:
loc_290B3:
// Fill in!
dp_test_cmd (arg3, arg2);
}
void at_task(unsigned int arg1, unsigned char* arg2, unsigned int arg3)
{
switch (arg1) {
case 0:
at_init_variables();
return;
case 0x15: case 0x17: case 0x18: case 0x19: case 0x1a: case 0x1b:
return;
case 0x16:
//atparse_cmd();
return;
case 0x1d:
if (x_dial_residual == 0)
at_result_code = 0;
else if (x_dial_residual == 2)
at_result_code = 6;
else if (x_dial_residual == 1)
at_result_code = 7;
else if (x_dial_residual == 3)
at_result_code = 8;
else if (x_dial_residual == 11)
at_result_code = 30;
else if (x_dial_residual == 12)
at_result_code = 31;
else if (x_dial_residual == 13)
at_result_code = 32;
else
at_result_code = 3;
//at_output_msg (0, 0);
return;
default:
// Needs filling in (low priority!).
printf("at_task(%d, %s, %d): not implemented.\n", arg1, arg2, arg3);
return;
}
}
// WARNING!! The states for version 568 differ slightly.
// It looks like a state has been taken out for 568.
// For example state 66 in the 535 version is the same
// as state 65 in the 568 version.
void dp_periodic_task (void)
{
unsigned int eax;
unsigned int ecx;
printf ("dp_periodic_task: IN dp_state = %d, ", dp_state);
eax = x_elapsed_time_long(x_minute_timer_long);
ecx = eax;
if (ecx >= 60000) {
// Update minute Timer variables.
/*
4f04: b8 73 b2 e7 45 movl $0x45e7b273,%eax
4f09: f7 e1 mull %ecx,%eax
4f0b: c1 ea 0e shrl $0xe,%edx
4f0e: 66 89 54 24 08 movw %dx,0x8(%esp,1)
4f13: 66 01 15 00 00 addw %dx,x_minute_count
4f18: 00 00
4f1a: 0f b7 44 24 08 movzwl 0x8(%esp,1),%eax
4f1f: 89 44 24 04 movl %eax,0x4(%esp,1)
4f23: 89 c2 movl %eax,%edx
4f25: c1 e2 05 shll $0x5,%edx
4f28: 29 c2 subl %eax,%edx
4f2a: 8d 14 90 leal (%eax,%edx,4),%edx
4f2d: 89 54 24 04 movl %edx,0x4(%esp,1)
4f31: c1 64 24 04 04 shll $0x4,0x4(%esp,1)
4f36: 29 54 24 04 subl %edx,0x4(%esp,1)
4f3a: c1 64 24 04 05 shll $0x5,0x4(%esp,1)
4f3f: 89 cb movl %ecx,%ebx
4f41: 2b 5c 24 04 subl 0x4(%esp,1),%ebx
4f45: e8 fc ff ff ff call x_current_time_long
4f4a: 89 c2 movl %eax,%edx
4f4c: 0f b7 c3 movzwl %bx,%eax
4f4f: 29 c2 subl %eax,%edx
4f51: 89 15 00 00 00 movl %edx,x_minute_timer_long
4f56: 00
4f57: e8 fc ff ff ff call x_current_time
4f5c: 89 c2 movl %eax,%edx
4f5e: 29 da subl %ebx,%edx
4f60: 66 89 15 00 00 movw %dx,x_minute_timer
4f65: 00 00
*/
}
//edx = dp_state -1;
if (dp_state > 71) return;
switch (dp_state) {
case 13: // 5850: Same as 568.
if (dp_dial_connect_success() == 1) {
dp_state = 15;
x_modem_state = 6;
dp_timer = x_current_time();
dp_timer1 = x_current_time();
x_send_mail(0x17, 3, 0, 0);
if (H_blacklist_or_delay_flag)
dp_update_blacklist(dp_dial_string, 0);
printf("Connected OK!\n");
}
// loc_28368:
else
// Connect failed?
// S_connect_completion_timeout is byte_59E67
if (x_elapsed_long_time(&dp_long_timer) >=
(unsigned int)(S_connect_completion_timeout * 10)) {
x_status[0x28] = 3;
dp_state = 33;
x_dial_residual = 9;
}
dp_detect_over_current(1);
break;
case 15:
// dp_state = 15 in Jamies is 2d0c8:
// and is 5a90 in 568 version. This section is based on the 568 version.
if (x_elapsed_time(dp_timer) < 500) goto loc_5b6e;
dp_modem_rate();
if (dp_retrain() != 1) goto loc_5b01;
dp_disable_workaround();
*(unsigned short*)(x_status + 0x26) = *(unsigned short*)(x_status + 0x26) + 1;
dp_bV34WkState = 0;
dp_count = 1;
dp_state = 50; // 535 version has state set to 49.
dp_timer1 = x_current_time();
x_send_mail(0x81, 3, 0, 0);
//568 version has this:
dp_lapm_error_check_init();
goto loc_5b6e;
loc_5b01:
if (dp_carrier_loss() != 1) goto loc_5b55;
if (x_elapsed_time(dp_timer)
< (S_auto_disconnect_delay * 100)) goto loc_5b6e;
// Auto disconnect.
dp_state = 33;
x_status[0x3c] = 0x3c;
x_dial_residual = 9;
x_status[0x28] = 1;
goto loc_5b6e;
loc_5b55:
if (S(0x2a) == 1)
dp_auto_rate();
dp_timer = x_current_time();
loc_5b6e:
if (S(0x2a) == 1)
dp_lapm_auto_rate();
break;
case 33: //5b85:
// Go onhook.
dp_onhook_cmd();
dp_state = 34;
dp_timer = x_current_time();
break;
case 34: //5ba0:
if ((dp_line_connect() == false) ||
(x_elapsed_time(dp_timer) > 1000)) {
// If not connected or nothing has happened for a second
// then go onhook.
x_modem_state = 1;
dp_onhook_cmd();
dp_state = 1;
x_send_mail(0x18, 3, 0, 0);
dp_56k_idle();
dp_vpcm_idle();
}
break;
case 60:
if (!dp_v8bis_ans_background())
dp_answer_cmd();
break;
case 64:
// Do the 56K (flex?) stuff.
dp_56k_background();
break;
case 65:
// Perform VPCM stuff.
dp_vpcm_background();
break;
default:
printf ("!!dp_periodic_task: error, clause for dp_state = %d not implemented!!\n",
dp_state);
}
printf (" OUT dp_state = %d!\n", dp_state);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -