MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / flash_write

Function flash_write

core/flash.c:259–330  ·  view source on GitHub ↗

Write to the 0x1000 range of ports */

Source from the content-addressed store, hash-verified

257
258/* Write to the 0x1000 range of ports */
259static void flash_write(const uint16_t pio, const uint8_t byte, bool poke) {
260 (void)poke;
261 if (asic.serFlash) {
262 if (!flash_unlocked()) {
263 return;
264 }
265
266 if (pio & 0x800) {
267 uint16_t index = pio & 0x7FF;
268 if (index < 0x10) {
269 flash.command[index] = byte;
270 if (index == 0xF) {
271 flash_execute_command();
272 }
273 }
274 else {
275 switch (index) {
276 case 0x24:
277 flash.commandStatus[0] &= ~(byte & 1);
278 break;
279 case 0x2C: case 0x2D: case 0x2E: case 0x2F:
280 flash.maskReg[index - 0x2C] = byte;
281 flash_set_mask();
282 break;
283 case 0x100:
284 if ((flash.command[0xC] & 1 << 1) && flash.commandLength) {
285 flash_write_command(byte);
286 flash_command_byte_transferred();
287 }
288 break;
289 }
290 }
291 return;
292 } else {
293 uint8_t index = pio & 0x7F;
294 switch (index) {
295 case 0x10:
296 flash.ports[index] = byte & 1;
297 break;
298 default:
299 flash.ports[index] = byte;
300 break;
301 }
302 }
303 } else {
304 uint8_t index = pio;
305 switch (index) {
306 case 0x00:
307 flash.ports[index] = byte & 1;
308 flash_set_map();
309 break;
310 case 0x01:
311 flash.ports[index] = byte;
312 flash_set_map();
313 break;
314 case 0x02:
315 flash.ports[index] = byte & 0xF;
316 flash_set_map();

Callers

nothing calls this directly

Calls 6

flash_unlockedFunction · 0.85
flash_execute_commandFunction · 0.85
flash_set_maskFunction · 0.85
flash_write_commandFunction · 0.85
flash_set_mapFunction · 0.85

Tested by

no test coverage detected