|
|
1.1 root 1: /* netboot
2: *
3: * packet.c,v
4: * Revision 1.1 1993/07/08 16:04:06 brezak
5: * Diskless boot prom code from Jim McKim ([email protected])
6: *
7: * Revision 1.1.1.1 1993/05/28 11:41:07 mckim
8: * Initial version.
9: *
10: *
11: * source in this file came from
12: * the Mach ethernet boot written by Leendert van Doorn.
13: *
14: * Packet allocation and deallocation routines.
15: *
16: * Copyright (c) 1992 by Leendert van Doorn
17: */
18: #include "proto.h"
19: #include "assert.h"
20: #include "param.h"
21: #include "packet.h"
22:
23: static packet_t *pool = (packet_t *)0;
24: static packet_t *last;
25:
26: void
27: PktInit(void) {
28: static packet_t s_pool[PKT_POOLSIZE];
29: pool = s_pool;
30: bzero((char *)pool, PKT_POOLSIZE * sizeof(packet_t));
31: last = pool;
32: }
33:
34: packet_t *
35: PktAlloc(u_long offset) {
36: int i;
37:
38: for (i = 0; i < PKT_POOLSIZE; i++) {
39: if (last->pkt_used == FALSE) {
40: bzero((char *)last->pkt_data, PKT_DATASIZE);
41: last->pkt_used = TRUE;
42: last->pkt_len = 0;
43: last->pkt_offset = last->pkt_data + offset;
44: #if 0
45: printf("PktAlloc: used %x\n", last);
46: #endif
47: return last;
48: }
49: if (++last == &pool[PKT_POOLSIZE])
50: last = pool;
51: }
52: printf("Pool out of free packets\n");
53: exit(1);
54: return 0; /* silence warnings */
55: }
56:
57: void
58: PktRelease(packet_t *pkt) {
59: #if 0
60: printf("PktAlloc: freed %x\n", pkt);
61: #endif
62: assert(pkt >= &pool[0]);
63: assert(pkt < &pool[PKT_POOLSIZE]);
64: (last = pkt)->pkt_used = FALSE;
65: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.