From d51639c91c2aca7db6df8150ab438b6cbf62227a Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Wed, 22 Aug 2012 07:43:42 -0400 Subject: Don't crash due to gpmc failure on desktop --- bus.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/bus.c b/bus.c index c45fda6..da5243a 100644 --- a/bus.c +++ b/bus.c @@ -183,19 +183,21 @@ static void gpmc_setup(int chipselect, int accesscycles, int size, bool enablecs gpmc_mapregisters(); - // disable before playing with the registers.. - *(registers + displacement + GPMC_CONFIG7) = 0x0; - - *(registers + displacement + GPMC_CONFIG1) = 0x0; - *(registers + displacement + GPMC_CONFIG2) = (accesscycles << CSWROFFTIME) | (accesscycles << CSRDOFFTIME); - *(registers + displacement + GPMC_CONFIG3) = 0x0; // not using ADV so we can ignore this guy - *(registers + displacement + GPMC_CONFIG4) = (accesscycles << OEOFFTIME); - *(registers + displacement + GPMC_CONFIG5) = (accesscycles << RDACCESSTIME) | (accesscycles << WRCYCLETIME) - | (accesscycles << RDCYCLETIME); - *(registers + displacement + GPMC_CONFIG6) = (accesscycles << WRACCESSTIME); - *(registers + displacement + GPMC_CONFIG7) = size << 8 | (enablecs ? 1 << 6 : 0) | baseaddress; - - gpmc_unmapregisters(); + if (registers != MAP_FAILED) { + // disable before playing with the registers.. + *(registers + displacement + GPMC_CONFIG7) = 0x0; + + *(registers + displacement + GPMC_CONFIG1) = 0x0; + *(registers + displacement + GPMC_CONFIG2) = (accesscycles << CSWROFFTIME) | (accesscycles << CSRDOFFTIME); + *(registers + displacement + GPMC_CONFIG3) = 0x0; // not using ADV so we can ignore this guy + *(registers + displacement + GPMC_CONFIG4) = (accesscycles << OEOFFTIME); + *(registers + displacement + GPMC_CONFIG5) = (accesscycles << RDACCESSTIME) | (accesscycles << WRCYCLETIME) + | (accesscycles << RDCYCLETIME); + *(registers + displacement + GPMC_CONFIG6) = (accesscycles << WRACCESSTIME); + *(registers + displacement + GPMC_CONFIG7) = size << 8 | (enablecs ? 1 << 6 : 0) | baseaddress; + + gpmc_unmapregisters(); + } } /* -- cgit