Commit 638bfb38 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

QEMU: experimental UART support in main firmware

(Dry-shell working on all DIGIC 4 and 5 models)

--HG--
branch : qemu
parent 5792b7744556
......@@ -1030,13 +1030,12 @@ static void eos_uart_rx(void *opaque, const uint8_t *buf, int size)
s->reg_st |= ST_RX_RDY;
s->reg_rx = *buf;
EOSState *es = (EOSState *)(opaque - offsetof(EOSState, uart));
if (strcmp(es->model->name, "5D3eeko") == 0)
{
/* fixme: hardcoded for Eeko */
eos_trigger_int(es, 0x39, 0);
}
assert(es->model->uart_rx_interrupt);
/* fixme: why it locks up without a delay? */
eos_trigger_int(es, es->model->uart_rx_interrupt, 10);
}
static void eos_uart_event(void *opaque, int event)
......@@ -3086,7 +3085,7 @@ static int edmac_do_transfer(EOSState *s, int channel)
/* assume 200 MB/s transfer speed */
int delay = transfer_data_size * 1e6 / (200*1024*1024) / 0x100;
printf("[EDMAC#%d] transfer delay %d x 256 us.\n", channel, delay);
fprintf(stderr, "[EDMAC#%d] transfer delay %d x 256 us.\n", channel, delay);
edmac_trigger_interrupt(s, channel, delay);
return 1;
......@@ -3771,12 +3770,17 @@ unsigned int eos_handle_uart ( unsigned int parm, EOSState *s, unsigned int addr
const char * msg = 0;
int msg_arg1 = 0;
static int enable_tio_interrupt = 0;
static int flags = 0;
if (address == 0xC0270000 && value == 0x80000000)
{
msg = "TIO enable flag on EOS M3?";
goto end;
}
if (address == 0xC0270000)
if (address == 0xC0270000 && value != (value & 0xFF))
{
/* TIO enable flag on EOS M3? */
static int mem = 0;
MMIO_VAR(mem);
/* unknown, probably not TIO */
goto end;
}
......@@ -3785,6 +3789,7 @@ unsigned int eos_handle_uart ( unsigned int parm, EOSState *s, unsigned int addr
case 0x00:
if(type & MODE_WRITE)
{
msg = "Write char";
assert(value == (value & 0xFF));
if (s->uart.chr) {
......@@ -3799,9 +3804,10 @@ unsigned int eos_handle_uart ( unsigned int parm, EOSState *s, unsigned int addr
fprintf(stderr, KRED"%c"KRESET, value);
}
/* 0 written during initialization */
if (enable_tio_interrupt)
{
eos_trigger_int(s, 0x3A + parm, 0);
eos_trigger_int(s, s->model->uart_tx_interrupt, 1);
}
}
else
......@@ -3811,12 +3817,19 @@ unsigned int eos_handle_uart ( unsigned int parm, EOSState *s, unsigned int addr
break;
case 0x04:
msg = "Read byte: 0x%02X";
msg = "Read char";
s->uart.reg_st &= ~(ST_RX_RDY);
ret = s->uart.reg_rx;
msg_arg1 = ret;
break;
case 0x08:
{
msg = "Flags?";
MMIO_VAR(flags);
flags &= ~0x800;
break;
}
case 0x14:
if(type & MODE_WRITE)
{
......@@ -3827,7 +3840,7 @@ unsigned int eos_handle_uart ( unsigned int parm, EOSState *s, unsigned int addr
}
else
{
ret = s->uart.reg_st;
s->uart.reg_st = value;
}
}
else
......@@ -3838,12 +3851,27 @@ unsigned int eos_handle_uart ( unsigned int parm, EOSState *s, unsigned int addr
break;
case 0x18:
/* 1000D expects interrupt 0x3A to be triggered after writing each char */
/* most other cameras are upset by this interrupt */
enable_tio_interrupt = (value == 0xFFFFFFC4);
msg = (value == 0xFFFFFFC4) ? "enable interrupt?" : "interrupt related?";
ret = 0;
{
msg = "interrupt flags?";
static int status = 0;
MMIO_VAR(status);
if(type & MODE_WRITE)
{
/* 1000D expects interrupt 0x3A to be triggered after writing each char */
/* most other cameras are upset by this interrupt */
if (value == 0xFFFFFFC4)
{
msg = "enable interrupt?";
enable_tio_interrupt = 1;
}
else
{
enable_tio_interrupt = value & 1;
}
}
break;
}
}
end:
......@@ -4541,8 +4569,69 @@ static void cfdma_trigger_interrupt(EOSState *s)
}
}
static unsigned int eos_handle_uart_dma ( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
unsigned int ret = 0;
const char * msg = 0;
static uint32_t addr;
static uint32_t count;
static uint32_t status;
switch(address & 0x1F)
{
case 0x00:
case 0x08:
msg = "Transfer memory address";
MMIO_VAR(addr);
break;
case 0x04:
case 0x0C:
msg = "Transfer byte count";
MMIO_VAR(count);
break;
case 0x10:
msg = "Transfer command / status?";
if (value == 0x10023)
{
/* read char? */
count = 0;
cpu_physical_memory_write(addr, &s->uart.reg_rx, 1);
status = 0x10;
/* guess: initialization? */
static int first_time = 1;
if (first_time)
{
eos_trigger_int(s, s->model->uart_rx_interrupt, 0);
first_time = 0;
}
}
ret = 0x20;
break;
case 0x14:
msg = "DMA status?";
if (s->uart.reg_st & ST_RX_RDY) {
status |= 0x4;
}
MMIO_VAR(status);
break;
}
io_log("UartDMA", s, address, type, value, ret, msg, 0, 0);
return ret;
}
unsigned int eos_handle_cfdma ( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
if (parm == 0 && s->model->digic_version >= 4)
{
return eos_handle_uart_dma(parm, s, address, type, value);
}
unsigned int ret = 0;
const char * msg = 0;
......
......@@ -25,6 +25,8 @@ struct eos_model_desc eos_model_list[] = {
.mpu_status_register = 0xC0220098,
.mpu_control_register = 0xC0203034,
.mpu_request_interrupt = 0x52,
.uart_rx_interrupt = 0x2E,
.uart_tx_interrupt = 0x3A,
},
{
/* defaults for DIGIC 4 cameras */
......@@ -54,6 +56,8 @@ struct eos_model_desc eos_model_list[] = {
.mpu_status_register = 0xC022009C,
.mpu_control_register = 0xC020302C,
.mpu_request_interrupt = 0x50,
.uart_rx_interrupt = 0x2E,
.uart_tx_interrupt = 0x3A,
},
{
/* defaults for DIGIC 5 cameras */
......@@ -80,6 +84,8 @@ struct eos_model_desc eos_model_list[] = {
.card_led_address = 0xC022C188, /* SD */
.mpu_control_register = 0xC020302C,
.mpu_request_interrupt = 0x50,
.uart_rx_interrupt = 0x2E,
.uart_tx_interrupt = 0x3A,
},
{
/* defaults for DIGIC 6 cameras */
......@@ -105,6 +111,8 @@ struct eos_model_desc eos_model_list[] = {
.sd_driver_interrupt = 0xEE,
.sd_dma_interrupt = 0xBE,
.card_led_address = 0xD20B0A24,
.uart_rx_interrupt = 0x15D,
.uart_tx_interrupt = 0x16D,
},
{
/* defaults for DIGIC 7 cameras */
......@@ -174,6 +182,7 @@ struct eos_model_desc eos_model_list[] = {
.dryos_timer_interrupt = 0xFE,
.current_task_addr = 0x40000148,
.current_task_name_offs = 0x09,
.uart_rx_interrupt = 0x39,
},
{
.name = "650D",
......@@ -249,6 +258,7 @@ struct eos_model_desc eos_model_list[] = {
.current_task_addr = 0x31170,
.sd_driver_interrupt = 0x4B,
.sd_dma_interrupt = 0x32,
.uart_rx_interrupt = 0x38,
},
{
.name = "EOSM",
......
......@@ -49,11 +49,13 @@ struct eos_model_desc {
uint32_t cf_dma_interrupt;
uint32_t card_led_address;
uint32_t ram_manufacturer_id;
uint32_t uart_rx_interrupt;
uint32_t uart_tx_interrupt;
};
/* this must match the number of items in the above struct */
/* note: you get a compile-time error if params[] is smaller than the struct */
uint32_t params[33];
uint32_t params[35];
};
} __attribute__((packed));
......
e8d09b6556000920b14f5d1556e3952a calls-from.log
2767fa1df0214319b126592d2e24070a calls-from.log
266e39fb03a112a57bd1dda859499def calls-from.idc
64b439982389db5b76af78b802b4f279 calls-from-basic.log
a2c2443354de18a2a156d363dd0ee3d2 calls-from-basic.idc
80e38328616e23ee98740084c0e9a2a5 calls-main.log
e8b52754d65f03ab033ea2c628f07a2b calls-main.idc
2b821871b971f6b241834fb83ec317aa calls-main-basic.log
f671502a62790342898af6676771b6d0 calls-main-basic.idc
bd0dae48c800b6f7ecc2cf003549036e calls-main.log
6e09433816c78c7c81faae0128204868 calls-main.idc
c26f9caecf449d8163f5bc26c4752c64 calls-main-basic.log
7e0b38524cac1ed7e6ffba5ed78b75d7 calls-main-basic.idc
de58bc6f720d5d3124872acc82a91403 calls-from.log
1c9b60a3fdf36770e147d1c888537cfa calls-from.log
cfb858a0d7b4dbf709af7061fff6a2a8 calls-from.idc
89261558dc36d611f8e084fcd27de7e9 calls-from-basic.log
a6c2f63ba10a1c944cb14a8385837cb0 calls-from-basic.idc
31e4aec9000c562a3dbf7df20e625980 calls-main.log
9a9f5fa1bf75c44d74642a44d6cbf768 calls-main.idc
cfcdcf4e1e5cf734b023d7ba9d8c4888 calls-main-basic.log
28a5ddc74aa9d235f5eda35b2d50ce51 calls-main-basic.idc
3459f6389351c15c02231deb0ded34c0 calls-main.log
8be9f948e0f5c009e74389486216919b calls-main.idc
4b26efc1e545d62787bc722c423435d9 calls-main-basic.log
832c6177452156a9b64a28eb29a50be1 calls-main-basic.idc
2a392642af0c865386f4355b51f2f59d calls-from.log
53fd78dacf39f2edd9b548ca4c44e372 calls-from.log
4d46e5d94dfc935a9a59c2479810a204 calls-from.idc
d735b265b0babffabc429532773d240c calls-from-basic.log
4c6a0e8912292aa7e6b3b264a261c4f5 calls-from-basic.idc
77afff96c80e349e15c7f224956fec26 calls-main.log
1a2b5ea02e08fd4e94b9f18fd423ef8c calls-main.idc
f1ac9a580196907f51b9208e04a1ad47 calls-main-basic.log
699e1888db1fa867dcc57662267f92d0 calls-main-basic.idc
4bf5f1fa6253a117f72488bd26d0ec9f calls-main.log
00d0d7b9296d9d41494f4ee07b15a8ed calls-main.idc
215958c4c77a187b8158465012242e28 calls-main-basic.log
86ca503c18540ffa23b7caf3922aee39 calls-main-basic.idc
65aa75ecf00c880536c5ab518e16e6d4 calls-from.log
4323ae2ce4581e66dfaf50433ecb1668 calls-from.log
65358b40d2247cbb1c4c591d4c571058 calls-from.idc
7f6e467eefdd2dec81e12e5b2f58ebcf calls-from-basic.log
7e8382a1aaf1437a6d7e8be76cffa6a5 calls-from-basic.idc
bb2e782c11980e0ceb1d260d4f894879 calls-main.log
37a6e731440b79a3a9436161e73fce6a calls-main.idc
e3e150be6f4dd6e78c5770c3aa71ec05 calls-main-basic.log
382c6a208704e8b1b66276c4003cecab calls-main-basic.idc
6cd64660b34db56ff651df32f09adc2a calls-main.log
85625392e01856bcf1ba3bfd9a6d8d3e calls-main.idc
6e456e529c36bf49908bb5228e872135 calls-main-basic.log
cc14d387f42f33277c0ee625a3712434 calls-main-basic.idc
c3a1db1051f01e3fc49c536360ad8289 calls-from.log
183e00adcbf383ef3c620cc7a575d13d calls-from.log
b0a825644e93a9bb98a67f6132ff03e8 calls-from.idc
a7e23002baad86dd030dae10dad5e34e calls-from-basic.log
adc633934830d0c501da1d4ac919ed89 calls-from-basic.idc
30ec682e7ee3b880bb6a523b34895606 calls-main.log
32e3b106bf9686b41b0853475e9686bc calls-main.idc
3cde0381d3bd6100d4e9afe51964ea82 calls-main-basic.log
d02bed44a87c7c8eebd900616c1ee548 calls-main-basic.idc
5476a5462dff58fe38e7c8bf3efe4926 calls-main.log
e537899da3313a07bf07f2bf7d334b8e calls-main.idc
02aecd0ba0a93f1d339dd44e4156b3fc calls-main-basic.log
782933910e471a1b7ac7dfcc5606db8d calls-main-basic.idc
4b0a66bd59d3127a46fd998b1e4754d9 calls-from.log
e6d342078f84c88970e09381d66d78bb calls-from.log
ef03d7bbf5fa76edb21cd5f97e0f18a5 calls-from.idc
ff6959b4371a4e88aa78b058291eacc3 calls-from-basic.log
6ce9b154ee82e6f73d0fdc6496292285 calls-from-basic.idc
3e5c94412a5e28eaa7ae91064e9ee477 calls-main.log
0ca23f3902c5a7928543c088ad6c33ad calls-main.idc
05ce118c08e7b4862c6c088e5ed9d1c0 calls-main-basic.log
7a7c099f3add21853f6e6335e3f458f4 calls-main-basic.idc
731fcf1a1f473488e537d9a4b1138400 calls-main.log
cdf249c787d306e0837bd9c2b88c41d0 calls-main.idc
beab039c6171bd551a027a0afa7ece1d calls-main-basic.log
8f09e7b51a0f2b5e1e1032f0766bd4a5 calls-main-basic.idc
a83bfac4ade3eb5a2e44fda17eba9817 calls-from.log
635f890ac1f596836b22167390baf2f1 calls-from.log
0aaef50ce1a2d9be713f805166ea5ca2 calls-from.idc
3614750958003240f0c75877e914fba5 calls-from-basic.log
ca06b92d8940dffa38cbe43097257dac calls-from-basic.idc
229501dbcb16f1997eb4b327ed9e1bd8 calls-main.log
8f13a7dec3742534115029194fcb26ef calls-main.idc
630f5ec2927021b7fbaca5140ac7905d calls-main-basic.log
519b5d875926c186ffb4e612a334f596 calls-main-basic.idc
6dda76bdc881e3f2630137f79a61e6e8 calls-main.log
87cb601db8651c24195fd154a4a842a5 calls-main.idc
d7f1ac376d43d0f4e98dcc647d185732 calls-main-basic.log
70c908491d03097000af287b98fe5af8 calls-main-basic.idc
067a5ce6e14aa05dc5e54f1891e0aa8f calls-main.idc
e167997ce60dc65e0ae6cd7dcfd621d4 calls-main-basic.idc
e50c4181f3c092fb72bbeba7390fb948 calls-main.idc
a7d1e06eea45b029490f21ef0ae59b62 calls-main-basic.idc
3273cfaae545b8c641590f1e9ce84706 calls-from.log
18efc2907ce91168f52c380a165450db calls-from.log
87fa125e4e1a525a3be26a16c8cf518b calls-from.idc
bf5474bc4d4fffe738709aadb1d8a30d calls-from-basic.log
83d1b34f40d9264c34c2ece303454236 calls-from-basic.idc
c5e79029aebba4c8e12bceddba60016e calls-main.log
2919c0f0efa69a928e8bc7ad271f3bc1 calls-main.idc
17d40151be3c6bced1e5d3ec15ea67dc calls-main-basic.log
397c3c2699672bcbc4818adfb48d3040 calls-main-basic.idc
10619f596a6272803e9a4de8563311be calls-main.log
21861a5f43b1582544132015611d8265 calls-main.idc
cf41c0f5de46a0ab194fa93bd8485d14 calls-main-basic.log
96aa97b19870cf67cf81216907e1791a calls-main-basic.idc
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