sd.c (0034ebe6ee3151e5c54fd13c6f441429bd2cdadf) sd.c (da34692234a03b6ffabd0b5b7864b423ac8eca56)
1/*
2 * SD Memory Card emulation as defined in the "SD Memory Card Physical
3 * layer specification, Version 1.10."
4 *
5 * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
6 * Copyright (c) 2007 CodeSourcery
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 112 unchanged lines hidden (view full) ---

121 uint64_t data_start;
122 uint32_t data_offset;
123 uint8_t data[512];
124 qemu_irq readonly_cb;
125 qemu_irq inserted_cb;
126 BlockBackend *blk;
127
128 bool enable;
1/*
2 * SD Memory Card emulation as defined in the "SD Memory Card Physical
3 * layer specification, Version 1.10."
4 *
5 * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
6 * Copyright (c) 2007 CodeSourcery
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 112 unchanged lines hidden (view full) ---

121 uint64_t data_start;
122 uint32_t data_offset;
123 uint8_t data[512];
124 qemu_irq readonly_cb;
125 qemu_irq inserted_cb;
126 BlockBackend *blk;
127
128 bool enable;
129 uint8_t dat_lines;
130 bool cmd_line;
129};
130
131};
132
133static uint8_t sd_get_dat_lines(SDState *sd)
134{
135 return sd->enable ? sd->dat_lines : 0;
136}
137
138static bool sd_get_cmd_line(SDState *sd)
139{
140 return sd->enable ? sd->cmd_line : false;
141}
142
131static void sd_set_voltage(SDState *sd, uint16_t millivolts)
132{
133 switch (millivolts) {
134 case 3001 ... 3600: /* SD_VOLTAGE_3_3V */
135 case 2001 ... 3000: /* SD_VOLTAGE_3_0V */
136 break;
137 default:
138 qemu_log_mask(LOG_GUEST_ERROR, "SD card voltage not supported: %.3fV",

--- 313 unchanged lines hidden (view full) ---

452 sd->wp_groups = bitmap_new(sd->wpgrps_size);
453 memset(sd->function_group, 0, sizeof(sd->function_group));
454 sd->erase_start = 0;
455 sd->erase_end = 0;
456 sd->size = size;
457 sd->blk_len = 0x200;
458 sd->pwd_len = 0;
459 sd->expecting_acmd = false;
143static void sd_set_voltage(SDState *sd, uint16_t millivolts)
144{
145 switch (millivolts) {
146 case 3001 ... 3600: /* SD_VOLTAGE_3_3V */
147 case 2001 ... 3000: /* SD_VOLTAGE_3_0V */
148 break;
149 default:
150 qemu_log_mask(LOG_GUEST_ERROR, "SD card voltage not supported: %.3fV",

--- 313 unchanged lines hidden (view full) ---

464 sd->wp_groups = bitmap_new(sd->wpgrps_size);
465 memset(sd->function_group, 0, sizeof(sd->function_group));
466 sd->erase_start = 0;
467 sd->erase_end = 0;
468 sd->size = size;
469 sd->blk_len = 0x200;
470 sd->pwd_len = 0;
471 sd->expecting_acmd = false;
472 sd->dat_lines = 0xf;
473 sd->cmd_line = true;
460 sd->multi_blk_cnt = 0;
461}
462
463static bool sd_get_inserted(SDState *sd)
464{
465 return sd->blk && blk_is_inserted(sd->blk);
466}
467

--- 1466 unchanged lines hidden (view full) ---

1934
1935 dc->realize = sd_realize;
1936 dc->props = sd_properties;
1937 dc->vmsd = &sd_vmstate;
1938 dc->reset = sd_reset;
1939 dc->bus_type = TYPE_SD_BUS;
1940
1941 sc->set_voltage = sd_set_voltage;
474 sd->multi_blk_cnt = 0;
475}
476
477static bool sd_get_inserted(SDState *sd)
478{
479 return sd->blk && blk_is_inserted(sd->blk);
480}
481

--- 1466 unchanged lines hidden (view full) ---

1948
1949 dc->realize = sd_realize;
1950 dc->props = sd_properties;
1951 dc->vmsd = &sd_vmstate;
1952 dc->reset = sd_reset;
1953 dc->bus_type = TYPE_SD_BUS;
1954
1955 sc->set_voltage = sd_set_voltage;
1956 sc->get_dat_lines = sd_get_dat_lines;
1957 sc->get_cmd_line = sd_get_cmd_line;
1942 sc->do_command = sd_do_command;
1943 sc->write_data = sd_write_data;
1944 sc->read_data = sd_read_data;
1945 sc->data_ready = sd_data_ready;
1946 sc->enable = sd_enable;
1947 sc->get_inserted = sd_get_inserted;
1948 sc->get_readonly = sd_get_readonly;
1949}

--- 17 unchanged lines hidden ---
1958 sc->do_command = sd_do_command;
1959 sc->write_data = sd_write_data;
1960 sc->read_data = sd_read_data;
1961 sc->data_ready = sd_data_ready;
1962 sc->enable = sd_enable;
1963 sc->get_inserted = sd_get_inserted;
1964 sc->get_readonly = sd_get_readonly;
1965}

--- 17 unchanged lines hidden ---