]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/powerpc/booke/machdep.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / powerpc / booke / machdep.c
1 /*-
2  * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
17  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
19  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 /*-
26  * Copyright (C) 2001 Benno Rice
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  * 1. Redistributions of source code must retain the above copyright
33  *    notice, this list of conditions and the following disclaimer.
34  * 2. Redistributions in binary form must reproduce the above copyright
35  *    notice, this list of conditions and the following disclaimer in the
36  *    documentation and/or other materials provided with the distribution.
37  *
38  * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
39  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
43  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
44  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
46  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48  * $NetBSD: machdep.c,v 1.74.2.1 2000/11/01 16:13:48 tv Exp $
49  */
50 /*-
51  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
52  * Copyright (C) 1995, 1996 TooLs GmbH.
53  * All rights reserved.
54  *
55  * Redistribution and use in source and binary forms, with or without
56  * modification, are permitted provided that the following conditions
57  * are met:
58  * 1. Redistributions of source code must retain the above copyright
59  *    notice, this list of conditions and the following disclaimer.
60  * 2. Redistributions in binary form must reproduce the above copyright
61  *    notice, this list of conditions and the following disclaimer in the
62  *    documentation and/or other materials provided with the distribution.
63  * 3. All advertising materials mentioning features or use of this software
64  *    must display the following acknowledgement:
65  *      This product includes software developed by TooLs GmbH.
66  * 4. The name of TooLs GmbH may not be used to endorse or promote products
67  *    derived from this software without specific prior written permission.
68  *
69  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
70  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
71  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
72  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
73  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
74  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
75  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
76  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
77  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
78  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79  */
80
81 #include <sys/cdefs.h>
82 __FBSDID("$FreeBSD$");
83
84 #include "opt_compat.h"
85 #include "opt_ddb.h"
86 #include "opt_kstack_pages.h"
87 #include "opt_platform.h"
88
89 #include <sys/cdefs.h>
90 #include <sys/types.h>
91 #include <sys/param.h>
92 #include <sys/proc.h>
93 #include <sys/systm.h>
94 #include <sys/time.h>
95 #include <sys/bio.h>
96 #include <sys/buf.h>
97 #include <sys/bus.h>
98 #include <sys/cons.h>
99 #include <sys/cpu.h>
100 #include <sys/kdb.h>
101 #include <sys/kernel.h>
102 #include <sys/lock.h>
103 #include <sys/mutex.h>
104 #include <sys/sysctl.h>
105 #include <sys/exec.h>
106 #include <sys/ktr.h>
107 #include <sys/syscallsubr.h>
108 #include <sys/sysproto.h>
109 #include <sys/signalvar.h>
110 #include <sys/sysent.h>
111 #include <sys/imgact.h>
112 #include <sys/msgbuf.h>
113 #include <sys/ptrace.h>
114
115 #include <vm/vm.h>
116 #include <vm/pmap.h>
117 #include <vm/vm_page.h>
118 #include <vm/vm_object.h>
119 #include <vm/vm_pager.h>
120
121 #include <machine/cpu.h>
122 #include <machine/kdb.h>
123 #include <machine/reg.h>
124 #include <machine/vmparam.h>
125 #include <machine/spr.h>
126 #include <machine/hid.h>
127 #include <machine/psl.h>
128 #include <machine/trap.h>
129 #include <machine/md_var.h>
130 #include <machine/mmuvar.h>
131 #include <machine/sigframe.h>
132 #include <machine/metadata.h>
133 #include <machine/platform.h>
134
135 #include <sys/linker.h>
136 #include <sys/reboot.h>
137
138 #include <dev/fdt/fdt_common.h>
139 #include <dev/ofw/openfirm.h>
140
141 #include <powerpc/mpc85xx/mpc85xx.h>
142
143 #ifdef DDB
144 extern vm_offset_t ksym_start, ksym_end;
145 #endif
146
147 #ifdef  DEBUG
148 #define debugf(fmt, args...) printf(fmt, ##args)
149 #else
150 #define debugf(fmt, args...)
151 #endif
152
153 extern unsigned char kernel_text[];
154 extern unsigned char _etext[];
155 extern unsigned char _edata[];
156 extern unsigned char __bss_start[];
157 extern unsigned char __sbss_start[];
158 extern unsigned char __sbss_end[];
159 extern unsigned char _end[];
160
161 extern void dcache_enable(void);
162 extern void dcache_inval(void);
163 extern void icache_enable(void);
164 extern void icache_inval(void);
165
166 /*
167  * Bootinfo is passed to us by legacy loaders. Save the address of the
168  * structure to handle backward compatibility.
169  */
170 uint32_t *bootinfo;
171
172 struct kva_md_info kmi;
173 struct pcpu __pcpu[MAXCPU];
174 struct trapframe frame0;
175 int cold = 1;
176 long realmem = 0;
177 long Maxmem = 0;
178 char machine[] = "powerpc";
179 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
180
181 int cacheline_size = 32;
182
183 SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
184            CTLFLAG_RD, &cacheline_size, 0, "");
185
186 int hw_direct_map = 0;
187
188 static void cpu_e500_startup(void *);
189 SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_e500_startup, NULL);
190
191 void print_kernel_section_addr(void);
192 void print_kenv(void);
193 u_int booke_init(uint32_t, uint32_t);
194
195 extern int elf32_nxstack;
196
197 static void
198 cpu_e500_startup(void *dummy)
199 {
200         int indx, size;
201
202         /* Initialise the decrementer-based clock. */
203         decr_init();
204
205         /* Good {morning,afternoon,evening,night}. */
206         cpu_setup(PCPU_GET(cpuid));
207
208         printf("real memory  = %ld (%ld MB)\n", ptoa(physmem),
209             ptoa(physmem) / 1048576);
210         realmem = physmem;
211
212         /* Display any holes after the first chunk of extended memory. */
213         if (bootverbose) {
214                 printf("Physical memory chunk(s):\n");
215                 for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
216                         size = phys_avail[indx + 1] - phys_avail[indx];
217
218                         printf("0x%08x - 0x%08x, %d bytes (%ld pages)\n",
219                             phys_avail[indx], phys_avail[indx + 1] - 1,
220                             size, size / PAGE_SIZE);
221                 }
222         }
223
224         vm_ksubmap_init(&kmi);
225
226         printf("avail memory = %ld (%ld MB)\n", ptoa(cnt.v_free_count),
227             ptoa(cnt.v_free_count) / 1048576);
228
229         /* Set up buffers, so they can be used to read disk labels. */
230         bufinit();
231         vm_pager_bufferinit();
232
233         /* Cpu supports execution permissions on the pages. */
234         elf32_nxstack = 1;
235 }
236
237 static char *
238 kenv_next(char *cp)
239 {
240
241         if (cp != NULL) {
242                 while (*cp != 0)
243                         cp++;
244                 cp++;
245                 if (*cp == 0)
246                         cp = NULL;
247         }
248         return (cp);
249 }
250
251 void
252 print_kenv(void)
253 {
254         int len;
255         char *cp;
256
257         debugf("loader passed (static) kenv:\n");
258         if (kern_envp == NULL) {
259                 debugf(" no env, null ptr\n");
260                 return;
261         }
262         debugf(" kern_envp = 0x%08x\n", (u_int32_t)kern_envp);
263
264         len = 0;
265         for (cp = kern_envp; cp != NULL; cp = kenv_next(cp))
266                 debugf(" %x %s\n", (u_int32_t)cp, cp);
267 }
268
269 void
270 print_kernel_section_addr(void)
271 {
272
273         debugf("kernel image addresses:\n");
274         debugf(" kernel_text    = 0x%08x\n", (uint32_t)kernel_text);
275         debugf(" _etext (sdata) = 0x%08x\n", (uint32_t)_etext);
276         debugf(" _edata         = 0x%08x\n", (uint32_t)_edata);
277         debugf(" __sbss_start   = 0x%08x\n", (uint32_t)__sbss_start);
278         debugf(" __sbss_end     = 0x%08x\n", (uint32_t)__sbss_end);
279         debugf(" __sbss_start   = 0x%08x\n", (uint32_t)__bss_start);
280         debugf(" _end           = 0x%08x\n", (uint32_t)_end);
281 }
282
283 u_int
284 booke_init(uint32_t arg1, uint32_t arg2)
285 {
286         struct pcpu *pc;
287         void *kmdp, *mdp;
288         vm_offset_t dtbp, end;
289         uint32_t csr;
290
291         kmdp = NULL;
292
293         end = (uintptr_t)_end;
294         dtbp = (vm_offset_t)NULL;
295
296         /*
297          * Handle the various ways we can get loaded and started:
298          *  -   FreeBSD's loader passes the pointer to the metadata
299          *      in arg1, with arg2 undefined. arg1 has a value that's
300          *      relative to the kernel's link address (i.e. larger
301          *      than 0xc0000000).
302          *  -   Juniper's loader passes the metadata pointer in arg2
303          *      and sets arg1 to zero. This is to signal that the
304          *      loader maps the kernel and starts it at its link
305          *      address (unlike the FreeBSD loader).
306          *  -   U-Boot passes the standard argc and argv parameters
307          *      in arg1 and arg2 (resp). arg1 is between 1 and some
308          *      relatively small number, such as 64K. arg2 is the
309          *      physical address of the argv vector.
310          */
311         if (arg1 > (uintptr_t)kernel_text)      /* FreeBSD loader */
312                 mdp = (void *)arg1;
313         else if (arg1 == 0)                     /* Juniper loader */
314                 mdp = (void *)arg2;
315         else                                    /* U-Boot */
316                 mdp = NULL;
317
318         /*
319          * Parse metadata and fetch parameters.
320          */
321         if (mdp != NULL) {
322                 preload_metadata = mdp;
323                 kmdp = preload_search_by_type("elf kernel");
324                 if (kmdp != NULL) {
325                         boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
326                         kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
327                         dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
328                         end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
329
330                         bootinfo = (uint32_t *)preload_search_info(kmdp,
331                             MODINFO_METADATA | MODINFOMD_BOOTINFO);
332
333 #ifdef DDB
334                         ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
335                         ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
336 #endif
337                 }
338         } else {
339                 bzero(__sbss_start, __sbss_end - __sbss_start);
340                 bzero(__bss_start, _end - __bss_start);
341         }
342
343 #if defined(FDT_DTB_STATIC)
344         /*
345          * In case the device tree blob was not retrieved (from metadata) try
346          * to use the statically embedded one.
347          */
348         if (dtbp == (vm_offset_t)NULL)
349                 dtbp = (vm_offset_t)&fdt_static_dtb;
350 #endif
351
352         if (OF_install(OFW_FDT, 0) == FALSE)
353                 while (1);
354
355         if (OF_init((void *)dtbp) != 0)
356                 while (1);
357
358         if (fdt_immr_addr(CCSRBAR_VA) != 0)
359                 while (1);
360
361         OF_interpret("perform-fixup", 0);
362
363         /* Initialize TLB1 handling */
364         tlb1_init(fdt_immr_pa);
365
366         /* Reset Time Base */
367         mttb(0);
368
369         /* Init params/tunables that can be overridden by the loader. */
370         init_param1();
371
372         /* Start initializing proc0 and thread0. */
373         proc_linkup0(&proc0, &thread0);
374         thread0.td_frame = &frame0;
375
376         /* Set up per-cpu data and store the pointer in SPR general 0. */
377         pc = &__pcpu[0];
378         pcpu_init(pc, 0, sizeof(struct pcpu));
379         pc->pc_curthread = &thread0;
380         __asm __volatile("mtsprg 0, %0" :: "r"(pc));
381
382         /* Initialize system mutexes. */
383         mutex_init();
384
385         /* Initialize the console before printing anything. */
386         cninit();
387
388         /* Print out some debug info... */
389         debugf("%s: console initialized\n", __func__);
390         debugf(" arg3 mdp = 0x%08x\n", (u_int32_t)mdp);
391         debugf(" end = 0x%08x\n", (u_int32_t)end);
392         debugf(" boothowto = 0x%08x\n", boothowto);
393         debugf(" kernel ccsrbar = 0x%08x\n", CCSRBAR_VA);
394         debugf(" MSR = 0x%08x\n", mfmsr());
395         debugf(" HID0 = 0x%08x\n", mfspr(SPR_HID0));
396         debugf(" HID1 = 0x%08x\n", mfspr(SPR_HID1));
397         debugf(" BUCSR = 0x%08x\n", mfspr(SPR_BUCSR));
398
399         __asm __volatile("msync; isync");
400         csr = ccsr_read4(OCP85XX_L2CTL);
401         debugf(" L2CTL = 0x%08x\n", csr);
402
403         debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp);
404
405         print_kernel_section_addr();
406         print_kenv();
407         //tlb1_print_entries();
408         //tlb1_print_tlbentries();
409
410         kdb_init();
411
412 #ifdef KDB
413         if (boothowto & RB_KDB)
414                 kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
415 #endif
416
417         /* Initialise platform module */
418         platform_probe_and_attach();
419
420         /* Initialise virtual memory. */
421         pmap_mmu_install(MMU_TYPE_BOOKE, 0);
422         pmap_bootstrap((uintptr_t)kernel_text, end);
423         debugf("MSR = 0x%08x\n", mfmsr());
424         //tlb1_print_entries();
425         //tlb1_print_tlbentries();
426
427         /* Initialize params/tunables that are derived from memsize. */
428         init_param2(physmem);
429
430         /* Finish setting up thread0. */
431         thread0.td_pcb = (struct pcb *)
432             ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE -
433             sizeof(struct pcb)) & ~15);
434         bzero((void *)thread0.td_pcb, sizeof(struct pcb));
435         pc->pc_curpcb = thread0.td_pcb;
436
437         /* Initialise the message buffer. */
438         msgbufinit(msgbufp, msgbufsize);
439
440         /* Enable Machine Check interrupt. */
441         mtmsr(mfmsr() | PSL_ME);
442         isync();
443
444         /* Enable D-cache if applicable */
445         csr = mfspr(SPR_L1CSR0);
446         if ((csr & L1CSR0_DCE) == 0) {
447                 dcache_inval();
448                 dcache_enable();
449         }
450
451         csr = mfspr(SPR_L1CSR0);
452         if ((boothowto & RB_VERBOSE) != 0 || (csr & L1CSR0_DCE) == 0)
453                 printf("L1 D-cache %sabled\n",
454                     (csr & L1CSR0_DCE) ? "en" : "dis");
455
456         /* Enable L1 I-cache if applicable. */
457         csr = mfspr(SPR_L1CSR1);
458         if ((csr & L1CSR1_ICE) == 0) {
459                 icache_inval();
460                 icache_enable();
461         }
462
463         csr = mfspr(SPR_L1CSR1);
464         if ((boothowto & RB_VERBOSE) != 0 || (csr & L1CSR1_ICE) == 0)
465                 printf("L1 I-cache %sabled\n",
466                     (csr & L1CSR1_ICE) ? "en" : "dis");
467
468         debugf("%s: SP = 0x%08x\n", __func__,
469             ((uintptr_t)thread0.td_pcb - 16) & ~15);
470
471         return (((uintptr_t)thread0.td_pcb - 16) & ~15);
472 }
473
474 #define RES_GRANULE 32
475 extern uint32_t tlb0_miss_locks[];
476
477 /* Initialise a struct pcpu. */
478 void
479 cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
480 {
481
482         pcpu->pc_tid_next = TID_MIN;
483
484 #ifdef SMP
485         uint32_t *ptr;
486         int words_per_gran = RES_GRANULE / sizeof(uint32_t);
487
488         ptr = &tlb0_miss_locks[cpuid * words_per_gran];
489         pcpu->pc_booke_tlb_lock = ptr;
490         *ptr = TLB_UNLOCKED;
491         *(ptr + 1) = 0;         /* recurse counter */
492 #endif
493 }
494
495 /*
496  * Flush the D-cache for non-DMA I/O so that the I-cache can
497  * be made coherent later.
498  */
499 void
500 cpu_flush_dcache(void *ptr, size_t len)
501 {
502         /* TBD */
503 }
504
505 void
506 spinlock_enter(void)
507 {
508         struct thread *td;
509         register_t msr;
510
511         td = curthread;
512         if (td->td_md.md_spinlock_count == 0) {
513                 msr = intr_disable();
514                 td->td_md.md_spinlock_count = 1;
515                 td->td_md.md_saved_msr = msr;
516         } else
517                 td->td_md.md_spinlock_count++;
518         critical_enter();
519 }
520
521 void
522 spinlock_exit(void)
523 {
524         struct thread *td;
525         register_t msr;
526
527         td = curthread;
528         critical_exit();
529         msr = td->td_md.md_saved_msr;
530         td->td_md.md_spinlock_count--;
531         if (td->td_md.md_spinlock_count == 0)
532                 intr_restore(msr);
533 }
534
535 /* Shutdown the CPU as much as possible. */
536 void
537 cpu_halt(void)
538 {
539
540         mtmsr(mfmsr() & ~(PSL_CE | PSL_EE | PSL_ME | PSL_DE));
541         while (1);
542 }
543
544 int
545 ptrace_set_pc(struct thread *td, unsigned long addr)
546 {
547         struct trapframe *tf;
548
549         tf = td->td_frame;
550         tf->srr0 = (register_t)addr;
551
552         return (0);
553 }
554
555 int
556 ptrace_single_step(struct thread *td)
557 {
558         struct trapframe *tf;
559
560         tf = td->td_frame;
561         tf->srr1 |= PSL_DE;
562         tf->cpu.booke.dbcr0 |= (DBCR0_IDM | DBCR0_IC);
563         return (0);
564 }
565
566 int
567 ptrace_clear_single_step(struct thread *td)
568 {
569         struct trapframe *tf;
570
571         tf = td->td_frame;
572         tf->srr1 &= ~PSL_DE;
573         tf->cpu.booke.dbcr0 &= ~(DBCR0_IDM | DBCR0_IC);
574         return (0);
575 }
576
577 void
578 kdb_cpu_clear_singlestep(void)
579 {
580         register_t r;
581
582         r = mfspr(SPR_DBCR0);
583         mtspr(SPR_DBCR0, r & ~DBCR0_IC);
584         kdb_frame->srr1 &= ~PSL_DE;
585 }
586
587 void
588 kdb_cpu_set_singlestep(void)
589 {
590         register_t r;
591
592         r = mfspr(SPR_DBCR0);
593         mtspr(SPR_DBCR0, r | DBCR0_IC | DBCR0_IDM);
594         kdb_frame->srr1 |= PSL_DE;
595 }
596
597 void
598 bzero(void *buf, size_t len)
599 {
600         caddr_t p;
601
602         p = buf;
603
604         while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) {
605                 *p++ = 0;
606                 len--;
607         }
608
609         while (len >= sizeof(u_long) * 8) {
610                 *(u_long*) p = 0;
611                 *((u_long*) p + 1) = 0;
612                 *((u_long*) p + 2) = 0;
613                 *((u_long*) p + 3) = 0;
614                 len -= sizeof(u_long) * 8;
615                 *((u_long*) p + 4) = 0;
616                 *((u_long*) p + 5) = 0;
617                 *((u_long*) p + 6) = 0;
618                 *((u_long*) p + 7) = 0;
619                 p += sizeof(u_long) * 8;
620         }
621
622         while (len >= sizeof(u_long)) {
623                 *(u_long*) p = 0;
624                 len -= sizeof(u_long);
625                 p += sizeof(u_long);
626         }
627
628         while (len) {
629                 *p++ = 0;
630                 len--;
631         }
632 }
633