Kernel Hacking

drivers/net/sunhme.c ?

static void happy_meal_tcvr_write(struct happy_meal *hp,
unsigned long tregs, int reg,
unsigned short value)
{
int tries = TCVR_WRITE_TRIES;

    ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg,

value));

    /* Welcome to Sun Microsystems, can I take your order please? */
    if (!hp->happy_flags & HFLAG_FENABLE)
            return happy_meal_bb_write(hp, tregs, reg, value);

    /* Would you like fries with that? */
    hme_write32(hp, tregs + TCVR_FRAME,
                (FRAME_WRITE | (hp->paddr << 23) |
                 ((reg & 0xff) << 18) | (value & 0xffff)));
    while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
            udelay(20);

    /* Anything else? */
    if (!tries)
            printk(KERN_ERR "happy meal: Aieee, transceiver MIF write

bolixed\n");

    /* Fifty-two cents is your change, have a nice day. */

}

[code]/* $Id: sunhme.c,v 1.124 2002/01/15 06:25:51 davem Exp $

  • sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching,
  •       auto carrier detecting ethernet driver.  Also known as the
    
  •       "Happy Meal Ethernet" found on SunSwift SBUS cards.
    
  • Copyright © 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com)
  • Changes :
  • 2000/11/11 Willy Tarreau
    • port to non-sparc architectures. Tested only on x86 and
  • only currently works with QFE PCI cards.
    
    • ability to specify the MAC address at module load time by passing this
  • argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
    

*/[/code]

Nije kernel kodiranje, ali je jako upečatljiv primjer. Razlika između “normalnih” i uber programera:

http://www.codemaestro.com/reviews/review00000105.html

(Carmack još uvijek piše određene kritične dijelove koda. Te dijelove koda uposlenici ID-a obično ne diraju, već samo komentarišu, hi hi hi)

P.S.
Sanele, ovo je ono o čemu sam ti pričao. Imam negdje zakopan link na disertaciju o matematici koja je potrebna da se izvuče ovo što je Carmack uradio, pokušat ću naći.

Edit:
OK, taj link je na dnu članka :slight_smile:

Carmack ima veliku tajnu :mrgreen:

Prilicno mi je nevjerovatno da je sam izveo konstantu(barem analiticki). Mozda se neko igrao inteligentnog “pogadjanja”, ipak postoji “samo” 2^31 kombinacija za pozitivne brojeve. Od toga ogroman broj nikako ne dolazi u obzir zbog karakteristika IEEE 754 realnih brojeva, a sigurno je moguce dodatno smanjiti broj mogucnosti adekvatnom matematickom analizom(cak i veoma jednostavnom).
U svakom slucaju skidam kapu. Da vise ljudi u industriji razmislja na ovakav nacin nvidia i ati bi danas imali manje posla :stuck_out_tongue: