Previous 199869 Revisions Next

r26229 Sunday 17th November, 2013 at 12:57:43 UTC by Jürgen Buchmüller
Clean up allocated global memory on exit
[/branches/alto2/src/emu/cpu/alto2]a2curt.c a2dht.c a2disk.c a2disp.c a2dvt.c a2dwt.c a2emu.c a2ether.c a2hw.c a2kbd.c a2ksec.c a2kwd.c a2mem.c a2mouse.c a2mrt.c a2part.c a2ram.c alto2.c alto2.h

branches/alto2/src/emu/cpu/alto2/a2curt.c
r26228r26229
5757/**
5858 * @brief curt_activate: called by the CPU when the cursor task becomes active
5959 */
60void alto2_cpu_device::curt_activate()
60void alto2_cpu_device::activate_curt()
6161{
6262   m_task_wakeup &= ~(1 << m_task);
6363   m_dsp.curt_wakeup = 0;
r26228r26229
6969   set_f1(task, f1_block,            &alto2_cpu_device::f1_curt_block_0, 0);
7070   set_f2(task, f2_curt_load_xpreg,   0, &alto2_cpu_device::f2_load_xpreg_1);
7171   set_f2(task, f2_curt_load_csr,      0, &alto2_cpu_device::f2_load_csr_1);
72   m_active_callback[task] = &alto2_cpu_device::curt_activate;
72   m_active_callback[task] = &alto2_cpu_device::activate_curt;
7373}
7474
75void alto2_cpu_device::exit_curt()
76{
77   // nothing to do yet
78}
79
branches/alto2/src/emu/cpu/alto2/a2mem.c
r26228r26229
842842   }
843843#endif
844844}
845
846void alto2_cpu_device::exit_memory()
847{
848   if (m_mem.hpb) {
849      global_free(m_mem.hpb);
850      m_mem.hpb = 0;
851   }
852   if (m_mem.ram) {
853      global_free(m_mem.ram);
854      m_mem.ram = 0;
855   }
856}
branches/alto2/src/emu/cpu/alto2/a2hw.c
r26228r26229
112112   m_hw.xbus[3] = 0177777;
113113}
114114
115void alto2_cpu_device::exit_hw()
116{
117   // nothing to do yet
118}
119
branches/alto2/src/emu/cpu/alto2/a2ram.c
r26228r26229
292292#endif
293293}
294294
295void alto2_cpu_device::exit_ram()
296{
297   // nothing to do yet
298}
299
branches/alto2/src/emu/cpu/alto2/a2dht.c
r26228r26229
5858   m_active_callback[task] = &alto2_cpu_device::activate_dht;
5959}
6060
61void alto2_cpu_device::exit_dht()
62{
63   // nothing to do yet
64}
65
branches/alto2/src/emu/cpu/alto2/a2ksec.c
r26228r26229
4545   m_task_wakeup |= 1 << task;
4646}
4747
48void alto2_cpu_device::exit_ksec()
49{
50   // nothing to do yet
51}
52
branches/alto2/src/emu/cpu/alto2/a2kwd.c
r26228r26229
4343   set_f2(task, f2_task_17,         0, 0);
4444}
4545
46void alto2_cpu_device::exit_kwd()
47{
48   // nothing to do yet
49}
4650
51
branches/alto2/src/emu/cpu/alto2/a2emu.c
r26228r26229
704704   set_f2(task, f2_emu_acsource,      &alto2_cpu_device::f2_acsource_0, &alto2_cpu_device::f2_acsource_1);
705705}
706706
707void alto2_cpu_device::exit_emu()
708{
709   // nothing to do yet
710}
711
branches/alto2/src/emu/cpu/alto2/a2mouse.c
r26228r26229
201201 * per inch.
202202 * </PRE>
203203 */
204void alto2_cpu_device::mouse_init()
204void alto2_cpu_device::init_mouse()
205205{
206   memset(&m_mouse, 0, sizeof(m_mouse));
206    memset(&m_mouse, 0, sizeof(m_mouse));
207207}
208
209void alto2_cpu_device::exit_mouse()
210{
211    if (m_madr_a32)
212        global_free(m_madr_a32);
213    m_madr_a32 = 0;
214}
branches/alto2/src/emu/cpu/alto2/a2disk.c
r26228r26229
913913 *
914914 *  TW_SECLATE   (85960 nsec)
915915 *  TW_SECLATE   (46*ALTO2_UCYCLE)
916*/
917#define   TW_SECLATE   8596
916 *  TW_SECLATE   8596
917 */
918#define TW_SECLATE  85960
918919
919920/** @brief monoflop 52b pulse duration
920921 * Rt = 20k, Cext = 0.01µF (=10000pF) => 57960ns (~58us)
r26228r26229
14291430      m_dsk.seclate_timer->adjust(attotime::from_nsec(TW_SECLATE), 1);
14301431      if (m_dsk.seclate) {
14311432         m_dsk.seclate = 0;
1432         LOG((LOG_DISK,6,"   SECLATE -> 0 pulse until %lldns\n", ntime() + TW_SECLATE));
1433         LOG((LOG_DISK,6,"   SECLATE -> 0 pulse until cycle %lld\n", cycle() + TW_SECLATE / ALTO2_UCYCLE));
14331434      }
14341435   }
14351436
r26228r26229
14911492}
14921493
14931494
1494/** @brief timer callback to take away the SECLATE pulse (monoflop) */
1495/**
1496 * @brief timer callback to take away the SECLATE pulse (monoflop)
1497 * @param ptr some unused pointer
1498 * @param arg contains the seclate value
1499 */
14951500void alto2_cpu_device::disk_seclate(void* ptr, INT32 arg)
14961501{
14971502   (void)ptr;
r26228r26229
15001505   m_dsk.seclate_timer->enable(false);
15011506}
15021507
1503/** @brief timer callback to take away the OK TO RUN pulse (reset) */
1508/**
1509 * @brief timer callback to take away the OK TO RUN pulse (reset)
1510 * @param ptr some unused pointer
1511 * @param arg contains the ok_to_run value
1512 */
15041513void alto2_cpu_device::disk_ok_to_run(void* ptr, INT32 arg)
15051514{
15061515   (void)ptr;
r26228r26229
15261535 * flag 0 (SKINC, active low). If the seek would go beyond the last cylinder,
15271536 * the drive deasserts seek_incomplete, but does not assert the addx_acknowledge.
15281537 *
1529 * @param id timer id
1538 * @param ptr some unused pointer
15301539 * @param arg contains the drive, cylinder, and restore flag
15311540 */
15321541void alto2_cpu_device::disk_strobon(void* ptr, INT32 arg)
r26228r26229
16111620   diablo_hd_device* dhd = m_drive[m_dsk.drive];
16121621   m_dsk.ready_mf31a = arg & dhd->get_ready_0();
16131622   /* log the not ready result with level 0, else 2 */
1614   LOG((LOG_DISK,m_dsk.ready_mf31a ? 0 : 2,"   ready mf31a:%d\n", m_dsk.ready_mf31a));
1623   LOG((LOG_DISK,m_dsk.ready_mf31a ? 0 : 2,"   mf31a:%d %sready\n", m_dsk.ready_mf31a, m_dsk.ready_mf31a ? "not " : ""));
16151624}
16161625
16171626/**
r26228r26229
21502159void alto2_cpu_device::f2_swrnrdy_1()
21512160{
21522161   diablo_hd_device* dhd = m_drive[m_dsk.drive];
2153//   UINT16 r = dhd->get_seek_read_write_0();
2154   UINT16 r = dhd->get_ready_0();
2162   UINT16 r = dhd->get_seek_read_write_0();
21552163   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
21562164
21572165   LOG((LOG_DISK,1,"   SWRNRDY; %sbranch (%#o|%#o|%#o)\n", (r | init) ? "" : "no ", m_next2, r, init));
r26228r26229
23822390   m_dsk.ready_timer->reset();
23832391}
23842392
2393/**
2394 * @brief exit disk controller - free all timers
2395 */
2396void alto2_cpu_device::exit_disk()
2397{
2398    // nothing to do yet
2399}
2400
branches/alto2/src/emu/cpu/alto2/a2dvt.c
r26228r26229
3838   m_active_callback[task] = &alto2_cpu_device::activate_dvt;
3939}
4040
41void alto2_cpu_device::exit_dvt()
42{
43   // nothing to do yet
44}
45
branches/alto2/src/emu/cpu/alto2/a2dwt.c
r26228r26229
4545   set_f1(task, f1_block,         &alto2_cpu_device::f1_dwt_block_0, 0);
4646   set_f2(task, f2_dwt_load_ddr,   0, &alto2_cpu_device::f2_dwt_load_ddr_1);
4747}
48
49void alto2_cpu_device::exit_dwt()
50{
51   // nothing to do yet
52}
branches/alto2/src/emu/cpu/alto2/alto2.c
r26228r26229
168168   m_is_octal = true;
169169}
170170
171alto2_cpu_device::~alto2_cpu_device()
172{
173   // call all subdevice's exit code
174   exit_kwd();
175   exit_part();
176   exit_dvt();
177   exit_dht();
178   exit_curt();
179   exit_dwt();
180   exit_mrt();
181   exit_ether();
182   exit_ksec();
183   exit_emu();
184   exit_hw();
185   exit_mouse();
186   exit_kbd();
187   exit_disp();
188   exit_disk();
189   exit_memory();
190
191   if (m_ucode_crom) {
192      global_free(m_ucode_crom);
193      m_ucode_crom = 0;
194   }
195   if (m_ucode_cram) {
196      global_free(m_ucode_cram);
197      m_ucode_cram = 0;
198   }
199   if (m_const_data) {
200      global_free(m_const_data);
201      m_const_data = 0;
202   }
203
204   if (m_ctl2k_u3) {
205      global_free(m_ctl2k_u3);
206      m_ctl2k_u3 = 0;
207   }
208   if (m_ctl2k_u38) {
209      global_free(m_ctl2k_u38);
210      m_ctl2k_u38 = 0;
211   }
212   if (m_ctl2k_u76) {
213      global_free(m_ctl2k_u76);
214      m_ctl2k_u76 = 0;
215   }
216   if (m_cram3k_a37) {
217      global_free(m_cram3k_a37);
218      m_cram3k_a37 = 0;
219   }
220   if (m_madr_a64) {
221      global_free(m_madr_a64);
222      m_madr_a64 = 0;
223   }
224   if (m_madr_a65) {
225      global_free(m_madr_a65);
226      m_madr_a65 = 0;
227   }
228   if (m_madr_a90) {
229      global_free(m_madr_a90);
230      m_madr_a90 = 0;
231   }
232   if (m_madr_a91) {
233      global_free(m_madr_a91);
234      m_madr_a91 = 0;
235   }
236   if (m_alu_a10) {
237      global_free(m_alu_a10);
238      m_alu_a10 = 0;
239   }
240
241}
242
171243#if   ALTO2_DEBUG
172244// FIXME: define types (sections) and print the section like [emu] [kwd] ...
173245// FIXME: use the level to suppress messages if logging is less verbose than level
r26228r26229
31813253   init_disk();
31823254   init_disp();
31833255   init_kbd();
3256   init_mouse();
31843257   init_hw();
31853258
31863259   init_emu(task_emu);
branches/alto2/src/emu/cpu/alto2/a2disp.c
r26228r26229
435435 * Allocate a raw_bitmap array to save blitting to the screen when
436436 * there is no change in the data words.
437437 */
438int alto2_cpu_device::init_disp()
438void alto2_cpu_device::init_disp()
439439{
440   int y;
441
442440   memset(&m_dsp, 0, sizeof(m_dsp));
443441   m_dsp.hlc = ALTO2_DISPLAY_HLC_START;
444
445442   m_dsp.raw_bitmap = global_alloc_array(UINT16, ALTO2_DISPLAY_HEIGHT * ALTO2_DISPLAY_SCANLINE_WORDS);
446   for (y = 0; y < ALTO2_DISPLAY_HEIGHT; y++)
443   for (int y = 0; y < ALTO2_DISPLAY_HEIGHT; y++)
447444      memset(m_dsp.raw_bitmap + y * ALTO2_DISPLAY_SCANLINE_WORDS, 0, ALTO2_DISPLAY_VISIBLE_WORDS * sizeof(UINT16));
448445
449446   m_dsp.scanline_dirty = global_alloc_array(UINT8, ALTO2_DISPLAY_HEIGHT);
450447   memset(m_dsp.scanline_dirty, 1, sizeof(UINT8) * ALTO2_DISPLAY_HEIGHT);
451   return 0;
452448}
453449
450void alto2_cpu_device::exit_disp()
451{
452   if (m_dsp.scanline_dirty) {
453      global_free(m_dsp.scanline_dirty);
454      m_dsp.scanline_dirty = 0;
455   }
456   if (m_dsp.raw_bitmap) {
457      global_free(m_dsp.raw_bitmap);
458      m_dsp.raw_bitmap = 0;
459   }
460   if (m_disp_a38) {
461      global_free(m_disp_a38);
462      m_disp_a38 = 0;
463   }
464   if (m_disp_a63) {
465      global_free(m_disp_a63);
466      m_disp_a63 = 0;
467   }
468   if (m_disp_a66) {
469      global_free(m_disp_a66);
470      m_disp_a66 = 0;
471   }
472}
473
454474#define   BLACK   1
455475#define   WHITE   0
456476
branches/alto2/src/emu/cpu/alto2/a2kbd.c
r26228r26229
5555   m_kbd.matrix[3] = 0177777;
5656}
5757
58void alto2_cpu_device::exit_kbd()
59{
60   // nothing to do yet
61}
62
branches/alto2/src/emu/cpu/alto2/a2mrt.c
r26228r26229
1818}
1919
2020//! called by the CPU when MRT becomes active
21void alto2_cpu_device::mrt_activate()
21void alto2_cpu_device::activate_mrt()
2222{
2323   /* TODO: what do we do here? */
2424   m_task_wakeup &= ~(1 << m_task);
r26228r26229
2929{
3030   set_f1(task, f1_block,      &alto2_cpu_device::f1_mrt_block_0, 0);
3131   /* auto block */
32   m_active_callback[task] = &alto2_cpu_device::mrt_activate;
32   m_active_callback[task] = &alto2_cpu_device::activate_mrt;
3333}
34
35void alto2_cpu_device::exit_mrt()
36{
37   // nothing to do yet
38}
branches/alto2/src/emu/cpu/alto2/alto2.h
r26228r26229
215215public:
216216   // construction/destruction
217217   alto2_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
218   ~alto2_cpu_device();
218219
219220   //! driver interface to set diablo_hd_device
220221   void set_diablo(int unit, diablo_hd_device* ptr);
r26228r26229
11241125#else   // ALTO2_UCODE_RAM_PAGES != 3
11251126   void f1_load_srb_1();                     //!< f1_load_srb late: load the S register bank from BUS[12-14]
11261127#endif
1127   void init_ram(int task);                  //!<
1128   void init_ram(int task);                  //!< called by RAM related tasks
1129   void exit_ram();
11281130
11291131   // ************************************************
11301132   // memory mapped i/o stuff
r26228r26229
12991301   DECLARE_READ16_MEMBER( xbus_r );         //!< read an XBUS address
13001302   DECLARE_WRITE16_MEMBER( xbus_w );         //!< write an XBUS address (?)
13011303   void init_hw();                        //!< initialize miscellaneous hardware
1304   void exit_hw();                        //!< deinitialize miscellaneous hardware
13021305
13031306   // ************************************************
13041307   // keyboard stuff
r26228r26229
13091312   }   m_kbd;
13101313   DECLARE_READ16_MEMBER( kbd_ad_r );         //!< read the keyboard matrix
13111314   void init_kbd(UINT16 bootkey = 0177777);   //!< initialize the keyboard hardware, optinally set the boot key
1315   void exit_kbd();                     //!< deinitialize the keyboard hardware
13121316
13131317   // ************************************************
13141318   // mouse stuff
r26228r26229
13731377    * </PRE>
13741378    */
13751379   UINT8* m_madr_a32;
1380
1381   //! mouse context
13761382   struct {
13771383      int x;
13781384      int y;
r26228r26229
13841390   UINT16 mouse_read();                     //!< return the mouse motion flags
13851391   void mouse_motion(int x, int y);            //!< register a mouse motion
13861392   void mouse_button(int b);                  //!< register a mouse button change
1387   void mouse_init();                        //!< initialize the mouse context to useful values
1393   void init_mouse();                        //!< initialize the mouse context to useful values
1394   void exit_mouse();                        //!< deinitialize the mouse
13881395
1389
13901396   // ************************************************
13911397   // disk controller stuff
13921398   // ************************************************
r26228r26229
14811487   void f2_swrnrdy_1();                     //!< f2_swrnrdy late: branch on the disk ready signal
14821488   void f2_nfer_1();                        //!< f2_nfer late: branch on the disk fatal error condition
14831489   void f2_strobon_1();                     //!< f2_strobon late: branch on the seek busy status
1484   void init_disk();                        //!< initialize the disk context and insert a disk wort timer
1490   void init_disk();                        //!< initialize the disk context
1491   void exit_disk();                        //!< deinitialize the disk context
14851492
14861493   // ************************************************
14871494   // display stuff
r26228r26229
17581765    * There are 32 states per scanline and 875 scanlines per frame.
17591766    *
17601767    * @param arg the current m_disp_a63 PROM address
1761    * @result returns the next state of the display state machine
1768    * @return next state of the display state machine
17621769    */
17631770   int display_state_machine(int arg);
17641771
1765   /** @brief branch on the evenfield flip-flop */
1772   //! branch on the evenfield flip-flop
17661773   void f2_evenfield_1(void);
17671774
1768   /** @brief initialize the display context */
1769   int init_disp();
1775   //! initialize the display context
1776   void init_disp();
1777   //! deinitialize the display context
1778   void exit_disp();
17701779
17711780   // ************************************************
17721781   // memory stuff
r26228r26229
18891898   void watch_write(UINT32 addr, UINT32 data);
18901899   void watch_read(UINT32 addr, UINT32 data);
18911900#endif
1901   void init_memory();                        //!< initialize the memory system
1902   void exit_memory();                        //!< deinitialize the memory system
18921903
1893   //! initialize the memory system
1894   void init_memory();
1895
18961904   // ************************************************
18971905   // emulator task
18981906   // ************************************************
r26228r26229
19181926   void f2_acsource_0();                     //!< f2_acsource early: modify RSELECT with SrcAC = (3 - IR[1-2])
19191927   void f2_acsource_1();                     //!< f2_acsource late: branch on arithmetic IR_SH, others PROM ctl2k_u3[IR[1-7]]
19201928   void init_emu(int task);                  //!< 000 initialize emulator task
1929   void exit_emu();                        //!< deinitialize emulator task
19211930
1931   // ************************************************
19221932   // ksec task
1933   // ************************************************
19231934   void f1_ksec_block_0(void);
19241935   void init_ksec(int task);                  //!< 004 initialize disk sector task
1936   void exit_ksec();
19251937
19261938   // ************************************************
19271939   // ethernet task
r26228r26229
20412053   void f2_ebfct_1();                        //!< f2_ebfct late: Ethernet branch function
20422054   void f2_ecbfct_1();                        //!< f2_ecbfct late: Ethernet countdown branch function
20432055   void f2_eisfct_1();                        //!< f2_eisfct late: Ethernet input start function
2044   void eth_activate();                     //!< called by the CPU when the Ethernet task becomes active
2056   void activate_eth();                     //!< called by the CPU when the Ethernet task becomes active
20452057   void init_ether(int task);                  //!< 007 initialize ethernet task
2058   void exit_ether();                        //!< deinitialize ethernet task
20462059
2060   // ************************************************
20472061   // memory refresh task
2062   // ************************************************
20482063   void f1_mrt_block_0();                     //!< f1_mrt_block early: block the display word task
2049   void mrt_activate();                     //!< called by the CPU when MRT becomes active
2064   void activate_mrt();                     //!< called by the CPU when MRT becomes active
20502065   void init_mrt(int task);                  //!< 010 initialize memory refresh task
2066   void exit_mrt();                        //!< deinitialize memory refresh task
20512067
2068   // ************************************************
20522069   // display word task
2070   // ************************************************
20532071   void f1_dwt_block_0();                     //!< f1_dwt_block early: block the display word task
20542072   void f2_dwt_load_ddr_1();                  //!< f2_dwt_load_ddr late: load the display data register
20552073   void init_dwt(int task);                  //!< 011 initialize display word task
2074   void exit_dwt();                        //!< deinitialize display word task
20562075
2076   // ************************************************
20572077   // cursor task
2078   // ************************************************
20582079   void f1_curt_block_0();                     //!< f1_curt_block early: disable the cursor task and set the curt_blocks flag
20592080   void f2_load_xpreg_1();                     //!< f2_load_xpreg late: load the x position register from BUS[6-15]
20602081   void f2_load_csr_1();                     //!< f2_load_csr late: load the cursor shift register from BUS[0-15]
2061   void curt_activate();                     //!< curt_activate: called by the CPU when the cursor task becomes active
2082   void activate_curt();                     //!< curt_activate: called by the CPU when the cursor task becomes active
20622083   void init_curt(int task);                   //!< 012 initialize cursor task
2084   void exit_curt();                        //!< deinitialize cursor task
20632085
2086   // ************************************************
20642087   // display horizontal task
2088   // ************************************************
20652089   void f1_dht_block_0();                     //!< f1_dht_block early: disable the display word task
20662090   void f2_dht_setmode_1();                  //!< f2_dht_setmode late: set the next scanline's mode inverse and half clock and branch
20672091   void activate_dht();                     //!< called by the CPU when the display horizontal task becomes active
20682092   void init_dht(int task);                  //!< 013 initialize display horizontal task
2093   void exit_dht();                        //!< deinitialize display horizontal task
20692094
2095   // ************************************************
20702096   // display vertical task
2097   // ************************************************
20712098   void f1_dvt_block_0();                     //!< f1_dvt_block early: disable the display word task
20722099   void activate_dvt();                     //!< called by the CPU when the display vertical task becomes active
20732100   void init_dvt(int task);                  //!< 014 initialize display vertical task
2101   void exit_dvt();                        //!< deinitialize display vertical task
20742102
2103   // ************************************************
20752104   // parity task
2105   // ************************************************
20762106   void activate_part();
20772107   void init_part(int task);                  //!< 015 initialize parity task
2108   void exit_part();                        //!< deinitialize parity task
20782109
2110   // ************************************************
20792111   // disk word task
2112   // ************************************************
20802113   void f1_kwd_block_0(void);
20812114   void init_kwd(int task);                  //!< 016 initialize disk word task
2115   void exit_kwd();                        //!< deinitialize disk word task
20822116};
20832117
20842118extern const device_type ALTO2;
branches/alto2/src/emu/cpu/alto2/a2part.c
r26228r26229
2222   m_active_callback[task] = &alto2_cpu_device::activate_part;
2323}
2424
25void alto2_cpu_device::exit_part()
26{
27   // nothing to do yet
28}
29
branches/alto2/src/emu/cpu/alto2/a2ether.c
r26228r26229
645645 *
646646 * Reset the Ether wake flip flop
647647 */
648void alto2_cpu_device::eth_activate()
648void alto2_cpu_device::activate_eth()
649649{
650   m_ewfct = 0;
650    m_ewfct = 0;
651651}
652652
653653/**
r26228r26229
673673   set_f2(task, f2_ether_ecbfct,   0, &alto2_cpu_device::f2_ecbfct_1);
674674   set_f2(task, f2_ether_eisfct,   0, &alto2_cpu_device::f2_eisfct_1);
675675
676   m_active_callback[task] = &alto2_cpu_device::eth_activate;
676   m_active_callback[task] = &alto2_cpu_device::activate_eth;
677677}
678678
679void alto2_cpu_device::exit_ether()
680{
681   if (m_ether_a41) {
682      global_free(m_ether_a41);
683      m_ether_a41 = 0;
684   }
685   if (m_ether_a42) {
686      global_free(m_ether_a42);
687      m_ether_a42 = 0;
688   }
689   if (m_ether_a49) {
690      global_free(m_ether_a49);
691      m_ether_a49 = 0;
692   }
693}
694

Previous 199869 Revisions Next


© 1997-2024 The MAME Team