?? init.c
字號:
/*
* Main initialisation functions.
*
* Copyright (C) 1999 R.J.M. Close
* Copyright (C) 1999 Jamie Lokier.
* distribute under GPL
*/
#include <stdio.h>
#include "init.h"
#include "irq.h"
#include "portIO.h"
#include "control.h"
//*****************************************
// Modem variables are first defined here.
//*****************************************
// Assume inactive for now.
#define INIT_C
#undef LT_GLOBALS_H
#include "modem_globals.h"
// There is a hell of lot of initialisation that is done.
// Most is straight forward variable setting, but needs translating
// none the less. Also country specific initialisation has to be performed.
// Main initialisation routine which is called by the driver entry code.
unsigned char MimicInit(void)
{
// just jumps to the start of this routine.
return UART_init();
}
unsigned char UART_init(void)
{
unsigned char retValue = 0;
ll_init_modem_variables();
io_task(0, 0, 0);
at_task(0, 0, 0);
dp_task(0, &retValue, 1);
x_send_mail(3,3,0,0);
//printf( "Modem init done\n" );
return retValue;
}
void big_init(void)
{
x_init_modem_options ();
PRINTF( "Initializing modem... " );
if (!dp_init_modem ()) {
PRINTF( "fail\n" );
exit(1);
}
PRINTF( "ok\n" );
}
void modem_reset(void)
{
printf( "Resetting modem...\n" );
dp_modem_command(0x13, 0, 0);
dp_modem_command(0x12, 0, 0);
dp_modem_command_long(0x29, 0xff, 1, 0x87, 0);
// Make sure the reset did not generate any
// RAM failures.
if (dp_readram_failcnt > 0)
printf( "RAM read errors detected, failure count: %d.\n",
dp_readram_failcnt);
}
// Empty for now.
void x_set_hardware_options(void){}
void UART_reset(void)
{
}
void v8bis_power_up_init(void)
{
// v8bis_ptr = 0x55a60;
//v8bis_msg1 = 0x58aa0;
//v8bis_msg2 = 0x58b04;
S(0x6a) = 1;
V8bis_Options[0] = 0;
V8bis_Options[1] = 0;
V8bis_Options[2] = 0;
V8bis_Options[3] = 0;
//right[0x18e] = 0;
//right[0x18f] = 0;
v8bis_state = 0;
/*
right[2] = 0;
right[3] = 0;
movw %ax,0x55bde <_right+0x17e>
movw %ax,0x55be0 <_right+0x180>
movw %ax,0x55be2 <_right+0x182>
movw %ax,0x55bd8 <_right+0x178>
movw %ax,0x55bda <_right+0x17a>
movb %al,0x55be4 <_right+0x184>
movb %al,0x55be5 <_right+0x185>
movb %al,0x55bec <_right+0x18c>
movb %al,0x55bed <_right+0x18d>
movw %ax,0x55be6 <_right+0x186>
movw %ax,0x55be8 <_right+0x188>
movw %ax,0x55bea <_right+0x18a>
movb %al,0x55bf0 <_right+0x190>
movb %al,0x55bf1 <_right+0x191>
movb %al,0x55bf2 <_right+0x192>
movb %al,0x55bf3 <_right+0x193>
*/
}
// What does this do? Called with 1 when going offhook, and
// with 0 when going onhook.
void init_1027(unsigned int arg)
{
unsigned int startTime;
//printf("init_1027 called with %d.", arg);
dp_regandor (0xcf, 0xff, 0x20);
writecioc(0x1f, 0xc0);
// Wait for 5 milliseconds.
usleep(5000);
dp_regandor (0xda, 0xfe, 0);
if (arg == 1)
writecioc(0x1f, 0xc0);
else
writecioc(0x0f, 0xc0);
writecioc(0x40, 0);
writecioc(0x85, 0x42);
writecioc(0xc8, 0x26);
// Wait for bit 2 to clear in reg or timeout after 500mS.
startTime = x_current_time();
while (dp_regread(0xd5) & 2) {
if (x_elapsed_time(startTime) >= 500) break;
}
dp_regandor (0xda, 0xfe, 1);
dp_regandor (0xcf, 0xdf, 0);
}
void ll_init_modem_variables (void)
{
x_modem_state = 0;
x_line_rate = 0x0A;
x_dial_residual = 0;
x_modem_ec = 0;
x_fax_state = 0;
x_modem_mode = 0;
x_test_mode_on = 0;
x_minute_count = 0;
x_minute_timer = x_current_time();
x_parity_mask = 0xFF;
x_minute_timer_long = x_current_time();
x_dma_xfer = 0;
// country_code = 0x19; //North America
S(0xd) = 8;
S(0x13) = 0;
S(0xf) = 0;
S(0x10) = 9;
word_59E9E = 0x7FFF; //<_S+0x3e>
word_59E9C = 0x8AB8; //<_S+0x3c>
x_init_modem_options();
// ll_load_modem_options();
at_init_diagnostics();
x_parameter_mode = 0;
// Extra - not in asm code.
dp_ring_int_count = 0;
dp_ring_int = 0;
}
// Used in dp_task prior to dp_init_modem.
void dp_init_variables(void) {
x_modem_state = 1;
x_dial_residual = 0;
dp_state = 1;
dp_calling_tone_disable = 0;
dp_wDspRetrainState = 0;
DpIdleFillChar = 0;
dp_init_blacklist(); // ?
dp_init_local_phone_state();
dp_tad_downloaded = 0;
dp_fax_downloaded = 0;
dp_fdsp_record = 0;
v8bis_power_up_init();
dp_redial = 0;
}
void dp_deinit_modem(void)
{
dp_init_modem();
dp_sleep_mode(0);
dp_board_disable();
}
// This is now complete, though some of the routines it calls
// may not be!
int dp_init_modem(void)
{
int romChecksum;
homol[0xf18-HBASE] = 0;
homol[0xef3-HBASE] = 0x12;
homol[0xef4-HBASE] = 0x50;
#if 0
// This resets _ciocs_ and is bad idea.
homol[0xf30-HBASE] = 0x88;
homol[0xf31-HBASE] = 0x80;
homol[0xf32-HBASE] = 0x6b;
homol[0xf33-HBASE] = 0x1e;
#endif
dp_bamil_rd7 = 0xff;
dp_dsp_data_in_progress = 0;
dp_sleep = 0;
//printf( "Enabling board\n" );
dp_board_enable();
dp_regwrite(0xd8, 0xff);
dp_regwrite(0xd7, 0xff);
dp_regwrite(0xcb, 8);
modem_reset();
dp_bamil_rbc = 0xff;
dp_regwrite(0xbc, 0xff);
dp_regwrite(0xbd, 0xff);
dp_regwrite(0xbd, 0);
dp_regwrite(0xbe, 0);
dp_regwrite(0xb7, 0xff);
dp_regwrite(0xd8, 0xff);
dp_regwrite(0xb6, 0xee);
dp_bamil_rd7 = 0xf3;
dp_regwrite(0xd7, 0xf3);
// Wait 100 milliseconds.
x_sleep(100);
dp_modem_command(0x13, 0, 0);
printf( "." );
dp_modem_command(0x2d, 0, 0);
printf( "." );
dp_modem_command_long(0x2e, 1, 0x23, 7, 0);
printf( "." );
dp_modem_command(0x13, 0, 0);
printf( "." );
dp_byte_f = 0;
dp_read_dsp_ram(0x3a);
// Interrupt is generated here!
dp_read_dsp_ram(0x3a);
printf( ".\n" );
if (dp_byte_f != 1) {
printf( "Init: read_dsp_ram did not set dp_byte_f to 1.\n" );
return 0;
}
//Check the rom checksum.
printf( "Rom checksum is " );
romChecksum = dp_dsp_rom_checksum(); // Also sets up dp_version.
printf( " %x.\n", romChecksum );
x_dsp_mars = 0;
if ((romChecksum == 0xf15d) && (dp_version == 0x39)) goto loc_2c12e;
else if ((romChecksum == 0xe49e) && (dp_version == 0x46)) goto loc_2c12e;
else if ((romChecksum == 0xe851) && (dp_version == 0x48)) goto loc_2c12e;
else {
// Failed to detect known chipset.
printf("ERROR: Unknown chipset/version.");
return 0;
}
loc_2c12e:
if (romChecksum == 0xe851) x_dsp_mars = 1;
if (x_dsp_mars) {
printf( "Chip version is " );
x_chip_version = dp_dsp_regread(0x0b) >> 6;
printf( " %x (Mars).\n", x_chip_version );
if (x_chip_version) {
dp_regwrite(0xa0, 0x21);
dp_regwrite(0xa4, 0);
}
}
x_output(0);
if (homol[0xF18-HBASE] == 0) {
dp_write_dsp_ram( 0x40, homol[0xEF3-HBASE]);
dp_write_dsp_ram(0x41, homol[0xEF4-HBASE]);
}
else {
dp_write_dsp_ram(0x40, homol[0xEF3-HBASE] >> 1);
dp_write_dsp_ram(0x41, homol[0xEF4-HBASE] >> 1);
}
dp_write_dsp_ram(0x43, 2);
if ((x_chip_version == 0) && (x_dsp_mars == 0)) {
// Set bit 8 in 0xDE register.
dp_regwrite (0xde, (dp_regread (0xde) | 0x10));
}
if (x_dsp_mars == 1)
dp_modem_command_long(3, 0xc0, 0, 8, 0);
dp_tad_downloaded = dp_fax_downloaded = 0;
dp_init_local_phone_timer();
dp_first_call = 1;
dp_set_mercury_gain();
if (D3Flag == 0) cell_init();
printf( "Modem init successfully complete\n" );
// Everthing went OK so return success.
return 1;
}
// FAKE!
int read_eeprom (int addr)
{
/* Fake. */
if (addr == 0)
return COUNTRY_CODE;
return 0;
}
void x_init_modem_options(void)
{
S (0) = 0;
S_ring_count = 0;
S_AT_escape_char = '+';
S_command_termination_char = 13;
S_response_format_char = 10;
S_command_backspace_char = 8;
S_wait_before_dialing = 2;
S_connect_completion_timeout = 50;
S_comma_dial_time = 2;
S_auto_disconnect_delay = 20;
S_DTMF_dial_speed = 95;
S_escape_guard_time = 50;
S_inactivity_timer = 0;
S_data_calling_tone = 1;
S_dial_line_rate = 0;
S_auto_rate = 1;
S_auto_mode = 1;
S (0x40) = read_eeprom (1);
S_0x4f = 0xffff;
// word_59EAF = 0xFFFF;
S_V34_enable = 1;
S_enable_K56flex_settings = 1;
S_network_codec_type = 1;
S (0x6b) = 0;
S (0x6d) = 0;
S (0x83) = 1;
S (0x2c) = 1;
S (0x70) = 0;
S (0x6f) = 0;
S (0x2d) = 1;
S (0x2e) = 1;
S (0x2f) = 1;
S (0x57) = 1;
S (0x31) = 0;
S (0x32) = 1;
S (0x33) = 1;
S (0x34) = 2;
S (0x51) = 0;
S (0x35) = 0;
S_speaker_volume = 2;
S_speaker_enable = 1;
S_negotiation_fallback = 7;
S_LAPM_negotiation_flags = 7;
S (0x38) = 6;
S (0x39) = 3;
S (0x3a) = 1;
S (0x3b) = 0;
S (0x58) = 2;
S (0xe6) = 0x23;
S_sleep_mode_timer_2 = 10;
S (0x41) = 0;
S (0x42) = 0x80;
S (0x43) = 0x80;
S (0x44) = 0;
S (0x45) = 50;
S (0x46) = 10;
S (0x47) = 0x80;
S (0x48) = 50;
S (0x49) = 0x81;
S (0x4a) = 1;
S_0x4b = 100;
S (0x4d) = 0;
S (0x4e) = 0;
S (0x1d) = 0;
S (0x1f) = 0;
S_synthetic_ring_volume = 10;
S_synthetic_ring_frequency = 0;
S (0x71) = 0;
S (0x72) = 0;
S (0x52) = 0;
S (0x74) = 0;
S (0x53) = 1;
S (0x54) = 0xc1;
S (0x55) = 1;
S (0x6a) = 1;
S (0x56) = 0;
S_0x5d = 0x9650;
S_0x61 = 0x3800;
S_0x64 = 0x03ff;
ETC_mode = 0;
S (0x28) = 0;
S (0x27) = 0;
S_general_options = 8;
S_results_options = 0x70;
S (0x76) = 0;
S (0x79) = 0xfa;
S (0x7a) = 0;
S (0x7b) = 5;
S (0x7c) = 3;
S (0x7d) = 0;
S (0x80) = 0;
if (!x_test_mode_on)
x_init_international ();
io_sync_power_up_init ();
v8bis_power_up_init ();
x_init_international_default ();
dp_dial_string [0] = 0;
if (((S(0x75) & 0xf0) == 0x30) && (country_code == COUNTRY_JAPAN))
dp_init_blacklist ();
}
//-------------------------------------------------------------
// Initialisation for AT command stuff.
void at_init_variables(void)
{
at_result_code = 0x3F;
at_state = 0;
// mov dword__at_cmd_ptr, offset byte__at_cmd_buf
at_cmd_ptr = &(at_cmd_buf); // Sort this out! Offset?
at_cmd_buf = 0;
at_cmd_len = 0;
at_connect_code_flag = 0;
at_view_more = 0;
at_timer = 0;
}
void at_init_diagnostics(void)
{
int i;
x_status[0] = 1;
for(i=1; i<=0x28; i++)
x_status[i] = 0;
for(i=0x2c; i<=0x30; i++)
x_status[i] = 0;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -