From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12462 invoked by alias); 20 Mar 2003 13:14:16 -0000 Mailing-List: contact ecos-maintainers-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: ecos-maintainers-owner@sources.redhat.com Received: (qmail 12454 invoked from network); 20 Mar 2003 13:14:15 -0000 Subject: Re: New CPM/DPRAM allocator From: Gary Thomas To: Nick Garnett Cc: John Dallaway , eCos Maintainers In-Reply-To: References: <200303180848.24682.jld@ecoscentric.com> <200303191019.45969.jld@ecoscentric.com> <200303191545.45265.jld@ecoscentric.com> <1048093613.7462.5303.camel@hermes.chez-thomas.org> <1048098401.9579.5496.camel@hermes.chez-thomas.org> <1048100525.7462.5617.camel@hermes.chez-thomas.org> Content-Type: multipart/mixed; boundary="=-ServoFA4uPnWa5gR4Dvy" X-Mailer: Ximian Evolution 1.0.3 (1.0.3-4) Date: Thu, 20 Mar 2003 13:14:00 -0000 Message-Id: <1048166054.7459.9069.camel@hermes.chez-thomas.org> Mime-Version: 1.0 X-SW-Source: 2003-03/txt/msg00042.txt.bz2 --=-ServoFA4uPnWa5gR4Dvy Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1087 On Thu, 2003-03-20 at 04:51, Nick Garnett wrote: > Gary Thomas writes: > > > With the attached version of the code, I think we'll be > > quite safe. This changes the behaviour of the code, mitigating > > the possibility of clashes, but it's not 100%. > > > > Is there any way you can test this? Do you have the original > > Adder ROM contents? If not, I've attached what I sent to A&M > > when it was first released. > > I've now tried this: it works correctly on the Adder with the old > RedBoot in place. So this change has my approval, for both the trunk > and the v2 branch. Excellent. I'll be committing this patch to the branch (trunk is already done). Just a final "looks good" please. -- ------------------------------------------------------------ Gary Thomas | MLB Associates | Consulting for the +1 (970) 229-1963 | Embedded world http://www.mlbassoc.com/ | email: | gpg: http://www.chez-thomas.org/gary/gpg_key.asc ------------------------------------------------------------ --=-ServoFA4uPnWa5gR4Dvy Content-Disposition: attachment; filename=diffs Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; name=diffs; charset=ISO-8859-1 Content-length: 24950 Index: devs/eth/powerpc/quicc/current/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/quicc/current/Chang= eLog,v retrieving revision 1.16 diff -u -5 -p -r1.16 ChangeLog --- devs/eth/powerpc/quicc/current/ChangeLog 25 Nov 2002 23:20:51 -0000 1.16 +++ devs/eth/powerpc/quicc/current/ChangeLog 17 Mar 2003 23:34:53 -0000 @@ -1,5 +1,9 @@ +2003-03-06 Gary Thomas + + * src/if_quicc.c (quicc_eth_init): New name for CPM/DPRAM allocator. + 2002-11-25 Gary Thomas =20 * src/quicc_eth.h:=20 * src/if_quicc.c: Split platform specifics into separate packages. =20 Index: devs/eth/powerpc/quicc/current/src/if_quicc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/devs/eth/powerpc/quicc/current/src/i= f_quicc.c,v retrieving revision 1.15 diff -u -5 -p -r1.15 if_quicc.c --- devs/eth/powerpc/quicc/current/src/if_quicc.c 25 Nov 2002 23:20:51 -000= 0 1.15 +++ devs/eth/powerpc/quicc/current/src/if_quicc.c 17 Mar 2003 23:34:53 -0000 @@ -245,12 +245,12 @@ quicc_eth_init(struct cyg_netdevtab_entr // Shut down ethernet, in case it is already running scc->scc_gsmr_l &=3D ~(QUICC_SCC_GSML_ENR | QUICC_SCC_GSML_ENT); =20 memset((void *)enet_pram, 0, sizeof(*enet_pram)); =20 - TxBD =3D cyg_hal_allocBd(CYGNUM_DEVS_ETH_POWERPC_QUICC_TxNUM * sizeof(= struct cp_bufdesc)); - RxBD =3D cyg_hal_allocBd(CYGNUM_DEVS_ETH_POWERPC_QUICC_RxNUM * sizeof(= struct cp_bufdesc)); + TxBD =3D _mpc8xx_allocBd(CYGNUM_DEVS_ETH_POWERPC_QUICC_TxNUM * sizeof(= struct cp_bufdesc)); + RxBD =3D _mpc8xx_allocBd(CYGNUM_DEVS_ETH_POWERPC_QUICC_RxNUM * sizeof(= struct cp_bufdesc)); =20 txbd =3D (struct cp_bufdesc *)((char *)eppc + TxBD); rxbd =3D (struct cp_bufdesc *)((char *)eppc + RxBD); qi->tbase =3D txbd; qi->txbd =3D txbd;=20=20=20=20 Index: devs/serial/powerpc/quicc/current/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/devs/serial/powerpc/quicc/current/Ch= angeLog,v retrieving revision 1.13 diff -u -5 -p -r1.13 ChangeLog --- devs/serial/powerpc/quicc/current/ChangeLog 24 Feb 2003 14:18:55 -0000 = 1.13 +++ devs/serial/powerpc/quicc/current/ChangeLog 17 Mar 2003 23:42:43 -0000 @@ -1,5 +1,10 @@ +2003-03-05 Gary Thomas + + * src/quicc_smc_serial.c: Use common routines to manage CPM/DPRAM + pointers - much nicer in a multi-driver environment. + 2003-02-24 Jonathan Larmour =20 * cdl/ser_quicc_smc.cdl: Remove irrelevant doc link. =20 2002-12-10 Gary Thomas Index: devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/devs/serial/powerpc/quicc/current/sr= c/quicc_smc_serial.c,v retrieving revision 1.9 diff -u -5 -p -r1.9 quicc_smc_serial.c --- devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c 23 May 2002 23= :01:23 -0000 1.9 +++ devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c 17 Mar 2003 23= :42:00 -0000 @@ -7,10 +7,11 @@ //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 or (at your option) any later ver= sion. // @@ -57,10 +58,11 @@ #include #include #include #include #include +#include #include CYGBLD_HAL_PLATFORM_H =20 #ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC =20 // macro for aligning buffers to cache lines @@ -388,10 +390,11 @@ quicc_smc_serial_init(struct cyg_devtab_ quicc_smc_serial_info *smc_chan =3D (quicc_smc_serial_info *)chan->dev= _priv; volatile EPPC *eppc =3D (volatile EPPC *)eppc_base(); int TxBD, RxBD; static int first_init =3D 1; int cache_state; + HAL_DCACHE_IS_ENABLED(cache_state); HAL_DCACHE_SYNC(); HAL_DCACHE_DISABLE(); #ifdef CYGDBG_IO_INIT diag_printf("QUICC_SMC SERIAL init - dev: %x.%d\n", smc_chan->channel,= smc_chan->int_num); @@ -400,12 +403,12 @@ quicc_smc_serial_init(struct cyg_devtab_ // Set up tables since many fields are dynamic [computed at runtim= e] first_init =3D 0; #ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SMC1 eppc->cp_cr =3D QUICC_SMC_CMD_Reset | QUICC_SMC_CMD_Go; // Totall= y reset CP while (eppc->cp_cr & QUICC_SMC_CMD_Reset) ; - TxBD =3D 0x2800; // Note: this should be configurable - RxBD =3D TxBD + CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_TxNUM*8; + TxBD =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*CYGNUM_IO_SERIA= L_POWERPC_QUICC_SMC_SMC1_TxNUM); + RxBD =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*CYGNUM_IO_SERIA= L_POWERPC_QUICC_SMC_SMC1_RxNUM); quicc_smc_serial_init_info(&quicc_smc_serial_info1, &eppc->pram[2].scc.pothers.smc_modem.ps= mc.u, // PRAM &eppc->smc_regs[0], // Control registers TxBD,=20 CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1= _TxNUM, @@ -417,11 +420,10 @@ quicc_smc_serial_init(struct cyg_devtab_ ALIGN_TO_CACHELINES(&quicc_smc1_rxbuf[0= ][0]), 0xC0, // PortB mask CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1= _BRG, 12 // SI mask position ); - TxBD =3D RxBD + CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC1_RxNUM*8; #else #ifdef CYGPKG_HAL_POWERPC_MBX // Ensure the SMC1 side is initialized first and use shared mem // above where it plays: diag_init(); // (pull in constructor that inits diag channel) @@ -433,11 +435,12 @@ quicc_smc_serial_init(struct cyg_devtab_ while (eppc->cp_cr & QUICC_SMC_CMD_Reset) ; TxBD =3D 0x2800; // Note: this should be configurable #endif=20=20=20=20=20=20=20=20 #endif #ifdef CYGPKG_IO_SERIAL_POWERPC_QUICC_SMC_SMC2 - RxBD =3D TxBD + CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2_TxNUM*8; + TxBD =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*CYGNUM_IO_SERIA= L_POWERPC_QUICC_SMC_SMC2_TxNUM); + RxBD =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*CYGNUM_IO_SERIA= L_POWERPC_QUICC_SMC_SMC2_RxNUM); quicc_smc_serial_init_info(&quicc_smc_serial_info2, &eppc->pram[3].scc.pothers.smc_modem.ps= mc.u, // PRAM &eppc->smc_regs[1], // Control registers TxBD,=20 CYGNUM_IO_SERIAL_POWERPC_QUICC_SMC_SMC2= _TxNUM, Index: hal/powerpc/quicc/current/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/quicc/current/ChangeLog,v retrieving revision 1.27 diff -u -5 -p -r1.27 ChangeLog --- hal/powerpc/quicc/current/ChangeLog 26 Nov 2002 15:36:55 -0000 1.27 +++ hal/powerpc/quicc/current/ChangeLog 17 Mar 2003 23:26:06 -0000 @@ -1,5 +1,22 @@ +2003-03-06 Gary Thomas + + * src/cpm.c: Handle case where DPRAM allocation is unknown. +=09 + * include/ppc8xx.h: Define limits of CPM/DPRAM space. + +2003-03-05 Gary Thomas + + * src/quicc_smc1.c: Need to flush data cache because the serial + driver may set use buffers in cacheable memory. Without this, + diag_printf() falls over if the serial driver is ever used. + + * src/cpm.c: New file with CPM/DPRAM support. + + * include/ppc8xx.h:=20 + * cdl/hal_powerpc_quicc.cdl: Split out support for CPM/DPRAM. + 2002-11-26 Gary Thomas =20 * src/quicc_smc1.c: Initialize BD allocation point. Note that it is different from when the CPM get's reset directly. This is to allow sharing of the space between ROM (RedBoot) code and applications. Index: hal/powerpc/quicc/current/cdl/hal_powerpc_quicc.cdl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/quicc/current/cdl/hal_po= werpc_quicc.cdl,v retrieving revision 1.8 diff -u -5 -p -r1.8 hal_powerpc_quicc.cdl --- hal/powerpc/quicc/current/cdl/hal_powerpc_quicc.cdl 26 Nov 2002 13:48:1= 9 -0000 1.8 +++ hal/powerpc/quicc/current/cdl/hal_powerpc_quicc.cdl 17 Mar 2003 23:26:0= 6 -0000 @@ -7,11 +7,11 @@ # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #####ECOSGPLCOPYRIGHTBEGIN#### ## ------------------------------------------- ## This file is part of eCos, the Embedded Configurable Operating System. ## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -## Copyright (C) 2002 Gary Thomas +## Copyright (C) 2002, 2003 Gary Thomas ## ## eCos is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free ## Software Foundation; either version 2 or (at your option) any later ver= sion. ## @@ -98,11 +98,11 @@ cdl_package CYGPKG_HAL_QUICC { display "SCC3 is available for serial I/O" description " Port SCC3 is available for serial I/O" } =20 - compile quicc_smc1.c + compile quicc_smc1.c cpm.c =20 cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS { display "Number of communication channels on the board" flavor data calculated CYGNUM_HAL_QUICC_SMC1+CYGNUM_HAL_QUICC_SMC2+CYGNUM_HAL= _QUICC_SCC1+CYGNUM_HAL_QUICC_SCC2+CYGNUM_HAL_QUICC_SCC3 Index: hal/powerpc/quicc/current/include/ppc8xx.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/quicc/current/include/pp= c8xx.h,v retrieving revision 1.11 diff -u -5 -p -r1.11 ppc8xx.h --- hal/powerpc/quicc/current/include/ppc8xx.h 25 Nov 2002 23:20:53 -0000 1= .11 +++ hal/powerpc/quicc/current/include/ppc8xx.h 17 Mar 2003 23:26:06 -0000 @@ -10,11 +10,11 @@ //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -// Copyright (C) 2002 Gary Thomas +// Copyright (C) 2002, 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 or (at your option) any later ver= sion. // @@ -937,13 +937,15 @@ static inline EPPC *eppc_base(void) } =20 =20 // Function used to allocate space in shared memory area // typically used for buffer descriptors, etc. -__externC unsigned short cyg_hal_allocBd(int len); +__externC void _mpc8xx_reset_cpm(void); +__externC unsigned short _mpc8xx_allocBd(int len); =20 #define QUICC_BD_BASE 0x2000 // Start of shared memory +#define QUICC_BD_END 0x3000 // End of shared memory =20 =20 #endif /* __ASSEMBLER__ */ =20 /* Memory Periodic Timer Prescaler Register values */ Index: hal/powerpc/quicc/current/src/cpm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: hal/powerpc/quicc/current/src/cpm.c diff -N hal/powerpc/quicc/current/src/cpm.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hal/powerpc/quicc/current/src/cpm.c 20 Mar 2003 13:11:06 -0000 @@ -0,0 +1,115 @@ +//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +// +// cpm.c +// +// PowerPC QUICC support functions +// +//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +//####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2003 Gary Thomas +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later ver= sion. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with eCos; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// As a special exception, if other files instantiate templates or use mac= ros +// or inline functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does n= ot +// by itself cause the resulting work to be covered by the GNU General Pub= lic +// License. However the source code for this file must still be made avail= able +// in accordance with section (3) of the GNU General Public License. +// +// This exception does not invalidate any other reasons why a work based on +// this file might be covered by the GNU General Public License. +// +// Alternative licenses for eCos may be arranged by contacting Red Hat, In= c. +// at http://sources.redhat.com/ecos/ecos-license/ +// ------------------------------------------- +//####ECOSGPLCOPYRIGHTEND#### +//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +//#####DESCRIPTIONBEGIN#### +// +// Author(s): Gary Thomas=20 +// Contributors:=20 +// Date: 2003-03-04 +// Purpose: Common support for the QUICC/CPM +// Description:=20=20 +//=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +// Usage: +// Notes:=20=20=20=20=20=20=20=20 +// +//####DESCRIPTIONEND#### +// +//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +#include +#include +#include +#include + +#ifdef CYGPKG_HAL_POWERPC_MPC860 +// eCos headers decribing PowerQUICC: +#include + +// Information about DPRAM usage +// This lets the CPM/DPRAM information be shared by all environments +// +static short *nextBd =3D (short *)(CYGHWR_HAL_VSR_TABLE + 0x1F0); + +/* + * Reset the communications processor + */ + +void +_mpc8xx_reset_cpm(void) +{ + EPPC *eppc =3D eppc_base(); + int i; + static int init_done =3D 0; + + if (init_done) return; + init_done++; + + eppc->cp_cr =3D QUICC_CPM_CR_RESET | QUICC_CPM_CR_BUSY; + memset(eppc->pram, 0, 0x400); + for (i =3D 0; i < 100000; i++); + + *nextBd =3D QUICC_BD_BASE; +} + +// +// Allocate a chunk of memory in the shared CPM memory, typically +// used for buffer descriptors, etc. The length will be aligned +// to a multiple of 8 bytes. +// +unsigned short +_mpc8xx_allocBd(int len) +{ + unsigned short bd; + + bd =3D *nextBd; + if ((bd < QUICC_BD_BASE) || (bd > QUICC_BD_END)) { + // Most likely not set up - make a guess :-( + bd =3D *nextBd =3D QUICC_BD_BASE+0x400; + } + len =3D (len + 7) & ~7; // Multiple of 8 bytes + *nextBd +=3D len; + if (*nextBd >=3D QUICC_BD_END) { + *nextBd =3D QUICC_BD_BASE; + } + return bd; +} + +#endif // CYGPKG_HAL_POWERPC_MPC860 +// EOF cpm.c Index: hal/powerpc/quicc/current/src/quicc_smc1.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/quicc/current/src/quicc_= smc1.c,v retrieving revision 1.23 diff -u -5 -p -r1.23 quicc_smc1.c --- hal/powerpc/quicc/current/src/quicc_smc1.c 26 Nov 2002 15:36:56 -0000 1= .23 +++ hal/powerpc/quicc/current/src/quicc_smc1.c 17 Mar 2003 23:26:06 -0000 @@ -7,11 +7,11 @@ //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D //####ECOSGPLCOPYRIGHTBEGIN#### // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. -// Copyright (C) 2002 Gary Thomas +// Copyright (C) 2002, 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 or (at your option) any later ver= sion. // @@ -131,49 +131,10 @@ static struct port_info ports[] =3D { #define QUICC_SMCE_BSY 0x04 // Busy - receive buffer overrun #define QUICC_SMCE_TX 0x02 // Tx interrupt #define QUICC_SMCE_RX 0x01 // Rx interrupt =20 /* - * Reset the communications processor - */ - -static short nextBd =3D QUICC_BD_BASE + 0x400; - -static void -reset_cpm(void) -{ - EPPC *eppc =3D eppc_base(); - int i; - static int init_done =3D 0; - - if (init_done) return; - init_done++; - - eppc->cp_cr =3D QUICC_CPM_CR_RESET | QUICC_CPM_CR_BUSY; - memset(eppc->pram, 0, 0x400); - for (i =3D 0; i < 100000; i++); - - nextBd =3D QUICC_BD_BASE; - -} - -// -// Allocate a chunk of memory in the shared CPM memory, typically -// used for buffer descriptors, etc. The length will be aligned -// to a multiple of 8 bytes. -// -unsigned short -cyg_hal_allocBd(int len) -{ - unsigned short bd =3D nextBd; - - len =3D (len + 7) & ~7; // Multiple of 8 bytes - nextBd +=3D len; - return bd; -} - -/* * Initialize SMCX as a uart. * * Comments below reference Motorola's "MPC860 User Manual". * The basic initialization steps are from Section 16.15.8 * of that manual. @@ -188,11 +149,11 @@ cyg_hal_smcx_init_channel(struct port_in struct cp_bufdesc *txbd, *rxbd; =20 if (info->init) return; info->init =3D 1; =20 - reset_cpm(); + _mpc8xx_reset_cpm(); =20 switch (port) { #if CYGNUM_HAL_QUICC_SMC1 > 0 case QUICC_CPM_SMC1: /* @@ -238,12 +199,12 @@ cyg_hal_smcx_init_channel(struct port_in =20 /* * Set pointers to buffer descriptors. * (Sections 16.15.4.1, 16.15.7.12, and 16.15.7.13) */ - uart_pram->rbase =3D cyg_hal_allocBd(sizeof(struct cp_bufdesc)*info->R= xnum + info->Rxnum); - uart_pram->tbase =3D cyg_hal_allocBd(sizeof(struct cp_bufdesc)*info->T= xnum + info->Txnum); + uart_pram->rbase =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*info->R= xnum + info->Rxnum); + uart_pram->tbase =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*info->T= xnum + info->Txnum); =20 /* * SDMA & LCD bus request level 5 * (Section 16.10.2.1) */ @@ -333,10 +294,11 @@ cyg_hal_smcx_putc(void* __ch_data, cyg_u EPPC *eppc =3D eppc_base(); struct port_info *info =3D (struct port_info *)__ch_data; volatile struct smc_uart_pram *uart_pram =3D (volatile struct smc_uart= _pram *)((char *)eppc + info->pram); volatile struct smc_regs *regs =3D (volatile struct smc_regs *)((char = *)eppc + info->regs); int timeout; + int cache_state; CYGARC_HAL_SAVE_GP(); =20 /* tx buffer descriptor */ bd =3D (struct cp_bufdesc *)((char *)eppc + uart_pram->tbptr); =20 @@ -356,12 +318,18 @@ cyg_hal_smcx_putc(void* __ch_data, cyg_u // This buffer has just completed interrupt output. Reset bits bd->ctrl &=3D ~QUICC_BD_CTL_Int; bd->length =3D 0; } =20 - bd->buffer[bd->length++] =3D ch; + bd->length =3D 1; + bd->buffer[0] =3D ch; bd->ctrl |=3D QUICC_BD_CTL_Ready; + // Flush cache if necessary - buffer may be in cacheable memory + HAL_DCACHE_IS_ENABLED(cache_state); + if (cache_state) { + HAL_DCACHE_FLUSH(bd->buffer, 1); + } =20 #ifdef CYGDBG_DIAG_BUF enable_diag_uart =3D 0; #endif // CYGDBG_DIAG_BUF timeout =3D 0; @@ -617,11 +585,11 @@ cyg_hal_sccx_init_channel(struct port_in struct cp_bufdesc *txbd, *rxbd; =20 if (info->init) return; info->init =3D 1; =20 - reset_cpm(); + _mpc8xx_reset_cpm(); =20 /* * Set up the Port pins for UART operation. */ switch (port) { @@ -650,30 +618,30 @@ cyg_hal_sccx_init_channel(struct port_in break; #endif #if CYGNUM_HAL_QUICC_SCC2 > 0 case QUICC_CPM_SCC2: #error FIXME - eppc->pio_papar |=3D 0x03; - eppc->pio_padir &=3D ~0x03; - eppc->pio_paodr &=3D ~0x03; + eppc->pio_papar |=3D 0x0C; + eppc->pio_padir &=3D ~0x0C; + eppc->pio_paodr &=3D ~0x0C; =20 /* CTS on PortC.11 */ - eppc->pio_pcdir &=3D 0x800; - eppc->pio_pcpar &=3D 0x800; - eppc->pio_pcso |=3D 0x800; + eppc->pio_pcdir &=3D 0xC00; + eppc->pio_pcpar &=3D 0xC00; + eppc->pio_pcso |=3D 0xC00; =20 /* RTS on PortB.19 */ - eppc->pip_pbpar |=3D 0x1000; - eppc->pip_pbdir |=3D 0x1000; + eppc->pip_pbpar |=3D 0x2000; + eppc->pip_pbdir |=3D 0x2000; =20 /* Configure baud rate generator (Section 16.13.2) */ eppc->brgc2 =3D 0x10000 | (UART_BIT_RATE(UART_BAUD_RATE)<<1); =20 /* - * NMSI mode, BRG2 to SCC1 + * NMSI mode, BRG2 to SCC2 */ - eppc->si_sicr |=3D (1<<3)|(1<<0); + eppc->si_sicr |=3D (1<<11)|(1<<8); break; #endif #if CYGNUM_HAL_QUICC_SCC3 > 0 case QUICC_CPM_SCC3: #if 0 @@ -704,12 +672,12 @@ cyg_hal_sccx_init_channel(struct port_in =20 /* * Set pointers to buffer descriptors. */ memset((void *)uart_pram, 0xFF, 0x100); - uart_pram->rbase =3D cyg_hal_allocBd(sizeof(struct cp_bufdesc)*info->R= xnum + info->Rxnum); - uart_pram->tbase =3D cyg_hal_allocBd(sizeof(struct cp_bufdesc)*info->T= xnum + info->Txnum); + uart_pram->rbase =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*info->R= xnum + info->Rxnum); + uart_pram->tbase =3D _mpc8xx_allocBd(sizeof(struct cp_bufdesc)*info->T= xnum + info->Txnum); =20 /* * SDMA & LCD bus request level 5 */ eppc->dma_sdcr =3D 1; --=-ServoFA4uPnWa5gR4Dvy--