Re: malloc: memory leak instrumentation
On Thu, May 05, 2011 at 08:21:25PM +0200, Otto Moerbeek wrote: > On Thu, May 05, 2011 at 02:29:39PM +0200, Otto Moerbeek wrote: > > > Hi, > > > > Now that the latest chunk scan optimization diff is committed, it's > > time to present a malloc feature diff. > > > > This diff adds instrumentation to a MALLOC_STATS enabled malloc.c to > > detect and report memory leaks, including the address of the code that > > allocated memory that was not freed. With the help of gdb, you can > > translate this address into a source file location. > > > > For instructions and to show some of the possibilities, check > > > > http://www.drijf.net/malloc/ > > > > Diff also below. It was good fun working on this, and I hope you'll > > enjoy it as well. > > > > Note that this diff a a bit bigger than strictly needed, I moved the > > stats reporting code to the bottom of the file. Something I wanted to > > do for a long time. > > Updated diff. Kent R. Spillner spotted a glitch that caused a (ironly!) > memory leak in the reporting code, > And another update. I'm now using the region field to store the code address for chunk 0 too. This saves some meta data space. -Otto Index: malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.130 diff -u -p -r1.130 malloc.c --- malloc.c5 May 2011 12:11:20 - 1.130 +++ malloc.c6 May 2011 05:46:36 - @@ -43,6 +43,7 @@ #include #ifdef MALLOC_STATS +#include #include #endif @@ -94,6 +95,9 @@ struct region_info { void *p;/* page; low bits used to mark chunks */ uintptr_t size; /* size for pages, or chunk_info pointer */ +#ifdef MALLOC_STATS + void *f;/* where allocated from */ +#endif }; LIST_HEAD(chunk_head, chunk_info); @@ -125,9 +129,11 @@ struct dir_info { size_t cheap_reallocs; #define STATS_INC(x) ((x)++) #define STATS_ZERO(x) ((x) = 0) +#define STATS_SETF(x,y) ((x)->f = (y)) #else #define STATS_INC(x) /* nothing */ #define STATS_ZERO(x) /* nothing */ +#define STATS_SETF(x,y)/* nothing */ #endif /* MALLOC_STATS */ u_int32_t canary2; }; @@ -192,6 +198,14 @@ static u_char getrnibble(void); extern char*__progname; +#ifdef MALLOC_STATS +void malloc_dump(int); +static void malloc_exit(void); +#define CALLER __builtin_return_address(0) +#else +#define CALLER NULL +#endif + /* low bits of r->p determine size: 0 means >= page size and p->size holding * real size, otherwise r->size is a shift count, or 1 for malloc(0) */ @@ -217,142 +231,6 @@ hash(void *p) return sum; } -#ifdef MALLOC_STATS -static void -dump_chunk(int fd, struct chunk_info *p, int fromfreelist) -{ - char buf[64]; - - while (p != NULL) { - snprintf(buf, sizeof(buf), "chunk %d %d/%d %p\n", p->size, - p->free, p->total, p->page); - write(fd, buf, strlen(buf)); - if (!fromfreelist) - break; - p = LIST_NEXT(p, entries); - if (p != NULL) { - snprintf(buf, sizeof(buf), ""); - write(fd, buf, strlen(buf)); - } - } -} - -static void -dump_free_chunk_info(int fd, struct dir_info *d) -{ - char buf[64]; - int i; - - snprintf(buf, sizeof(buf), "Free chunk structs:\n"); - write(fd, buf, strlen(buf)); - for (i = 0; i < MALLOC_MAXSHIFT; i++) { - struct chunk_info *p = LIST_FIRST(&d->chunk_dir[i]); - if (p != NULL) { - snprintf(buf, sizeof(buf), "%2d) ", i); - write(fd, buf, strlen(buf)); - dump_chunk(fd, p, 1); - } - } - -} - -static void -dump_free_page_info(int fd, struct dir_info *d) -{ - char buf[64]; - int i; - - snprintf(buf, sizeof(buf), "Free pages cached: %zu\n", - d->free_regions_size); - write(fd, buf, strlen(buf)); - for (i = 0; i < mopts.malloc_cache; i++) { - if (d->free_regions[i].p != NULL) { - snprintf(buf, sizeof(buf), "%2d) ", i); - write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "free at %p: %zu\n", - d->free_regions[i].p, d->free_regions[i].size); - write(fd, buf, strlen(buf)); - } - } -} - -static void -malloc_dump1(int fd, struct dir_info *d) -{ - char buf[64]; - size_t i, realsize; - - snprintf(buf, sizeof(buf), "Malloc dir of %s at %p\n", __progname, d); - write(fd, buf, strlen(buf)); - if (d == NULL) - return; - snprintf(buf, sizeof(buf), "Regions slots %zu\n", d->regions_total); - write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "Finds %zu/%zu %f\n", d->finds,
合y作
f( e/d:d8e fg+ g5&d= e!! g5&f(ggh(o< d8;h&g;h%:d8e chgci;i9$f%http://tw.myblog.yahoo.com/jw!1K84p1yREQXRDO9YOXH0EfAuoaYkEjm18Q--/article?mid=1 Yahoo!e%f)fe0 d= gfe0.ee3.gf4;f0i+i)c http://tw.fashion.yahoo.com/ g f, f f Yahoo!e%f)
Nueva línea de Filmadoras HD
USD2150 Filmadora Panasonic HDC-MDH1 Sensor CMOS / Full HD/SD 16:9 4:3 / Salida HDMI / USB / AV / Entrada Para micrófono / Zoomóptico 23X Filmadoras Sony DCR-SX65 USD 390 Sony DCR-SX85 USD 400 Sony HDR-CX130 USD 625 Sony HDR-CX560 USD 1199 Cámaras digitales Sony DSC-W330 USD 212 Sony DSC-W350 USD 220 Sony DSC-HX1 USD 490 Panasonic FZ40 USD 485
We have extended the $1.95 shirt offer - Stitch Logo Uniforms
Due to the great response we have extended this offer another month! Embroidered Polo or Dress Shirt ONLY $1.95 New Customers Only - Offer Expires May 31st. Details: Pick any polo or dress shirt on our website: www.stitchlogo.com or from one of our paper catalogs. We will embroider your company logo on your shirt. Your cost for the first shirt is only $1.95 plus shipping. There is no set-up charge which saves you an additional $40.00. 25% Discount given to the additional shirts in your initial order. Minimum order is 6 pieces - mix and match styles, colors and sizes. Discounts only apply to your initial order. Why are we doing this? We are hoping that by showing you the quality of our embroidery, our pricing and great customer service that we can retain you as a customer down the road. Easy Ordering: Pick out the items you want. Email your order along with your logo to br...@stitchlogo.com or call us toll free 1-877-652-8600. Our policy is to send you an invoice showing all the charges for your approval before we start on your order. You can either email or fax this back to us. Once your order is approved we will email you a sew-out of your logo proof for approval. We will not embroider your shirts until you are completely satisfied with your logo. If you want a free paper catalog please visit our website or call 1-877-652-8600. Any Questions? Please email br...@stitchlogo.com or call 1-877-652-8600 Stitch Logo, Inc. 2165 Sunnydale Blvd., Ste. H, Clearwater, FL 33765 Note: A surcharge will apply to sizes 2XL and larger. unsubscribe mailto:speci...@stitchlogo.com?subject=Unsubscribe-13Mjc0Mjg5
Приглашение В Новую Социальную Сеть!
This is a text part of the message. It is shown for the users of old-style e-mail clients
Re: pf(4) man page: include missing header in example program
On Thu, May 05, 2011 at 11:56:24PM +0100, Stuart Henderson wrote: > On 2011/05/03 19:51, Mike Belopuhov wrote: > > On Tue, May 3, 2011 at 9:56 AM, Stuart Henderson > > wrote: > > > On 2011/05/02 22:28, Lawrence Teo wrote: > > >> The DIOCNATLOOK example program at the end of the pf(4) man page > > >> uses memset(3), but string.h is not included. The following diff > > >> fixes this. Any thoughts? > > > > > > That change is correct but I'm not sure about keeping this example > > > code at all. We've had divert-to since OpenBSD 4.4 - when this is used > > > instead of rdr-to the destination address is preserved, so it can be > > > fetched with getsockname() without the DIOCNATLOOK dance. > > > > > > As a result the code becomes much less complicated, so we don't > > > really need an example any more, also another big advantage is that > > > there's no need for access to the privileged /dev/pf device. > > > > > > How about this? > > > > > > > i'm in favor of this change, so ok mikeb > > > > slightly tweaked after knowledge gained from converting tftp-proxy; > specifically, mention the socket options that will be needed for udp > as they're not easy to track down. > > This was primarily used to support transparent proxies with rdr- > to rules. New proxies should use divert-to rules instead. These > do not require access to the privileged /dev/pf device and > preserve the original destination address for getsockname(2). > For SOCK_DGRAM sockets, the ip(4) socket options IP_RECVDSTADDR > and IP_RECVDSTPORT can be used to retrieve destination address > and port. > > jmc asked about changing the example; if we replace it with a > code fragment using getsockname it's no longer specific to pf(4), > and the code is so much simpler than DIOCNATLOOK that IMO a > sample isn't really needed for this. > > however we could probably usefully add a line or two to > getsockname(4) explaining its use with divert-to. > > looking through the ports tree, there are two occasions where > DIOCNATLOOK is used that can't be replaced with divert-to/getsockname: > ftpsesame, which needs to lookup addresses gleaned from BPF captured > connections, and oidentd which needs to lookup in response to ident > requests. does anyone think it's worth keeping the example for cases > like these? (personally I don't, but could be persuaded otherwise > if people feel strongly about it). Way back when I was a new OpenBSD user, I interpreted the DIOCNATLOOK example to be a simple generic program that demonstrates how to use PF ioctl commands as a whole. The man page with the example was very helpful to me as a beginner's guide that shows "here's the list of PF ioctl commands and their data structures," and ends with "and here's an example of how to use one of the PF ioctl commands." Since there are now better alternatives to DIOCNATLOOK in most cases as you pointed out, what do you think about replacing the example program with another simple program that does a different ioctl command? Two candidates could be DIOCGETLIMIT or DIOCGETSTATUS; basically, calls that new users could try without changing or harming their system. Those two commands will also always work, since they do not require the user's PF rules to include non-default features like tables or queues. I have included a diff that merges your new paragraph with an example that uses DIOCGETLIMIT instead of DIOCNATLOOK. I also added a .Pp right before your text so that there is a blank line between the pfioc_natlook struct declaration and your new text for readability. Please let me know what you think. Thanks, Lawrence Index: pf.4 === RCS file: /cvs/src/share/man/man4/pf.4,v retrieving revision 1.72 diff -u -p -r1.72 pf.4 --- pf.428 Dec 2010 13:56:11 - 1.72 +++ pf.46 May 2011 02:04:06 - @@ -314,6 +314,17 @@ struct pfioc_natlook { u_int8_t direction; }; .Ed +.Pp +This was primarily used to support transparent proxies with rdr-to rules. +New proxies should use divert-to rules instead. +These do not require access to the privileged +.Pa /dev/pf +device and preserve the original destination address for +.Xr getsockname 2 . +For SOCK_DGRAM sockets, the +.Xr ip 4 +socket options IP_RECVDSTADDR and IP_RECVDSTPORT can be used to retrieve +destination address and port. .It Dv DIOCSETDEBUG Fa "u_int32_t *level" Set the debug level. See the @@ -990,68 +1001,77 @@ packet filtering device. .El .Sh EXAMPLES The following example demonstrates how to use the -.Dv DIOCNATLOOK -command to find the internal host/port of a NATed connection: +.Dv DIOCGETLIMIT +command to show the hard limit of a memory pool: .Bd -literal #include #include #include #include #include -#include #include #include #include #include +#include -u_int32_t -read_address(const char *s) -{ -
Making umount DUID capable
In the current spirit of making stuff DUID capable i found that umount(8) was still not so. Diff makes use of "unrawname()" from fsck/fsutils.[ch]. Not sure if this is what and how we want it, so no man page changes included so far. Thoughts? OK's? Manpage diffs? ;-) /Alexander Index: Makefile === RCS file: /cvs/src/sbin/umount/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- Makefile21 Sep 1997 11:38:25 - 1.3 +++ Makefile6 May 2011 02:07:01 - @@ -1,6 +1,11 @@ # $OpenBSD: Makefile,v 1.3 1997/09/21 11:38:25 deraadt Exp $ PROG= umount +SRCS= umount.c fsutil.c +.PATH: ${.CURDIR}/../fsck +CFLAGS+= -I${.CURDIR}/../fsck +DPADD= ${LIBUTIL} +LDADD= -lutil MAN= umount.8 .include Index: umount.c === RCS file: /cvs/src/sbin/umount/umount.c,v retrieving revision 1.21 diff -u -p -r1.21 umount.c --- umount.c27 Oct 2009 23:59:34 - 1.21 +++ umount.c6 May 2011 02:07:01 - @@ -44,10 +44,14 @@ #include #include +#include #include #include #include #include +#include + +#include "fsutil.h" typedef enum { MNTON, MNTFROM } mntwhat; @@ -149,7 +153,7 @@ umountfs(char *oname) struct stat sb; struct timeval pertry, try; CLIENT *clp; - int so; + int so, devfd; char *delimp, *hostp, *mntpt; char *name, *newname, rname[MAXPATHLEN], type[MFSNAMELEN]; @@ -170,6 +174,12 @@ umountfs(char *oname) warnx("%s: not a directory or special device", name); return (1); } + } + + /* Special treatment for DUIDs (and short form device names) */ + if ((devfd = opendev(oname, O_RDONLY, 0, &name)) >= 0) { + close(devfd); + unrawname(name); } /*
Re: pf(4) man page: include missing header in example program
On 2011/05/03 19:51, Mike Belopuhov wrote: > On Tue, May 3, 2011 at 9:56 AM, Stuart Henderson wrote: > > On 2011/05/02 22:28, Lawrence Teo wrote: > >> The DIOCNATLOOK example program at the end of the pf(4) man page > >> uses memset(3), but string.h is not included. The following diff > >> fixes this. Any thoughts? > > > > That change is correct but I'm not sure about keeping this example > > code at all. We've had divert-to since OpenBSD 4.4 - when this is used > > instead of rdr-to the destination address is preserved, so it can be > > fetched with getsockname() without the DIOCNATLOOK dance. > > > > As a result the code becomes much less complicated, so we don't > > really need an example any more, also another big advantage is that > > there's no need for access to the privileged /dev/pf device. > > > > How about this? > > > > i'm in favor of this change, so ok mikeb > slightly tweaked after knowledge gained from converting tftp-proxy; specifically, mention the socket options that will be needed for udp as they're not easy to track down. This was primarily used to support transparent proxies with rdr- to rules. New proxies should use divert-to rules instead. These do not require access to the privileged /dev/pf device and preserve the original destination address for getsockname(2). For SOCK_DGRAM sockets, the ip(4) socket options IP_RECVDSTADDR and IP_RECVDSTPORT can be used to retrieve destination address and port. jmc asked about changing the example; if we replace it with a code fragment using getsockname it's no longer specific to pf(4), and the code is so much simpler than DIOCNATLOOK that IMO a sample isn't really needed for this. however we could probably usefully add a line or two to getsockname(4) explaining its use with divert-to. looking through the ports tree, there are two occasions where DIOCNATLOOK is used that can't be replaced with divert-to/getsockname: ftpsesame, which needs to lookup addresses gleaned from BPF captured connections, and oidentd which needs to lookup in response to ident requests. does anyone think it's worth keeping the example for cases like these? (personally I don't, but could be persuaded otherwise if people feel strongly about it). (the other ports using DIOCNATLOOK can probably be converted fairly easily - transproxy, tor, commoncpp, tircproxy). Index: pf.4 === RCS file: /cvs/src/share/man/man4/pf.4,v retrieving revision 1.72 diff -u -p -r1.72 pf.4 --- pf.428 Dec 2010 13:56:11 - 1.72 +++ pf.45 May 2011 22:41:15 - @@ -314,6 +314,16 @@ struct pfioc_natlook { u_int8_t direction; }; .Ed +This was primarily used to support transparent proxies with rdr-to rules. +New proxies should use divert-to rules instead. +These do not require access to the privileged +.Pa /dev/pf +device and preserve the original destination address for +.Xr getsockname 2 . +For SOCK_DGRAM sockets, the +.Xr ip 4 +socket options IP_RECVDSTADDR and IP_RECVDSTPORT can be used to retrieve +destination address and port. .It Dv DIOCSETDEBUG Fa "u_int32_t *level" Set the debug level. See the @@ -988,73 +998,6 @@ Explicitly remove source tracking nodes. .It Pa /dev/pf packet filtering device. .El -.Sh EXAMPLES -The following example demonstrates how to use the -.Dv DIOCNATLOOK -command to find the internal host/port of a NATed connection: -.Bd -literal -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -u_int32_t -read_address(const char *s) -{ - int a, b, c, d; - - sscanf(s, "%i.%i.%i.%i", &a, &b, &c, &d); - return htonl(a << 24 | b << 16 | c << 8 | d); -} - -void -print_address(u_int32_t a) -{ - a = ntohl(a); - printf("%d.%d.%d.%d", a >> 24 & 255, a >> 16 & 255, - a >> 8 & 255, a & 255); -} - -int -main(int argc, char *argv[]) -{ - struct pfioc_natlook nl; - int dev; - - if (argc != 5) { - printf("%s\en", - argv[0]); - return 1; - } - - dev = open("/dev/pf", O_RDWR); - if (dev == -1) - err(1, "open(\e"/dev/pf\e") failed"); - - memset(&nl, 0, sizeof(struct pfioc_natlook)); - nl.saddr.v4.s_addr = read_address(argv[1]); - nl.sport= htons(atoi(argv[2])); - nl.daddr.v4.s_addr = read_address(argv[3]); - nl.dport= htons(atoi(argv[4])); - nl.af = AF_INET; - nl.proto= IPPROTO_TCP; - nl.direction= PF_IN; - - if (ioctl(dev, DIOCNATLOOK, &nl)) - err(1, "DIOCNATLOOK"); - - printf("internal host "); - print_address(nl.rsaddr.v4.s_addr); - printf(":%u\en", ntohs(nl.rsport)); - return 0; -} -.Ed .Sh SEE ALSO .Xr ioctl 2 ,
Canon EOS 600D T3i
USD1160 Canon EOS 600D T3i Kit 18-55 Tipo réflex, objetivos intercambiables / Sensor CMOS de 18,00 MP efectivos / Tamaño sensor 22,30 x 14,90 mm / Montura Canon EF-S - Kit de lentes 18-55 mm/ Factor de multiplicación 1,60x / Pantalla TFT de 3,00 pulgadas
Re: macppc: nvram support
> > Date: Thu, 5 May 2011 21:06:21 +0530 > > From: Martin Pieuchot > > > > Hi, > > > > "recent" macppc machines, power{mac,book}2.1 and onward, also known as > > "Core99" powermac and after, have an onboard nvram of 8kB (actually 2 > > banks of 8kB). > > > > This nvram is used, at least by the Open Firmware, to store its > > variables. The following diff is a driver to access the nvram > > without calling the openfirmware. Its interest may be not that important > > considering that we can already access the nvram through the "options" > > node of the ofw. But here it is, if someone is interested ;) > > If this really only provides access to the variables that are already > avilable through eeprom(8) through openprom(4), I don't think we > should add this. > Seconded. Either the nvram memory is free to use and it gets supported as a block device, or it is supposed to match a specific layout and the only access to it should then be done through openprom(4).
Re: macppc: nvram support
> Date: Thu, 5 May 2011 21:06:21 +0530 > From: Martin Pieuchot > > Hi, > > "recent" macppc machines, power{mac,book}2.1 and onward, also known as > "Core99" powermac and after, have an onboard nvram of 8kB (actually 2 > banks of 8kB). > > This nvram is used, at least by the Open Firmware, to store its > variables. The following diff is a driver to access the nvram > without calling the openfirmware. Its interest may be not that important > considering that we can already access the nvram through the "options" > node of the ofw. But here it is, if someone is interested ;) If this really only provides access to the variables that are already avilable through eeprom(8) through openprom(4), I don't think we should add this.
Elvis Presley - 63 Álbumes mas Pendrive de Regalo
ElvisPresley 30 #1 Hits 2nd To None A Touch Of Platinum - A Life In Music Aloha From Hawaii Always On My Mind Artist Of The Century As Recorded Live On Stage In Memphiso Back In Memphis Blue Hawaii Country Double Feature Viva Las Vegas And Roustabout Elvis 1 Elvis2 Elvis Christmas Elvis In Concertt Elvis Is Back For Lp Fans Only aFrom Elvis Boulevard Memphis Tennessee >From Elvis In Memphis aFrom The Heart G.I. Blues Girls Girls Girls Golden Records Good Times Great Country Songs aHe Touched Me aa His Hand In Mine How Great Thou Art In Concert In Person Jailhouse Rock aKing Creole Live At Madison Square Garden Love Letters Love Songs Loving You Moody Blue Nbc - Tv Special Now On Stage Platinum Pot Luck s Promised Land s Pure Gold Raised On Rock Reconsider Baby Sings The Wonderful World Of Christmas Something For Everybody That’s The Way It Is The Essential70's Master aa aThe Fool o The Lost Album The Other Side Hits The Top Ten Hits Today Ultimate Gospel The King Of Rock And RollDe la A a la Z, 268 temas Tv Special Absent Without Leave Charleston Rocks Something for everybody Taking Care of Business That's the way it is The Hampton Concert Multitud The complete 50'masters The Essential 2007 The Essential Collection The last live sessions a The Rise of Elvis Presley a The way it is a Way Down Viva Elvis
Re: malloc: memory leak instrumentation
On Thu, May 05, 2011 at 02:29:39PM +0200, Otto Moerbeek wrote: > Hi, > > Now that the latest chunk scan optimization diff is committed, it's > time to present a malloc feature diff. > > This diff adds instrumentation to a MALLOC_STATS enabled malloc.c to > detect and report memory leaks, including the address of the code that > allocated memory that was not freed. With the help of gdb, you can > translate this address into a source file location. > > For instructions and to show some of the possibilities, check > > http://www.drijf.net/malloc/ > > Diff also below. It was good fun working on this, and I hope you'll > enjoy it as well. > > Note that this diff a a bit bigger than strictly needed, I moved the > stats reporting code to the bottom of the file. Something I wanted to > do for a long time. Updated diff. Kent R. Spillner spotted a glitch that caused a (ironly!) memory leak in the reporting code, -Otto Index: malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.130 diff -u -p -r1.130 malloc.c --- malloc.c5 May 2011 12:11:20 - 1.130 +++ malloc.c5 May 2011 18:15:15 - @@ -43,6 +43,7 @@ #include #ifdef MALLOC_STATS +#include #include #endif @@ -94,6 +95,9 @@ struct region_info { void *p;/* page; low bits used to mark chunks */ uintptr_t size; /* size for pages, or chunk_info pointer */ +#ifdef MALLOC_STATS + void *f;/* where allocated from */ +#endif }; LIST_HEAD(chunk_head, chunk_info); @@ -125,9 +129,11 @@ struct dir_info { size_t cheap_reallocs; #define STATS_INC(x) ((x)++) #define STATS_ZERO(x) ((x) = 0) +#define STATS_SETF(x,y) ((x)->f = (y)) #else #define STATS_INC(x) /* nothing */ #define STATS_ZERO(x) /* nothing */ +#define STATS_SETF(x,y)/* nothing */ #endif /* MALLOC_STATS */ u_int32_t canary2; }; @@ -143,6 +149,9 @@ struct dir_info { struct chunk_info { LIST_ENTRY(chunk_info) entries; void *page; /* pointer to the page */ +#ifdef MALLOC_STATS + void *f; +#endif u_int32_t canary; u_short size; /* size of this page's chunks */ u_short shift; /* how far to shift for this size */ @@ -192,6 +201,14 @@ static u_char getrnibble(void); extern char*__progname; +#ifdef MALLOC_STATS +void malloc_dump(int); +static void malloc_exit(void); +#define CALLER __builtin_return_address(0) +#else +#define CALLER NULL +#endif + /* low bits of r->p determine size: 0 means >= page size and p->size holding * real size, otherwise r->size is a shift count, or 1 for malloc(0) */ @@ -217,142 +234,6 @@ hash(void *p) return sum; } -#ifdef MALLOC_STATS -static void -dump_chunk(int fd, struct chunk_info *p, int fromfreelist) -{ - char buf[64]; - - while (p != NULL) { - snprintf(buf, sizeof(buf), "chunk %d %d/%d %p\n", p->size, - p->free, p->total, p->page); - write(fd, buf, strlen(buf)); - if (!fromfreelist) - break; - p = LIST_NEXT(p, entries); - if (p != NULL) { - snprintf(buf, sizeof(buf), ""); - write(fd, buf, strlen(buf)); - } - } -} - -static void -dump_free_chunk_info(int fd, struct dir_info *d) -{ - char buf[64]; - int i; - - snprintf(buf, sizeof(buf), "Free chunk structs:\n"); - write(fd, buf, strlen(buf)); - for (i = 0; i < MALLOC_MAXSHIFT; i++) { - struct chunk_info *p = LIST_FIRST(&d->chunk_dir[i]); - if (p != NULL) { - snprintf(buf, sizeof(buf), "%2d) ", i); - write(fd, buf, strlen(buf)); - dump_chunk(fd, p, 1); - } - } - -} - -static void -dump_free_page_info(int fd, struct dir_info *d) -{ - char buf[64]; - int i; - - snprintf(buf, sizeof(buf), "Free pages cached: %zu\n", - d->free_regions_size); - write(fd, buf, strlen(buf)); - for (i = 0; i < mopts.malloc_cache; i++) { - if (d->free_regions[i].p != NULL) { - snprintf(buf, sizeof(buf), "%2d) ", i); - write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "free at %p: %zu\n", - d->free_regions[i].p, d->free_regions[i].size); - write(fd, buf, strlen(buf)); - } - } -} - -static void -malloc_dump1(int fd, struct dir_info *d) -{ - char buf[64]; - size_t i, realsize; - - snprintf(buf, sizeof(buf), "Malloc dir of %s at %p\n", __progname, d); - write(fd, buf, strlen(buf)); - if (d == NULL) - return; - snprintf(buf, sizeof(buf), "R
macppc: nvram support
Hi, "recent" macppc machines, power{mac,book}2.1 and onward, also known as "Core99" powermac and after, have an onboard nvram of 8kB (actually 2 banks of 8kB). This nvram is used, at least by the Open Firmware, to store its variables. The following diff is a driver to access the nvram without calling the openfirmware. Its interest may be not that important considering that we can already access the nvram through the "options" node of the ofw. But here it is, if someone is interested ;) I've tested it with an amd flash, it's basically a port of apple's xnu driver so the commands should be correct. I also include at the end of the mail a slightly modified version of FreeBSD's nvram(8) utility, if you want to test it. Comments are welcome. Have fun, Martin Index: conf/GENERIC === RCS file: /cvs/src/sys/arch/macppc/conf/GENERIC,v retrieving revision 1.207 diff -u -p -r1.207 GENERIC --- conf/GENERIC19 Apr 2011 23:07:54 - 1.207 +++ conf/GENERIC5 May 2011 14:43:23 - @@ -32,6 +32,7 @@ configbsd swap generic mainbus0 at root cpu* at mainbus0 mem* at mainbus0 +nvram0 at mainbus0 # nvram mpcpcibr* at mainbus0 # MPC106 PCI Bridge. memc* at mainbus0 @@ -146,7 +147,6 @@ bm* at macobio? # BMAC ethernet mc*at macobio? # MACE ethernet #esp* at macobio? flags 0x # 53c9x SCSI mesh* at macobio? flags 0x # MESH SCSI -#nvram*at macobio? # nvram adb* at macobio? # Apple Desktop Bus apm0 at adb? # APM emulation piic0 at adb? # PMU I2C Index: conf/files.macppc === RCS file: /cvs/src/sys/arch/macppc/conf/files.macppc,v retrieving revision 1.63 diff -u -p -r1.63 files.macppc --- conf/files.macppc 6 Dec 2010 20:10:18 - 1.63 +++ conf/files.macppc 5 May 2011 14:43:23 - @@ -51,6 +51,10 @@ device memc {} attach memc at mainbus file arch/macppc/dev/uni_n.c memc +device nvram +attach nvram at mainbus +file arch/macppc/dev/nvram.c nvram needs-flag + major {rd = 17} major {wd = 0} major {sd = 2} @@ -111,7 +115,6 @@ device macobio {} attach macobio at pci file arch/macppc/pci/macobio.c macobio - # kauai ATA glue device kauaiata {} attach kauaiata at pci @@ -219,10 +222,6 @@ file arch/macppc/dev/aoa.c aoa device daca: audio, auconv, mulaw, i2s attach daca at macobio file arch/macppc/dev/daca.c daca - -#devicenvram -#attachnvram at macobio -#file arch/macppc/dev/nvram.c nvram needs-flag device macgpio {} attach macgpio at macobio with macgpio Index: dev/nvram.c === RCS file: dev/nvram.c diff -N dev/nvram.c --- /dev/null 1 Jan 1970 00:00:00 - +++ dev/nvram.c 5 May 2011 14:43:23 - @@ -0,0 +1,518 @@ +/* $OpenBSD$ */ +/* + * Copyright (c) 2011 Martin Pieuchot + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define NVRAM_DEBUG 1 + +#ifdef NVRAM_DEBUG +#define DPRINTF(x...) printf(x) +#else +#define DPRINTF(x...) +#endif + +#define DEVNAME(sc)((sc)->sc_dev.dv_xname) + +#define NVRAM_SIZE 0x2000 /* 8kB for each bank. */ +#define NVRAM_SIGN 0x5a + +struct nvram_header { + uint8_t sign; + uint8_t csum; /* checksum sign, len & name */ + uint16_tlen; + charname[12]; + uint32_tadler; /* adler32 bank checksum */ + uint32_tgen; + uint32_treserved[2]; +}; + +#define CHRP_SIZE 14 /* size of len + name */ +#define ADLER_OFFSET 20 /* offset of hdr->gen */ +#define ADLER_SIZE (NVRAM_SIZE - ADLER_OFFSET) + +struct nvram_softc { + struct devicesc_dev; + int
Re: alc(4) support for Atheros AR815x
On Wed, May 04, 2011 at 09:32:47AM +0200, Gabriel Linder wrote: > I have an alc device too, and would like to fix it. Starting from > kevlo's diff I updated it some month ago to compile, and compared > FreeBSD driver to add some more things, finding some bugs in their > driver (reported and fixed in their tree). I now have a working alc, > with and without cable at boot or after boot but I have to update my > tree (lagging some months behind) and probably fix some conflicts > before posting an up to date diff. It would help me if someone could > answer my silly questions about differences between FreeBSD and > OpenBSD internals, by the way. Slides at > http://www.openbsd.org/papers/ were very useful but do not cover > this :) FYI, Marius just made a huge commit which includes some alc/PHY code. I don't know if it is relevent. http://svnweb.freebsd.org/base?view=revision&revision=221407 -- Best Regards Edd Barrett http://www.theunixzoo.co.uk
Re: add mute support for i2s (any macppc audio card)
On 05/05/11(Thu) 15:59, Martin Pieuchot wrote: > The following diff adds the possibility to mute the master channel on > any i2s based card. As a side effect the "mute key" on the keyboard now > works as expected. > > Comments, Ok? New diff, should fix mixerctl crash with chipsets that don't support bass nor treble. Index: dev/i2s.c === RCS file: /cvs/src/sys/arch/macppc/dev/i2s.c,v retrieving revision 1.19 diff -u -p -r1.19 i2s.c --- dev/i2s.c 4 May 2011 15:50:49 - 1.19 +++ dev/i2s.c 5 May 2011 14:00:23 - @@ -155,6 +155,7 @@ i2s_attach(struct device *parent, struct printf(": irq %d,%d,%d\n", cirq, oirq, iirq); i2s_set_rate(sc, 44100); + sc->sc_mute = 0; i2s_gpio_init(sc, ca->ca_node, parent); } @@ -512,15 +513,14 @@ enum { I2S_VOL_OUTPUT, I2S_INPUT_SELECT, I2S_VOL_INPUT, + I2S_MUTE, /* should be before bass/treble */ I2S_BASS, I2S_TREBLE, I2S_ENUM_LAST }; int -i2s_set_port(h, mc) - void *h; - mixer_ctrl_t *mc; +i2s_set_port(void *h, mixer_ctrl_t *mc) { struct i2s_softc *sc = h; int l, r; @@ -553,6 +553,30 @@ i2s_set_port(h, mc) (*sc->sc_setvolume)(sc, l, r); return 0; + case I2S_MUTE: + if (mc->type != AUDIO_MIXER_ENUM) + return (EINVAL); + + sc->sc_mute = (mc->un.ord != 0); + + if (sc->sc_mute) { + if (sc->sc_output_mask & 1 << 0) + i2s_mute_speaker(sc, 1); + if (sc->sc_output_mask & 1 << 1) + i2s_mute_headphone(sc, 1); + if (sc->sc_output_mask & 1 << 2) + i2s_mute_lineout(sc, 1); + } else { + if (sc->sc_output_mask & 1 << 0) + i2s_mute_speaker(sc, 0); + if (sc->sc_output_mask & 1 << 1) + i2s_mute_headphone(sc, 0); + if (sc->sc_output_mask & 1 << 2) + i2s_mute_lineout(sc, 0); + } + + return (0); + case I2S_BASS: if (sc->sc_setbass != NULL) (*sc->sc_setbass)(sc, l); @@ -589,9 +613,7 @@ i2s_set_port(h, mc) } int -i2s_get_port(h, mc) - void *h; - mixer_ctrl_t *mc; +i2s_get_port(void *h, mixer_ctrl_t *mc) { struct i2s_softc *sc = h; @@ -607,6 +629,10 @@ i2s_get_port(h, mc) mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->sc_vol_r; return 0; + case I2S_MUTE: + mc->un.ord = sc->sc_mute; + return (0); + case I2S_INPUT_SELECT: mc->un.mask = sc->sc_record_source; return 0; @@ -670,13 +696,29 @@ i2s_query_devinfo(void *h, mixer_devinfo dip->mixer_class = I2S_OUTPUT_CLASS; strlcpy(dip->label.name, AudioNmaster, sizeof(dip->label.name)); dip->type = AUDIO_MIXER_VALUE; - dip->prev = dip->next = AUDIO_MIXER_LAST; + dip->prev = AUDIO_MIXER_LAST; + dip->next = I2S_MUTE; dip->un.v.num_channels = 2; dip->un.v.delta = 8; strlcpy(dip->un.v.units.name, AudioNvolume, sizeof(dip->un.v.units.name)); return 0; + case I2S_MUTE: + dip->mixer_class = I2S_OUTPUT_CLASS; + dip->prev = I2S_VOL_OUTPUT; + dip->next = AUDIO_MIXER_LAST; + strlcpy(dip->label.name, AudioNmute, sizeof(dip->label.name)); + dip->type = AUDIO_MIXER_ENUM; + dip->un.e.num_mem = 2; + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); + dip->un.e.member[0].ord = 0; + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); + dip->un.e.member[1].ord = 1; + return (0); + case I2S_INPUT_SELECT: dip->mixer_class = I2S_RECORD_CLASS; strlcpy(dip->label.name, AudioNsource, sizeof(dip->label.name)); @@ -1086,7 +1128,8 @@ i2s_cint(v) if (((sense & 0x02) >> 1) == headphone_detect_active) { DPRINTF(("headphone is inserted\n")); sc->sc_output_mask |= 1 << 1; - i2s_mute_headphone(sc, 0); + if (!sc->sc_mute) + i2s_mute_headphone(sc, 0); } else { DPRINTF(("headphone is NOT inserted\n")); } @@ -1100,14 +1143,16 @@ i2s_cint(v) if (((sense & 0x02) >> 1) == lineout_detect_active) { DPRINTF(("lineout is inserted\n")
Re: malloc: speedup chunk housekeeping
>> malloc_cache is a power of the, so a bitwise and with malloc_cache - 1 >> is equivalent to modulo malloc_cache. > > of two, that is. > > Room is reserved for MALLOC_MAXCACHE pointers, but only malloc_cache > are ever used. So doing a modulo malloc_cache is ok. Ahh, sorry for that. I was thrown by that 256!
ospfd to test
People running ospfd should better test this diff. The diff is a start at supporting opaque LSA (type 9, 10 and 11). Those are used for things like graceful restart. Now even if you don't have systems emitting such LSA it is important to test the diff to make sure normal operation is still working. If you have systems announcing the new LSA I would be interested in ospfctl show da output. I do not have such systems around. happy testing -- :wq Claudio Index: ospfctl/ospfctl.c === RCS file: /cvs/src/usr.sbin/ospfctl/ospfctl.c,v retrieving revision 1.55 diff -u -p -r1.55 ospfctl.c --- ospfctl/ospfctl.c 25 Sep 2010 13:29:56 - 1.55 +++ ospfctl/ospfctl.c 3 May 2011 09:54:44 - @@ -47,7 +47,7 @@ const char*fmt_timeframe(time_t t); const char *fmt_timeframe_core(time_t t); const char *log_id(u_int32_t ); const char *log_adv_rtr(u_int32_t); -voidshow_database_head(struct in_addr, u_int8_t); +voidshow_database_head(struct in_addr, char *, u_int8_t); int show_database_msg(struct imsg *); char *print_ls_type(u_int8_t); voidshow_db_hdr_msg_detail(struct lsa_hdr *); @@ -183,6 +183,9 @@ main(int argc, char *argv[]) case SHOW_DBASBR: imsg_compose(ibuf, IMSG_CTL_SHOW_DB_ASBR, 0, 0, -1, NULL, 0); break; + case SHOW_DBOPAQ: + imsg_compose(ibuf, IMSG_CTL_SHOW_DB_OPAQ, 0, 0, -1, NULL, 0); + break; case SHOW_RIB: printf("%-20s %-17s %-12s %-9s %-7s %-8s\n", "Destination", "Nexthop", "Path Type", "Type", "Cost", "Uptime"); @@ -283,6 +286,7 @@ main(int argc, char *argv[]) case SHOW_DBRTR: case SHOW_DBSUM: case SHOW_DBASBR: + case SHOW_DBOPAQ: done = show_db_msg_detail(&imsg); break; case SHOW_RIB: @@ -586,9 +590,10 @@ mask2prefixlen(in_addr_t ina) } void -show_database_head(struct in_addr aid, u_int8_t type) +show_database_head(struct in_addr aid, char *ifname, u_int8_t type) { char*header, *format; + int cleanup = 0; switch (type) { case LSA_TYPE_ROUTER: @@ -608,24 +613,47 @@ show_database_head(struct in_addr aid, u if ((header = strdup("Type-5 AS External Link States")) == NULL) err(1, NULL); break; + case LSA_TYPE_LINK_OPAQ: + format = "Type-9 Link Local Opaque Link States"; + break; + case LSA_TYPE_AREA_OPAQ: + format = "Type-10 Area Local Opaque Link States"; + break; + case LSA_TYPE_AS_OPAQ: + format = NULL; + if ((header = strdup("Type-11 AS Wide Opaque Link States")) == + NULL) + err(1, NULL); + break; default: - errx(1, "unknown LSA type"); + if (asprintf(&format, "LSA type %x", ntohs(type)) == -1) + err(1, NULL); + cleanup = 1; + break; } - if (type != LSA_TYPE_EXTERNAL) + if (type == LSA_TYPE_LINK_OPAQ) { + if (asprintf(&header, "%s (Area %s Interface %s)", format, + inet_ntoa(aid), ifname) == -1) + err(1, NULL); + } else if (type != LSA_TYPE_EXTERNAL && type != LSA_TYPE_AS_OPAQ) if (asprintf(&header, "%s (Area %s)", format, inet_ntoa(aid)) == -1) err(1, NULL); printf("\n%-15s %s\n\n", "", header); free(header); + if (cleanup) + free(format); } int show_database_msg(struct imsg *imsg) { static struct in_addrarea_id; + static char ifname[IF_NAMESIZE]; static u_int8_t lasttype; struct area *area; + struct iface*iface; struct lsa_hdr *lsa; switch (imsg->hdr.type) { @@ -633,7 +661,7 @@ show_database_msg(struct imsg *imsg) case IMSG_CTL_SHOW_DB_SELF: lsa = imsg->data; if (lsa->type != lasttype) { - show_database_head(area_id, lsa->type); + show_database_head(area_id, ifname, lsa->type); printf("%-15s %-15s %-4s %-10s %-8s\n", "Link ID", "Adv Router", "Age", "Seq#", "Checksum"); } @@ -648,6 +676,11 @@ show_database_msg(struct imsg *imsg) area_id = area->id; lasttype = 0; break; + case IMSG_CTL_IFACE: + iface = imsg->data; + strlcpy(ifname, iface->name, sizeof(ifname)); + lasttype = 0; +
malloc: memory leak instrumentation
Hi, Now that the latest chunk scan optimization diff is committed, it's time to present a malloc feature diff. This diff adds instrumentation to a MALLOC_STATS enabled malloc.c to detect and report memory leaks, including the address of the code that allocated memory that was not freed. With the help of gdb, you can translate this address into a source file location. For instructions and to show some of the possibilities, check http://www.drijf.net/malloc/ Diff also below. It was good fun working on this, and I hope you'll enjoy it as well. Note that this diff a a bit bigger than strictly needed, I moved the stats reporting code to the bottom of the file. Something I wanted to do for a long time. -Otto Index: malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.130 diff -u -p -r1.130 malloc.c --- malloc.c5 May 2011 12:11:20 - 1.130 +++ malloc.c5 May 2011 12:14:51 - @@ -43,6 +43,7 @@ #include #ifdef MALLOC_STATS +#include #include #endif @@ -94,6 +95,9 @@ struct region_info { void *p;/* page; low bits used to mark chunks */ uintptr_t size; /* size for pages, or chunk_info pointer */ +#ifdef MALLOC_STATS + void *f;/* where allocated from */ +#endif }; LIST_HEAD(chunk_head, chunk_info); @@ -125,9 +129,11 @@ struct dir_info { size_t cheap_reallocs; #define STATS_INC(x) ((x)++) #define STATS_ZERO(x) ((x) = 0) +#define STATS_SETF(x,y) ((x)->f = (y)) #else #define STATS_INC(x) /* nothing */ #define STATS_ZERO(x) /* nothing */ +#define STATS_SETF(x,y)/* nothing */ #endif /* MALLOC_STATS */ u_int32_t canary2; }; @@ -143,6 +149,9 @@ struct dir_info { struct chunk_info { LIST_ENTRY(chunk_info) entries; void *page; /* pointer to the page */ +#ifdef MALLOC_STATS + void *f; +#endif u_int32_t canary; u_short size; /* size of this page's chunks */ u_short shift; /* how far to shift for this size */ @@ -192,6 +201,14 @@ static u_char getrnibble(void); extern char*__progname; +#ifdef MALLOC_STATS +void malloc_dump(int); +static void malloc_exit(void); +#define CALLER __builtin_return_address(0) +#else +#define CALLER NULL +#endif + /* low bits of r->p determine size: 0 means >= page size and p->size holding * real size, otherwise r->size is a shift count, or 1 for malloc(0) */ @@ -217,142 +234,6 @@ hash(void *p) return sum; } -#ifdef MALLOC_STATS -static void -dump_chunk(int fd, struct chunk_info *p, int fromfreelist) -{ - char buf[64]; - - while (p != NULL) { - snprintf(buf, sizeof(buf), "chunk %d %d/%d %p\n", p->size, - p->free, p->total, p->page); - write(fd, buf, strlen(buf)); - if (!fromfreelist) - break; - p = LIST_NEXT(p, entries); - if (p != NULL) { - snprintf(buf, sizeof(buf), ""); - write(fd, buf, strlen(buf)); - } - } -} - -static void -dump_free_chunk_info(int fd, struct dir_info *d) -{ - char buf[64]; - int i; - - snprintf(buf, sizeof(buf), "Free chunk structs:\n"); - write(fd, buf, strlen(buf)); - for (i = 0; i < MALLOC_MAXSHIFT; i++) { - struct chunk_info *p = LIST_FIRST(&d->chunk_dir[i]); - if (p != NULL) { - snprintf(buf, sizeof(buf), "%2d) ", i); - write(fd, buf, strlen(buf)); - dump_chunk(fd, p, 1); - } - } - -} - -static void -dump_free_page_info(int fd, struct dir_info *d) -{ - char buf[64]; - int i; - - snprintf(buf, sizeof(buf), "Free pages cached: %zu\n", - d->free_regions_size); - write(fd, buf, strlen(buf)); - for (i = 0; i < mopts.malloc_cache; i++) { - if (d->free_regions[i].p != NULL) { - snprintf(buf, sizeof(buf), "%2d) ", i); - write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "free at %p: %zu\n", - d->free_regions[i].p, d->free_regions[i].size); - write(fd, buf, strlen(buf)); - } - } -} - -static void -malloc_dump1(int fd, struct dir_info *d) -{ - char buf[64]; - size_t i, realsize; - - snprintf(buf, sizeof(buf), "Malloc dir of %s at %p\n", __progname, d); - write(fd, buf, strlen(buf)); - if (d == NULL) - return; - snprintf(buf, sizeof(buf), "Regions slots %zu\n", d->regions_total); - write(fd, buf, strlen(buf)); - snprintf(buf, sizeof(buf), "Finds %zu/%zu %f\n", d->finds, - d->find_collisions, - 1.0 + (double)d->find_
Re: tunefs(8) don't need no stinkin' opendisk(3). And wants DUIDs!
On Thu, May 05, 2011 at 08:09:16AM -0400, Kenneth R Westerback wrote: > On Thu, May 05, 2011 at 11:51:22AM +0100, Owain Ainsworth wrote: > > On Wed, May 04, 2011 at 11:59:52PM -0400, Kenneth R Westerback wrote: > > > And by using opendev(3) tunefs can accept disk UID's. > > > > > > Any actual tunefs(8) guru's out there who can explain what this > > > might break? > > > > > > Inspired by oga@'s work on atactl. > > > > millert already provided a diff for that, the the getpartition dance is > > necessary if you want to be able to provide partition names from fstab > > (say tunefs -N /home). This diff breaks that ability. > > Aha. I have no such ability here, since getfsfile() doesn't 'work' > for DUID entries in the fstab. :-) If I put back a 'real' device > name in my sacrificial entry I do see the millert version work > better than mine. > > Looking at that. > > Ken > And looking closer I see I managed to misapply millert@'s version. Properly applied it does work fine. So ok krw@ on millert's diff. Ken
Re: tunefs(8) don't need no stinkin' opendisk(3). And wants DUIDs!
On 2011/05/05 11:51, Owain Ainsworth wrote: > I have no idea, but a porter should probably check the distfiles. It's not used in ports at present. (symon has a SMART stats module which uses it, but it's only used on NetBSD).
Re: tunefs(8) don't need no stinkin' opendisk(3). And wants DUIDs!
On Thu, May 05, 2011 at 11:51:22AM +0100, Owain Ainsworth wrote: > On Wed, May 04, 2011 at 11:59:52PM -0400, Kenneth R Westerback wrote: > > And by using opendev(3) tunefs can accept disk UID's. > > > > Any actual tunefs(8) guru's out there who can explain what this > > might break? > > > > Inspired by oga@'s work on atactl. > > millert already provided a diff for that, the the getpartition dance is > necessary if you want to be able to provide partition names from fstab > (say tunefs -N /home). This diff breaks that ability. Aha. I have no such ability here, since getfsfile() doesn't 'work' for DUID entries in the fstab. :-) If I put back a 'real' device name in my sacrificial entry I do see the millert version work better than mine. Looking at that. Ken
Re: tunefs(8) don't need no stinkin' opendisk(3). And wants DUIDs!
On Wed, May 04, 2011 at 11:59:52PM -0400, Kenneth R Westerback wrote: > And by using opendev(3) tunefs can accept disk UID's. > > Any actual tunefs(8) guru's out there who can explain what this > might break? > > Inspired by oga@'s work on atactl. millert already provided a diff for that, the the getpartition dance is necessary if you want to be able to provide partition names from fstab (say tunefs -N /home). This diff breaks that ability. The diff is appended here for completeness (from millert, not me) > > This is the last use of opendisk(3) in the tree. Any reason to > keep it if this goes in? ports? I have no idea, but a porter should probably check the distfiles. -0- Index: tunefs.c === RCS file: /cvs/src/sbin/tunefs/tunefs.c,v retrieving revision 1.30 diff -u -p -r1.30 tunefs.c --- tunefs.c27 Oct 2009 23:59:34 - 1.30 +++ tunefs.c4 May 2011 18:30:33 - @@ -71,7 +71,7 @@ staticvoidbwrite(daddr64_t, char *, in static voidbread(daddr64_t, char *, int, const char *); static int getnum(const char *, const char *, int, int); static voidgetsb(struct fs *, const char *); -static int openpartition(const char *, int, char *, size_t); +static int openpartition(char *, int, char **); static voidusage(void); int @@ -79,8 +79,8 @@ main(int argc, char *argv[]) { #defineOPTSTRING "AFNe:g:h:m:o:" int i, ch, Aflag, Fflag, Nflag, openflags; - const char *special, *chg[2]; - chardevice[MAXPATHLEN]; + char*special; + const char *chg[2]; int maxbpg, minfree, optim; int avgfilesize, avgfpdir; @@ -151,10 +151,8 @@ main(int argc, char *argv[]) openflags = Nflag ? O_RDONLY : O_RDWR; if (Fflag) fi = open(special, openflags); - else { - fi = openpartition(special, openflags, device, sizeof(device)); - special = device; - } + else + fi = openpartition(special, openflags, &special); if (fi == -1) err(1, "%s", special); getsb(&sblock, special); @@ -319,11 +317,11 @@ bread(daddr64_t blk, char *buffer, int c } static int -openpartition(const char *name, int flags, char *device, size_t devicelen) +openpartition(char *name, int flags, char **devicep) { charrawspec[MAXPATHLEN], *p; struct fstab*fs; - int fd, oerrno; + int fd; fs = getfsfile(name); if (fs) { @@ -334,11 +332,8 @@ openpartition(const char *name, int flag } else name = fs->fs_spec; } - fd = opendisk(name, flags, device, devicelen, 0); - if (fd == -1 && errno == ENOENT) { - oerrno = errno; - strlcpy(device, name, devicelen); - errno = oerrno; - } + fd = opendev(name, flags, 0, devicep); + if (fd == -1 && errno == ENOENT) + devicep = &name; return (fd); } -- I fell asleep reading a dull book, and I dreamt that I was reading on, so I woke up from sheer boredom.
add mute support for i2s (any macppc audio card)
The following diff adds the possibility to mute the master channel on any i2s based card. As a side effect the "mute key" on the keyboard now works as expected. Comments, Ok? Index: dev/i2s.c === RCS file: /cvs/src/sys/arch/macppc/dev/i2s.c,v retrieving revision 1.19 diff -u -p -r1.19 i2s.c --- dev/i2s.c 4 May 2011 15:50:49 - 1.19 +++ dev/i2s.c 5 May 2011 10:27:20 - @@ -155,6 +155,7 @@ i2s_attach(struct device *parent, struct printf(": irq %d,%d,%d\n", cirq, oirq, iirq); i2s_set_rate(sc, 44100); + sc->sc_mute = 0; i2s_gpio_init(sc, ca->ca_node, parent); } @@ -514,13 +515,12 @@ enum { I2S_VOL_INPUT, I2S_BASS, I2S_TREBLE, + I2S_MUTE, I2S_ENUM_LAST }; int -i2s_set_port(h, mc) - void *h; - mixer_ctrl_t *mc; +i2s_set_port(void *h, mixer_ctrl_t *mc) { struct i2s_softc *sc = h; int l, r; @@ -553,6 +553,30 @@ i2s_set_port(h, mc) (*sc->sc_setvolume)(sc, l, r); return 0; + case I2S_MUTE: + if (mc->type != AUDIO_MIXER_ENUM) + return (EINVAL); + + sc->sc_mute = (mc->un.ord != 0); + + if (sc->sc_mute) { + if (sc->sc_output_mask & 1 << 0) + i2s_mute_speaker(sc, 1); + if (sc->sc_output_mask & 1 << 1) + i2s_mute_headphone(sc, 1); + if (sc->sc_output_mask & 1 << 2) + i2s_mute_lineout(sc, 1); + } else { + if (sc->sc_output_mask & 1 << 0) + i2s_mute_speaker(sc, 0); + if (sc->sc_output_mask & 1 << 1) + i2s_mute_headphone(sc, 0); + if (sc->sc_output_mask & 1 << 2) + i2s_mute_lineout(sc, 0); + } + + return (0); + case I2S_BASS: if (sc->sc_setbass != NULL) (*sc->sc_setbass)(sc, l); @@ -589,9 +613,7 @@ i2s_set_port(h, mc) } int -i2s_get_port(h, mc) - void *h; - mixer_ctrl_t *mc; +i2s_get_port(void *h, mixer_ctrl_t *mc) { struct i2s_softc *sc = h; @@ -607,6 +629,10 @@ i2s_get_port(h, mc) mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->sc_vol_r; return 0; + case I2S_MUTE: + mc->un.ord = sc->sc_mute; + return (0); + case I2S_INPUT_SELECT: mc->un.mask = sc->sc_record_source; return 0; @@ -670,13 +696,29 @@ i2s_query_devinfo(void *h, mixer_devinfo dip->mixer_class = I2S_OUTPUT_CLASS; strlcpy(dip->label.name, AudioNmaster, sizeof(dip->label.name)); dip->type = AUDIO_MIXER_VALUE; - dip->prev = dip->next = AUDIO_MIXER_LAST; + dip->prev = AUDIO_MIXER_LAST; + dip->next = I2S_MUTE; dip->un.v.num_channels = 2; dip->un.v.delta = 8; strlcpy(dip->un.v.units.name, AudioNvolume, sizeof(dip->un.v.units.name)); return 0; + case I2S_MUTE: + dip->mixer_class = I2S_OUTPUT_CLASS; + dip->prev = I2S_VOL_OUTPUT; + dip->next = AUDIO_MIXER_LAST; + strlcpy(dip->label.name, AudioNmute, sizeof(dip->label.name)); + dip->type = AUDIO_MIXER_ENUM; + dip->un.e.num_mem = 2; + strlcpy(dip->un.e.member[0].label.name, AudioNoff, + sizeof dip->un.e.member[0].label.name); + dip->un.e.member[0].ord = 0; + strlcpy(dip->un.e.member[1].label.name, AudioNon, + sizeof dip->un.e.member[1].label.name); + dip->un.e.member[1].ord = 1; + return (0); + case I2S_INPUT_SELECT: dip->mixer_class = I2S_RECORD_CLASS; strlcpy(dip->label.name, AudioNsource, sizeof(dip->label.name)); @@ -1086,7 +1128,8 @@ i2s_cint(v) if (((sense & 0x02) >> 1) == headphone_detect_active) { DPRINTF(("headphone is inserted\n")); sc->sc_output_mask |= 1 << 1; - i2s_mute_headphone(sc, 0); + if (!sc->sc_mute) + i2s_mute_headphone(sc, 0); } else { DPRINTF(("headphone is NOT inserted\n")); } @@ -1100,14 +1143,16 @@ i2s_cint(v) if (((sense & 0x02) >> 1) == lineout_detect_active) { DPRINTF(("lineout is inserted\n")); sc->sc_output_mask |= 1 << 2; - i2s_mute_lineout(sc, 0); + if (!sc->sc_mute) + i2s_mute_lineout(sc, 0); } else { DPRINTF(("lineout is NOT inserted\n")
Re: macppc: support for Dynamic Frequency Switching
On 04/05/11(Wed) 20:29, Miod Vallat wrote: > > > Speaking of DELAY()... it is implemented using the processor internal > > > counter register. Is this register impacted by frequency changes? If so, > > > shouldn't you update the computed ns_per_tick delay() constant? > > > > Reading the doc again, it's said that the time base register is clocked > > at one-fourth of the bus clock. But the DFS feature divides the processor > > to system bus ratio. So, if I understand well there is no impact on the > > time base counter frequency. > > Good. This is easy to check, does ntpd start complaining after running a > few minutes at `setperf=0' speed? It doesn't complain and adjusts the clock the same way than with setperf=100. > > > Index: sys/arch/macppc/dev/dfs.c > > > +#include > > +#include > > Could you use instead of here? This is the > preferred (yet objectionable) form of satisfying > dependencies. Understood. > > +struct cfattach dfs_ca = { > > + sizeof(struct device), dfs_match, dfs_attach > > This needs to be sizeof(struct dfs_softc) now. That is, unless you want > to get funny panics after dfs0 attaches. Of course. I'm waiting some more test from the powermac owners to know if their machine support DFS or not, before sending a new diff.