1 /* This file is part of the program psim.
3 Copyright (C) 1994-1998, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "hw-device.h"
25 #include "hw-properties.h"
35 hw_unit_address (struct hw
*me
)
37 return &me
->unit_address_of_hw
;
45 hw_ioctl (struct hw
*me
,
46 hw_ioctl_request request
,
51 va_start(ap
, request
);
52 status
= me
->to_ioctl (me
, request
, ap
);
57 /* Mechanism for associating allocated memory regions to a device.
58 When a device is deleted any remaining memory regions are also
61 FIXME: Perhaphs this can be generalized, perhaphs it should not
64 struct hw_alloc_data
{
67 struct hw_alloc_data
*next
;
71 hw_zalloc (struct hw
*me
, unsigned long size
)
73 struct hw_alloc_data
*memory
= ZALLOC (struct hw_alloc_data
);
74 memory
->alloc
= zalloc (size
);
76 memory
->next
= me
->alloc_of_hw
;
77 me
->alloc_of_hw
= memory
;
82 hw_malloc (struct hw
*me
, unsigned long size
)
84 struct hw_alloc_data
*memory
= ZALLOC (struct hw_alloc_data
);
85 memory
->alloc
= zalloc (size
);
87 memory
->next
= me
->alloc_of_hw
;
88 me
->alloc_of_hw
= memory
;
93 hw_free (struct hw
*me
,
96 struct hw_alloc_data
**memory
;
97 for (memory
= &me
->alloc_of_hw
;
99 memory
= &(*memory
)->next
)
101 if ((*memory
)->alloc
== alloc
)
103 struct hw_alloc_data
*die
= (*memory
);
104 (*memory
) = die
->next
;
113 hw_abort (me
, "free of memory not belonging to a device");
117 hw_free_all (struct hw
*me
)
119 while (me
->alloc_of_hw
!= NULL
)
121 hw_free (me
, me
->alloc_of_hw
->alloc
);
126 hw_strdup (struct hw
*me
, const char *str
)
130 char *dup
= hw_zalloc (me
, strlen (str
) + 1);
This page took 0.033476 seconds and 4 git commands to generate.