From: Mike Frysinger Date: Mon, 29 Aug 2011 21:32:31 -0400 Subject: [U-Boot] [RFC PATCH] Pre-console buffer for ARM In-Reply-To: References: <1314638517-20178-1-git-send-email-sjg@chromium.org> <201108291610.31528.vapier@gentoo.org> Message-ID: <201108292132.32574.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Monday, August 29, 2011 19:00:46 Graeme Russ wrote: > On Tue, Aug 30, 2011 at 6:10 AM, Mike Frysinger wrote: > > On Monday, August 29, 2011 15:42:23 Simon Glass wrote: > >> On Mon, Aug 29, 2011 at 12:20 PM, Mike Frysinger wrote: > >> > On Monday, August 29, 2011 13:21:57 Simon Glass wrote: > >> >> + if (gd->con_buf_idx < CONFIG_SYS_TMP_CON_BUF_SZ) > >> >> + buffer[gd->con_buf_idx++] = c; > >> > > >> > seems like a circular buffer would make more sense ... usually the > >> > part of the log you want is the last chunk and not the first > > Well you would need an 'overflow' flag and then based on that you would > need to do two printf()'s when dumping the buffer - One from the 'index to > end' which is the 'top' of the buffer and one from 'start to index' which > is the bottom. you wouldnt need an overflow flag unless you wrote out more than 2^32 bytes. look at the logic again ... it isnt masking the write, it's masking the read. so by virtual of the con_buf_idx being larger than the max, you know you've wrapped around. otherwise yes, you'd need to split up the writes. not that big of a deal i dont think ... > >> Yes I agree, although if you have more than 1KB of data it might be a > >> bug. > > I personally don't see the need - I expect the amount of pre-console output > would be faily limited considering that the board should do everything it > can to initialise console as early as possible. until people hit an early fail and add a lot of debug printf's and then the output gets silently clipped. it's confusing imo, and i say this having implemented early debug output in other systems (including linux) and seeing how people used/reacted to it. > > give people a foot and they'll take 1MiB :p > > > > it's fairly easy as well: > > #define CIRC_BUF_IDX(idx) ((idx) & (CONFIG_SYS_TMP_CON_BUF_SZ-1)) > > buffer[CIRC_BUF_IDX(gd->conf_buf_idx++)] = c; > > But does that work for non power-of-two buffer sizes... no, but not that big of a deal. so you get limited to the last 1KiB, 4KiB, 8KiB, 16KiB, etc... amount of data. -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20110829/481a0f2a/attachment.pgp